-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
-## ##
-# The cmake build system for the deal.II project #
-# #
-# See doc/readme.html and doc/development/cmake.html for further #
-# details on how to use the cmake build system of deal.II. #
-## ##
+## ##
+# The cmake build system for the deal.II project #
+# #
+# See doc/readme.html and doc/development/cmake.html for further #
+# details on how to use the cmake build system of deal.II. #
+## ##
-###########################################################################
-# #
-# Configuration: #
-# #
-###########################################################################
+########################################################################
+# #
+# Configuration: #
+# #
+########################################################################
#
# General configuration for cmake:
ENDFOREACH()
#
-# Check whether the doc and bundled folders are available:
+# Check for the existence of various optional folders:
#
IF(EXISTS ${CMAKE_SOURCE_DIR}/bundled/CMakeLists.txt)
SET(DEAL_II_HAVE_BUNDLED_DIRECTORY TRUE)
SET(DEAL_II_HAVE_DOC_DIRECTORY TRUE)
ENDIF()
+IF(NOT DEFINED TEST_DIR)
+ GET_FILENAME_COMPONENT(TEST_DIR "${CMAKE_SOURCE_DIR}" PATH)
+ SET(TEST_DIR "${TEST_DIR}/tests")
+ENDIF()
+IF(EXISTS ${TEST_DIR}/CMakeLists.txt)
+ SET(DEAL_II_HAVE_TESTS_DIRECTORY TRUE)
+ENDIF()
+
#
# We have to initialize some cached variables before PROJECT is called, so
# do it at this point:
#
# Now, set the project and set up the rest:
#
-PROJECT(deal.II)
+PROJECT(deal.II CXX)
+ENABLE_LANGUAGE_OPTIONAL(C)
+ENABLE_LANGUAGE_OPTIONAL(Fortran)
+
+INCLUDE(setup_post_project_call)
+
INCLUDE(setup_deal_ii)
INCLUDE(setup_compiler_flags)
INCLUDE(setup_finalize)
-###########################################################################
-# #
-# Compilation and installation: #
-# #
-###########################################################################
+########################################################################
+# #
+# Compilation and installation: #
+# #
+########################################################################
MESSAGE(STATUS "")
MESSAGE(STATUS "Configuring done. Proceed to target definitions now.")
ADD_SUBDIRECTORY(contrib) # has to be included after source
ADD_SUBDIRECTORY(examples)
-#
-# Define some custom targets for convenience
-#
-INCLUDE(setup_custom_targets)
+IF(DEAL_II_HAVE_TESTS_DIRECTORY)
+ ADD_SUBDIRECTORY(${TEST_DIR} ${CMAKE_BINARY_DIR}/tests)
+ENDIF()
#
# And finally, print the configuration:
DAMAGES.
END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
- <one line to give the library's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
- <signature of Ty Coon>, 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Export information about bundled library locations and do the actual
COMPONENT library
PATTERN ".svn" EXCLUDE
)
+ FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/deal_ii_source_includes
+ "${BOOST_FOLDER}/include\n"
+ )
ADD_SUBDIRECTORY(${BOOST_FOLDER}/libs/serialization/src)
#
# Threading Building Blocks library
#
-IF(NOT CMAKE_SYSTEM_NAME MATCHES "CYGWIN")
+IF(NOT CMAKE_SYSTEM_NAME MATCHES "CYGWIN"
+ AND NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
#
- # Cygwin is unsupported by tbb
+ # Cygwin is unsupported by tbb, Windows due to the way we compile tbb...
#
SET(FEATURE_THREADS_HAVE_BUNDLED TRUE)
OPTION(DEAL_II_FORCE_BUNDLED_THREADS
FILES_MATCHING PATTERN "*.h"
PATTERN ".svn" EXCLUDE
)
+ FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/deal_ii_source_includes
+ "${TBB_FOLDER}/include\n"
+ )
ADD_SUBDIRECTORY(${TBB_FOLDER}/src)
ENDIF()
#include <boost/fusion/tuple/detail/preprocessed/tuple50.hpp>
#else
#error "FUSION_MAX_VECTOR_SIZE out of bounds for preprocessed headers"
-#endif
\ No newline at end of file
+#endif
#include <boost/fusion/tuple/detail/preprocessed/tuple50_fwd.hpp>
#else
#error "FUSION_MAX_VECTOR_SIZE out of bounds for preprocessed headers"
-#endif
\ No newline at end of file
+#endif
#include <boost/smart_ptr/bad_weak_ptr.hpp>
#include <boost/utility/swap.hpp>
-#if !defined(BOOST_INTEL_STDCXX0X)
-namespace std
-{
- template<typename T> class shared_ptr;
- template<typename T> class weak_ptr;
-}
-#endif
-
namespace boost
{
template<typename T> class shared_ptr;
{
typedef boost::shared_ptr<T> shared_type;
};
+
+// Workaround for a bug in boost:
+// https://svn.boost.org/trac/boost/ticket/6655
+//
+// It should be safe to depend on DEAL macros at this point as this header
+// should only be used by deal.II and dependent projects...
+//
+// - Maier, 2013
+#ifdef DEAL_II_CAN_USE_CXX11
template<typename T> struct weak_ptr_traits<std::weak_ptr<T> >
{
typedef std::shared_ptr<T> shared_type;
};
+#endif
template<typename SharedPtr> struct shared_ptr_traits
{};
{
typedef boost::weak_ptr<T> weak_type;
};
+// as above
+#ifdef DEAL_II_CAN_USE_CXX11
template<typename T> struct shared_ptr_traits<std::shared_ptr<T> >
{
typedef std::weak_ptr<T> weak_type;
};
+#endif
namespace detail
{
enum xtime_clock_types
{
- TIME_UTC=1
+ TIME_UTC_=1
// TIME_TAI,
// TIME_MONOTONIC,
// TIME_PROCESS,
inline int xtime_get(struct xtime* xtp, int clock_type)
{
- if (clock_type == TIME_UTC)
+ if (clock_type == TIME_UTC_)
{
*xtp=get_xtime(get_system_time());
return clock_type;
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
SET(src_boost_serialization
basic_archive.cpp
<< "very hot ..." << std::endl;
}
boost::xtime xt;
- boost::xtime_get(&xt, boost::TIME_UTC);
+ boost::xtime_get(&xt, boost::TIME_UTC_);
xt.sec += 3;
boost::thread::sleep(xt);
m_chickens += value;
std::cout << "(" << clock() << ") Chef: cooking ..." << std::endl;
}
boost::xtime xt;
- boost::xtime_get(&xt, boost::TIME_UTC);
+ boost::xtime_get(&xt, boost::TIME_UTC_);
xt.sec += 2;
boost::thread::sleep(xt);
{
if (m_id > 0)
{
boost::xtime xt;
- boost::xtime_get(&xt, boost::TIME_UTC);
+ boost::xtime_get(&xt, boost::TIME_UTC_);
xt.sec += 3;
boost::thread::sleep(xt);
}
boost::thread thrdb(thread_adapter(&player, (void*)PLAYER_B));
boost::xtime xt;
- boost::xtime_get(&xt, boost::TIME_UTC);
+ boost::xtime_get(&xt, boost::TIME_UTC_);
xt.sec += 1;
boost::thread::sleep(xt);
{
void operator()()
{
boost::xtime xt;
- boost::xtime_get(&xt, boost::TIME_UTC);
+ boost::xtime_get(&xt, boost::TIME_UTC_);
xt.sec += m_secs;
boost::thread::sleep(xt);
int main(int argc, char* argv[])
{
boost::xtime xt;
- boost::xtime_get(&xt, boost::TIME_UTC);
+ boost::xtime_get(&xt, boost::TIME_UTC_);
xt.sec += 1;
boost::thread::sleep(xt); // Sleep for 1 second
}
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
IF(DEAL_II_USE_MT_POSIX)
SET(src_boost_thread
cond.timed_wait(lock, xt);
# endif
xtime cur;
- xtime_get(&cur, TIME_UTC);
+ xtime_get(&cur, TIME_UTC_);
if (xtime_cmp(xt, cur) <= 0)
return;
}
BOOST_VERIFY(!pthread_yield());
# else
xtime xt;
- xtime_get(&xt, TIME_UTC);
+ xtime_get(&xt, TIME_UTC_);
sleep(xt);
# endif
}
inline void to_time(int milliseconds, boost::xtime& xt)
{
int res = 0;
- res = boost::xtime_get(&xt, boost::TIME_UTC);
- BOOST_ASSERT(res == boost::TIME_UTC); (void)res;
+ res = boost::xtime_get(&xt, boost::TIME_UTC_);
+ BOOST_ASSERT(res == boost::TIME_UTC_); (void)res;
xt.sec += (milliseconds / MILLISECONDS_PER_SECOND);
xt.nsec += ((milliseconds % MILLISECONDS_PER_SECOND) *
{
boost::xtime cur;
int res = 0;
- res = boost::xtime_get(&cur, boost::TIME_UTC);
- BOOST_ASSERT(res == boost::TIME_UTC); (void)res;
+ res = boost::xtime_get(&cur, boost::TIME_UTC_);
+ BOOST_ASSERT(res == boost::TIME_UTC_); (void)res;
if (boost::xtime_cmp(xt, cur) <= 0)
{
{
boost::xtime cur;
int res = 0;
- res = boost::xtime_get(&cur, boost::TIME_UTC);
- BOOST_ASSERT(res == boost::TIME_UTC); (void)res;
+ res = boost::xtime_get(&cur, boost::TIME_UTC_);
+ BOOST_ASSERT(res == boost::TIME_UTC_); (void)res;
if (boost::xtime_cmp(xt, cur) <= 0)
milliseconds = 0;
{
boost::xtime cur;
int res = 0;
- res = boost::xtime_get(&cur, boost::TIME_UTC);
- BOOST_ASSERT(res == boost::TIME_UTC); (void)res;
+ res = boost::xtime_get(&cur, boost::TIME_UTC_);
+ BOOST_ASSERT(res == boost::TIME_UTC_); (void)res;
if (boost::xtime_cmp(xt, cur) <= 0)
microseconds = 0;
inline void to_time(int milliseconds, boost::xtime& xt)
{
int res = 0;
- res = boost::xtime_get(&xt, boost::TIME_UTC);
- assert(res == boost::TIME_UTC);
+ res = boost::xtime_get(&xt, boost::TIME_UTC_);
+ assert(res == boost::TIME_UTC_);
xt.sec += (milliseconds / MILLISECONDS_PER_SECOND);
xt.nsec += ((milliseconds % MILLISECONDS_PER_SECOND) *
{
boost::xtime cur;
int res = 0;
- res = boost::xtime_get(&cur, boost::TIME_UTC);
- assert(res == boost::TIME_UTC);
+ res = boost::xtime_get(&cur, boost::TIME_UTC_);
+ assert(res == boost::TIME_UTC_);
if (boost::xtime_cmp(xt, cur) <= 0)
{
{
boost::xtime cur;
int res = 0;
- res = boost::xtime_get(&cur, boost::TIME_UTC);
- assert(res == boost::TIME_UTC);
+ res = boost::xtime_get(&cur, boost::TIME_UTC_);
+ assert(res == boost::TIME_UTC_);
if (boost::xtime_cmp(xt, cur) <= 0)
milliseconds = 0;
{
boost::xtime cur;
int res = 0;
- res = boost::xtime_get(&cur, boost::TIME_UTC);
- assert(res == boost::TIME_UTC);
+ res = boost::xtime_get(&cur, boost::TIME_UTC_);
+ assert(res == boost::TIME_UTC_);
if (boost::xtime_cmp(xt, cur) <= 0)
microseconds = 0;
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Remove -Wall and -pedantic from CMAKE_CXX_FLAGS (in directory scope) to
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Remove -Wall and -pedantic from CMAKE_CXX_FLAGS (in directory scope) to
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
SET(src_amd
amd_1.cc
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Logic copied from the distributed UMFPACK Makefile.
+++ /dev/null
-Some last bits and thoughts:
-
-* A TECPLOT feature has to be written
-
-* Support debug;optimized;general for all FEATURES
-
-* document that we no longer need the two-lib installation of p4est
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-#####
+## ---------------------------------------------------------------------
-###########################################################################
-# #
-# Check for various compiler features: #
-# #
-###########################################################################
+########################################################################
+# #
+# Check for various compiler features: #
+# #
+########################################################################
#
# This file sets up:
"
HAVE_GLIBC_STACKTRACE)
-IF(HAVE_GLIBC_STACKTRACE)
- ENABLE_IF_SUPPORTED(CMAKE_SHARED_LINKER_FLAGS "-rdynamic")
+IF(HAVE_GLIBC_STACKTRACE AND NOT DEAL_II_STATIC_EXECUTABLE)
+ ENABLE_IF_SUPPORTED(DEAL_II_LINKER_FLAGS "-rdynamic")
ENDIF()
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
-###########################################################################
-# #
-# Platform and CPU specific tests: #
-# #
-###########################################################################
+########################################################################
+# #
+# Platform and CPU specific tests: #
+# #
+########################################################################
#
# This file sets up
#
# Determine the Endianess of the platform:
#
-INCLUDE(TestBigEndian)
-TEST_BIG_ENDIAN(DEAL_II_WORDS_BIGENDIAN)
-
-
-IF(DEAL_II_ALLOW_PLATFORM_INTROSPECTION)
+IF(CMAKE_C_COMPILER_WORKS)
+ INCLUDE(TestBigEndian)
- #
- # These tests depend on certain cpu instruction sets being enabled, so
- # use the user supplied compiler flags for the tests as well:
- #
- SET(CMAKE_REQUIRED_FLAGS "${CMAKE_CXX_FLAGS_SAVED}")
+ CLEAR_CMAKE_REQUIRED()
+ TEST_BIG_ENDIAN(DEAL_II_WORDS_BIGENDIAN)
+ RESET_CMAKE_REQUIRED()
+ELSE()
+ MESSAGE(STATUS
+ "No suitable C compiler was found! Assuming little endian platform."
+ )
+ SET(DEAL_II_WORDS_BIGENDIAN "0")
+ENDIF()
+IF(DEAL_II_ALLOW_PLATFORM_INTROSPECTION)
#
# Take care that the following tests are rerun if CMAKE_REQUIRED_FLAGS
# changes..
}
"
DEAL_II_HAVE_AVX)
-
- SET(CMAKE_REQUIRED_FLAGS "")
ENDIF()
+
IF(DEAL_II_HAVE_SSE2)
IF(DEAL_II_HAVE_AVX)
SET(DEAL_II_COMPILER_VECTORIZATION_LEVEL 2)
ELSE()
SET(DEAL_II_COMPILER_VECTORIZATION_LEVEL 0)
ENDIF()
-
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Check for various C++ language features
#
-###########################################################################
-# #
-# C++11 Support: #
-# #
-###########################################################################
+########################################################################
+# #
+# C++11 Support: #
+# #
+########################################################################
#
# See if there is a compiler flag to enable C++11 features
ENDIF()
-###########################################################################
-# #
-# Check for various C++ features: #
-# #
-###########################################################################
+########################################################################
+# #
+# Check for various C++ features: #
+# #
+########################################################################
CHECK_CXX_SOURCE_COMPILES(
"
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# This file sets up:
#
-###########################################################################
-# #
-# POSIX and Linux specific tests: #
-# #
-###########################################################################
+########################################################################
+# #
+# POSIX and Linux specific tests: #
+# #
+########################################################################
#
# Check for various posix (and linux) specific header files and symbols
#
# Do we have the Bessel function jn?
#
-FIND_LIBRARY(m_lib NAMES m)
-MARK_AS_ADVANCED(m_lib)
+# Switch the library preference back to prefer dynamic libraries if
+# DEAL_II_PREFER_STATIC_LIBS=TRUE but DEAL_II_STATIC_EXECUTABLE=FALSE. In
+# this case system libraries should be linked dynamically.
+#
+SWITCH_LIBRARY_PREFERENCE()
+FIND_LIBRARY(m_LIBRARY NAMES m)
+SWITCH_LIBRARY_PREFERENCE()
+MARK_AS_ADVANCED(m_LIBRARY)
-IF(NOT m_lib MATCHES "-NOTFOUND")
- SET(CMAKE_REQUIRED_LIBRARIES ${m_lib})
+IF(NOT m_LIBRARY MATCHES "-NOTFOUND")
+ LIST(APPEND CMAKE_REQUIRED_LIBRARIES ${m_LIBRARY})
CHECK_CXX_SYMBOL_EXISTS("jn" "math.h" HAVE_JN)
- SET(CMAKE_REQUIRED_LIBRARIES)
+ RESET_CMAKE_REQUIRED()
IF(HAVE_JN)
- LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES ${m_lib})
+ LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES ${m_LIBRARY})
ENDIF()
ENDIF()
-###########################################################################
-# #
-# Mac OSX specific setup: #
-# #
-###########################################################################
+########################################################################
+# #
+# Mac OSX specific setup: #
+# #
+########################################################################
IF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
#
#
# TODO: MM: Check whether this is still necessary...
#
- STRIP_FLAG(CMAKE_SHARED_LINKER_FLAGS "-rdynamic")
+ STRIP_FLAG(DEAL_II_LINKER_FLAGS "-rdynamic")
ENDIF()
-###########################################################################
-# #
-# Windows and CYGWIN specific setup: #
-# #
-###########################################################################
+########################################################################
+# #
+# Windows and CYGWIN specific setup: #
+# #
+########################################################################
IF(CMAKE_SYSTEM_NAME MATCHES "Windows")
#
SET(DEAL_II_MSVC TRUE)
#
- # Disable shared libraries on native Windows targets for the moment.
+ # Shared library handling:
#
- MESSAGE(WARNING "\n"
- "BUILD_SHARED_LIBS forced to OFF\n\n"
- )
- SET(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
+ IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
+ #
+ # With MinGW we're lucky:
+ #
+ ENABLE_IF_LINKS(DEAL_II_LINKER_FLAGS "-Wl,--export-all-symbols")
+ ENABLE_IF_LINKS(DEAL_II_LINKER_FLAGS "-Wl,--enable-auto-import")
+ ENABLE_IF_LINKS(DEAL_II_LINKER_FLAGS "-Wl,--allow-multiple-definition")
+
+ #
+ # Workaround for a miscompilation and linkage issue with shared libraries
+ # with MinGW. Replacing -O0 with -O1 seems to help..
+ #
+ REPLACE_FLAG(DEAL_II_CXX_FLAGS_DEBUG "-O0" "-O1")
+
+ ELSE()
+
+ #
+ # Otherwise disable shared libraries:
+ #
+ MESSAGE(WARNING "\n"
+ "BUILD_SHARED_LIBS forced to OFF\n\n"
+ )
+ SET(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
+ ENDIF()
#
# Disable -ggdb and -g on Windows/MinGW targets for the moment until the
# - Matthias Maier, 2012
#
STRIP_FLAG(DEAL_II_CXX_FLAGS_DEBUG "-ggdb")
- STRIP_FLAG(DEAL_II_SHARED_LINKER_FLAGS_DEBUG "-ggdb")
+ STRIP_FLAG(DEAL_II_LINKER_FLAGS_DEBUG "-ggdb")
STRIP_FLAG(DEAL_II_CXX_FLAGS_DEBUG "-g")
- STRIP_FLAG(DEAL_II_SHARED_LINKER_FLAGS_DEBUG "-g")
+ STRIP_FLAG(DEAL_II_LINKER_FLAGS_DEBUG "-g")
ENDIF()
+
IF(CMAKE_SYSTEM_NAME MATCHES "CYGWIN")
#
# Workaround for a miscompilation and linkage issue with shared libraries
# - Matthias Maier, 2013
#
REPLACE_FLAG(DEAL_II_CXX_FLAGS_DEBUG "-O0" "-O1")
-
ENDIF()
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-#####
+## ---------------------------------------------------------------------
-###########################################################################
-# #
-# Check for various compiler bugs: #
-# #
-###########################################################################
-
-
-#
-# Some compiler versions, notably ICC, have trouble with the
-# following code in which we explicitly call a destructor.
-# This has to be worked around with a typedef. The problem is
-# that the workaround fails with some other compilers, so that
-# we can not unconditionally use the workaround...
-#
-# - Wolfgang Bangerth, Matthias Maier, rewritten 2012
-#
-CHECK_CXX_COMPILER_BUG(
- "
- namespace dealii
- {
- namespace FEValuesViews
- {
- template <int dim, int spacedim> struct Scalar {};
- }
-
- template <int dim, int spacedim>
- struct X
- {
- FEValuesViews::Scalar<dim,spacedim> scalars[dim*spacedim];
-
- void f()
- {
- scalars[0].dealii::FEValuesViews::Scalar<dim,spacedim>::~Scalar ();
- }
- };
-
- template struct X<2,2>;
- }
- int main() { return 0; }
- "
- DEAL_II_EXPLICIT_DESTRUCTOR_BUG
- )
+########################################################################
+# #
+# Check for various compiler bugs: #
+# #
+########################################################################
#
ENDIF()
-#
-# Some gcc compiler versions have a problem when using an unsigned count
-# in the std::advance function. Unfortunately, this also happens
-# occasionally from within the standard library, so we can't prevent the
-# warning messages. Since this is annoying, switch of the flag -W which
-# causes this.
-#
-# - Matthias Maier, rewritten 2012
-#
-
-# TODO: We use the mpi.h header file for this check. We should test this
-# bug directly...
-CHECK_INCLUDE_FILE_CXX("mpi.h" HAVE_MPI_H)
-
-IF(HAVE_MPI_H)
- PUSH_TEST_FLAG("-Wunused-parameter")
- PUSH_TEST_FLAG("-Werror")
- CHECK_CXX_COMPILER_BUG(
- "
- #include <mpi.h>
- int main() { return 0; }
- "
- DEAL_II_ADVANCE_WARNING_BUG)
- POP_TEST_FLAG()
- POP_TEST_FLAG()
-
- IF(DEAL_II_ADVANCE_WARNING_BUG)
- ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-unused-parameter")
- ENDIF()
-ENDIF()
-
-
#
# In some cases, we would like to name partial specializations
# as friends. However, the standard forbids us to do so. But
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
+#
+# This file sets up the project configuration consisting of
+#
+# Make.global_options (legacy)
+# deal.IIConfig.cmake
+# deal.IIVersionConfig.cmake
+#
+# and copies it (a) to the build directory and (b) prepares it for later
+# installation (the copy in CMAKE_CURRENT_BINARY_DIR).
+#
+
+#
+# Read in auxiliary include directories for the build directory
+# configuration:
+#
+FILE(STRINGS
+ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/deal_ii_source_includes
+ deal_ii_source_includes
+ )
#
# Configure the template-arguments file
#
-CONFIGURE_FILE(
+CONFIGURE_FILE( # for binary dir:
${CMAKE_CURRENT_SOURCE_DIR}/template-arguments.in
- ${CMAKE_CURRENT_BINARY_DIR}/template-arguments
+ ${CMAKE_BINARY_DIR}/${DEAL_II_COMMON_RELDIR}/template-arguments
)
-###########################################################################
-# #
-# Setup and install the convenience macros: #
-# #
-###########################################################################
+########################################################################
+# #
+# Setup and install the convenience macros: #
+# #
+########################################################################
-INSTALL(FILES
+FILE(COPY # for binary dir:
+ ${CMAKE_SOURCE_DIR}/cmake/macros/macro_deal_ii_initialize_cached_variables.cmake
+ ${CMAKE_SOURCE_DIR}/cmake/macros/macro_deal_ii_invoke_autopilot.cmake
+ ${CMAKE_SOURCE_DIR}/cmake/macros/macro_deal_ii_setup_target.cmake
+ DESTINATION ${CMAKE_BINARY_DIR}/${DEAL_II_CMAKE_MACROS_RELDIR}
+ )
+INSTALL(FILES # for installation:
${CMAKE_SOURCE_DIR}/cmake/macros/macro_deal_ii_initialize_cached_variables.cmake
${CMAKE_SOURCE_DIR}/cmake/macros/macro_deal_ii_invoke_autopilot.cmake
${CMAKE_SOURCE_DIR}/cmake/macros/macro_deal_ii_setup_target.cmake
)
-###########################################################################
-# #
-# Configure and install the cmake project configuration: #
-# #
-###########################################################################
+########################################################################
+# #
+# Configure and install the cmake project configuration: #
+# #
+########################################################################
#
# Strip -Wno-deprecated from CMAKE_CXX_FLAGS so that deprecation warnings
SET(CONFIG_LIBRARIES_${_build}
\${DEAL_II_PATH}/\${DEAL_II_LIBRARY_RELDIR}/${CONFIG_LIBRARY_${_build}}
- ${DEAL_II_EXTERNAL_LIBRARIES}
${DEAL_II_EXTERNAL_LIBRARIES_${_build}}
+ ${DEAL_II_EXTERNAL_LIBRARIES}
)
LIST(APPEND CONFIG_LIBRARIES
${_keyword}
- ${CONFIG_LIBRARIES_${_build}}
+ \${DEAL_II_LIBRARIES_${_build}}
)
SET(CONFIG_TARGET_${_build}
)
LIST(APPEND CONFIG_TARGET
${_keyword}
- ${DEAL_II_BASE_NAME}${DEAL_II_${_build}_SUFFIX}
+ \${DEAL_II_TARGET_${_build}}
)
ENDFOREACH()
-SET(CONFIG_INCLUDE_DIRS
+#
+# For binary dir:
+#
+SET(CONFIG_INCLUDE_DIRS_BINARY
+ \${DEAL_II_PATH}/include
+ \${DEAL_II_PATH}/include/deal.II
+ ${CMAKE_SOURCE_DIR}/include/
+ ${CMAKE_SOURCE_DIR}/include/deal.II
+ ${deal_ii_source_includes}
+ ${DEAL_II_USER_INCLUDE_DIRS}
+ )
+#
+# For installation:
+#
+SET(CONFIG_INCLUDE_DIRS_INSTALLATION
\${DEAL_II_PATH}/\${DEAL_II_INCLUDE_RELDIR}
\${DEAL_II_PATH}/\${DEAL_II_INCLUDE_RELDIR}/deal.II
\${DEAL_II_PATH}/\${DEAL_II_INCLUDE_RELDIR}/deal.II/bundled
${DEAL_II_USER_INCLUDE_DIRS}
)
-
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
- ${CMAKE_CURRENT_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_NAME}Config.cmake
+ ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}Config.cmake
@ONLY
)
-
#
# Append feature configuration:
#
-
-SET(_file ${CMAKE_CURRENT_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_NAME}Config.cmake)
+SET(_file
+ ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}Config.cmake
+ )
FILE(APPEND ${_file}
"\n\n#\n# Feature configuration:\n#\n\n"
)
ENDIF()
ENDFOREACH()
-
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/ConfigVersion.cmake.in
- ${CMAKE_CURRENT_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_NAME}ConfigVersion.cmake
+ ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}ConfigVersion.cmake
@ONLY
)
INSTALL(FILES
- ${CMAKE_CURRENT_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_NAME}Config.cmake
- ${CMAKE_CURRENT_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_NAME}ConfigVersion.cmake
+ ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}Config.cmake
+ ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}ConfigVersion.cmake
DESTINATION ${DEAL_II_PROJECT_CONFIG_RELDIR}
COMPONENT library
)
-###########################################################################
-# #
-# Configure and install the old Makefile configuration: #
-# #
-###########################################################################
+########################################################################
+# #
+# Configure and install the old Makefile configuration: #
+# #
+########################################################################
IF(DEAL_II_COMPONENT_COMPAT_FILES)
# Transform some cmake lists into a string that the old Makefile
# mechanism actually understands:
#
- TO_STRING_AND_ADD_PREFIX(MAKEFILE_INCLUDE_DIRS "${CMAKE_INCLUDE_FLAG_CXX}"
- $(D)/${DEAL_II_INCLUDE_RELDIR}
- $(D)/${DEAL_II_INCLUDE_RELDIR}/deal.II
- $(D)/${DEAL_II_INCLUDE_RELDIR}/deal.II/bundled
- ${DEAL_II_USER_INCLUDE_DIRS}
- ${DEAL_II_INCLUDE_DIRS}
- )
FOREACH(build ${DEAL_II_BUILD_TYPES})
TO_STRING_AND_ADD_PREFIX(MAKEFILE_DEFINITIONS_${build}
#
SET(_libs)
FOREACH(_lib
- ${DEAL_II_EXTERNAL_LIBRARIES}
${DEAL_II_EXTERNAL_LIBRARIES_${build}}
+ ${DEAL_II_EXTERNAL_LIBRARIES}
)
IF(_lib MATCHES "^/")
LIST(APPEND _libs "${_lib}")
SET(_paths)
FOREACH(_lib
$(D)/${DEAL_II_LIBRARY_RELDIR}/${CONFIG_LIBRARY_${build}}
- ${DEAL_II_EXTERNAL_LIBRARIES}
${DEAL_II_EXTERNAL_LIBRARIES_${build}}
+ ${DEAL_II_EXTERNAL_LIBRARIES}
)
LIST(APPEND MAKEFILE_LIBS_${build} ${_lib})
#
# Set up our linker flags:
#
SET(MAKEFILE_LDFLAGS_${build}
- "${CMAKE_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${build}} ${CMAKE_SHARED_LINKER_FLAGS} ${DEAL_II_SHARED_LINKER_FLAGS_${build}}"
+ "${CMAKE_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${build}} ${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${build}}"
)
ENDFOREACH()
# Boilerplate: The Make.global_options expects variables to be set to
# yes, as is common for Makefiles.
#
- COND_SET_TO_YES(DEAL_II_WITH_TBB MAKEFILE_enablethreads)
+ COND_SET_TO_YES(DEAL_II_WITH_THREADS MAKEFILE_enablethreads)
COND_SET_TO_YES(DEAL_II_WITH_FUNCTIONPARSER MAKEFILE_enableparser)
COND_SET_TO_YES(BUILD_SHARED_LIBS MAKEFILE_enableshared)
COND_SET_TO_YES(DEAL_II_WITH_P4EST MAKEFILE_P4EST)
COND_SET_TO_YES(DEAL_II_WITH_MPI MAKEFILE_MPI)
+ #
+ # For binary dir:
+ #
+ SET(MAKEFILE_D_BINARY ${CMAKE_BINARY_DIR})
+ TO_STRING_AND_ADD_PREFIX(MAKEFILE_INCLUDE_DIRS_BINARY "${CMAKE_INCLUDE_FLAG_CXX}"
+ $(D)/install
+ $(D)/install/deal.II
+ ${CMAKE_SOURCE_DIR}/include/
+ ${CMAKE_SOURCE_DIR}/include/deal.II
+ ${deal_ii_source_includes}
+ ${DEAL_II_USER_INCLUDE_DIRS}
+ )
+ #
+ # For installation:
+ #
+ SET(MAKEFILE_D_INSTALLATION ${CMAKE_INSTALL_PREFIX})
+ TO_STRING_AND_ADD_PREFIX(MAKEFILE_INCLUDE_DIRS_INSTALLATION "${CMAKE_INCLUDE_FLAG_CXX}"
+ $(D)/${DEAL_II_INCLUDE_RELDIR}
+ $(D)/${DEAL_II_INCLUDE_RELDIR}/deal.II
+ $(D)/${DEAL_II_INCLUDE_RELDIR}/deal.II/bundled
+ ${DEAL_II_USER_INCLUDE_DIRS}
+ )
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/Make.global_options.in
- ${CMAKE_CURRENT_BINARY_DIR}/Make.global_options
+ ${CMAKE_BINARY_DIR}/${DEAL_II_COMMON_RELDIR}/Make.global_options
)
INSTALL(FILES
- ${CMAKE_CURRENT_BINARY_DIR}/template-arguments
- ${CMAKE_CURRENT_BINARY_DIR}/Make.global_options
+ ${CMAKE_BINARY_DIR}/${DEAL_II_COMMON_RELDIR}/template-arguments
+ ${CMAKE_BINARY_DIR}/${DEAL_II_COMMON_RELDIR}/Make.global_options
DESTINATION ${DEAL_II_COMMON_RELDIR}
COMPONENT compat_files
)
ENDIF()
+#
+# Finally, add a target to create the "binary" file in
+# ${DEAL_II_PROJECT_CONFIG_RELDIR} and add it to the library target:
+#
+ADD_CUSTOM_TARGET(setup_build_dir ALL
+ COMMAND ${CMAKE_COMMAND} -E touch
+ ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/binary
+ COMMAND ${CMAKE_COMMAND} -E touch
+ ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}Config.cmake
+ )
+ADD_DEPENDENCIES(library setup_build_dir)
+
+#
+# And a script to remove it upon installation from the install prefix:
+#
+INSTALL(CODE
+ "
+ FILE(REMOVE ${CMAKE_INSTALL_PREFIX}/${DEAL_II_PROJECT_CONFIG_RELDIR}/binary)
+ EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E touch
+ ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}Config.cmake
+ )
+ "
+ COMPONENT library
+ )
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
-##########################################################################
-## ##
-## The deal.II project configuration file ##
-## ##
-##########################################################################
+########################################################################
+## ##
+## The deal.II project configuration file ##
+## ##
+########################################################################
#
GET_FILENAME_COMPONENT(_path "${_path}" PATH)
ENDWHILE()
+#
+# Is this project reside in a build directory or at an installed location?
+#
+
+IF(EXISTS ${DEAL_II_PATH}/${DEAL_II_PROJECT_CONFIG_RELDIR}/binary)
+ SET(DEAL_II_BUILD_DIR TRUE)
+ENDIF()
+
#
# Print a message after inclusion of this file:
#
SET(DEAL_II_PROJECT_CONFIG_INCLUDED TRUE)
IF(NOT ${DEAL_II_PACKAGE_NAME}_FIND_QUIETLY)
- MESSAGE(STATUS
- "Using the ${DEAL_II_PACKAGE_NAME}-${DEAL_II_PACKAGE_VERSION} installation found at ${DEAL_II_PATH}"
- )
+ IF(DEAL_II_BUILD_DIR)
+ MESSAGE(STATUS
+ "Using the ${DEAL_II_PACKAGE_NAME}-${DEAL_II_PACKAGE_VERSION} build directory found at ${DEAL_II_PATH}"
+ )
+ ELSE()
+ MESSAGE(STATUS
+ "Using the ${DEAL_II_PACKAGE_NAME}-${DEAL_II_PACKAGE_VERSION} installation found at ${DEAL_II_PATH}"
+ )
+ ENDIF()
ENDIF()
SET(DEAL_II_CXX_FLAGS_RELEASE "@DEAL_II_CXX_FLAGS_RELEASE@")
# used for all targets:
-SET(DEAL_II_LINKER_FLAGS "@CMAKE_SHARED_LINKER_FLAGS@")
+SET(DEAL_II_LINKER_FLAGS "@DEAL_II_LINKER_FLAGS@")
# _additionally_ used for debug targets:
-SET(DEAL_II_LINKER_FLAGS_DEBUG "@DEAL_II_SHARED_LINKER_FLAGS_DEBUG@")
+SET(DEAL_II_LINKER_FLAGS_DEBUG "@DEAL_II_LINKER_FLAGS_DEBUG@")
# _additionally_ used for release targets:
-SET(DEAL_II_LINKER_FLAGS_RELEASE "@DEAL_II_SHARED_LINKER_FLAGS_RELEASE@")
+SET(DEAL_II_LINKER_FLAGS_RELEASE "@DEAL_II_LINKER_FLAGS_RELEASE@")
# used for all targets:
SET(DEAL_II_USER_DEFINITIONS "@DEAL_II_USER_DEFINITIONS@")
#
-# Information about include directories and libraries
+# Build a static executable:
#
-SET(DEAL_II_INCLUDE_DIRS "@CONFIG_INCLUDE_DIRS@")
+SET(DEAL_II_STATIC_EXECUTABLE "@DEAL_II_STATIC_EXECUTABLE@")
+
+
+#
+# Information about include directories and libraries
+#
+IF(DEAL_II_BUILD_DIR)
+ SET(DEAL_II_INCLUDE_DIRS "@CONFIG_INCLUDE_DIRS_BINARY@")
+ELSE()
+ SET(DEAL_II_INCLUDE_DIRS "@CONFIG_INCLUDE_DIRS_INSTALLATION@")
+ENDIF()
# Full list of libraries for the debug target:
SET(DEAL_II_LIBRARIES_DEBUG "@CONFIG_LIBRARIES_DEBUG@")
# Information about library targets
#
-SET(DEAL_II_TARGET_CONFIG "${DEAL_II_PATH}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}Targets.cmake")
+IF(DEAL_II_BUILD_DIR)
+ SET(DEAL_II_TARGET_CONFIG "${DEAL_II_PATH}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}BuildTargets.cmake")
+ELSE()
+ SET(DEAL_II_TARGET_CONFIG "${DEAL_II_PATH}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}Targets.cmake")
+ENDIF()
# The Debug target:
SET(DEAL_II_TARGET_DEBUG "@CONFIG_TARGET_DEBUG@")
-# $Id$
-
-#
-# Compatibility Make.global_options file
-#
-
-###############################################################################
-## Please note:
+## ---------------------------------------------------------------------
+## $Id$
+##
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
-## This is a compatibility Make.global_options file generated by CMake
-## from the ./cmake/config/Make.global_options.in file.
+## This file is part of the deal.II library.
##
-###############################################################################
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
#
-# the following lines will be replaced by cmake
+# Please note:
+#
+# This is a compatibility Make.global_options file generated by CMake
+# from the ./cmake/config/Make.global_options.in file.
#
-D = @CMAKE_INSTALL_PREFIX@
+
+ifeq ($(wildcard $(D)/@DEAL_II_PROJECT_CONFIG_RELDIR@/binary),)
+ D = @MAKEFILE_D_INSTALLATION@
+else
+ D = @MAKEFILE_D_BINARY@
+endif
+
CXX = @CMAKE_CXX_COMPILER@
CXX-ID = @CMAKE_CXX_COMPILER_ID@
CXX-VERSION = @CMAKE_CXX_COMPILER_VERSION@
OBJEXT = o
EXEEXT =
+shared-lib-suffix = .so
+static-lib-suffix = .a
+
+ifeq ($(enable-shared),yes)
+ lib-suffix = $(shared-lib-suffix)
+else
+ lib-suffix = $(static-lib-suffix)
+endif
+
# set paths to all the libraries we need:
-lib-deal2.o = ${MAKEFILE_TARGETS_RELEASE}
-lib-deal2.g = ${MAKEFILE_TARGETS_DEBUG}
+lib-deal2.o = @MAKEFILE_TARGETS_RELEASE@
+lib-deal2.g = @MAKEFILE_TARGETS_DEBUG@
-# include paths as command line flags. while compilers allow a space between
-# the '-I' and the actual path, we also send these flags to the
-# make_dependencies program that doesn't support the extra space.
-#
-INCLUDE = ${MAKEFILE_INCLUDE_DIRS}
+# Include paths as command line flags
+ifeq ($(wildcard $(D)/@DEAL_II_PROJECT_CONFIG_RELDIR@/binary),)
+ INCLUDE = @MAKEFILE_INCLUDE_DIRS_INSTALLATION@
+else
+ INCLUDE = @MAKEFILE_INCLUDE_DIRS_BINARY@
+endif
# compiler flags for debug and optimized mode
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Configuration for the lapack library:
#
MACRO(FEATURE_LAPACK_FIND_EXTERNAL var)
- FIND_PACKAGE(LAPACK)
+ FIND_PACKAGE(DEALII_LAPACK)
IF(LAPACK_FOUND)
- MARK_AS_ADVANCED(
- atlas_LIBRARY
- blas_LIBRARY
- gslcblas_LIBRARY
- lapack_LIBRARY
- m_LIBRARY
- ptf77blas_LIBRARY
- ptlapack_LIBRARY
- refblas_LIBRARY
- reflapack_LIBRARY
- )
SET(${var} TRUE)
ENDIF()
ENDMACRO()
)
MACRO(CHECK_FOR_LAPACK_FUNCTIONS)
+ #
+ # Clear the test flags because the following test will use a C compiler
+ #
+ CLEAR_CMAKE_REQUIRED()
+ SET(CMAKE_REQUIRED_FLAGS "${LAPACK_LINKER_FLAGS}")
SET(CMAKE_REQUIRED_LIBRARIES ${LAPACK_LIBRARIES})
#
- # For some static lapack versions it is necessary to link with -lm.
- # So link with it as well if -lm is already present in our link
- # interface:
+ # Push -pthread as well:
#
- IF(NOT m_lib MATCHES "-NOTFOUND")
- LIST(APPEND CMAKE_REQUIRED_LIBRARIES ${m_lib})
+ ENABLE_IF_SUPPORTED(CMAKE_REQUIRED_FLAGS "-pthread")
+
+ IF(CMAKE_C_COMPILER_WORKS)
+ FOREACH(_func ${DEAL_II_LAPACK_FUNCTIONS})
+ STRING(TOUPPER ${_func} _func_uppercase)
+ CHECK_FUNCTION_EXISTS(${_func} HAVE_${_func_uppercase})
+ ENDFOREACH()
+ ELSE()
+ MESSAGE(STATUS
+ "No suitable C compiler was found! Skipping LAPACK symbol check."
+ )
+ FOREACH(_func ${DEAL_II_LAPACK_FUNCTIONS})
+ SET_IF_EMPTY(HAVE_${_func_uppercase} TRUE)
+ ENDFOREACH()
ENDIF()
- ADD_FLAGS(CMAKE_REQUIRED_FLAGS "${LAPACK_LINKER_FLAGS}")
-
- FOREACH(_func ${DEAL_II_LAPACK_FUNCTIONS})
- STRING(TOUPPER ${_func} _func_uppercase)
- CHECK_FUNCTION_EXISTS(${_func} HAVE_${_func_uppercase})
- ENDFOREACH()
-
- SET(CMAKE_REQUIRED_LIBRARIES)
- STRIP_FLAG(CMAKE_REQUIRED_FLAGS "${LAPACK_LINKER_FLAGS}")
+ RESET_CMAKE_REQUIRED()
ENDMACRO()
ENDMACRO()
-MACRO(FEATURE_LAPACK_CONFIGURE_EXTERNAL)
- #
- # So, well... LAPACK_LINKER_FLAGS and LAPACK_LIBRARIES should contain the
- # complete link interface. But for invalid user overrides we include
- # BLAS_LIBRARIES and BLAS_LINKER_FLAGS as well..
- #
- IF(NOT LAPACK_LINKER_FLAGS MATCHES "${BLAS_LINKER_FLAGS}")
- MESSAGE(STATUS
- "Manually adding BLAS_LINKER_FLAGS to LAPACK_LINKER_FLAGS"
- )
- ADD_FLAGS(LAPACK_LINKER_FLAGS "${BLAS_LINKER_FLAGS}")
- ENDIF()
- IF(NOT "${LAPACK_LIBRARIES}" MATCHES "${BLAS_LIBRARIES}")
- MESSAGE(STATUS
- "Manually adding BLAS_LIBRARIES to LAPACK_LIBRARIES"
- )
- LIST(APPEND LAPACK_LIBRARIES ${BLAS_LIBRARIES})
- ENDIF()
- ADD_FLAGS(CMAKE_SHARED_LINKER_FLAGS "${LAPACK_LINKER_FLAGS}")
- LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES ${LAPACK_LIBRARIES})
+MACRO(FEATURE_LAPACK_CONFIGURE_EXTERNAL)
+ ADD_FLAGS(DEAL_II_LINKER_FLAGS "${LAPACK_LINKER_FLAGS}")
+ DEAL_II_APPEND_LIBRARIES(${LAPACK_LIBRARIES})
CHECK_FOR_LAPACK_FUNCTIONS()
ENDMACRO()
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Configuration for mpi support:
#
+# We look for the C and Fortran libraries as well because they are needed
+# by some external libraries:
+#
MACRO(FEATURE_MPI_FIND_EXTERNAL var)
#
# directly.
#
SET_IF_EMPTY(MPI_CXX_COMPILER ${CMAKE_CXX_COMPILER})
- SET_IF_EMPTY(MPI_C_COMPILER ${CMAKE_C_COMPILER}) # for good measure
+ IF(CMAKE_C_COMPILER_WORKS)
+ SET_IF_EMPTY(MPI_C_COMPILER ${CMAKE_C_COMPILER}) # for good measure
+ ELSE()
+ MESSAGE(STATUS
+ "No suitable C compiler was found! MPI C interface can not be "
+ "autodetected"
+ )
+ ENDIF()
+ IF(CMAKE_Fortran_COMPILER_WORKS)
+ SET_IF_EMPTY(MPI_Fortran_COMPILER ${CMAKE_Fortran_COMPILER}) # for good measure
+ ELSE()
+ MESSAGE(STATUS
+ "No suitable Fortran compiler was found! MPI Fortran interface can "
+ "not be autodetected"
+ )
+ ENDIF()
FIND_PACKAGE(MPI)
IF(NOT MPI_CXX_FOUND)
SET(MPI_FOUND) # clear this value so that FIND_PACKAGE runs again.
UNSET(MPI_CXX_COMPILER CACHE)
UNSET(MPI_C_COMPILER CACHE)
+ UNSET(MPI_Fortran_COMPILER CACHE)
FIND_PACKAGE(MPI)
ENDIF()
ENDIF()
- IF(MPI_CXX_FOUND)
- # Hide some variables:
- MARK_AS_ADVANCED(MPI_EXTRA_LIBRARY MPI_LIBRARY)
+ #
+ # Manually clean up variables:
+ #
+ FOREACH(_lang C CXX Fortran)
+ IF(MPI_${_lang}_LIBRARIES MATCHES "-NOTFOUND")
+ SET(MPI_${_lang}_LIBRARIES)
+ ENDIF()
+ ENDFOREACH()
+ # Hide some variables:
+ MARK_AS_ADVANCED(MPI_EXTRA_LIBRARY MPI_LIBRARY)
+
+ IF(MPI_CXX_FOUND)
SET(${var} TRUE)
ENDIF()
ENDMACRO()
MACRO(FEATURE_MPI_CONFIGURE_EXTERNAL)
ADD_FLAGS(CMAKE_CXX_FLAGS "${MPI_CXX_COMPILE_FLAGS}")
- ADD_FLAGS(CMAKE_SHARED_LINKER_FLAGS "${MPI_CXX_LINK_FLAGS}")
+ ADD_FLAGS(DEAL_II_LINKER_FLAGS "${MPI_CXX_LINK_FLAGS}")
- LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES ${MPI_CXX_LIBRARIES})
+ DEAL_II_APPEND_LIBRARIES(${MPI_CXX_LIBRARIES})
INCLUDE_DIRECTORIES(${MPI_CXX_INCLUDE_PATH})
# The user has to know the location of the mpi headers as well:
MESSAGE(FATAL_ERROR "\n"
"Could not find any suitable mpi library!\n"
"Please ensure that an mpi library is installed on your computer\n"
- "and set CMAKE_CXX_COMPILER and CMAKE_C_COMPILER to the appropriate mpi\n"
- "wrappers:\n"
- " $ CC=\".../mpicc\" CXX=\".../mpicxx\" cmake <...>\n"
- " $ cmake -DCMAKE_C_COMPILER=\".../mpicc\" -DCMAKE_CXX_COMPIER=\".../mpicxx\" <...>\n"
+ "and set CMAKE_CXX_COMPILER to the appropriate mpi wrappers:\n"
+ " $ CXX=\".../mpicxx\" cmake <...>\n"
+ " $ cmake -DCMAKE_CXX_COMPILER=\".../mpicxx\" <...>\n"
+ "Or with additional C and Fortran wrappers (recommended!):\n"
+ " $ CC=\".../mpicc\" CXX=\".../mpicxx\" F90=\".../mpif90\" cmake <...>\n"
+ " $ cmake -DCMAKE_C_COMPILER=\".../mpicc\"\\\n"
+ " -DCMAKE_CXX_COMPILER=\".../mpicxx\"\\\n"
+ " -DCMAKE_Fortran_COMPILER=\".../mpif90\"\\\n"
+ " <...>\n"
)
ENDMACRO()
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# The macro will be included in CONFIGURE_FEATURE_THREADS_EXTERNAL/BUNDLED.
#
MACRO(SETUP_THREADING)
- FIND_PACKAGE(Threads)
+ #
+ # Unfortunately the FindThreads macro needs a working C compiler
+ #
+ IF(CMAKE_C_COMPILER_WORKS)
+ #
+ # Switch the library preference back to prefer dynamic libraries if
+ # DEAL_II_PREFER_STATIC_LIBS=TRUE but DEAL_II_STATIC_EXECUTABLE=FALSE. In
+ # this case system libraries should be linked dynamically.
+ #
+ SWITCH_LIBRARY_PREFERENCE()
+
+ #
+ # Clear the test flags because FindThreads.cmake will use a C compiler:
+ #
+ CLEAR_CMAKE_REQUIRED()
+
+ FIND_PACKAGE(Threads)
+
+ RESET_CMAKE_REQUIRED()
+ SWITCH_LIBRARY_PREFERENCE()
+
+ ELSE()
+
+ #
+ # We have no way to query for thread support. Just assume that it is
+ # provided by Pthreads...
+ #
+ MESSAGE(STATUS
+ "No suitable C compiler was found! Assuming threading is provided by Pthreads."
+ )
+ SET_IF_EMPTY(Threads_FOUND TRUE)
+ SET_IF_EMPTY(CMAKE_THREAD_LIBS_INIT "-lpthread")
+ SET_IF_EMPTY(CMAKE_USE_PTHREADS_INIT TRUE)
+ ENDIF()
IF(NOT Threads_FOUND)
- # TODO:
+ #
+ # TODO: This is a dead end. Threading might be setup with internal TBB
+ # so we have no way of returning unsuccessfully...
+ #
MESSAGE(FATAL_ERROR
"\nInternal configuration error: No Threading support found\n\n"
)
ENDIF()
ENDIF()
- ADD_FLAGS(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_THREAD_LIBS_INIT}")
+ ADD_FLAGS(DEAL_II_LINKER_FLAGS "${CMAKE_THREAD_LIBS_INIT}")
#
# Set up some posix thread specific configuration toggles:
}
"
DEAL_II_HAVE_MT_POSIX_BARRIERS)
- STRIP_FLAG(CMAKE_REQUIRED_FLAGS "${CMAKE_THREAD_LIBS_INIT}")
+ RESET_CMAKE_REQUIRED()
IF(NOT DEAL_II_HAVE_MT_POSIX_BARRIERS)
SET(DEAL_II_USE_MT_POSIX_NO_BARRIERS TRUE)
ENDIF()
MACRO(FEATURE_THREADS_CONFIGURE_EXTERNAL)
INCLUDE_DIRECTORIES(${TBB_INCLUDE_DIR})
- SPLIT_DEBUG_RELEASE(_tbb_debug _tbb_release ${TBB_LIBRARIES})
+ DEAL_II_APPEND_LIBRARIES(${TBB_LIBRARIES})
IF(CMAKE_BUILD_TYPE MATCHES "Debug")
IF(TBB_WITH_DEBUG_LIB)
)
ENDIF()
- LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES_DEBUG ${_tbb_debug})
ENDIF()
- IF(CMAKE_BUILD_TYPE MATCHES "Release")
- LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES_RELEASE ${_tbb_release})
- ENDIF()
SETUP_THREADING()
ENDMACRO()
-#
-# Resolve a cache invalidation problem by searching for these flags
-# unconditionally. They're used in FEATURE_THREADS_CONFIGURE_BUNDLED
-# depending on cached variables.
-#
-ENABLE_IF_SUPPORTED(_dummy "-Wno-parentheses")
-ENABLE_IF_SUPPORTED(_dummy "-Wno-long-long")
-
-
MACRO(FEATURE_THREADS_CONFIGURE_BUNDLED)
#
# Setup threading (before configuring our build...)
#
# tbb uses dlopen/dlclose, so link against libdl.so as well:
#
- FIND_LIBRARY(dl_lib NAMES dl)
- MARK_AS_ADVANCED(dl_lib)
- IF(NOT dl_lib MATCHES "-NOTFOUND")
- LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES ${dl_lib})
+ FIND_LIBRARY(dl_LIBRARY NAMES dl)
+ MARK_AS_ADVANCED(dl_LIBRARY)
+ IF(NOT dl_LIBRARY MATCHES "-NOTFOUND")
+ DEAL_II_APPEND_LIBRARIES(${dl_LIBRARY})
ENDIF()
INCLUDE_DIRECTORIES(${TBB_FOLDER}/include)
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Configuration for the umfpack library:
--- /dev/null
+## ---------------------------------------------------------------------
+## $Id$
+##
+## Copyright (C) 2012 - 2013 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
+
+#
+# Configuration for the metis library:
+#
+
+MACRO(FEATURE_METIS_FIND_EXTERNAL var)
+ FIND_PACKAGE(METIS)
+
+ IF(METIS_FOUND)
+ IF(METIS_VERSION_MAJOR GREATER 4)
+ SET(${var} TRUE)
+ ELSE()
+ MESSAGE(STATUS "Insufficient metis installation found: "
+ "Version 5.x required!"
+ )
+ SET(METIS_ADDITIONAL_ERROR_STRING
+ "Could not find a sufficient modern metis installation: "
+ "Version 5.x required!\n"
+ )
+
+ UNSET(METIS_LIBRARY CACHE)
+ UNSET(METIS_INCLUDE_DIR CACHE)
+ SET(METIS_DIR "" CACHE PATH
+ "An optional hint to a metis directory"
+ )
+ MARK_AS_ADVANCED(CLEAR METIS_DIR)
+ ENDIF()
+ ENDIF()
+ENDMACRO()
+
+CONFIGURE_FEATURE(METIS)
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Configuration for the petsc library:
SET(PETSC_ARCH "" CACHE STRING
"An optional hint to a PETSc arch"
)
+ MARK_AS_ADVANCED(CLEAR PETSC_DIR PETSC_ARCH)
ENDIF()
ENDIF()
ENDMACRO()
-#
-# Resolve a cache invalidation problem by searching for this flag
-# unconditionally. It is used in FEATURE_PETSC_CONFIGURE_EXTERNAL
-# depending on cached variables.
-#
-ENABLE_IF_SUPPORTED(_dummy "-Wno-long-long")
-
MACRO(FEATURE_PETSC_CONFIGURE_EXTERNAL)
INCLUDE_DIRECTORIES(${PETSC_INCLUDE_DIRS})
# The user has to know the location of the petsc headers as well:
LIST(APPEND DEAL_II_USER_INCLUDE_DIRS ${PETSC_INCLUDE_DIRS})
- LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES ${PETSC_LIBRARIES})
+ DEAL_II_APPEND_LIBRARIES(${PETSC_LIBRARIES})
#
# Disable a bunch of warnings when compiling with petsc:
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Configuration for the trilinos library:
"has to be configured to use the same number of bits as deal.II, but "
"found:\n"
" DEAL_II_WITH_64BIT_INDICES = ${DEAL_II_WITH_64BIT_INDICES}\n"
- " TRILINOS_WITH_NO_32BIT_INDICES = ${TRILINOS_WITH_NO_32_BIT_INDICES}\n"
+ " TRILINOS_WITH_NO_32BIT_INDICES = ${TRILINOS_WITH_NO_32_BIT_INDICES}\n"
)
SET(${var} FALSE)
- ENDIF()
+ ENDIF()
#
# Trilinos has to be configured with 64bit indices if deal.II uses unsigned long
IF(TRILINOS_WITH_NO_64BIT_INDICES AND DEAL_II_WITH_64BIT_INDICES)
MESSAGE(STATUS "deal.II was configured to use 64bit global indices but "
"Trilinos was not."
- )
+ )
SET(TRILINOS_ADDITIONAL_ERROR_STRING
${TRILINOS_ADDITIONAL_ERROR_STRING}
"The Trilinos installation (found at \"${TRILINOS_DIR}\")\n"
"has to be configured to use the same number of bits as deal.II, but "
"found:\n"
" DEAL_II_WITH_64BIT_INDICES = ${DEAL_II_WITH_64BIT_INDICES}\n"
- " TRILINOS_WITH_NO_64BIT_INDICES = ${TRILINOS_WITH_NO_64_BIT_INDICES}\n"
+ " TRILINOS_WITH_NO_64BIT_INDICES = ${TRILINOS_WITH_NO_64_BIT_INDICES}\n"
)
SET(${var} FALSE)
- ENDIF()
-
+ ENDIF()
#
# Some versions of Sacado_cmath.hpp do things that aren't compatible
# with the -std=c++0x flag of GCC, see deal.II FAQ.
# Test whether that is indeed the case
#
- IF(${var})
- SET(CMAKE_REQUIRED_INCLUDES ${TRILINOS_INCLUDE_DIRS})
- PUSH_TEST_FLAG("${DEAL_II_CXX11_FLAG}")
-
- CHECK_CXX_SOURCE_COMPILES(
- "
- #include <Sacado_cmath.hpp>
- int main(){ return 0; }
- "
- TRILINOS_SUPPORTS_CPP11)
-
- IF(DEAL_II_CAN_USE_CXX11 AND NOT TRILINOS_SUPPORTS_CPP11)
- #
- # Try whether exporting HAS_C99_TR1_CMATH helps:
- #
- PUSH_TEST_FLAG("-DHAS_C99_TR1_CMATH")
- CHECK_CXX_SOURCE_COMPILES(
- "
- #include <Sacado_cmath.hpp>
- int main(){ return 0; }
- "
- TRILINOS_HAS_C99_TR1_WORKAROUND)
- POP_TEST_FLAG()
+ IF(DEAL_II_CAN_USE_CXX11 AND NOT TRILINOS_SUPPORTS_CPP11)
- IF(TRILINOS_HAS_C99_TR1_WORKAROUND)
- LIST(APPEND DEAL_II_DEFINITIONS "HAS_C99_TR1_CMATH")
- LIST(APPEND DEAL_II_USER_DEFINITIONS "HAS_C99_TR1_CMATH")
- ELSE()
- MESSAGE(STATUS "Could not find a sufficient Trilinos installation: "
- "The installation is not compatible with the C++ standard selected for "
- "this compiler."
- )
- SET(TRILINOS_ADDITIONAL_ERROR_STRING
- ${TRILINOS_ADDITIONAL_ERROR_STRING}
- "The Trilinos installation (found at \"${TRILINOS_DIR}\")\n"
- "is not compatible with the C++ standard selected for\n"
- "this compiler. See the deal.II FAQ page for a solution.\n\n"
- )
- SET(${var} FALSE)
- ENDIF()
+ IF(TRILINOS_HAS_C99_TR1_WORKAROUND)
+ LIST(APPEND DEAL_II_DEFINITIONS "HAS_C99_TR1_CMATH")
+ LIST(APPEND DEAL_II_USER_DEFINITIONS "HAS_C99_TR1_CMATH")
+ ELSE()
+ MESSAGE(STATUS "Could not find a sufficient Trilinos installation: "
+ "The installation is not compatible with the C++ standard selected for "
+ "this compiler."
+ )
+ SET(TRILINOS_ADDITIONAL_ERROR_STRING
+ ${TRILINOS_ADDITIONAL_ERROR_STRING}
+ "The Trilinos installation (found at \"${TRILINOS_DIR}\")\n"
+ "is not compatible with the C++ standard selected for\n"
+ "this compiler. See the deal.II FAQ page for a solution.\n\n"
+ )
+ SET(${var} FALSE)
ENDIF()
-
- POP_TEST_FLAG()
- SET(CMAKE_REQUIRED_INCLUDES)
-
- #
- # Remove the following variables from the cache to force a recheck:
- #
- UNSET(TRILINOS_SUPPORTS_CPP11 CACHE)
- UNSET(TRILINOS_HAS_C99_TR1_WORKAROUND CACHE)
ENDIF()
ENDIF(TRILINOS_FOUND)
-ENDMACRO()
+ IF(NOT ${var})
+ UNSET(TRILINOS_CONFIG CACHE)
+ SET(TRILINOS_DIR "" CACHE STRING
+ "An optional hint to a Trilinos installation"
+ )
+ MARK_AS_ADVANCED(CLEAR TRILINOS_DIR)
+ ENDIF()
+
+ENDMACRO()
-#
-# Resolve a cache invalidation problem by searching for these flags
-# unconditionally. They're used in FEATURE_TRILINOS_CONFIGURE_EXTERNAL
-# depending on cached variables.
-#
-ENABLE_IF_SUPPORTED(_dummy "-Wno-unused")
-ENABLE_IF_SUPPORTED(_dummy "-Wno-extra")
-ENABLE_IF_SUPPORTED(_dummy "-Wno-overloaded-virtual")
MACRO(FEATURE_TRILINOS_CONFIGURE_EXTERNAL)
- #
- # *Boy* Sanitize the include paths given by TrilinosConfig.cmake...
- #
- STRING(REGEX REPLACE
- "(lib64|lib)\\/cmake\\/Trilinos\\/\\.\\.\\/\\.\\.\\/\\.\\.\\/" ""
- TRILINOS_INCLUDE_DIRS "${TRILINOS_INCLUDE_DIRS}"
- )
INCLUDE_DIRECTORIES(${TRILINOS_INCLUDE_DIRS})
# The user has to know the location of the trilinos headers as well:
LIST(APPEND DEAL_II_USER_INCLUDE_DIRS ${TRILINOS_INCLUDE_DIRS})
- LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES
- # The Trilinos libraries:
- ${TRILINOS_LIBRARIES}
- # All external libraries necessary for the Trilinos libraries. Nice and
- # easy :-)
- ${Trilinos_TPL_LIBRARIES}
- )
+ DEAL_II_APPEND_LIBRARIES(${TRILINOS_LIBRARIES})
SET(DEAL_II_EXPAND_TRILINOS_VECTOR "TrilinosWrappers::Vector")
SET(DEAL_II_EXPAND_TRILINOS_BLOCKVECTOR "TrilinosWrappers::BlockVector")
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Configuration for the ARPACK library:
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Configuration for the boost library:
IF(NOT FEATURE_THREADS_PROCESSED)
MESSAGE(FATAL_ERROR "\n"
"Internal build system error:\n"
- "configure_boost.cmake included before configure_tbb.cmake\n\n"
+ "configure_boost.cmake included before configure_1_threads.cmake\n\n"
)
ENDIF()
MACRO(FEATURE_BOOST_FIND_EXTERNAL var)
- #
- # We require at least version 1.44
- #
+
+ IF(NOT DEFINED BOOST_DIR)
+ SET(BOOST_DIR "$ENV{BOOST_DIR}")
+ ELSE()
+ SET_IF_EMPTY(BOOST_DIR "$ENV{BOOST_DIR}")
+ ENDIF()
+ IF(NOT "${BOOST_DIR}" STREQUAL "")
+ SET(BOOST_ROOT "${BOOST_DIR}")
+ ENDIF()
+
IF(DEAL_II_WITH_THREADS)
- FIND_PACKAGE(Boost 1.44 COMPONENTS serialization system thread)
+ SET(_boost_components serialization system thread)
ELSE()
- FIND_PACKAGE(Boost 1.44 COMPONENTS serialization system)
+ SET(_boost_components serialization system)
ENDIF()
+ #
+ # Prefer static libs if BUILD_SHARED_LIBS=OFF:
+ #
+ IF(NOT BUILD_SHARED_LIBS)
+ SET(Boost_USE_STATIC_LIBS TRUE)
+ ENDIF()
+
+ FIND_PACKAGE(Boost 1.44 COMPONENTS ${_boost_components})
+
+ #
+ # Fall back to dynamic libraries if no static libraries could be found:
+ #
+ IF( Boost_USE_STATIC_LIBS AND
+ (NOT Boost_SERIALIZATION_FOUND OR NOT Boost_SYSTEM_FOUND)
+ )
+ SET(Boost_USE_STATIC_LIBS FALSE)
+ FIND_PACKAGE(Boost 1.44 COMPONENTS ${_boost_components})
+ ENDIF()
+
+ MARK_AS_ADVANCED(Boost_DIR)
+
+ SET(BOOST_VERSION_MAJOR "${Boost_MAJOR_VERSION}")
+ SET(BOOST_VERSION_MINOR "${Boost_MINOR_VERSION}")
+ SET(BOOST_VERSION_SUBMINOR "${Boost_SUBMINOR_VERSION}")
+ SET(BOOST_VERSION
+ "${BOOST_VERSION_MAJOR}.${BOOST_VERSION_MINOR}.${BOOST_VERSION_SUBMINOR}"
+ )
+
+
IF( Boost_SERIALIZATION_FOUND AND
Boost_SYSTEM_FOUND AND
(NOT DEAL_II_WITH_THREADS OR Boost_THREAD_FOUND)
)
+ MARK_AS_ADVANCED(BOOST_DIR)
SET(${var} TRUE)
- MARK_AS_ADVANCED(Boost_DIR)
+ ELSE()
+ SET(BOOST_DIR "" CACHE PATH
+ "An optional hint to a boost directory"
+ )
ENDIF()
ENDMACRO()
#
LIST(REMOVE_ITEM Boost_LIBRARIES "pthread")
- #
- # Transform Boost_LIBRARIES into a list of debug and release libraries
- # without keywords:
- #
- SPLIT_DEBUG_RELEASE(_boost_debug _boost_release ${Boost_LIBRARIES})
+ DEAL_II_APPEND_LIBRARIES(${Boost_LIBRARIES})
- IF (CMAKE_BUILD_TYPE MATCHES "Debug")
- LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES_DEBUG ${_boost_debug})
- ENDIF()
-
- IF (CMAKE_BUILD_TYPE MATCHES "Release")
- LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES_RELEASE ${_boost_release})
- ENDIF()
ENDMACRO()
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Configuration for functionparser
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Configuration for the hdf5 library:
" HDF5_WITH_MPI = ${HDF5_WITH_MPI}\n"
)
ENDIF()
+
+ INCLUDE_DIRECTORIES(${HDF5_INCLUDE_DIRS})
+ LIST(APPEND DEAL_II_USER_INCLUDE_DIRS ${HDF5_INCLUDE_DIRS})
+ DEAL_II_APPEND_LIBRARIES(${HDF5_LIBRARIES})
+
+
ENDIF()
ENDMACRO()
+++ /dev/null
-#####
-##
-## Copyright (C) 2012, 2013 by the deal.II authors
-##
-## This file is part of the deal.II library.
-##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
-##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
-
-#
-# Configuration for the netcdf library:
-#
-
-MACRO(FEATURE_METIS_FIND_EXTERNAL var)
- FIND_PACKAGE(METIS)
-
- IF(METIS_FOUND)
- IF(METIS_MAJOR GREATER 4)
- SET(${var} TRUE)
- ELSE()
- MESSAGE(STATUS "Insufficient metis installation found: "
- "Version 5.x required!"
- )
- SET(METIS_ADDITIONAL_ERROR_STRING
- "Could not find a sufficient modern metis installation: "
- "Version 5.x required!\n"
- )
-
- UNSET(METIS_LIBRARY CACHE)
- UNSET(METIS_INCLUDE_DIR CACHE)
- SET(METIS_DIR "" CACHE PATH
- "An optional hint to a metis directory"
- )
- ENDIF()
- ENDIF()
-ENDMACRO()
-
-CONFIGURE_FEATURE(METIS)
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Configuration for the MUMPS library:
# The user has to know the location of the MUMPS headers as well:
LIST(APPEND DEAL_II_USER_INCLUDE_DIRS ${MUMPS_INCLUDE_DIRS})
- LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES ${MUMPS_LIBRARIES})
+ DEAL_II_APPEND_LIBRARIES(${MUMPS_LIBRARIES})
ENDMACRO()
CONFIGURE_FEATURE(MUMPS)
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Configuration for the netcdf library:
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Configuration for the p4est and sc libraries:
"p4est has to be configured with MPI enabled.\n"
)
- UNSET(P4EST_LIBRARY CACHE)
+ UNSET(P4EST_LIBRARY_OPTIMIZED CACHE)
+ UNSET(P4EST_LIBRARY_DEBUG CACHE)
UNSET(P4EST_INCLUDE_DIR CACHE)
- UNSET(SC_LIBRARY CACHE)
+ UNSET(SC_LIBRARY_OPTIMIZED CACHE)
+ UNSET(SC_LIBRARY_DEBUG CACHE)
UNSET(SC_INCLUDE_DIR CACHE)
SET(P4EST_DIR "" CACHE PATH
"An optional hint to a p4est installation/directory"
)
+ MARK_AS_ADVANCED(CLEAR P4EST_DIR)
ELSE()
SET(${var} TRUE)
ENDIF()
# The user has to know the location of the P4EST headers as well:
LIST(APPEND DEAL_II_USER_INCLUDE_DIRS ${P4EST_INCLUDE_DIRS})
- LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES ${P4EST_LIBRARIES})
+ DEAL_II_APPEND_LIBRARIES(${P4EST_LIBRARIES})
ENDMACRO()
CONFIGURE_FEATURE(P4EST)
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Configuration for the SLEPC library:
IF(SLEPC_FOUND)
#
- # Check whether SLEPc and PETSc are compatible.
+ # Check whether SLEPc and PETSc are compatible according to
+ # SLEPc's rules: This is equivalent to asking if the VERSION_MAJOR
+ # and VERSION_MINOR of PETSc and SLEPc are
+ # equivalent; and where VERSION_SUBMINORs are allowed to differ.
#
- IF("${SLEPC_VERSION}" STREQUAL "${PETSC_VERSION}")
+ IF( ("${SLEPC_VERSION_MAJOR}" STREQUAL "${PETSC_VERSION_MAJOR}")
+ AND
+ ("${SLEPC_VERSION_MINOR}" STREQUAL "${PETSC_VERSION_MINOR}"))
SET(${var} TRUE)
ELSE()
SET(SLEPC_DIR "" CACHE PATH
"An optional hint to a SLEPc directory"
)
+ MARK_AS_ADVANCED(CLEAR SLEPC_DIR)
SET(${var} FALSE)
ENDIF()
# The user has to know the location of the SLEPC headers as well:
LIST(APPEND DEAL_II_USER_INCLUDE_DIRS ${SLEPC_INCLUDE_DIRS})
- LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES ${SLEPC_LIBRARIES})
+ DEAL_II_APPEND_LIBRARIES(${SLEPC_LIBRARIES})
ENDMACRO()
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Configuration for the zlib library:
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# A small macro used for (string-)appending a string "${flags}" to a
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Check for a compiler bug.
--- /dev/null
+## ---------------------------------------------------------------------
+## $Id$
+##
+## Copyright (C) 2013 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
+
+#
+# A small macro to clear the CMAKE_REQUIRED_* variables.
+#
+# Usage:
+# CLEAR_CMAKE_REQUIRED_FLAGS
+#
+
+MACRO(CLEAR_CMAKE_REQUIRED)
+ SET(CMAKE_REQUIRED_FLAGS)
+ SET(CMAKE_REQUIRED_INCLUDES)
+ SET(CMAKE_REQUIRED_LIBRARIES)
+ENDMACRO()
+
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# If bool is "true" (in a cmake fashion...), set variable to "yes",
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# This macro is used for the feature configuration in deal.II
#
-###########################################################################
-# #
-# Helper Macros: #
-# #
-###########################################################################
+########################################################################
+# #
+# Helper Macros: #
+# #
+########################################################################
#
# Some black magic to have substitution in command names:
INCLUDE_DIRECTORIES(${${_feature}_INCLUDE_DIRS})
ENDIF()
IF(DEFINED ${_feature}_LIBRARIES)
- LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES ${${_feature}_LIBRARIES})
+ DEAL_II_APPEND_LIBRARIES(${${_feature}_LIBRARIES})
ENDIF()
IF(DEFINED ${_feature}_LINKER_FLAGS)
- ADD_FLAGS(CMAKE_SHARED_LINKER_FLAGS "${${_feature}_LINKER_FLAGS}")
+ ADD_FLAGS(DEAL_II_LINKER_FLAGS "${${_feature}_LINKER_FLAGS}")
ENDIF()
ENDMACRO()
-###########################################################################
-# #
-# CONFIGURE_FEATURE: #
-# #
-###########################################################################
+########################################################################
+# #
+# CONFIGURE_FEATURE: #
+# #
+########################################################################
MACRO(CONFIGURE_FEATURE _feature)
#
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# A small wrapper around
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# A small wrapper around ADD_DEPENDENCIES to add the specified dependencies
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# A small wrapper around ADD_LIBRARY that will define a target for each
# build type specified in DEAL_II_BUILD_TYPES
#
# It is assumed that the desired compilation configuration is set via
-# DEAL_II_SHARED_LINKER_FLAGS_${build}
+# DEAL_II_LINKER_FLAGS_${build}
# DEAL_II_CXX_FLAGS_${build}
# DEAL_II_DEFINITIONS_${build}
#
# as well as the global (for all build types)
-# CMAKE_SHARED_LINKER_FLAGS
+# DEAL_II_LINKER_FLAGS
# CMAKE_CXX_FLAGS
# DEAL_II_DEFINITIONS
#
)
SET_TARGET_PROPERTIES(${_library}.${_build_lowercase} PROPERTIES
- LINK_FLAGS "${DEAL_II_SHARED_LINKER_FLAGS_${_build}}"
+ LINK_FLAGS "${DEAL_II_LINKER_FLAGS};${DEAL_II_LINKER_FLAGS_${_build}}"
COMPILE_DEFINITIONS "${DEAL_II_DEFINITIONS};${DEAL_II_DEFINITIONS_${_build}}"
COMPILE_FLAGS "${DEAL_II_CXX_FLAGS_${_build}}"
LINKER_LANGUAGE "CXX"
--- /dev/null
+## ---------------------------------------------------------------------
+## $Id$
+##
+## Copyright (C) 2013 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
+
+#
+# A small macro to add libraries to
+# DEAL_II_EXTERNAL_LIBRARIES
+# DEAL_II_EXTERNAL_LIBRARIES_DEBUG
+# DEAL_II_EXTERNAL_LIBRARIES_RELEASE
+# depending on the "optmized", "debug" or "general" keyword
+#
+# Usage:
+# DEAL_II_APPEND_LIBRARIES(<list of libraries>)
+#
+
+MACRO(DEAL_II_APPEND_LIBRARIES)
+
+ SET(_toggle "general")
+ FOREACH(_tmp ${ARGN})
+ IF( "${_tmp}" STREQUAL "debug" OR
+ "${_tmp}" STREQUAL "optimized" OR
+ "${_tmp}" STREQUAL "general" )
+ SET(_toggle "${_tmp}")
+ ELSE()
+ IF("${_toggle}" STREQUAL "general")
+ LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES ${_tmp})
+ ELSEIF("${_toggle}" STREQUAL "debug")
+ LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES_DEBUG ${_tmp})
+ ELSEIF("${_toggle}" STREQUAL "optimized")
+ LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES_RELEASE ${_tmp})
+ ENDIF()
+ ENDIF()
+ ENDFOREACH()
+
+ENDMACRO()
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# This file implements the DEAL_II_INITIALIZE_VARIABLES macro, which is
ENDIF()
#
- # Bail out if build type is unknown...
+ # Reset build type if unsupported, i.e. if it is not (case insensitively
+ # equal to Debug or Release or unsupported by the current build type:
#
- IF( NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Release" AND
- NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" )
- MESSAGE(FATAL_ERROR
- "\nCMAKE_BUILD_TYPE does neither match Release nor Debug!\n\n"
+ STRING(TOLOWER "${CMAKE_BUILD_TYPE}" _cmake_build_type)
+ STRING(TOLOWER "${DEAL_II_BUILD_TYPE}" _deal_ii_build_type)
+
+ IF( NOT "${_cmake_build_type}" MATCHES "^(debug|release)$"
+ OR NOT _deal_ii_build_type MATCHES "${_cmake_build_type}" )
+
+ IF("${DEAL_II_BUILD_TYPE}" STREQUAL "DebugRelease")
+ SET(_new_build_type "Debug")
+ ELSE()
+ SET(_new_build_type "${DEAL_II_BUILD_TYPE}")
+ ENDIF()
+
+ MESSAGE(
+"###
+#
+# WARNING:
+#
+# CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\" unsupported by current installation!
+# deal.II was built with CMAKE_BUILD_TYPE \"${DEAL_II_BUILD_TYPE}\".
+#
+# CMAKE_BUILD_TYPE is forced to \"${_new_build_type}\".
+#
+###"
)
- ENDIF()
- #
- # ... or unsupported
- #
- IF(NOT DEAL_II_BUILD_TYPE MATCHES "${CMAKE_BUILD_TYPE}")
- MESSAGE(FATAL_ERROR "\n"
- "CMAKE_BUILD_TYPE \"${CMAKE_BUILD_TYPE}\" unsupported by current installation!\n"
- "deal.II was build with \"${DEAL_II_BUILD_TYPE}\" only build type.\n\n"
+ SET(CMAKE_BUILD_TYPE "${_new_build_type}" CACHE STRING
+ "Choose the type of build, options are: Debug, Release"
+ FORCE
)
ENDIF()
+
SET(CMAKE_CXX_COMPILER ${DEAL_II_CXX_COMPILER} CACHE STRING
"CXX Compiler.")
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# This file implements the DEAL_II_INVOKE_AUTOPILOT macro, which is
ADD_EXECUTABLE(${TARGET} ${TARGET_SRC})
DEAL_II_SETUP_TARGET(${TARGET})
- IF(NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
- MESSAGE(STATUS
- "Out-of-source build. Target ${TARGET} defined but additional "
- "autopilot funcionality is not available."
- )
+ MESSAGE(STATUS "Autopilot invoked")
- ELSE()
+ # Define a custom target to easily run the program:
+
+ IF(NOT DEFINED TARGET_RUN)
+ SET(TARGET_RUN ${TARGET})
+ ENDIF()
- MESSAGE(STATUS "Autopilot invoked")
-
- # Define a custom target to easily run the program:
-
- IF(NOT DEFINED TARGET_RUN)
- SET(TARGET_RUN ${TARGET})
- ENDIF()
-
- #
- # Hack for Cygwin targets: Export PATH to point to the dynamic library.
- # This is more or less harmless, so do this unconditionally.
- #
- FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/run_target.cmake
- "SET(ENV{PATH} \"${CMAKE_CURRENT_BINARY_DIR}:${DEAL_II_PATH}/${DEAL_II_LIBRARY_RELDIR}:\$ENV{PATH}\")\n"
- "EXECUTE_PROCESS(COMMAND ${TARGET_RUN}\n"
- " RESULT_VARIABLE _return_value\n"
- " )\n"
- "IF(NOT \"\${_return_value}\" STREQUAL "0")\n"
- " MESSAGE(SEND_ERROR \"\nProgram terminated with exit code: \${_return_value}\")\n"
- "ENDIF()\n"
+ #
+ # Hack for Cygwin targets: Export PATH to point to the dynamic library.
+ # This is more or less harmless, so do this unconditionally.
+ #
+ FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/run_target.cmake
+ "SET(ENV{PATH} \"${CMAKE_CURRENT_BINARY_DIR}:${DEAL_II_PATH}/${DEAL_II_LIBRARY_RELDIR}:\$ENV{PATH}\")\n"
+ "EXECUTE_PROCESS(COMMAND ${TARGET_RUN}\n"
+ " RESULT_VARIABLE _return_value\n"
+ " )\n"
+ "IF(NOT \"\${_return_value}\" STREQUAL "0")\n"
+ " MESSAGE(SEND_ERROR \"\nProgram terminated with exit code: \${_return_value}\")\n"
+ "ENDIF()\n"
+ )
+ IF(NOT "${TARGET_RUN}" STREQUAL "")
+ ADD_CUSTOM_TARGET(run
+ COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/run_target.cmake
+ DEPENDS ${TARGET}
+ COMMENT "Run ${TARGET} with ${CMAKE_BUILD_TYPE} configuration"
)
- IF(NOT "${TARGET_RUN}" STREQUAL "")
- ADD_CUSTOM_TARGET(run
- COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/run_target.cmake
- DEPENDS ${TARGET}
- COMMENT "Run ${TARGET} with ${CMAKE_BUILD_TYPE} configuration"
- )
- SET(_run_targets
- "# $ make run - to (compile, link and) run the program\n"
- )
- ENDIF()
-
- # Define custom targets to easily switch the build type:
- IF(${DEAL_II_BUILD_TYPE} MATCHES "Debug")
- ADD_CUSTOM_TARGET(debug
- COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR}
- COMMENT "Switch CMAKE_BUILD_TYPE to Debug"
- )
- SET(_switch_targets
- "# $ make debug - to switch the build type to \"Debug\"\n"
- )
- ENDIF()
- IF(${DEAL_II_BUILD_TYPE} MATCHES "Release")
- ADD_CUSTOM_TARGET(release
- COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR}
- COMMENT "Switch CMAKE_BUILD_TYPE to Release"
- )
- SET(_switch_targets
- "${_switch_targets}# $ make release - to switch the build type to \"Release\"\n"
- )
- ENDIF()
-
- # And another custom target to clean up all files generated by the program:
- IF("${CLEAN_UP_FILES}" STREQUAL "")
- SET(CLEAN_UP_FILES *.log *.gmv *.gnuplot *.gpl *.eps *.pov *.vtk *.ucd *.d2)
- ENDIF()
- ADD_CUSTOM_TARGET(runclean
- COMMAND ${CMAKE_COMMAND} -E remove ${CLEAN_UP_FILES}
- COMMENT "runclean invoked"
+ SET(_run_targets
+ "# $ make run - to (compile, link and) run the program\n"
)
+ ENDIF()
- # Define a distclean target to remove every generated file:
- ADD_CUSTOM_TARGET(distclean
- COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target clean
- COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target runclean
- COMMAND ${CMAKE_COMMAND} -E remove_directory CMakeFiles
- COMMAND ${CMAKE_COMMAND} -E remove CMakeCache.txt cmake_install.cmake Makefile
- COMMENT "distclean invoked"
+ # Define custom targets to easily switch the build type:
+ ADD_CUSTOM_TARGET(debug
+ COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR}
+ COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all
+ COMMENT "Switch CMAKE_BUILD_TYPE to Debug"
+ )
+
+ ADD_CUSTOM_TARGET(release
+ COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR}
+ COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all
+ COMMENT "Switch CMAKE_BUILD_TYPE to Release"
+ )
+
+ # Only mention release and debug targets if it is actuallay possible to
+ # switch between them:
+ IF(${DEAL_II_BUILD_TYPE} MATCHES "DebugRelease")
+ SET(_switch_targets
+"# $ make debug - to switch the build type to \"Debug\"
+# $ make release - to switch the build type to \"Release\"\n"
)
+ ENDIF()
- # Define a strip-comments target:
- FIND_PACKAGE(Perl QUIET)
- IF(PERL_FOUND)
- ADD_CUSTOM_TARGET(strip_comments
- COMMAND ${PERL_EXECUTABLE} -pi -e 's\#^[ \\t]*//.*\\n\#\#g;' ${TARGET_SRC}
- COMMENT "strip comments"
- )
- ENDIF()
-
- # Print out some usage information to file:
- FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_usage.cmake
+ # And another custom target to clean up all files generated by the program:
+ IF("${CLEAN_UP_FILES}" STREQUAL "")
+ SET(CLEAN_UP_FILES *.log *.gmv *.gnuplot *.gpl *.eps *.pov *.vtk *.ucd *.d2)
+ ENDIF()
+ ADD_CUSTOM_TARGET(runclean
+ COMMAND ${CMAKE_COMMAND} -E remove ${CLEAN_UP_FILES}
+ COMMENT "runclean invoked"
+ )
+
+ # Define a distclean target to remove every generated file:
+ ADD_CUSTOM_TARGET(distclean
+ COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target clean
+ COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target runclean
+ COMMAND ${CMAKE_COMMAND} -E remove_directory CMakeFiles
+ COMMAND ${CMAKE_COMMAND} -E remove CMakeCache.txt cmake_install.cmake Makefile
+ COMMENT "distclean invoked"
+ )
+
+ # Define a strip-comments target:
+ FIND_PACKAGE(Perl QUIET)
+ IF(PERL_FOUND)
+ ADD_CUSTOM_TARGET(strip_comments
+ COMMAND ${PERL_EXECUTABLE} -pi -e 's\#^[ \\t]*//.*\\n\#\#g;' ${TARGET_SRC}
+ COMMENT "strip comments"
+ )
+ ENDIF()
+
+ # Print out some usage information to file:
+ FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_usage.cmake
"MESSAGE(
\"###
#
# Have a nice day!
#
###\")"
- )
+ )
- # A custom target to print the message:
- ADD_CUSTOM_TARGET(help
- COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_usage.cmake
- )
-
- # Print this message once:
- IF(NOT USAGE_PRINTED)
- INCLUDE(${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_usage.cmake)
- SET(USAGE_PRINTED TRUE CACHE INTERNAL "")
- ELSE()
- MESSAGE(STATUS "Run $ make help to print a detailed help message")
- ENDIF()
+ # A custom target to print the message:
+ ADD_CUSTOM_TARGET(help
+ COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_usage.cmake
+ )
+ # Print this message once:
+ IF(NOT USAGE_PRINTED)
+ INCLUDE(${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/print_usage.cmake)
+ SET(USAGE_PRINTED TRUE CACHE INTERNAL "")
+ ELSE()
+ MESSAGE(STATUS "Run $ make help to print a detailed help message")
ENDIF()
ENDMACRO()
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# This file implements the DEAL_II_SETUP_TARGET macro, which is
)
#
- # Append build type dependend flags and definitions.
+ # Append build type dependent flags and definitions.
#
#
# For this we obey the behaviour of the "optimized" and "debug"
# keywords and this is a bit tricky:
#
- # If the global property DEBUG_CONFIGURATIONS is set all build
- # types that (case insensitive) match one of the listed build types is
- # considered a "debug" build. Ther rest is "optimized".
+ # If the global property DEBUG_CONFIGURATIONS is set all build types that
+ # (case insensitively) match one of the listed build types is considered
+ # a "debug" build. The rest is "optimized".
#
# Otherwise every build type that (case insensitively) matches "debug" is
# considered a debug build.
ENDIF()
ENDIF()
- IF(_on_debug_build)
+ #
+ # We can only append DEBUG link flags and compile definitions if deal.II
+ # was build with Debug or DebugRelease build type. So test for this:
+ #
+ IF( _on_debug_build
+ AND DEAL_II_BUILD_TYPE MATCHES "Debug" )
SET_PROPERTY(TARGET ${_target} APPEND_STRING PROPERTY
LINK_FLAGS " ${DEAL_II_LINKER_FLAGS_DEBUG}"
)
#
TARGET_LINK_LIBRARIES(${_target} ${DEAL_II_TARGET})
+ #
+ # If DEAL_II_STATIC_EXECUTABLE is set, switch the final link type to
+ # static:
+ #
+ IF(DEAL_II_STATIC_EXECUTABLE)
+ SET_PROPERTY(TARGET ${_target} PROPERTY
+ LINK_SEARCH_END_STATIC TRUE
+ )
+ ENDIF()
+
ENDMACRO()
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Tests whether it is possible to compile and link a dummy program with a
STRING(REPLACE "," "" _flag_name "${_flag_name}")
STRING(REPLACE "--" "__" _flag_name "${_flag_name}")
SET(_backup ${CMAKE_REQUIRED_LIBRARIES})
- SET(CMAKE_REQUIRED_LIBRARIES "${_flag_stripped}")
+ LIST(APPEND CMAKE_REQUIRED_LIBRARIES "${_flag_stripped}")
CHECK_CXX_COMPILER_FLAG(
""
DEAL_II_HAVE_FLAG_${_flag_name}
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Tests whether the cxx compiler understands a flag.
STRING(REGEX REPLACE "^-" "" _flag_name "${_flag_stripped}")
STRING(REPLACE "," "" _flag_name "${_flag_name}")
STRING(REPLACE "--" "__" _flag_name "${_flag_name}")
+ STRING(REPLACE "++" "__" _flag_name "${_flag_name}")
CHECK_CXX_COMPILER_FLAG(
"${_flag_stripped}"
DEAL_II_HAVE_FLAG_${_flag_name}
--- /dev/null
+## ---------------------------------------------------------------------
+## $Id$
+##
+## Copyright (C) 2013 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
+
+
+#
+# Test whether a usable language compiler is available and if yes, call
+# ENABLE_LANGUAGE(language)
+#
+# This works around a severe bug [1] in
+#
+# ENABLE_LANGUAGE(Fortran OPTIONAL)
+#
+# [1] http://public.kitware.com/Bug/view.php?id=9220
+#
+# Usage:
+# ENABLE_LANGUAGE_FORTRAN_OPTIONAL(language)
+#
+# where language is either C or Fortran
+#
+
+MACRO(ENABLE_LANGUAGE_OPTIONAL _language)
+ IF(NOT ${_language}_CHECKED)
+ #
+ # Run this check exactly once:
+ #
+ SET(${_language}_CHECKED TRUE CACHE INTERNAL "" FORCE)
+
+ SET(_tmp ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/${_language}_test)
+ file(REMOVE ${_tmp})
+
+ IF(DEFINED CMAKE_${_language}_COMPILER)
+ SET(_hint "-DCMAKE_${_language}_COMPILER=${CMAKE_${_language}_COMPILER}")
+ ENDIF()
+
+ FILE(WRITE ${_tmp}/CMakeLists.txt
+ "PROJECT(foobar ${_language})"
+ )
+
+ EXECUTE_PROCESS(
+ COMMAND ${CMAKE_COMMAND} -G${CMAKE_GENERATOR} ${_hint} .
+ WORKING_DIRECTORY ${_tmp}
+ RESULT_VARIABLE _result
+ OUTPUT_QUIET
+ ERROR_QUIET
+ )
+
+ IF("${_result}" STREQUAL "0")
+ SET(DEAL_II_${_language}_COMPILER_WORKS TRUE CACHE INTERNAL "" FORCE)
+ ENABLE_LANGUAGE(${_language})
+ ELSE()
+ MESSAGE(STATUS "No working ${_language} compiler found, disabling ${_language}")
+ ENDIF()
+ ELSE()
+ #
+ # Enable the language depending on the cached result from a former run:
+ #
+ IF(DEAL_II_${_language}_COMPILER_WORKS)
+ ENABLE_LANGUAGE(${_language})
+ ENDIF()
+ ENDIF()
+ENDMACRO()
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# A macro for the inst.in file expansion
MACRO(EXPAND_INSTANTIATIONS _target _inst_in_files)
- IF(CMAKE_CROSSCOMPILING)
- SET(_ei_exec native-expand_instantiations)
- ELSE()
- SET(_ei_exec expand_instantiations)
- ENDIF()
-
FOREACH (_inst_in_file ${_inst_in_files})
STRING(REGEX REPLACE "\\.in$" "" _inst_file "${_inst_in_file}" )
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_inst_file}
- DEPENDS ${_ei_exec}
- ${CMAKE_BINARY_DIR}/cmake/config/template-arguments
+ DEPENDS expand_instantiations
+ ${CMAKE_BINARY_DIR}/${DEAL_II_COMMON_RELDIR}/template-arguments
${CMAKE_CURRENT_SOURCE_DIR}/${_inst_in_file}
- COMMAND ${_ei_exec}
- ARGS ${CMAKE_BINARY_DIR}/cmake/config/template-arguments
+ COMMAND expand_instantiations
+ ARGS ${CMAKE_BINARY_DIR}/${DEAL_II_COMMON_RELDIR}/template-arguments
< ${CMAKE_CURRENT_SOURCE_DIR}/${_inst_in_file}
> ${CMAKE_CURRENT_BINARY_DIR}/${_inst_file}
)
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
## Copyright (C) 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# A small wrapper around FIND_PACKAGE.
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# A small macro to test whether a given list contains an element.
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# A small macro used in the platform checks to remove the right most flag in
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# A small macro used in the platform checks to easily add a flag to
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Replace all occurences of "${flag}" with "${replacement}" in the string
--- /dev/null
+## ---------------------------------------------------------------------
+## $Id$
+##
+## Copyright (C) 2013 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
+
+#
+# A small macro to reset the CMAKE_REQUIRED_* variables to its default
+# values
+#
+# Usage:
+# RESET_CMAKE_REQUIRED_FLAGS
+#
+
+MACRO(RESET_CMAKE_REQUIRED)
+ SET(CMAKE_REQUIRED_FLAGS ${CMAKE_CXX_FLAGS_SAVED})
+ SET(CMAKE_REQUIRED_INCLUDES)
+ SET(CMAKE_REQUIRED_LIBRARIES)
+ENDMACRO()
+
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# If 'variable' is empty it will be set to 'value'
+++ /dev/null
-#####
-##
-## Copyright (C) 2013 by the deal.II authors
-##
-## This file is part of the deal.II library.
-##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
-##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
-
-
-#
-# A small macro to split a list of libraries with debug, optimized and
-# general keywords into two lists consisting of all libraries necessary for
-# the debug and release target only. If no keyword is given "optimized" is
-# assumed.
-#
-# Usage:
-# SPLIT_DEBUG_RELEASE(list_debug list_release <...list of libraries...>)
-#
-#
-
-MACRO(SPLIT_DEBUG_RELEASE _list_debug _list_release)
-
- SET(_toggle "optimized")
- FOREACH(_tmp ${ARGN})
- IF("${_tmp}" STREQUAL "debug" OR
- "${_tmp}" STREQUAL "optimized" OR
- "${_tmp}" STREQUAL "general")
- SET(_toggle "${_tmp}")
- ELSE()
- IF("${_toggle}" STREQUAL "general")
- LIST(APPEND ${_list_debug} "${_tmp}")
- LIST(APPEND ${_list_release} "${_tmp}")
- ELSEIF("${_toggle}" STREQUAL "debug")
- LIST(APPEND ${_list_debug} "${_tmp}")
- ELSEIF("${_toggle}" STREQUAL "optimized")
- LIST(APPEND ${_list_release} "${_tmp}")
- ENDIF()
- ENDIF()
- ENDFOREACH()
-
- IF("${${_list_debug}}" STREQUAL "")
- SET(${_list_debug} ${${_list_release}})
- ELSEIF("${${_list_release}}" STREQUAL "")
- SET(${_list_release} ${${_list_debug}})
- ENDIF()
-
-ENDMACRO()
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Remove all occurences of "${flag}" in the string variable.
--- /dev/null
+## ---------------------------------------------------------------------
+## $Id$
+##
+## Copyright (C) 2013 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
+
+#
+# This macro toggles the preference for static/shared libraries if
+# DEAL_II_PREFER_STATIC_LIBS=TRUE but the final executable will still be
+# dynamically linked, i.e. DEAL_II_STATIC_EXECUTABLE=OFF
+#
+# Usage:
+# SWITCH_LIBRARY_PREFERENCE()
+#
+
+MACRO(SWITCH_LIBRARY_PREFERENCE)
+ IF(DEAL_II_PREFER_STATIC_LIBS AND NOT DEAL_II_STATIC_EXECUTABLE)
+ #
+ # Invert the search order for libraries when DEAL_II_PREFER_STATIC_LIBS
+ # is set. This will prefer static archives instead of shared libraries:
+ LIST(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES)
+ ENDIF()
+ENDMACRO()
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# A small macro used for converting a list into a space
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# A small macro used for converting a cmake list into a space
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Try to find the ARPACK library
#
# ARPACK needs LAPACK and BLAS as dependencies:
#
-FIND_PACKAGE(LAPACK)
+FIND_PACKAGE(DEALII_LAPACK)
FIND_LIBRARY(ARPACK_LIBRARY
NAMES arpack
LAPACK_FOUND
)
+MARK_AS_ADVANCED(
+ lapack_LIBRARY
+ atlas_LIBRARY
+ blas_LIBRARY
+ ARPACK_LIBRARY
+ )
+
IF(ARPACK_FOUND)
SET(ARPACK_LIBRARIES
- ${ARPACK_LIBRARY} ${LAPACK_LIBRARIES}
+ ${ARPACK_LIBRARY}
+ ${LAPACK_LIBRARIES}
)
SET(ARPACK_LINKER_FLAGS
${LAPACK_LINKER_FLAGS}
)
- MARK_AS_ADVANCED(
- lapack_LIBRARY
- atlas_LIBRARY
- blas_LIBRARY
- ARPACK_LIBRARY
- ARPACK_DIR
- )
+ MARK_AS_ADVANCED(ARPACK_DIR)
ELSE()
SET(ARPACK_DIR "" CACHE PATH
"An optional hint to an ARPACK installation"
--- /dev/null
+## ---------------------------------------------------------------------
+## $Id$
+##
+## Copyright (C) 2013 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
+
+#
+# This module is a wrapper around the FindLAPACK.cmake module provided by
+# CMake.
+#
+# This module exports
+#
+# LAPACK_FOUND
+# LAPACK_LIBRARIES
+# LAPACK_LINKER_FLAGS
+# BLAS_FOUND
+# BLAS_LIBRARIES
+# BLAS_LINKER_FLAGS
+# METIS_INCLUDE_DIRS
+#
+
+
+
+#
+# We have to use a trick with CMAKE_PREFIX_PATH to make LAPACK_DIR and
+# BLAS_DIR work...
+#
+SET_IF_EMPTY(BLAS_DIR "$ENV{BLAS_DIR}")
+SET_IF_EMPTY(LAPACK_DIR "$ENV{LAPACK_DIR}")
+
+SET(_cmake_prefix_path_backup "${CMAKE_PREFIX_PATH}")
+
+SET(CMAKE_PREFIX_PATH ${BLAS_DIR} ${LAPACK_DIR} ${_cmake_prefix_path_backup})
+
+FIND_PACKAGE(BLAS)
+
+SET(CMAKE_PREFIX_PATH ${LAPACK_DIR} ${_cmake_prefix_path_backup})
+
+FIND_PACKAGE(LAPACK)
+
+SET(CMAKE_PREFIX_PATH ${_cmake_prefix_path_backup})
+
+MARK_AS_ADVANCED(
+ atlas_LIBRARY
+ blas_LIBRARY
+ gslcblas_LIBRARY
+ lapack_LIBRARY
+ m_LIBRARY
+ ptf77blas_LIBRARY
+ ptlapack_LIBRARY
+ refblas_LIBRARY
+ reflapack_LIBRARY
+ )
+
+
+IF(LAPACK_FOUND)
+ SET(DEALII_LAPACK_FOUND TRUE)
+
+ #
+ # So, well... LAPACK_LINKER_FLAGS and LAPACK_LIBRARIES should contain the
+ # complete link interface. But for invalid user overrides we include
+ # BLAS_LIBRARIES and BLAS_LINKER_FLAGS as well..
+ #
+ IF(NOT LAPACK_LINKER_FLAGS MATCHES "${BLAS_LINKER_FLAGS}")
+ MESSAGE(STATUS
+ "Manually adding BLAS_LINKER_FLAGS to LAPACK_LINKER_FLAGS"
+ )
+ ADD_FLAGS(LAPACK_LINKER_FLAGS "${BLAS_LINKER_FLAGS}")
+ ENDIF()
+ IF(NOT "${LAPACK_LIBRARIES}" MATCHES "${BLAS_LIBRARIES}")
+ MESSAGE(STATUS
+ "Manually adding BLAS_LIBRARIES to LAPACK_LIBRARIES"
+ )
+ LIST(APPEND LAPACK_LIBRARIES ${BLAS_LIBRARIES})
+ ENDIF()
+
+ #
+ # Well, in case of static archives we have to manually pick up the
+ # complete link interface. *sigh*
+ #
+ # Do this unconditionally for the most common case:
+ # TODO: Non-GNU setups...
+ #
+ # Switch the library preference back to prefer dynamic libraries if
+ # DEAL_II_PREFER_STATIC_LIBS=TRUE but DEAL_II_STATIC_EXECUTABLE=FALSE. In
+ # this case system libraries should be linked dynamically.
+ #
+ SWITCH_LIBRARY_PREFERENCE()
+ FOREACH(_lib gfortran m quadmath)
+ FIND_LIBRARY(${_lib}_LIBRARY
+ NAMES ${_lib}
+ HINTS ${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES})
+ MARK_AS_ADVANCED(${_lib}_LIBRARY)
+
+ IF(NOT ${_lib}_LIBRARY MATCHES "-NOTFOUND")
+ LIST(APPEND BLAS_LIBRARIES ${${_lib}_LIBRARY})
+ LIST(APPEND LAPACK_LIBRARIES ${${_lib}_LIBRARY})
+ ENDIF()
+ ENDFOREACH()
+ SWITCH_LIBRARY_PREFERENCE()
+
+ MARK_AS_ADVANCED(
+ BLAS_DIR
+ LAPACK_DIR
+ )
+
+ELSE()
+ SET(DEALII_LAPACK_FOUND FALSE)
+
+ SET(LAPACK_DIR "" CACHE PATH
+ "An optional hint to a LAPACK installation"
+ )
+ SET(BLAS_DIR "" CACHE PATH
+ "An optional hint to a BLAS installation"
+ )
+
+ #
+ # If we couldn't find LAPACK, clean up the library variables:
+ #
+
+ IF("${BLAS_LIBRARIES}" STREQUAL "FALSE")
+ SET(BLAS_LIBRARIES "")
+ ENDIF()
+ IF("${LAPACK_LIBRARIES}" STREQUAL "FALSE")
+ SET(LAPACK_LIBRARIES "")
+ ENDIF()
+
+ENDIF()
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Try to find the HDF5 library
lib${LIB_SUFFIX} lib64 lib
)
-SET(_output ${HDF5_LIBRARY} ${HDF5_HL_LIBRARY})
+SET(_output ${HDF5_HL_LIBRARY} ${HDF5_LIBRARY})
FIND_PACKAGE_HANDLE_STANDARD_ARGS(HDF5 DEFAULT_MSG
_output # Cosmetic: Gives nice output
+ HDF5_HL_LIBRARY
+ HDF5_LIBRARY
+ HDF5_INCLUDE_DIR
+ )
+
+MARK_AS_ADVANCED(
HDF5_LIBRARY
HDF5_HL_LIBRARY
HDF5_INCLUDE_DIR
${HDF5_INCLUDE_DIR}
)
SET(HDF5_LIBRARIES
- ${HDF5_LIBRARY}
${HDF5_HL_LIBRARY}
+ ${HDF5_LIBRARY}
+ ${MPI_C_LIBRARIES} # for good measure
)
#
SET(HDF5_WITH_MPI TRUE)
ENDIF()
- MARK_AS_ADVANCED(
- HDF5_DIR
- HDF5_LIBRARY
- HDF5_HL_LIBRARY
- HDF5_INCLUDE_DIR
- )
+ MARK_AS_ADVANCED(HDF5_DIR)
ELSE()
SET(HDF5_DIR "" CACHE PATH
"An optional hint to an hdf5 directory"
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Try to find the (serial) METIS library
#
# METIS_LIBRARIES
# METIS_INCLUDE_DIRS
+# METIS_VERSION
+# METIS_VERSION_MAJOR
+# METIS_VERSION_MINOR
+# METIS_VERSION_SUBMINOR
#
INCLUDE(FindPackageHandleStandardArgs)
SET_IF_EMPTY(METIS_DIR "$ENV{METIS_DIR}")
#
-# TODO: Metis is usually pretty self contained. So no external dependencies
-# so far... But there could be dependencies on pcre and mpi...
+# Metis is usually pretty self contained. So no external dependencies
+# so far. But there could be dependencies on pcre and mpi...
+#
+# Link in MPI unconditionally (if found).
#
FIND_PATH(METIS_INCLUDE_DIR metis.h
build/${CMAKE_CXX_PLATFORM_ID}-${CMAKE_SYSTEM_PROCESSOR}/libmetis
)
+FIND_LIBRARY(PARMETIS_LIBRARY
+ NAMES parmetis
+ HINTS
+ ${METIS_DIR}
+ PATH_SUFFIXES
+ lib${LIB_SUFFIX} lib64 lib
+ # This is a hint, isn't it?
+ build/${CMAKE_CXX_PLATFORM_ID}-${CMAKE_SYSTEM_PROCESSOR}/libmetis
+ )
+
FIND_PACKAGE_HANDLE_STANDARD_ARGS(METIS DEFAULT_MSG
METIS_LIBRARY
METIS_INCLUDE_DIR
)
+MARK_AS_ADVANCED(
+ METIS_LIBRARY
+ PARMETIS_LIBRARY
+ METIS_INCLUDE_DIR
+ )
+
IF(METIS_FOUND)
- SET(METIS_LIBRARIES ${METIS_LIBRARY})
+
+ IF(NOT PARMETIS_LIBRARY MATCHES "-NOTFOUND")
+ SET(METIS_LIBRARIES ${PARMETIS_LIBRARY})
+ ENDIF()
+
+ LIST(APPEND METIS_LIBRARIES
+ ${METIS_LIBRARY}
+ ${MPI_C_LIBRARIES} # for good measure
+ )
SET(METIS_INCLUDE_DIRS ${METIS_INCLUDE_DIR})
#
# Extract the version number out of metis.h
#
- FILE(STRINGS "${METIS_INCLUDE_DIR}/metis.h" METIS_MAJOR_STRING
- REGEX "METIS_VER_MAJOR")
- STRING(REGEX REPLACE "^.*METIS_VER_MAJOR.* ([0-9]+).*" "\\1" METIS_MAJOR "${METIS_MAJOR_STRING}")
-
- FILE(STRINGS "${METIS_INCLUDE_DIR}/metis.h" METIS_MINOR_STRING
- REGEX "METIS_VER_MINOR")
- STRING(REGEX REPLACE "^.*METIS_VER_MINOR.* ([0-9]+).*" "\\1" METIS_MINOR "${METIS_MINOR_STRING}")
+ FILE(STRINGS "${METIS_INCLUDE_DIR}/metis.h" _metis_major_string
+ REGEX "METIS_VER_MAJOR"
+ )
+ STRING(REGEX REPLACE "^.*METIS_VER_MAJOR.* ([0-9]+).*" "\\1"
+ METIS_VERSION_MAJOR "${_metis_major_string}"
+ )
+ FILE(STRINGS "${METIS_INCLUDE_DIR}/metis.h" _metis_minor_string
+ REGEX "METIS_VER_MINOR"
+ )
+ STRING(REGEX REPLACE "^.*METIS_VER_MINOR.* ([0-9]+).*" "\\1"
+ METIS_VERSION_MINOR "${_metis_minor_string}"
+ )
+ FILE(STRINGS "${METIS_INCLUDE_DIR}/metis.h" _metis_subminor_string
+ REGEX "METIS_VER_SUBMINOR"
+ )
+ STRING(REGEX REPLACE "^.*METIS_VER_SUBMINOR.* ([0-9]+).*" "\\1"
+ METIS_VERSION_SUBMINOR "${_metis_subminor_string}"
+ )
+ SET(METIS_VERSION
+ "${METIS_VERSION_MAJOR}.${METIS_VERSION_MINOR}.${METIS_VERSION_SUBMINOR}"
+ )
- MARK_AS_ADVANCED(
- METIS_LIBRARY
- METIS_INCLUDE_DIR
- METIS_DIR
- )
+ MARK_AS_ADVANCED(METIS_DIR)
ELSE()
SET(METIS_DIR "" CACHE PATH
"An optional hint to a metis directory"
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Try to find the MUMPS library
# (We'll rely on the user of FindMUMPS, setting up mpi *cough*)
#
FIND_PACKAGE(SCALAPACK) # which will also include lapack and blas
+FIND_PACKAGE(METIS)
-#
-# TODO: mumps might link to scotch and or metis as well. Ignore this for
-# now. :-]
-#
FIND_PATH(MUMPS_INCLUDE_DIR dmumps_c.h
HINTS
SCALAPACK_FOUND
)
+MARK_AS_ADVANCED(
+ DMUMPS_LIBRARY
+ MUMPS_COMMON_LIBRARY
+ MUMPS_INCLUDE_DIR
+ PORT_LIBRARY
+ )
+
IF(MUMPS_FOUND)
SET(MUMPS_INCLUDE_DIRS
${MUMPS_INCLUDE_DIR}
${MUMPS_COMMON_LIBRARY}
${PORD_LIBRARY}
${SCALAPACK_LIBRARIES}
- ${MPI_CXX_LIBRARIES} # For good measure
+ ${METIS_LIBRARIES} # for good measure
+ ${MPI_Fortran_LIBRARIES} # for good measure
)
SET(MUMPS_LINKER_FLAGS
${SCALAPACK_LINKER_FLAGS}
)
- MARK_AS_ADVANCED(
- DMUMPS_LIBRARY
- MUMPS_COMMON_LIBRARY
- MUMPS_INCLUDE_DIR
- PORT_LIBRARY
- )
+ MARK_AS_ADVANCED(MUMPS_DIR)
ELSE()
SET(MUMPS_DIR "" CACHE PATH
"An optional hint to a mumps directory"
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Try to find the NETCDF C and C++ libraries
NETCDF_INCLUDE_DIR
)
+MARK_AS_ADVANCED(
+ NETCDF_CPLUSPLUS_LIBRARY
+ NETCDF_C_LIBRARY
+ NETCDF_INCLUDE_DIR
+ )
+
IF(NETCDF_FOUND)
SET(NETCDF_INCLUDE_DIRS
${NETCDF_INCLUDE_DIR}
${NETCDF_C_LIBRARY}
)
- MARK_AS_ADVANCED(
- NETCDF_CPLUSPLUS_LIBRARY
- NETCDF_C_LIBRARY
- NETCDF_INCLUDE_DIR
- NETCDF_DIR
- )
+ MARK_AS_ADVANCED(NETCDF_DIR)
ELSE()
SET(NETCDF_DIR "" CACHE PATH
"An optional hint to a NETCDF installation"
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Try to find the P4EST library
# P4EST_LIBRARIES
# P4EST_INCLUDE_DIRS
# P4EST_WITH_MPI
+# P4EST_VERSION
+# P4EST_VERSION_MAJOR
+# P4EST_VERSION_MINOR
+# P4EST_VERSION_SUBMINOR
+# P4EST_VERSION_PATCH
#
INCLUDE(FindPackageHandleStandardArgs)
SET_IF_EMPTY(P4EST_DIR "$ENV{P4EST_DIR}")
SET_IF_EMPTY(SC_DIR "$ENV{SC_DIR}")
-#
-# We used to recommend installing p4est with a custom script that
-# compiled p4est twice, once in debug and once in optimized mode.
-# the installation would then have happened into directories
-# $P4EST_DIR/DEBUG and $P4EST_DIR/FAST. If we can find these
-# two directories, then use the FAST directory rather than trying
-# to figure out how we can build deal.II against the two libraries
-# depending on whether we are in debug or optimized mode.
-#
-IF(P4EST_DIR
- AND EXISTS ${P4EST_DIR}/DEBUG
- AND EXISTS ${P4EST_DIR}/FAST)
- MESSAGE(STATUS "Found old-style p4est directory layout")
- SET (P4EST_DIR ${P4EST_DIR}/FAST)
-ENDIF()
-
-
#
# Search for the sc library, usually bundled with p4est. If no SC_DIR was
# given, take what we chose for p4est.
#
-FIND_PATH(P4EST_INCLUDE_DIR p4est.h
+FIND_PATH(P4EST_INCLUDE_DIR p4est_config.h
HINTS
+ ${P4EST_DIR}/FAST
+ ${P4EST_DIR}/DEBUG
${P4EST_DIR}
PATH_SUFFIXES
p4est include/p4est include src
FIND_PATH(SC_INCLUDE_DIR sc.h
HINTS
+ ${SC_DIR}/FAST
+ ${SC_DIR}/DEBUG
${SC_DIR}
+ ${P4EST_DIR}/FAST
+ ${P4EST_DIR}/DEBUG
${P4EST_DIR}
PATH_SUFFIXES
sc include/p4est include src sc/src
)
-FIND_LIBRARY(P4EST_LIBRARY
+FIND_LIBRARY(P4EST_LIBRARY_OPTIMIZED
NAMES p4est
HINTS
+ ${P4EST_DIR}/FAST
+ ${P4EST_DIR}/DEBUG
${P4EST_DIR}
PATH_SUFFIXES
lib${LIB_SUFFIX} lib64 lib src
)
-FIND_LIBRARY(SC_LIBRARY
+FIND_LIBRARY(P4EST_LIBRARY_DEBUG
+ NAMES p4est
+ HINTS
+ ${P4EST_DIR}/DEBUG
+ PATH_SUFFIXES
+ lib${LIB_SUFFIX} lib64 lib src
+ )
+
+FIND_LIBRARY(SC_LIBRARY_OPTIMIZED
NAMES sc
HINTS
+ ${SC_DIR}/FAST
+ ${SC_DIR}/DEBUG
${SC_DIR}
+ ${P4EST_DIR}/FAST
+ ${P4EST_DIR}/DEBUG
${P4EST_DIR}
PATH_SUFFIXES
lib${LIB_SUFFIX} lib64 lib src sc/src
)
-SET(_output ${P4EST_LIBRARY} ${SC_LIBRARY})
+FIND_LIBRARY(SC_LIBRARY_DEBUG
+ NAMES sc
+ HINTS
+ ${SC_DIR}/DEBUG
+ ${P4EST_DIR}/DEBUG
+ PATH_SUFFIXES
+ lib${LIB_SUFFIX} lib64 lib src sc/src
+ )
+
+SET(_output ${P4EST_LIBRARY_OPTMIZED} ${SC_LIBRARY_OPTIMIZED})
FIND_PACKAGE_HANDLE_STANDARD_ARGS(P4EST DEFAULT_MSG
- P4EST_LIBRARY
- SC_LIBRARY
+ _output # Cosmetic: Gives nice output
+ P4EST_LIBRARY_OPTIMIZED
+ SC_LIBRARY_OPTIMIZED
P4EST_INCLUDE_DIR
SC_INCLUDE_DIR
)
+MARK_AS_ADVANCED(
+ P4EST_LIBRARY_OPTIMIZED
+ P4EST_LIBRARY_DEBUG
+ P4EST_INCLUDE_DIR
+ SC_LIBRARY_OPTIMIZED
+ SC_LIBRARY_DEBUG
+ SC_INCLUDE_DIR
+ )
+
+
IF(P4EST_FOUND)
- SET(P4EST_LIBRARIES
- ${P4EST_LIBRARY}
- ${SC_LIBRARY}
+
+ IF( ( "${P4EST_LIBRARY_OPTIMIZED}" STREQUAL "${P4EST_LIBRARY_DEBUG}"
+ AND
+ "${SC_LIBRARY_OPTIMIZED}" STREQUAL "${SC_LIBRARY_DEBUG}" )
+ OR P4EST_LIBRARY_DEBUG MATCHES "-NOTFOUND"
+ OR SC_LIBRARY_DEBUG MATCHES "-NOTFOUND" )
+ SET(P4EST_LIBRARIES
+ ${P4EST_LIBRARY_OPTIMIZED}
+ ${SC_LIBRARY_OPTIMIZED}
+ )
+ ELSE()
+ SET(P4EST_LIBRARIES
+ optimized
+ ${P4EST_LIBRARY_OPTIMIZED}
+ ${SC_LIBRARY_OPTIMIZED}
+ debug
+ ${P4EST_LIBRARY_DEBUG}
+ ${SC_LIBRARY_DEBUG}
+ general
+ )
+ ENDIF()
+
+ LIST(APPEND P4EST_LIBRARIES
+ ${LAPACK_LIBRARIES} # for good measure
+ ${MPI_C_LIBRARIES} # for good measure
)
SET(P4EST_INCLUDE_DIRS
${P4EST_INCLUDE_DIR}
IF("${P4EST_MPI_STRING}" STREQUAL "")
SET(P4EST_WITH_MPI FALSE)
ELSE()
+
SET(P4EST_WITH_MPI TRUE)
ENDIF()
- MARK_AS_ADVANCED(
- P4EST_DIR
- P4EST_LIBRARY
- P4EST_INCLUDE_DIR
- SC_LIBRARY
- SC_INCLUDE_DIR
- )
+ #
+ # Extract version numbers:
+ #
+ FILE(STRINGS "${P4EST_INCLUDE_DIR}/p4est_config.h" P4EST_VERSION
+ REGEX "#define P4EST_VERSION \"")
+ STRING(REGEX REPLACE "^.*P4EST_VERSION.*\"([0-9]+.*)\".*" "\\1"
+ P4EST_VERSION "${P4EST_VERSION}"
+ )
+ STRING(REGEX REPLACE
+ "^([0-9]+).*$" "\\1"
+ P4EST_VERSION_MAJOR "${P4EST_VERSION}")
+ STRING(REGEX REPLACE
+ "^[0-9]+\\.([0-9]+).*$" "\\1"
+ P4EST_VERSION_MINOR "${P4EST_VERSION}")
+ STRING(REGEX REPLACE
+ "^[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1"
+ P4EST_VERSION_SUBMINOR "${P4EST_VERSION}")
+
+ # Now for the patch number such as in 0.3.4.1. If there
+ # is no patch number, then the REGEX REPLACE will fail,
+ # setting P4EST_VERSION_PATCH to P4EST_VERSION. If that
+ # is the case, then set the patch number to zero
+ STRING(REGEX REPLACE
+ "^[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+)?.*$" "\\1"
+ P4EST_VERSION_PATCH "${P4EST_VERSION}")
+ IF(${P4EST_VERSION_PATCH} STREQUAL "${P4EST_VERSION}")
+ SET(P4EST_VERSION_PATCH "0")
+ ENDIF()
+
+
+ MARK_AS_ADVANCED(P4EST_DIR)
ELSE()
SET(P4EST_DIR "" CACHE PATH
"An optional hint to a p4est installation/directory"
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Try to find the petsc library
PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib
)
+#
+# Search for the first part of the includes:
+#
+
+FIND_PATH(PETSC_INCLUDE_DIR_ARCH petscconf.h
+ HINTS
+ # petsc is special. Account for that
+ ${PETSC_DIR}
+ ${PETSC_DIR}/${PETSC_ARCH}
+ ${PETSC_INCLUDE_DIRS}
+ PATH_SUFFIXES petsc include include/petsc
+)
+
+#
+# Sometimes, this is not enough...
+# If petsc is not installed but in source tree layout, there will be
+# ${PETSC_DIR}/${PETSC_ARCH}/include - which we should have found by now.
+# ${PETSC_DIR}/include - which we still have to find.
+#
+# Or it is installed in a non standard layout in the system (e.g. in
+# Gentoo), where there will be
+# ${PETSC_DIR}/${PETSC_ARCH}/include
+# /usr/include/petsc ...
+#
+# Either way, we must be able to find petscversion.h:
+#
+
+FIND_PATH(PETSC_INCLUDE_DIR_COMMON petscversion.h
+ HINTS
+ ${PETSC_DIR}
+ ${PETSC_DIR}/${PETSC_ARCH}
+ ${PETSC_INCLUDE_DIRS}
+ PATH_SUFFIXES petsc include include/petsc
+)
#
# So, up to this point it was easy. Now, the tricky part. Search for
-# petscvariables and determine the link interface from that file:
+# petscvariables and determine the includes and the link interface from
+# that file:
#
+
FIND_FILE(PETSC_PETSCVARIABLES
NAMES petscvariables
HINTS
- ${PETSC_DIR}
${PETSC_DIR}/${PETSC_ARCH}
+ ${PETSC_DIR}
PATH_SUFFIXES conf
)
IF(NOT PETSC_PETSCVARIABLES MATCHES "-NOTFOUND")
+ #
+ # Includes:
+ #
+
+ FILE(STRINGS "${PETSC_PETSCVARIABLES}" _external_includes
+ REGEX "^PETSC_CC_INCLUDES =.*")
+ SEPARATE_ARGUMENTS(_external_includes)
+
+ SET(_petsc_includes)
+ FOREACH(_token ${_external_includes})
+ IF(_token MATCHES "^-I")
+ STRING(REGEX REPLACE "^-I" "" _token "${_token}")
+ LIST(APPEND _petsc_includes ${_token})
+ ENDIF()
+ ENDFOREACH()
+
+ # Remove petsc's own include directories:
+ IF(NOT "${_petsc_includes}" STREQUAL "")
+ LIST(REMOVE_AT _petsc_includes 0 1)
+ ENDIF()
+
+ #
+ # Link line:
+ #
+
FILE(STRINGS "${PETSC_PETSCVARIABLES}" _external_link_line
REGEX "^PETSC_WITH_EXTERNAL_LIB =.*")
SEPARATE_ARGUMENTS(_external_link_line)
SET(_hints)
+ SET(_petsc_libraries)
FOREACH(_token ${_external_link_line}})
IF(_token MATCHES "^-L")
# Build up hints with the help of all tokens passed with -L:
IF(NOT _token MATCHES "(petsc|stdc\\+\\+|gcc_s)")
FIND_LIBRARY(PETSC_LIBRARY_${_token}
NAMES ${_token}
- HINTS ${_hintes}
+ HINTS ${_hints}
)
IF(NOT PETSC_LIBRARY_${_token} MATCHES "-NOTFOUND")
LIST(APPEND _petsc_libraries ${PETSC_LIBRARY_${_token}})
ENDIF()
ENDIF()
ENDFOREACH()
+
ENDIF()
-#
-# Search for the first part of the includes:
-#
-FIND_PATH(PETSC_INCLUDE_DIR_ARCH petscconf.h
- HINTS
- # petsc is special. Account for that
- ${PETSC_DIR}
- ${PETSC_DIR}/${PETSC_ARCH}
- ${PETSC_INCLUDE_DIRS}
- PATH_SUFFIXES petsc include include/petsc
-)
-
-#
-# Sometimes, this is not enough...
-# If petsc is not installed but in source tree layout, there will be
-# ${PETSC_DIR}/${PETSC_ARCH}/include - which we should have found by now.
-# ${PETSC_DIR}/include - which we still have to find.
-#
-# Or it is installed in a non standard layout in the system (e.g. in
-# Gentoo), where there will be
-# ${PETSC_DIR}/${PETSC_ARCH}/include
-# /usr/include/petsc ...
-#
-# Either way, we must be able to find petscversion.h:
-#
-FIND_PATH(PETSC_INCLUDE_DIR_COMMON petscversion.h
- HINTS
- ${PETSC_DIR}
- ${PETSC_DIR}/${PETSC_ARCH}
- ${PETSC_INCLUDE_DIRS}
- PATH_SUFFIXES petsc include include/petsc
-)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PETSC DEFAULT_MSG
PETSC_LIBRARY
PETSC_INCLUDE_DIR_COMMON
)
+MARK_AS_ADVANCED(
+ PETSC_INCLUDE_DIR_ARCH
+ PETSC_INCLUDE_DIR_COMMON
+ PETSC_INCLUDE_DIRS
+ PETSC_LIBRARY
+ PETSC_PETSCVARIABLES
+ )
+
IF(PETSC_FOUND)
SET(PETSC_LIBRARIES
${PETSC_LIBRARY}
${_petsc_libraries}
)
SET(PETSC_INCLUDE_DIRS
- ${PETSC_INCLUDE_DIR_ARCH}
${PETSC_INCLUDE_DIR_COMMON}
+ ${PETSC_INCLUDE_DIR_ARCH}
+ ${_petsc_includes}
)
SET(PETSC_PETSCCONF_H "${PETSC_INCLUDE_DIR_ARCH}/petscconf.h")
PETSC_VERSION_PATCH "${PETSC_VERSION_PATCH_STRING}"
)
- SET(PETSC_VERSION "${PETSC_VERSION_MAJOR}.${PETSC_VERSION_MINOR}.${PETSC_VERSION_SUBMINOR}")
+ SET(PETSC_VERSION
+ "${PETSC_VERSION_MAJOR}.${PETSC_VERSION_MINOR}.${PETSC_VERSION_SUBMINOR}.${PETSC_VERSION_PATCH}"
+ )
- MARK_AS_ADVANCED(
- PETSC_ARCH
- PETSC_DIR
- PETSC_INCLUDE_DIR_ARCH
- PETSC_INCLUDE_DIR_COMMON
- PETSC_INCLUDE_DIRS
- PETSC_LIBRARY
- PETSC_PETSCVARIABLES
- )
+ MARK_AS_ADVANCED(PETSC_ARCH PETSC_DIR)
ELSE()
SET(PETSC_DIR "" CACHE PATH
"An optional hint to a PETSc directory"
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Try to find the SCALAPACK library
# SCALAPACK needs LAPACK and BLAS as dependency, search for them with the help
# of the LAPACK find module:
#
-FIND_PACKAGE(LAPACK)
+FIND_PACKAGE(DEALII_LAPACK)
#
# Well, depending on the version of scalapack and the distribution it might
FOREACH(_lib blacs blacsCinit blacsF77init)
STRING(TOUPPER "${_lib}" _lib_upper)
FIND_LIBRARY(${_lib_upper}_LIBRARY
- NAMES ${_lib} ${_lib}_MPI-LINUX-0
+ NAMES ${_lib} ${_lib}_MPI-LINUX-0 ${_lib}_MPI-DARWIN-0
HINTS
${BLACS_DIR}
${SCALAPACK_DIR}
LAPACK_FOUND
)
+MARK_AS_ADVANCED(
+ lapack_LIBRARY
+ atlas_LIBRARY
+ blas_LIBRARY
+ SCALAPACK_LIBRARY
+ BLACS_LIBRARY
+ BLACSCINIT_LIBRARY
+ BLACSF77INIT_LIBRARY
+ )
+
IF(SCALAPACK_FOUND)
SET(SCALAPACK_LIBRARIES
${SCALAPACK_LIBRARY}
${LAPACK_LIBRARIES}
${BLACS_LIBRARIES}
+ ${MPI_Fortran_LIBRARIES} # for good measure
)
SET(SCALAPACK_LINKER_FLAGS
${LAPACK_LINKER_FLAGS}
)
- MARK_AS_ADVANCED(
- lapack_LIBRARY
- atlas_LIBRARY
- blas_LIBRARY
- SCALAPACK_DIR
- SCALAPACK_LIBRARY
- BLACS_DIR
- BLACS_LIBRARY
- BLACSCINIT_LIBRARY
- BLACSF77INIT_LIBRARY
- )
+ MARK_AS_ADVANCED(SCALAPACK_DIR BLACS_DIR)
ELSE()
SET(SCALAPACK_DIR "" CACHE PATH
"An optional hint to a SCALAPACK directory"
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Try to find the SLEPC library
PETSC_FOUND
)
+MARK_AS_ADVANCED(
+ SLEPC_DIR
+ SLEPC_INCLUDE_DIR_ARCH
+ SLEPC_INCLUDE_DIR_COMMON
+ SLEPC_INCLUDE_DIRS
+ SLEPC_LIBRARY
+ )
+
IF(SLEPC_FOUND)
SET(SLEPC_INCLUDE_DIRS
${SLEPC_INCLUDE_DIR_ARCH}
SLEPC_VERSION_PATCH "${SLEPC_VERSION_PATCH_STRING}"
)
- SET(SLEPC_VERSION "${SLEPC_VERSION_MAJOR}.${SLEPC_VERSION_MINOR}.${SLEPC_VERSION_SUBMINOR}")
+ SET(SLEPC_VERSION
+ "${SLEPC_VERSION_MAJOR}.${SLEPC_VERSION_MINOR}.${SLEPC_VERSION_SUBMINOR}.${SLEPC_VERSION_PATCH}"
+ )
- MARK_AS_ADVANCED(
- SLEPC_DIR
- SLEPC_INCLUDE_DIR_ARCH
- SLEPC_INCLUDE_DIR_COMMON
- SLEPC_INCLUDE_DIRS
- SLEPC_LIBRARY
- )
+ MARK_AS_ADVANCED(SLEPC_DIR)
ELSE()
SET(SLEPC_DIR "" CACHE PATH
"An optional hint to a SLEPC directory"
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Try to find the Threading Building Blocks library
TBB_INCLUDE_DIR
)
+MARK_AS_ADVANCED(
+ TBB_LIBRARY
+ TBB_DEBUG_LIBRARY
+ TBB_INCLUDE_DIR
+ )
+
IF(TBB_FOUND)
- MARK_AS_ADVANCED(TBB_LIBRARY TBB_DEBUG_LIBRARY TBB_INCLUDE_DIR)
IF(NOT TBB_DEBUG_LIBRARY MATCHES "-NOTFOUND")
SET(TBB_WITH_DEBUGLIB TRUE)
SET(TBB_INCLUDE_DIRS ${TBB_INCLUDE_DIR})
+ MARK_AS_ADVANCED(TBB_DIR)
ELSE()
-
SET(TBB_DIR "" CACHE PATH
"An optional hint to a TBB installation"
)
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Try to find the Trilinos library
#
# This module exports:
#
-# TRILINOS_DIR (cached)
+# TRILINOS_DIR
# TRILINOS_INCLUDE_DIRS
# TRILINOS_LIBRARIES
+# TRILINOS_VERSION
# TRILINOS_VERSION_MAJOR
# TRILINOS_VERSION_MINOR
# TRILINOS_VERSION_SUBMINOR
# TRILINOS_WITH_MPI
+# TRILINOS_SUPPORTS_CPP11
+# TRILINOS_HAS_C99_TR1_WORKAROUND
#
INCLUDE(FindPackageHandleStandardArgs)
SET_IF_EMPTY(TRILINOS_DIR "$ENV{TRILINOS_DIR}")
#
-# Include the trilinos package configuration:
+# Do not include TrilinosConfig.cmake directly, it is just too big o_O
+#
+# Just search for the file:
#
-FIND_PACKAGE(TRILINOS_CONFIG
- CONFIG QUIET
- NAMES Trilinos TRILINOS
+FIND_FILE(TRILINOS_CONFIG
+ NAMES TrilinosConfig.cmake trilinos-config.cmake
HINTS
- ${TRILINOS_DIR}/lib/cmake/Trilinos
${TRILINOS_DIR}
PATH_SUFFIXES
lib64/cmake/Trilinos
NO_SYSTEM_ENVIRONMENT_PATH
)
-SET(TRILINOS_INCLUDE_DIRS ${Trilinos_INCLUDE_DIRS})
+IF(NOT "${TRILINOS_CONFIG}" STREQUAL "${TRILINOS_CONFIG_SAVED}")
+ SET(_new_trilinos_config TRUE)
+ENDIF()
+SET(TRILINOS_CONFIG_SAVED "${TRILINOS_CONFIG}" CACHE INTERNAL "" FORCE)
+
+
+IF(NOT TRILINOS_CONFIG MATCHES "-NOTFOUND")
+
+ SET(_filtered_trilinos_config
+ "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TrilinosConfig.cmake"
+ )
+
+ IF(_new_trilinos_config)
+ GET_FILENAME_COMPONENT(_trilinos_path "${TRILINOS_CONFIG}" PATH)
+ FILE(WRITE ${_filtered_trilinos_config} "SET(_cmake_current_list_dir ${_trilinos_path})\n")
+
+ #
+ # Only pick up every line that starts with "^SET("...
+ #
+ FILE(STRINGS "${TRILINOS_CONFIG}" _trilinos_config_filtered REGEX "^SET")
+
+ FOREACH(_line ${_trilinos_config_filtered})
+ STRING(REPLACE "CMAKE_CURRENT_LIST_DIR" "_cmake_current_list_dir"
+ _line "${_line}"
+ )
+ FILE(APPEND ${_filtered_trilinos_config} "${_line}\n")
+ ENDFOREACH()
+ ENDIF()
+
+ #
+ # ... and include only that:
+ #
+ INCLUDE(${_filtered_trilinos_config})
+
+ SET(TRILINOS_CONFIG_FOUND TRUE)
+ENDIF()
+
+
+#
+# Look for the one include file that we'll query for further information:
+#
+IF(_new_trilinos_config)
+ UNSET(EPETRA_CONFIG_H CACHE)
+ENDIF()
+FIND_FILE(EPETRA_CONFIG_H Epetra_config.h
+ HINTS ${Trilinos_INCLUDE_DIRS}
+ NO_DEFAULT_PATH
+ NO_CMAKE_ENVIRONMENT_PATH
+ NO_CMAKE_PATH
+ NO_SYSTEM_ENVIRONMENT_PATH
+ NO_CMAKE_SYSTEM_PATH
+ NO_CMAKE_FIND_ROOT_PATH
+ )
+IF(EPETRA_CONFIG_H MATCHES "-NOTFOUND")
+ SET(TRILINOS_CONFIG_FOUND FALSE)
+ELSE()
+ SET(TRILINOS_INCLUDE_DIRS ${Trilinos_INCLUDE_DIRS})
+ #
+ # *Boy* Sanitize the include paths given by TrilinosConfig.cmake...
+ #
+ STRING(REGEX REPLACE
+ "(lib64|lib)\\/cmake\\/Trilinos\\/\\.\\.\\/\\.\\.\\/\\.\\.\\/" ""
+ TRILINOS_INCLUDE_DIRS "${TRILINOS_INCLUDE_DIRS}"
+ )
+ENDIF()
+
#
# We'd like to have the full library names but the Trilinos package only
# So we check again for every lib and store the full path:
#
FOREACH(_library ${Trilinos_LIBRARIES})
+ IF(_new_trilinos_config)
+ UNSET(TRILINOS_LIBRARY_${_library} CACHE)
+ ENDIF()
+
FIND_LIBRARY(TRILINOS_LIBRARY_${_library}
NAMES ${_library}
HINTS ${Trilinos_LIBRARY_DIRS}
NO_CMAKE_FIND_ROOT_PATH
)
- LIST(APPEND TRILINOS_LIBRARIES ${TRILINOS_LIBRARY_${_library}})
+ MARK_AS_ADVANCED(TRILINOS_LIBRARY_${_library})
- #
- # Remove the variables from the cache, so that updating TRILINOS_DIR will
- # find the new libraries..
- #
- UNSET(TRILINOS_LIBRARY_${_library} CACHE)
+ IF(TRILINOS_LIBRARY_${_library} MATCHES "-NOTFOUND")
+ SET(TRILINOS_CONFIG_FOUND FALSE)
+ ELSE()
+ LIST(APPEND TRILINOS_LIBRARIES ${TRILINOS_LIBRARY_${_library}})
+ ENDIF()
ENDFOREACH()
+#
+# Add the link interface:
+#
+LIST(APPEND TRILINOS_LIBRARIES
+ ${Trilinos_TPL_LIBRARIES}
+ ${MPI_CXX_LIBRARIES} # for good measure
+ )
+
FIND_PACKAGE_HANDLE_STANDARD_ARGS(TRILINOS DEFAULT_MSG
TRILINOS_LIBRARIES # cosmetic: Gives nice output
TRILINOS_CONFIG_FOUND
)
+MARK_AS_ADVANCED(TRILINOS_CONFIG EPETRA_CONFIG_H)
+
IF(TRILINOS_FOUND)
#
- # Extract the major and minor version numbers:
+ # Extract version numbers:
#
+ SET(TRILINOS_VERSION "${Trilinos_VERSION}")
+
STRING(REGEX REPLACE
"^([0-9]+).*$" "\\1"
TRILINOS_VERSION_MAJOR "${Trilinos_VERSION}")
#
# Determine whether Trilinos was configured with MPI and 64bit indices:
#
- FIND_FILE(EPETRA_CONFIG_H Epetra_config.h
- HINTS ${TRILINOS_INCLUDE_DIRS}
- NO_DEFAULT_PATH
- NO_CMAKE_ENVIRONMENT_PATH
- NO_CMAKE_PATH
- NO_SYSTEM_ENVIRONMENT_PATH
- NO_CMAKE_SYSTEM_PATH
- NO_CMAKE_FIND_ROOT_PATH
- )
FILE(STRINGS "${EPETRA_CONFIG_H}" EPETRA_MPI_STRING
REGEX "#define HAVE_MPI")
IF("${EPETRA_MPI_STRING}" STREQUAL "")
SET(TRILINOS_WITH_NO_64BITS_INDICES FALSE)
ENDIF()
- UNSET(EPETRA_CONFIG_H CACHE)
+ #
+ # Some versions of Sacado_cmath.hpp do things that aren't compatible
+ # with the -std=c++0x flag of GCC, see deal.II FAQ.
+ # Test whether that is indeed the case:
+ #
+ IF(_new_trilinos_config)
+ UNSET(TRILINOS_SUPPORTS_CPP11 CACHE)
+ UNSET(TRILINOS_HAS_C99_TR1_WORKAROUND CACHE)
+ ENDIF()
+
+ LIST(APPEND CMAKE_REQUIRED_INCLUDES ${TRILINOS_INCLUDE_DIRS})
+ PUSH_TEST_FLAG("${DEAL_II_CXX11_FLAG}")
- MARK_AS_ADVANCED(
- TRILINOS_DIR
- TRILINOS_CONFIG_DIR
+ CHECK_CXX_SOURCE_COMPILES(
+ "
+ #include <Sacado_cmath.hpp>
+ int main(){ return 0; }
+ "
+ TRILINOS_SUPPORTS_CPP11
)
+ #
+ # Try whether exporting HAS_C99_TR1_CMATH helps:
+ #
+ PUSH_TEST_FLAG("-DHAS_C99_TR1_CMATH")
+ CHECK_CXX_SOURCE_COMPILES(
+ "
+ #include <Sacado_cmath.hpp>
+ int main(){ return 0; }
+ "
+ TRILINOS_HAS_C99_TR1_WORKAROUND
+ )
+
+ RESET_CMAKE_REQUIRED()
+
+
+ MARK_AS_ADVANCED(TRILINOS_DIR)
+
ELSE()
SET(TRILINOS_DIR "" CACHE PATH
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Try to find the UMFPACK library
# TODO: There might be an external dependency for metis, ignore this for
# now.
#
-FIND_PACKAGE(LAPACK)
+FIND_PACKAGE(DEALII_LAPACK)
+FIND_PACKAGE(METIS)
#
# Two macros to make life easier:
FIND_UMFPACK_LIBRARY(AMD amd REQUIRED)
FIND_UMFPACK_LIBRARY(CHOLMOD cholmod)
FIND_UMFPACK_LIBRARY(COLAMD colamd)
+FIND_UMFPACK_LIBRARY(CCOLAMD ccolamd)
+FIND_UMFPACK_LIBRARY(CAMD camd)
FIND_UMFPACK_LIBRARY(SuiteSparse_config suitesparseconfig)
-SET(_output ${UMFPACK_LIBRARY} ${CHOLMOD_LIBRARY} ${COLAMD_LIBRARY} ${AMD_LIBRARY} ${SuiteSparse_config_LIBRARY})
+SET(_output ${UMFPACK_LIBRARY} ${CHOLMOD_LIBRARY} ${CCOLAMD_LIBRARY} ${COLAMD_LIBRARY} ${CAMD_LIBRARY} ${AMD_LIBRARY} ${SuiteSparse_config_LIBRARY})
FIND_PACKAGE_HANDLE_STANDARD_ARGS(UMFPACK DEFAULT_MSG
_output # Cosmetic: Gives nice output
UMFPACK_LIBRARY
LAPACK_FOUND
)
+MARK_AS_ADVANCED(
+ AMD_INCLUDE_DIR
+ AMD_LIBRARY
+ atlas_LIBRARY
+ blas_LIBRARY
+ CAMD_LIBRARY
+ CHOLMOD_LIBRARY
+ CCOLAMD_LIBRARY
+ COLAMD_LIBRARY
+ SuiteSparse_config_INCLUDE_DIR
+ SuiteSparse_config_LIBRARY
+ UMFPACK_INCLUDE_DIR
+ UMFPACK_LIBRARY
+ )
+
IF(UMFPACK_FOUND)
SET(UMFPACK_LIBRARIES
${UMFPACK_LIBRARY}
${CHOLMOD_LIBRARY}
+ ${CCOLAMD_LIBRARY}
${COLAMD_LIBRARY}
+ ${CAMD_LIBRARY}
${AMD_LIBRARY}
${SuiteSparse_config_LIBRARY}
- ${LAPACK_LIBRARIES}
)
+ #
+ # For good measure:
+ #
+ IF(METIS_FOUND)
+ LIST(APPEND UMFPACK_LIBRARIES ${METIS_LIBRARIES})
+ ENDIF()
+
+ LIST(APPEND UMFPACK_LIBRARIES ${LAPACK_LIBRARIES})
+
#
# Add rt to the link interface as well (for whatever reason,
# libsuitesparse.so depends on clock_gettime but the shared
# lib does not record its dependence on librt.so as evidenced
# by ldd :-( ):
#
- FIND_LIBRARY(rt_lib NAMES rt)
- MARK_AS_ADVANCED(rt_lib)
- IF(NOT rt_lib MATCHES "-NOTFOUND")
- LIST(APPEND UMFPACK_LIBRARIES ${rt_lib})
+ SWITCH_LIBRARY_PREFERENCE()
+ FIND_LIBRARY(rt_LIBRARY NAMES rt)
+ SWITCH_LIBRARY_PREFERENCE()
+ MARK_AS_ADVANCED(rt_LIBRARY)
+ IF(NOT rt_LIBRARY MATCHES "-NOTFOUND")
+ LIST(APPEND UMFPACK_LIBRARIES ${rt_LIBRARY})
ENDIF()
SET(UMFPACK_INCLUDE_DIRS
${LAPACK_LINKER_FLAGS}
)
- MARK_AS_ADVANCED(
- atlas_LIBRARY
- blas_LIBRARY
- UMFPACK_LIBRARY
- AMD_LIBRARY
- CHOLMOD_LIBRARY
- COLAMD_LIBRARY
- SuiteSparse_config_LIBRARY
- UMFPACK_INCLUDE_DIR
- AMD_INCLUDE_DIR
- SuiteSparse_config_INCLUDE_DIR
- UMFPACK_DIR
- SUITESPARSE_DIR
- )
+ MARK_AS_ADVANCED(UMFPACK_DIR SUITESPARSE_DIR)
ELSE()
SET(UMFPACK_DIR "" CACHE PATH
"An optional hint to an UMFPACK directory"
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
-ADD_EXECUTABLE(expand_instantiations expand_instantiations.cc)
IF(NOT CMAKE_CROSSCOMPILING)
- #
- # Export expand_instantiations for use in cross compilation:
- #
+ ADD_EXECUTABLE(expand_instantiations expand_instantiations.cc)
+
+ IF(DEAL_II_COMPONENT_COMPAT_FILES)
+ SET_TARGET_PROPERTIES(expand_instantiations
+ PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/common/scripts
+ )
+ INSTALL(TARGETS expand_instantiations
+ EXPORT ${DEAL_II_PROJECT_CONFIG_NAME}Targets
+ DESTINATION ${DEAL_II_COMMON_RELDIR}/scripts
+ COMPONENT compat_files
+ )
+ ENDIF()
+
EXPORT(TARGETS expand_instantiations
- FILE ${CMAKE_CURRENT_BINARY_DIR}/importExecutables.cmake
- NAMESPACE native- # Prefix a namespace
+ FILE ${CMAKE_BINARY_DIR}/importExecutables.cmake
)
ENDIF()
# Build and install the old dependency_resolution and report_features
# executables:
#
+
INCLUDE_DIRECTORIES(
BEFORE # Ensure deal.II include directories come first
- ${CMAKE_BINARY_DIR}/include/
+ #
+ # Reverse order due to BEFORE:
+ #
${CMAKE_SOURCE_DIR}/include/
+ ${CMAKE_BINARY_DIR}/include/
)
ADD_EXECUTABLE(make_dependencies make_dependencies.cc)
ADD_EXECUTABLE(report_features
${CMAKE_CURRENT_BINARY_DIR}/report_features.cc
)
+
+ #
+ # Link report_features in the same way as the library/final executable:
+ #
TARGET_LINK_LIBRARIES(report_features ${DEAL_II_EXTERNAL_LIBRARIES})
SET_TARGET_PROPERTIES(report_features
PROPERTIES
- LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}"
+ LINK_FLAGS "${DEAL_II_LINKER_FLAGS}"
COMPILE_DEFINITIONS "${DEAL_II_DEFINITIONS}"
)
+ IF(DEAL_II_STATIC_EXECUTABLE)
+ SET_PROPERTY(TARGET report_features PROPERTY
+ LINK_SEARCH_END_STATIC TRUE
+ )
+ ENDIF()
+
+ #
+ # A custom target with the same name as the component:
+ #
+ ADD_CUSTOM_TARGET(compat_files
+ DEPENDS
+ expand_instantiations
+ make_dependencies
+ report_features
+ )
IF(NOT CMAKE_CROSSCOMPILING)
ADD_CUSTOM_TARGET(run_report_features COMMAND report_features)
ENDIF()
- INSTALL(TARGETS make_dependencies report_features expand_instantiations
+ SET_TARGET_PROPERTIES(make_dependencies report_features
+ PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/common/scripts
+ )
+
+ INSTALL(TARGETS make_dependencies report_features
EXPORT ${DEAL_II_PROJECT_CONFIG_NAME}Targets
DESTINATION ${DEAL_II_COMMON_RELDIR}/scripts
COMPONENT compat_files
-//---------------------------- expand_instantiations.cc -------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2007, 2008, 2009, 2010, 2011 by the deal.II authors
+// Copyright (C) 2007 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------- expand_instantiations.cc -------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
// This is the program that we use to generate explicit instantiations for a
// variety of template arguments. It takes two kinds of input files. The first
-//---------------------------- make_dependencies.cc ------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2007, 2008, 2010, 2011 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------- make_dependencies.cc ------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
// Make a dependency file tree
// usage: make_depencies -Iinc_path1 -Iinc_path2 ... -Bbasepath files
-//----------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//----------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/config.h>
if(${_shared_libs})
std::cout << "dealii-feature: shared_libs=yes" << std::endl;
else
- std::cout << "dealii-feature: shared_libs=yes" << std::endl;
+ std::cout << "dealii-feature: shared_libs=no" << std::endl;
#ifdef DEAL_II_WITH_ARPACK
std::cout << "dealii-feature: ARPACK=yes" << std::endl;
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Setup cached variables (prior to the PROJECT(deal.II) call)
#
# Options regarding compilation and linking:
#
+# CMAKE_BUILD_TYPE
# DEAL_II_ALLOW_PLATFORM_INTROSPECTION
# DEAL_II_SETUP_DEFAULT_COMPILER_FLAGS
-# CMAKE_BUILD_TYPE
# BUILD_SHARED_LIBS
+# DEAL_II_PREFER_STATIC_LIBS
+# DEAL_II_STATIC_EXECUTABLE
# CMAKE_INSTALL_RPATH_USE_LINK_PATH
-# CMAKE_C_FLAGS
# CMAKE_CXX_FLAGS *)
-# CMAKE_SHARED_LINKER_FLAGS *)
+# DEAL_II_LINKER_FLAGS *)
# DEAL_II_CXX_FLAGS_DEBUG
-# DEAL_II_SHARED_LINKER_FLAGS_DEBUG
+# DEAL_II_LINKER_FLAGS_DEBUG
# DEAL_II_CXX_FLAGS_RELEASE
-# DEAL_II_SHARED_LINKER_FLAGS_RELEASE
+# DEAL_II_LINKER_FLAGS_RELEASE
# DEAL_II_WITH_64BIT_INDICES
#
-# *) May also be set via environment variable (CFLAGS, CXXFLAGS, LDFLAGS)
-# (nonempty cached variable has precedence will not be overwritten by
-# environment)
+# *) May also be set via environment variable (CXXFLAGS, LDFLAGS)
+# (a nonempty cached variable has precedence and will not be
+# overwritten by environment)
#
-###########################################################################
-# #
-# General configuration options: #
-# #
-###########################################################################
+########################################################################
+# #
+# General configuration options: #
+# #
+########################################################################
If(DEAL_II_HAVE_BUNDLED_DIRECTORY)
OPTION(DEAL_II_ALLOW_BUNDLED
ENDIF()
-###########################################################################
-# #
-# Compilation and linking: #
-# #
-###########################################################################
-
-OPTION(DEAL_II_ALLOW_PLATFORM_INTROSPECTION
- "Allow platform introspection for CPU command set, SSE and AVX"
- ON
- )
-MARK_AS_ADVANCED(DEAL_II_ALLOW_PLATFORM_INTROSPECTION)
-
-OPTION(DEAL_II_SETUP_DEFAULT_COMPILER_FLAGS
- "Configure sensible default CFLAGS and CXXFLAGS depending on platform, compiler and build target."
- ON
- )
-MARK_AS_ADVANCED(DEAL_II_SETUP_DEFAULT_COMPILER_FLAGS)
+########################################################################
+# #
+# Compilation and linking: #
+# #
+########################################################################
#
# Setup CMAKE_BUILD_TYPE:
)
ENDIF()
+
+OPTION(DEAL_II_ALLOW_PLATFORM_INTROSPECTION
+ "Allow platform introspection for CPU command sets, SSE and AVX"
+ ON
+ )
+MARK_AS_ADVANCED(DEAL_II_ALLOW_PLATFORM_INTROSPECTION)
+
+OPTION(DEAL_II_SETUP_DEFAULT_COMPILER_FLAGS
+ "Configure sensible default CFLAGS and CXXFLAGS depending on platform, compiler and build target."
+ ON
+ )
+MARK_AS_ADVANCED(DEAL_II_SETUP_DEFAULT_COMPILER_FLAGS)
+
SET(BUILD_SHARED_LIBS "ON" CACHE BOOL
"Build a shared library"
)
-MARK_AS_ADVANCED(BUILD_SHARED_LIBS)
+
+OPTION(DEAL_II_PREFER_STATIC_LIBS
+ "Prefer static libraries over dynamic libraries when searching for features and corresponding link interface"
+ OFF
+ )
+MARK_AS_ADVANCED(DEAL_II_PREFER_STATIC_LIBS)
+
+OPTION(DEAL_II_STATIC_EXECUTABLE
+ "Provide a link interface that is suitable for static linkage of executables. Enabling this option forces BUILD_SHARED_LIBS=OFF and DEAL_II_PREFER_STATIC_LIBS=ON"
+ OFF
+ )
+MARK_AS_ADVANCED(DEAL_II_STATIC_EXECUTABLE)
+
+IF(DEAL_II_STATIC_EXECUTABLE)
+ SET(BUILD_SHARED_LIBS "OFF" CACHE BOOL
+ "Build a shared library"
+ FORCE
+ )
+ SET(DEAL_II_PREFER_STATIC_LIBS "ON" CACHE BOOL
+ "Prefer static libraries over dynamic libraries when searching for features and corresponding link interface"
+ FORCE
+ )
+ENDIF()
+
#
# Set CMAKE_INSTALL_RPATH_USE_LINK_PATH to default to ON and promote to
)
MARK_AS_ADVANCED(CMAKE_INSTALL_RPATH_USE_LINK_PATH)
+
#
# Define the variable that defines whether we should use 32- or 64-bit
# global DoF indices.
)
-
#
# Tell the user very prominently, that we're doing things differently w.r.t
# CMAKE_(C|CXX)_FLAGS_(DEBUG|RELEASE)
SHARED_LINKER_FLAGS_DEBUG
)
IF(NOT "${CMAKE_${_flag}}" STREQUAL "")
+ UNSET(${CMAKE_${_flag}} CACHE)
MESSAGE(FATAL_ERROR
"\nThe deal.II cmake build system does not use CMAKE_${_flag}.\n"
"Use DEAL_II_${_flag}, instead!\n\n"
ENDIF()
ENDFOREACH()
+
#
# Hide all unused compiler flag variables:
#
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELWITHDEBINFO
+ CMAKE_Fortran_FLAGS_RELEASE
+ CMAKE_Fortran_FLAGS_DEBUG
+ CMAKE_Fortran_FLAGS_MINSIZEREL
+ CMAKE_Fortran_FLAGS_RELWITHDEBINFO
+ CMAKE_SHARED_LINKER_FLAGS
CMAKE_SHARED_LINKER_FLAGS_DEBUG
CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL
CMAKE_SHARED_LINKER_FLAGS_RELEASE
SET(${_flag} "" CACHE INTERNAL "" FORCE)
ENDFOREACH()
+
#
# Set cached compiler flags to an empty string:
#
SET(DEAL_II_USED_FLAGS
- CMAKE_C_FLAGS
CMAKE_CXX_FLAGS
DEAL_II_CXX_FLAGS_DEBUG
DEAL_II_CXX_FLAGS_RELEASE
- CMAKE_SHARED_LINKER_FLAGS
- DEAL_II_SHARED_LINKER_FLAGS_DEBUG
- DEAL_II_SHARED_LINKER_FLAGS_RELEASE
+ DEAL_II_LINKER_FLAGS
+ DEAL_II_LINKER_FLAGS_DEBUG
+ DEAL_II_LINKER_FLAGS_RELEASE
)
FOREACH(_flag ${DEAL_II_USED_FLAGS})
#
-# Finally, read in CFLAGS, CXXFLAGS and LDFLAGS from environment and
-# prepend them to the saved variables:
+# Finally, read in CXXFLAGS and LDFLAGS from environment and prepend them
+# to the saved variables:
#
-SET(CMAKE_C_FLAGS_SAVED "$ENV{CFLAGS} ${CMAKE_C_FLAGS_SAVED}")
SET(CMAKE_CXX_FLAGS_SAVED "$ENV{CXXFLAGS} ${CMAKE_CXX_FLAGS_SAVED}")
-SET(CMAKE_SHARED_LINKER_FLAGS_SAVED "$ENV{LDFLAGS} ${CMAKE_SHARED_LINKER_FLAGS_SAVED}")
-UNSET(ENV{CFLAGS})
+SET(DEAL_II_LINKER_FLAGS_SAVED "$ENV{LDFLAGS} ${DEAL_II_LINKER_FLAGS_SAVED}")
UNSET(ENV{CXXFLAGS})
UNSET(ENV{LDFLAGS})
-###########################################################################
-# #
-# Miscellaneous setup: #
-# #
-###########################################################################
+########################################################################
+# #
+# Miscellaneous setup: #
+# #
+########################################################################
GET_CMAKE_PROPERTY(_res VARIABLES)
FOREACH(_var ${_res})
#
- # Rename WITH_* by DEAL_II_WITH_*
+ # Rename (ALLOW|WITH|FORCE|COMPONENT)_* by DEAL_II_(ALLOW|WITH|FORCE|COMPONENT)_*
#
- IF(_var MATCHES "^WITH_")
- SET(DEAL_II_${_var} ${${_var}} CACHE BOOL "" FORCE)
- UNSET(${_var} CACHE)
- ENDIF()
+ FOREACH(_match ALLOW_ WITH_ FORCE_ COMPONENT_)
+ IF(_var MATCHES "^${_match}")
+ SET(DEAL_II_${_var} ${${_var}} CACHE BOOL "" FORCE)
+ UNSET(${_var} CACHE)
+ ENDIF()
+ ENDFOREACH()
#
# Same for components:
#
- IF(_var MATCHES "^COMPONENT_")
- SET(DEAL_II_${_var} ${${_var}} CACHE BOOL "" FORCE)
- UNSET(${_var} CACHE)
- ENDIF()
IF(_var MATCHES "^(COMPAT_FILES|DOCUMENTATION|EXAMPLES|MESH_CONVERTER|PARAMETER_GUI)")
SET(DEAL_II_COMPONENT_${_var} ${${_var}} CACHE BOOL "" FORCE)
UNSET(${_var} CACHE)
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Setup default compiler flags: This file sets up sensible default compiler
# CMAKE_CXX_FLAGS
# DEAL_II_CXX_FLAGS_DEBUG
# DEAL_II_CXX_FLAGS_RELEASE
-# CMAKE_SHARED_LINKER_FLAGS
-# DEAL_II_SHARED_LINKER_FLAGS_DEBUG
-# DEAL_II_SHARED_LINKER_FLAGS_RELEASE
+# DEAL_II_LINKER_FLAGS
+# DEAL_II_LINKER_FLAGS_DEBUG
+# DEAL_II_LINKER_FLAGS_RELEASE
#
# All modifications shall be guarded with the ENABLE_IF_SUPPORTED
# or ENABLE_IF_LINKS macro, e.g.
#
# ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-fpic")
-# ENABLE_IF_LINKS(CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed")
+# ENABLE_IF_LINKS(DEAL_II_LINKER_FLAGS "-Wl,--as-needed")
#
# Checks for compiler features (such as C++11 support) and compiler
# specific bugs that
#
-###########################################################################
-# #
-# Sanity checks: #
-# #
-###########################################################################
+########################################################################
+# #
+# Sanity checks: #
+# #
+########################################################################
#
-# Check the user provided C and CXX flags:
+# Check the user provided CXX flags:
#
-IF(NOT "${CMAKE_C_FLAGS_SAVED}" STREQUAL "${DEAL_II_C_FLAGS_SAVED}")
- UNSET(DEAL_II_HAVE_USABLE_C_FLAGS CACHE)
-ENDIF()
-SET(DEAL_II_C_FLAGS_SAVED "${CMAKE_C_FLAGS_SAVED}" CACHE INTERNAL "" FORCE)
-
-SET(CMAKE_REQUIRED_FLAGS "${CMAKE_C_FLAGS_SAVED}")
-CHECK_C_SOURCE_COMPILES(
- "int main(){ return 0; }"
- DEAL_II_HAVE_USABLE_C_FLAGS)
-SET(CMAKE_REQUIRED_FLAGS "")
-
-IF(NOT DEAL_II_HAVE_USABLE_C_FLAGS)
- UNSET(DEAL_II_HAVE_USABLE_C_FLAGS CACHE)
- MESSAGE(FATAL_ERROR "\n"
- "Configuration error: Cannot compile with the specified C flags: "
- "${CMAKE_C_FLAGS_SAVED}\n"
- )
-ENDIF()
-
-
+MESSAGE(STATUS "")
IF(NOT "${CMAKE_CXX_FLAGS_SAVED}" STREQUAL "${DEAL_II_CXX_FLAGS_SAVED}")
+ # Rerun this test if cxx flags changed:
UNSET(DEAL_II_HAVE_USABLE_CXX_FLAGS CACHE)
ENDIF()
SET(DEAL_II_CXX_FLAGS_SAVED "${CMAKE_CXX_FLAGS_SAVED}" CACHE INTERNAL "" FORCE)
-SET(CMAKE_REQUIRED_FLAGS "${CMAKE_CXX_FLAGS_SAVED}")
+# Initialize all CMAKE_REQUIRED_* variables a this point:
+RESET_CMAKE_REQUIRED()
+
CHECK_CXX_SOURCE_COMPILES(
"int main(){ return 0; }"
DEAL_II_HAVE_USABLE_CXX_FLAGS)
-SET(CMAKE_REQUIRED_FLAGS "")
IF(NOT DEAL_II_HAVE_USABLE_CXX_FLAGS)
UNSET(DEAL_II_HAVE_USABLE_CXX_FLAGS CACHE)
MESSAGE(FATAL_ERROR "\n"
- "Configuration error: Cannot compile with the specified CXX flags: "
+ "Configuration error: Cannot compile with the user supplied CXX flags:\n"
"${CMAKE_CXX_FLAGS_SAVED}\n"
)
ENDIF()
-#
-# CMAKE_C_COMPILER and CMAKE_CXX_COMPILER have to be of the same brand.
-#
-IF(NOT ( "${CMAKE_C_COMPILER_ID}" STREQUAL "${CMAKE_CXX_COMPILER_ID}" AND
- "${CMAKE_C_COMPILER_VERSION}" STREQUAL "${CMAKE_CXX_COMPILER_VERSION}" ) )
- MESSAGE(FATAL_ERROR "\n"
- "Configuration error: The specified C and CXX compiler have to be of the "
- "same family, but cmake found:\n"
- "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION}\n"
- "CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}\n"
- )
-ENDIF()
-
-
-###########################################################################
-# #
-# Compiler setup: #
-# #
-###########################################################################
+########################################################################
+# #
+# Compiler setup: #
+# #
+########################################################################
IF(DEAL_II_SETUP_DEFAULT_COMPILER_FLAGS)
#
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# General setup for GCC and compilers sufficiently close to GCC
# Check whether the -as-needed flag is available. If so set it to link
# the deal.II library with it.
#
-ENABLE_IF_LINKS(CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed")
+ENABLE_IF_LINKS(DEAL_II_LINKER_FLAGS "-Wl,--as-needed")
#
# Setup various warnings:
#
ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-unused-local-typedefs")
+#
+# Disable Wlong-long that will trigger a lot of warnings when compiling
+# with disabled C++11 support:
+#
+ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-Wno-long-long")
+
#
# Disable deprecation warnings
#
IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ #
+ # Silence Clang warnings about unused parameters:
+ #
+ SET(CMAKE_CXX_FLAGS "-Qunused-arguments ${CMAKE_CXX_FLAGS}")
+
#
# *Boy*, clang seems to be the very definition of "pedantic" in
# "-pedantic" mode, so disable a bunch of harmless warnings
ENDIF()
+IF(DEAL_II_STATIC_EXECUTABLE)
+ #
+ # To produce a static executable, we have to statically link libstdc++
+ # and gcc's support libraries and glibc:
+ #
+ ENABLE_IF_SUPPORTED(DEAL_II_LINKER_FLAGS "-static")
+ ENABLE_IF_SUPPORTED(DEAL_II_LINKER_FLAGS "-pthread")
+ENDIF()
+
+
#############################
# #
# For Release target: #
ADD_FLAGS(DEAL_II_CXX_FLAGS_RELEASE "-O2")
ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS_RELEASE "-funroll-loops")
+ ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS_RELEASE "-funroll-all-loops")
ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS_RELEASE "-fstrict-aliasing")
ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS_RELEASE "-felide-constructors")
LIST(APPEND DEAL_II_DEFINITIONS_DEBUG "DEBUG")
LIST(APPEND DEAL_II_USER_DEFINITIONS_DEBUG "DEBUG")
- ADD_FLAGS(DEAL_II_CXX_FLAGS_DEBUG "-O0")
+ ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS_DEBUG "-Og")
+ #
+ # If -Og is not available, fall back to -O0:
+ #
+ IF(NOT DEAL_II_HAVE_FLAG_Og)
+ ADD_FLAGS(DEAL_II_CXX_FLAGS_DEBUG "-O0")
+ ENDIF()
ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS_DEBUG "-ggdb")
- ENABLE_IF_SUPPORTED(DEAL_II_SHARED_LINKER_FLAGS_DEBUG "-ggdb")
+ ENABLE_IF_SUPPORTED(DEAL_II_LINKER_FLAGS_DEBUG "-ggdb")
#
# If -ggdb is not available, fall back to -g:
#
IF(NOT DEAL_II_HAVE_FLAG_ggdb)
ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS_DEBUG "-g")
- ENABLE_IF_SUPPORTED(DEAL_II_SHARED_LINKER_FLAGS_DEBUG "-g")
+ ENABLE_IF_SUPPORTED(DEAL_II_LINKER_FLAGS_DEBUG "-g")
ENDIF()
ENDIF()
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# General setup for the Intel C++ Compiler
# Check whether the -as-needed flag is available. If so set it to link
# the deal.II library with it.
#
-ENABLE_IF_LINKS(CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed")
+ENABLE_IF_LINKS(DEAL_II_LINKER_FLAGS "-Wl,--as-needed")
#
# Set ansi mode:
ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-wd1572")
+IF(DEAL_II_STATIC_EXECUTABLE)
+ #
+ # To produce a static executable, we have to statically link intel's
+ # support libraries:
+ #
+ ENABLE_IF_SUPPORTED(DEAL_II_LINKER_FLAGS "-static")
+ ENABLE_IF_SUPPORTED(DEAL_II_LINKER_FLAGS "-static-intel")
+ ENABLE_IF_SUPPORTED(DEAL_II_LINKER_FLAGS "-static-gcc")
+ ENABLE_IF_SUPPORTED(DEAL_II_LINKER_FLAGS "-pthread")
+ENDIF()
+
+
#############################
# #
# For Release target: #
#
# General optimization flags:
#
- ADD_FLAGS(DEAL_II_CXX_FLAGS_RELEASE "-O2")
+
+ IF(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "13.0" )
+ ADD_FLAGS(DEAL_II_CXX_FLAGS_RELEASE "-O2")
+ ELSE()
+ #
+ # Disable aggressive optimization for intel-13* compilers, until we
+ # resolve a lot of funny miscompilations...
+ #
+ # - Maier, 2013
+ #
+ ADD_FLAGS(DEAL_II_CXX_FLAGS_RELEASE "-O1")
+ ENDIF()
+
ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS_RELEASE "-ip")
ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS_RELEASE "-funroll-loops")
- ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS_RELEASE "-ansi-alias") # equiv. -fstrict-aliasing
+ # equivalent to -fno-strict-aliasing:
+ ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS_RELEASE "-no-ansi-alias")
ENDIF()
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Timo Heister
-##
-#####
+## ---------------------------------------------------------------------
#
# General setup for the Microsoft Visual Studio C++ Compiler (Windows)
+++ /dev/null
-#####
-##
-## Copyright (C) 2012, 2013 by the deal.II authors
-##
-## This file is part of the deal.II library.
-##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
-##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
-
-#
-# Setup some convenience custom targets for the build system:
-#
-
-
-###########################################################################
-# #
-# Custom targets for library, documentation and compat_files components: #
-# #
-###########################################################################
-
-ADD_CUSTOM_TARGET(library)
-FOREACH(_build ${DEAL_II_BUILD_TYPES})
- ADD_DEPENDENCIES(library ${DEAL_II_BASE_NAME}${DEAL_II_${_build}_SUFFIX})
-ENDFOREACH()
-
-IF(DEAL_II_COMPONENT_DOCUMENTATION)
- ADD_CUSTOM_TARGET(documentation
- DEPENDS doxygen
- )
-ENDIF()
-
-IF(DEAL_II_COMPONENT_COMPAT_FILES)
- ADD_CUSTOM_TARGET(compat_files
- DEPENDS
- expand_instantiations
- make_dependencies
- report_features
- )
-ENDIF()
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Set up deal.II specific definitions
# DEAL_II_PROJECT_CONFIG_RELDIR *)
#
# DEAL_II_BUILD_TYPES
-# DEAL_II_WITH_BUNDLED_DIRECTORY
-# DEAL_II_WITH_DOC_DIRECTORY
#
# *) Can be overwritten by the command line via -D<...>
#
-###########################################################################
-# #
-# General information about deal.II: #
-# #
-###########################################################################
+########################################################################
+# #
+# General information about deal.II: #
+# #
+########################################################################
SET_IF_EMPTY(DEAL_II_PACKAGE_NAME "deal.II")
SET(DEAL_II_VERSION ${DEAL_II_VERSION_MAJOR}.${DEAL_II_VERSION_MINOR})
-###########################################################################
-# #
-# Information about paths, install locations and names: #
-# #
-###########################################################################
+########################################################################
+# #
+# Information about paths, install locations and names: #
+# #
+########################################################################
SET(DEAL_II_PROJECT_CONFIG_NAME "${DEAL_II_PACKAGE_NAME}")
(NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") )
#
# Ensure that in case of an out of source build BINARY_DIR/include !=
- # INSTALL_PREFIX/include us always true. Otherwise stale headers might
+ # INSTALL_PREFIX/include is always true. Otherwise stale headers might
# get included resulting in a failing build.
#
SET_IF_EMPTY(DEAL_II_INCLUDE_RELDIR "include/install")
LIST(APPEND DEAL_II_BUILD_TYPES "RELEASE")
ENDIF()
-
-###########################################################################
-# #
-# Cleanup and Includes that have to happen after the call to PROJECT(): #
-# #
-###########################################################################
-
-#
-# Cleanup some files used for storing the names of all object targets that
-# will be bundled to the deal.II library.
-# (Right now, i.e. cmake 2.8.8, this is the only reliable way to get
-# information into a global scope...)
-#
-FOREACH(_build ${DEAL_II_BUILD_TYPES})
- STRING(TOLOWER "${_build}" _build_lowercase)
- FILE(REMOVE
- ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/deal_ii_objects_${_build_lowercase}
- )
-ENDFOREACH()
-
-
-#
-# Cross compilation stuff:
-#
-IF(CMAKE_CROSSCOMPILING)
- #
- # Disable platform introspection when cross compiling
- #
- SET(DEAL_II_ALLOW_PLATFORM_INTROSPECTION OFF CACHE BOOL "" FORCE)
-
- #
- # Import native expand_instantiations for use in cross compilation:
- #
- SET(DEAL_II_NATIVE "DEAL_II_NATIVE-NOTFOUND" CACHE FILEPATH
- "A pointer to a native deal.Ii build directory"
- )
- INCLUDE(${DEAL_II_NATIVE}/cmake/scripts//importExecutables.cmake)
-ENDIF()
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Include all external (cmake) macros that we will use:
INCLUDE(CheckCXXCompilerFlag)
INCLUDE(CheckCXXSourceCompiles)
-INCLUDE(CheckCSourceCompiles)
INCLUDE(CheckCXXSourceRuns)
INCLUDE(CheckCXXSymbolExists)
INCLUDE(CheckIncludeFileCXX)
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
-###########################################################################
-# #
-# Finalize the configuration: #
-# #
-###########################################################################
+########################################################################
+# #
+# Finalize the configuration: #
+# #
+########################################################################
#
# Hide some cmake specific cached variables. This is annoying...
ENDIF()
ENDFOREACH()
+#
+# Cleanup some files used for storing the names of all object targets that
+# will be bundled to the deal.II library.
+# (Right now, i.e. cmake 2.8.8, this is the only reliable way to get
+# information into a global scope...)
+#
+FOREACH(_build ${DEAL_II_BUILD_TYPES})
+ STRING(TOLOWER "${_build}" _build_lowercase)
+ FILE(REMOVE
+ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/deal_ii_objects_${_build_lowercase}
+ )
+ENDFOREACH()
+FILE(WRITE
+ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/deal_ii_source_includes
+ ""
+ )
+
+#
+# Cleanup deal.IITargets.cmake in the build directory:
+#
+FILE(REMOVE
+ ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}BuildTargets.cmake
+ )
+
-###########################################################################
-# #
-# And write a nice configuration summary to file: #
-# #
-###########################################################################
+########################################################################
+# #
+# And write a nice configuration summary to file: #
+# #
+########################################################################
SET(_log_detailed "${CMAKE_BINARY_DIR}/detailed.log")
SET(_log_summary "${CMAKE_BINARY_DIR}/summary.log")
)
IF(CMAKE_CROSSCOMPILING)
_both(
- "# CROSSCOMPILING!\n"
+ "#\n# CROSSCOMPILING!\n"
"# DEAL_II_NATIVE: ${DEAL_II_NATIVE}\n"
)
ENDIF()
+IF(DEAL_II_STATIC_EXECUTABLE)
+ _both(
+ "#\n# STATIC LINKAGE!\n"
+ )
+ENDIF()
+
_both("#\n")
_detailed(
"# Compiler flags used for this build:
-# CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}
+# CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}
"
)
IF(CMAKE_BUILD_TYPE MATCHES "Release")
- _detailed("# DEAL_II_CXX_FLAGS_RELEASE: ${DEAL_II_CXX_FLAGS_RELEASE}\n")
+ _detailed("# DEAL_II_CXX_FLAGS_RELEASE: ${DEAL_II_CXX_FLAGS_RELEASE}\n")
ENDIF()
IF(CMAKE_BUILD_TYPE MATCHES "Debug")
- _detailed("# DEAL_II_CXX_FLAGS_DEBUG: ${DEAL_II_CXX_FLAGS_DEBUG}\n")
+ _detailed("# DEAL_II_CXX_FLAGS_DEBUG: ${DEAL_II_CXX_FLAGS_DEBUG}\n")
ENDIF()
-_detailed("# CMAKE_SHARED_LINKER_FLAGS: ${CMAKE_SHARED_LINKER_FLAGS}\n")
+_detailed("# DEAL_II_LINKER_FLAGS: ${DEAL_II_LINKER_FLAGS}\n")
IF(CMAKE_BUILD_TYPE MATCHES "Release")
- _detailed("# DEAL_II_SHARED_LINKER_FLAGS_RELEASE: ${DEAL_II_SHARED_LINKER_FLAGS_RELEASE}\n")
+ _detailed("# DEAL_II_LINKER_FLAGS_RELEASE: ${DEAL_II_LINKER_FLAGS_RELEASE}\n")
ENDIF()
IF(CMAKE_BUILD_TYPE MATCHES "Debug")
- _detailed("# DEAL_II_SHARED_LINKER_FLAGS_DEBUG: ${DEAL_II_SHARED_LINKER_FLAGS_DEBUG}\n")
+ _detailed("# DEAL_II_LINKER_FLAGS_DEBUG: ${DEAL_II_LINKER_FLAGS_DEBUG}\n")
ENDIF()
_detailed("#\n")
LIST(APPEND _components "${_var}")
ELSEIF(_var MATCHES "(MPI_CXX_COMPILER|MPI_CXX_COMPILE_FLAGS|MPI_CXX_LINK_FLAGS)")
LIST(APPEND _features_config ${_var})
- ELSEIF(_var MATCHES "(LIBRARIES|INCLUDE_PATH|INCLUDE_DIRS|LINKER_FLAGS)"
- # Avoid a lot of Trilinos variables:
- AND (NOT _var MATCHES "_TPL_|_MPI_") )
+ ELSEIF(_var MATCHES "(LIBRARIES|INCLUDE_PATH|INCLUDE_DIRS|LINKER_FLAGS)")
LIST(APPEND _features_config ${_var})
ENDIF()
ENDFOREACH()
IF(FEATURE_${_feature}_EXTERNAL_CONFIGURED)
_both("# ${_var} set up with external dependencies\n")
+ #
+ # Print out version number:
+ #
+ IF(DEFINED ${_feature}_VERSION)
+ _detailed("# ${_feature}_VERSION = ${${_feature}_VERSION}\n")
+ ENDIF()
+
+ #
+ # Print out ${_feature}_DIR:
+ #
+ IF(DEFINED ${_feature}_DIR)
+ _detailed("# ${_feature}_DIR = ${${_feature}_DIR}\n")
+ ENDIF()
+
#
# Print the feature configuration:
#
--- /dev/null
+## ---------------------------------------------------------------------
+## $Id$
+##
+## Copyright (C) 2013 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
+
+
+########################################################################
+# #
+# Setup that has to happen after the call to PROJECT(): #
+# #
+########################################################################
+
+#
+# Library search order:
+#
+IF(DEAL_II_PREFER_STATIC_LIBS)
+ #
+ # Invert the search order for libraries when DEAL_II_PREFER_STATIC_LIBS
+ # is set. This will prefer static archives instead of shared libraries:
+ #
+ # TODO: Does this work on a Windows or CYGWIN target?
+ LIST(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES)
+ENDIF()
+
+
+#
+# Cross compilation stuff:
+#
+IF(CMAKE_CROSSCOMPILING)
+ #
+ # Disable platform introspection when cross compiling
+ #
+ SET(DEAL_II_ALLOW_PLATFORM_INTROSPECTION OFF CACHE BOOL "" FORCE)
+
+ #
+ # Import native expand_instantiations for use in cross compilation:
+ #
+ SET(DEAL_II_NATIVE "DEAL_II_NATIVE-NOTFOUND" CACHE FILEPATH
+ "A pointer to a native deal.Ii build directory"
+ )
+ IF(DEAL_II_NATIVE MATCHES "-NOTFOUND")
+ MESSAGE(FATAL_ERROR
+ "Please set the CMake variable DEAL_II_NATIVE to a valid path that points to a native deal.II build directory"
+ )
+ ENDIF()
+ INCLUDE(${DEAL_II_NATIVE}/importExecutables.cmake)
+ENDIF()
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
IF(DEAL_II_COMPONENT_MESH_CONVERTER)
ADD_SUBDIRECTORY(mesh_conversion)
ENDIF()
IF(DEAL_II_COMPONENT_PARAMETER_GUI)
- ADD_SUBDIRECTorY(parameter_gui)
+ ADD_SUBDIRECTORY(parameter_gui)
ENDIF()
+#ADD_SUBDIRECTORY(test_affinity)
+
+## ---------------------------------------------------------------------
+## $Id$
+##
+## Copyright (C) 2013 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
+
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/deal.II/lac/lapack_templates.h
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/deal.II/lac/
-#---------------------------------------------------------------------------
-# $Id$
-# Version: $Name$
-#
-# Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2012 by the deal 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.
-#
-#---------------------------------------------------------------------------
+## ---------------------------------------------------------------------
+## $Id$
+##
+## Copyright (C) 2005 - 2013 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
#---------------------------------------------------------------------------
# This perl script translates lapack_templates.h.in to lapack_templates.h
print << 'EOT'
-//---------------------------------------------------------------------------
+// ---------------------------------------------------------------------
+// $Id$
//
-// This file was automatically generated from lapack_templates.h.in
-// See blastemplates in the deal.II contrib directory
+// Copyright (C) 2005 - 2013 by the deal.II authors
//
-// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 by the deal authors
+// This file is part of the deal.II library.
//
-// 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.
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
//
-//---------------------------------------------------------------------------
+// ---------------------------------------------------------------------
#ifndef __LAPACK_TEMPLATES_H
#define __LAPACK_TEMPLATES_H
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is multi licensed under
-## - QPL 1.0,
-## - GPL 2.0 or any later version,
-## - LGL 2.1 or any later version.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
#PROJECT(mesh_converter)
Author: Jean-Paul Pelteret
jppelteret.uct@gmail.com
- modified by: Timo Heister, heister@math.tamu.edu
+ modified by: Timo Heister, heister@clemson.edu
===================================================
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by Martin Steigemann and Wolfgang Bangerth
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
#PROJECT(parameter_gui)
-This subdirectory contains the parameterr_gui project.
+This subdirectory contains the parameter_gui project.
It is copyrighted by Martin Steigemann and Wolfgang Bangerth and
distributed under the same license as the deal.II library, i.e.
-//---------------------------------------------------------------------------
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011 by the deal.II authors
+// Copyright (C) 2010 - 2013 by Martin Steigemann and Wolfgang Bangerth
//
-// 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <QtGui>
-//---------------------------------------------------------------------------
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011 by the deal.II authors
+// Copyright (C) 2010 - 2013 by Martin Steigemann and Wolfgang Bangerth
//
-// 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef BROWSELINEEDIT_H
#define BROWSELINEEDIT_H
-//---------------------------------------------------------------------------
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011 by the deal.II authors
+// Copyright (C) 2010 - 2013 by Martin Steigemann and Wolfgang Bangerth
//
-// 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <QtGui>
-//---------------------------------------------------------------------------
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011 by the deal.II authors
+// Copyright (C) 2010 - 2013 by Martin Steigemann and Wolfgang Bangerth
//
-// 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef INFOMESSAGE_H
#define INFOMESSAGE_H
-//---------------------------------------------------------------------------
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011 by the deal.II authors
+// Copyright (C) 2013 by Martin Steigemann and Wolfgang Bangerth
//
-// 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <QApplication>
#include <QSplashScreen>
-//---------------------------------------------------------------------------
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011 by the deal.II authors
+// Copyright (C) 2010 - 2013 by Martin Steigemann and Wolfgang Bangerth
//
-// 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <QtGui>
-//---------------------------------------------------------------------------
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011 by the deal.II authors
+// Copyright (C) 2010 - 2013 by Martin Steigemann and Wolfgang Bangerth
//
-// 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
-//---------------------------------------------------------------------------
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011 by the deal.II authors
+// Copyright (C) 2010 - 2013 by Martin Steigemann and Wolfgang Bangerth
//
-// 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <QtGui>
{
QString pattern_description = index.data(Qt::StatusTipRole).toString(); // load pattern description
// stored in the StatusLine
- QRegExp rx_string("\\b(Anything|MultipleSelection|List)\\b"),
+ QRegExp rx_string("\\b(Anything|MultipleSelection|List|Map)\\b"),
rx_filename("\\b(FileName)\\b"),
rx_dirname("\\b(DirectoryName)\\b"),
rx_integer("\\b(Integer)\\b"),
-//---------------------------------------------------------------------------
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011 by the deal.II authors
+// Copyright (C) 2010 - 2013 by Martin Steigemann and Wolfgang Bangerth
//
-// 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef PARAMETERDELEGATE_H
#define PARAMETERDELEGATE_H
* The ParameterDelegate class implements special delegates for the QTreeWidget class used in the parameterGUI.
* The QTreeWidget class provides some different standard delegates for editing parameters shown in the
* tree structure. The ParameterDelegate class provides special editors for the different types of parameters defined in
- * the ParameterHandler class. For all parameter types based on strings as "Anything", "MultipleSelection" and
+ * the ParameterHandler class. For all parameter types based on strings as "Anything", "MultipleSelection" "Map" and
* "List" a simple line editor will be shown up. In the case of integer and double type parameters the editor is a spin box and for
* "Selection" type parameters a combo box will be shown up. For parameters of type "FileName" and "DirectoryName"
* the delegate shows a @ref BrowseLineEdit editor. The column of the tree structure with the parameter values has to be set
-//---------------------------------------------------------------------------
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011 by the deal.II authors
+// Copyright (C) 2010 - 2013 by Martin Steigemann and Wolfgang Bangerth
//
-// 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <QtGui>
-//---------------------------------------------------------------------------
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011 by the deal.II authors
+// Copyright (C) 2010 - 2013 by Martin Steigemann and Wolfgang Bangerth
//
-// 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef XMLPARAMETERREADER_H
#define XMLPARAMETERREADER_H
-//---------------------------------------------------------------------------
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011 by the deal.II authors
+// Copyright (C) 2010 - 2013 by Martin Steigemann and Wolfgang Bangerth
//
-// 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <QtGui>
-//---------------------------------------------------------------------------
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011 by the deal.II authors
+// Copyright (C) 2010 - 2013 by Martin Steigemann and Wolfgang Bangerth
//
-// 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef XMLPARAMETERWRITER_H
#define XMLPARAMETERWRITER_H
--- /dev/null
+## ---------------------------------------------------------------------
+## $Id$
+##
+## Copyright (C) 2013 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
+
+INCLUDE_DIRECTORIES(
+ BEFORE
+ ${CMAKE_SOURCE_DIR}/include/
+ ${CMAKE_BINARY_DIR}/include/
+ )
+
+ADD_EXECUTABLE(test_affinity
+ test_affinity.cc
+ )
+
+IF(CMAKE_BUILD_TYPE MATCHES "Debug")
+ SET(_build "DEBUG")
+ELSE()
+ SET(_build "RELEASE")
+ENDIF()
+
+SET_TARGET_PROPERTIES(test_affinity PROPERTIES
+ LINK_FLAGS "${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${_build}}"
+ COMPILE_DEFINITIONS "${DEAL_II_DEFINITIONS};${DEAL_II_DEFINITIONS_${_build}}"
+ COMPILE_FLAGS "${DEAL_II_CXX_FLAGS_${_build}}"
+ LINKER_LANGUAGE "CXX"
+ )
+
+TARGET_LINK_LIBRARIES(test_affinity ${DEAL_II_BASE_NAME}${DEAL_II_${_build}_SUFFIX})
+
+IF(NOT CMAKE_CROSSCOMPILING)
+ ADD_CUSTOM_TARGET(run_test_affinity COMMAND test_affinity)
+ENDIF()
--- /dev/null
+#include <deal.II/grid/tria.h>
+#include <sched.h>
+
+int main ()
+{
+ // we need this, otherwise gcc will not link against deal.II
+ dealii::Triangulation<2> test;
+
+ cpu_set_t my_set;
+ CPU_ZERO(&my_set);
+
+ unsigned int len = sizeof(my_set);
+ int ret = sched_getaffinity(0, len, &my_set);
+
+ if (ret!=0)
+ {
+ printf("sched_getaffinity() failed, return value: %d\n", ret);
+ return -1;
+ }
+
+ unsigned int bits_set = CPU_COUNT(&my_set);
+
+ if (bits_set==1)
+ {
+ printf("Warning: sched_getaffinity() returns that we can only use one CPU.\n");
+ return 1;
+ }
+ printf("ncpus=%d, mask=%08X\n", bits_set, *(unsigned int*)(&my_set));
+}
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
-#
-# Required packages for the document generation:
-#
-FIND_PACKAGE(Perl)
-FIND_PACKAGE(Doxygen)
#
#
IF(DEAL_II_COMPONENT_DOCUMENTATION)
+ #
+ # Required packages for the document generation:
+ #
+ FIND_PACKAGE(Perl)
+ FIND_PACKAGE(Doxygen)
+
#
# Do we have all necessary dependencies?
#
#
ADD_SUBDIRECTORY(doxygen)
+ #
+ # A custom target with the same name as the component:
+ #
+ ADD_CUSTOM_TARGET(documentation DEPENDS doxygen)
+
#
# Install the static elements of the html documentation:
#
</head>
<body>
- <h1>deal.II Credits</h1>
+ <h1>deal.II Authors</h1>
<p>
The <acronym>deal.II</acronym> project was initially started by
</li>
<li>
- <a href="http://www.math.tamu.edu/~heister"
+ <a href="http://www.math.clemson.edu/~heister"
target="_top">Timo Heister</a>,
- Texas A&M University, TX, USA
+ Clemson University, SC, USA
</li>
<li>
</li>
</ul>
- <p>In order to get in contact with them, send email to <tt>authors</tt>
- at <tt>dealii.org</tt>.
- </p>
-
<p>Many people have contributed to deal.II over the years, some of them very
substantial parts of the library. Their work
is greatly appreciated: no open source project can survice without a
Step-29 tutorial program.
<li><em>Fahad Alrashed:</em>
- work in PETScWrappers.
+ work in PETScWrappers, various other fixes.
<li><em>Michael Anderson:</em>
Linear complexity grid reordering algorithm in 2d and 3d.
<li><em>Chih-Che Chueh:</em>
Step-43 tutorial program.
+ <li><em>Denis Davydov:</em>
+ FEValuesExtractors::Tensor and associated functionality, various other changes.
+
<li><em>Kevin Dugan:</em>
Fixes in VectorTools::interpolate.
Support for arbitrary nodes in FE_Q. Matrix-free
framework. step-37 and step-48 tutorial programs.
+ <li><em>Oleh Krehel:</em>
+ Many documentation fixes.
+
<li><em>Martin Kronbichler:</em>
step-22, step-31, step-32, step-37, step-48, interfaces to
Trilinos, significant parts of ConstraintMatrix, matrix-free
2.5 format.
<li><em>Matthias Maier:</em>
- CMake build system. Periodic boundary conditions. Enhancements throughout the library.
+ CMake build system for the library and the testsuite. Periodic
+ boundary conditions. Enhancements throughout the library.
<li><em>Cataldo Manigrasso:</em>
Work on the codimension-one meshes, DoFHandler, and finite
Eulerian mappings.
<li><em>Martin Steigemann:</em>
- Graphical user interface for the ParameterHandler class. ParaSails preconditioner.
+ Graphical user interface for the ParameterHandler
+ class. ParaSails preconditioner. Functionality in various
+ places of the library.
<li><em>Franz-Theo Suttmeier:</em>
Initial parts of the linear algebra libraries.
Packaging and configuration issues.
<li><em>Bruno Turcksin:</em>
- Extending deal.ii for 64-bit integer support.
+ Extending deal.ii for 64-bit integer support. Converting the
+ testsuite to CMake. Various other changes.
<li><em>Kainan Wang:</em>
Extending deal.ii for 64-bit integer support.
-
+
<li><em>Yaqi Wang:</em>
The step-28 tutorial program;
<li><em>Joshua White:</em>
Arbitrary order Eulerian mappings.
+ <li><em>Christian Wülker:</em>
+ GridOut::write_svg.
+
<li><em>Toby D. Young:</em>
Interfaces to SLEPc; many changes in the interfaces to PETSc;
MUMPS interface;
Siegen, Germany.
</p>
-
+ <hr />
+ <address>
+ <a href="authors.html" target="body">The deal.II Authors</a>
+ $Date$
+ </address>
<div class="right">
- <a href="http://validator.w3.org/check?uri=referer" target="_top"><img
- style="border:0"
- src="http://www.w3.org/Icons/valid-html401"
- alt="Valid HTML 4.01!"></a>
- <a href="http://jigsaw.w3.org/css-validator/check/referer"
- target="_top"><img
- style="border:0;width:88px;height:31px"
- src="http://jigsaw.w3.org/css-validator/images/vcss"
- alt="Valid CSS!">
- </a>
+ <a href="http://validator.w3.org/check?uri=referer" target="_top">
+ <img style="border:0" src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
+ <a href="http://jigsaw.w3.org/css-validator/check/referer" target="_top">
+ <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
</div>
</body>
<meta name="keywords" content="deal.II">
</head>
- <body>
-
-
- <h1><acronym>Build system internals</h1>
-
- <p>
- This page provides details about the CMake build system. Files
- processed by the top level <code>CMakeLists.txt</code> script are
- listed in the TOC in cronological order.
- </p>
-
- <p>
- <table class="tutorial" width="50%">
- <tr><th colspan="2"><b><small>Table of contents</small></b></th></tr>
- <tr><td valign="top">
- <ul>
- <li><a href="#codingstyle">Coding convention</a>
- </ul>
- </br><b>Configuration:</b>
- <ul>
- <li><a href="#setup"><code>./CMakeLists.txt</code> and
- <code>./cmake/setup_*.cmake</code></a>
- <li><a href="#checks"><code>./cmake/checks/check_*.cmake</code></a>
- <li><a href="#findmodules"><code>./cmake/modules/Find*.cmake</code></a>
- <li><a href="#configure"><code>./cmake/configure/configure_*.cmake</code></a>
- <li><a href="#variables">Global variables controlling the build process</a>
- </ul>
- </br><b>Target definition and installation</b>
- <ul>
- <li><a href="#config.h.in"><code>./include/deal.II/base/config.h.in</code></a>
- <li><a href="#source"><code>./source/CMakeLists.txt</code></a>
- <li><a href="#projectconfig"><code>./cmake/config/CMakeLists.txt</code></a>
- <li>TODO
- </ul>
- </td>
- </tr>
- </table>
- </p>
-
- <a name="codingstyle"></a>
- <h3> Coding convention </h3>
- <p>
- Coding conventions are always a matter of choice. Nevertheless, the
- following rules should be considered:
- <ul>
- <li>
- Statements and keywords are written in all caps.
- <li>
- Indenting is done by two spaces; the usual indenting rules apply.
- <li>
- The <code>ELSE()</code>, <code>ENDIF()</code>,
- <code>ENDFOREACH()</code>, etc. statements shall not repeat the
- corresponding condition in <code>IF()</code>,
- <code>FOREACH()</code>, etc.
- <li>
- To emphasize a comment it may be enclosed by a leading and
- trailing empty comment line.
- </ul>
- An example:
- <pre>
-
- FOREACH(_build ${DEAL_II_BUILD_TYPES})
- #
- # Set an appropriate keyword depending on target and build type:
- #
- IF(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "DebugRelease")
- SET(_keyword "general")
- ELSE()
- IF(_build MATCHES DEBUG)
- SET(_keyword "debug")
- ELSE()
- SET(_keyword "optimized")
- ENDIF()
- ENDIF()
- ENDFOREACH()
- </pre>
- <ul>
- <li>
- Line break is at 78 characters and should be obeyed whenever
- reasonable.
- <li>
- Long statements should be broken into several lines at reasonable
- places. Additional lines for a statement are indented by 2
- spaces.
- <li>
- Multiline statements must end with the closing bracket at a
- single line:
- </ul>
- <pre>
-
- LIST(APPEND CONFIG_LIBRARIES
- ${_keyword}
- ${CONFIG_LIBRARIES_${_build}}
- )
-
- SET_TARGET_PROPERTIES(${DEAL_II_BASE_NAME}${DEAL_II_${build}_SUFFIX}
- PROPERTIES
- VERSION ${VERSION}
- SOVERSION ${VERSION}
- LINK_FLAGS "${DEAL_II_SHARED_LINKER_FLAGS_${build}}"
- COMPILE_DEFINITIONS "${DEAL_II_DEFINITIONS};${DEAL_II_DEFINITIONS_${build}}"
- COMPILE_FLAGS "${DEAL_II_CXX_FLAGS_${build}}"
- )
- </pre>
- CMake operates almost always with variables in global state. To guard
- against accidential overwrite of variables the following naming
- conventions must be followed at all times:
- <ul>
- <li>
- Global (configuration) variables are written in all caps. When
- introducing a new one, ensure that the name isn't already used
- somewhere else. Unrelated global variables must never be
- overwritten.
- <li>
- Global variables can be prefixed by <code>DEAL_II_</code>.
- (Global variables defined by CMake are usually prefixed by
- <code>CMAKE_</code>.)
- <li>
- Local variables should always be named in all lowercase with a
- leading "_". Local variables cannot be assumed to remain valid.
- The may get overwritten at any time.
- </ul>
- </p>
-
-
- <a name="setup"></a>
- <h3> <code>./CMakeLists.txt</code> and <code>./cmake/setup_*.cmake</code> </h3>
-
- <p>
- The very first configuration steps after some initial setup in
- <code>./CMakeLists.txt</code> takes place in some
- <code>./cmake/setup_*.cmake</code> files:
- <ul>
- <li> <code>setup_cached_variables.cmake</code>:
- This sets up all cached variables prior to the call to
- <code>PROJECT(deal.II)</code>. For details see the comment at the
- top. Furthermore, some bookkeeping for compiler and linker flags
- takes place, see <a href="cmake.html#configurebuild">the section
- about compile flags</a>.
- <li> <code>setup_deal_ii.cmake</code>:
- This file is included immediately after the call to
- <code>PROJECT(deal.II)</code> and will set up all <i>magic
- numbers</i> such as names, definitions, relative and absolute
- paths used in the build system. Most of the definitions are
- guarded with the help of the <code>SET_IF_EMPTY</code> macro so
- that it is possible to override the values from the command line.
- <li> <code>setup_compiler_flags.cmake</code>
- sets up a suitable set of default compile flag for a known
- compiler by including the appropriate
- <code>setup_compiler_flags_*.cmake</code> file. When adding new
- flags or compiler support, please respect the following note
- <pre>
+<body>
+<h1><acronym>Build system internals</h1>
+
+<p>
+ This page provides details about the CMake build system. Files
+ processed by the top level <code>CMakeLists.txt</code> script are
+ listed in the TOC in chronological order.
+</p>
+
+<div class="toc">
+ <ol>
+ <li><a href="#codingstyle">Coding convention</a></li>
+ <li>Configuration
+ <ol>
+ <li><a href="#setup"><code>./CMakeLists.txt</code> and
+ <code>./cmake/setup_*.cmake</code></a></li>
+ <li><a href="#checks"><code>./cmake/checks/check_*.cmake</code></a></li>
+ <li><a href="#findmodules"><code>./cmake/modules/Find*.cmake</code></a></li>
+ <li><a href="#configure"><code>./cmake/configure/configure_*.cmake</code></a></li>
+ <li><a href="#variables">Global variables controlling the build process</a></li>
+ </ol>
+ </li>
+ <li>Target definition and installation
+ <ol>
+ <li><a href="#config.h.in"><code>./include/deal.II/base/config.h.in</code></a></li>
+ <li><a href="#source"><code>./source/CMakeLists.txt</code></a></li>
+ <li><a href="#projectconfig"><code>./cmake/config/CMakeLists.txt</code></a></li>
+ </ol>
+ </li>
+</div>
+
+<a name="codingstyle"></a>
+<h2> Coding convention </h2>
+<p>
+ Coding conventions are always a matter of choice. Nevertheless, the
+ following rules should be considered:
+ <ul>
+ <li>
+ Statements and keywords are written in all caps.
+ <li>
+ Indenting is done by two spaces; the usual indenting rules apply.
+ <li>
+ The <code>ELSE()</code>, <code>ENDIF()</code>,
+ <code>ENDFOREACH()</code>, etc. statements shall not repeat the
+ corresponding condition in <code>IF()</code>,
+ <code>FOREACH()</code>, etc.
+ <li>
+ To emphasize a comment it may be enclosed by a leading and
+ trailing empty comment line.
+ </ul>
+ An example:
+<pre class="cmake">
+FOREACH(_build ${DEAL_II_BUILD_TYPES})
+#
+# Set an appropriate keyword depending on target and build type:
+#
+ IF(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "DebugRelease")
+ SET(_keyword "general")
+ ELSE()
+ IF(_build MATCHES DEBUG)
+ SET(_keyword "debug")
+ ELSE()
+ SET(_keyword "optimized")
+ ENDIF()
+ ENDIF()
+ENDFOREACH()
+</pre>
+
+<ul>
+ <li>
+ Line break is at 78 characters and should be obeyed whenever
+ reasonable.
+ <li>
+ Long statements should be broken into several lines at reasonable
+ places. Additional lines for a statement are indented by 2
+ spaces.
+ <li>
+ Multiline statements must end with the closing bracket at a
+ single line:
+</ul>
+<pre class="cmake">
+LIST(APPEND CONFIG_LIBRARIES
+ ${_keyword}
+ ${CONFIG_LIBRARIES_${_build}}
+)
+
+SET_TARGET_PROPERTIES(${DEAL_II_BASE_NAME}${DEAL_II_${build}_SUFFIX}
+ PROPERTIES
+ VERSION ${VERSION}
+ SOVERSION ${VERSION}
+ LINK_FLAGS "${DEAL_II_LINKER_FLAGS_${build}}"
+ COMPILE_DEFINITIONS "${DEAL_II_DEFINITIONS};${DEAL_II_DEFINITIONS_${build}}"
+ COMPILE_FLAGS "${DEAL_II_CXX_FLAGS_${build}}"
+)
+</pre>
+
+<p>
+ CMake operates almost always with variables in global state. To
+ guard against accidental overwrite of variables the following naming
+ conventions must be followed at all times:
+</p>
+
+<ul>
+ <li>
+ Global (configuration) variables are written in all caps. When
+ introducing a new one, ensure that the name isn't already used
+ somewhere else. Unrelated global variables must never be
+ overwritten.
+ <li>
+ Global variables can be prefixed by <code>DEAL_II_</code>.
+ (Global variables defined by CMake are usually prefixed by
+ <code>CMAKE_</code>.)
+ <li>
+ Local variables should always be named in all lowercase with a
+ leading "_". Local variables cannot be assumed to remain valid.
+ The may get overwritten at any time.
+</ul>
+</p>
+
+<h2>Configuration</h2>
+
+<a name="setup"></a>
+<h3> <code>./CMakeLists.txt</code> and <code>./cmake/setup_*.cmake</code> </h3>
+
+<p>
+ The very first configuration steps after some initial setup in
+ <code>./CMakeLists.txt</code> takes place in some
+ <code>./cmake/setup_*.cmake</code> files:
+ <ul>
+ <li> <code>setup_cached_variables.cmake</code>:
+ This sets up all cached variables prior to the call to
+ <code>PROJECT(deal.II)</code>. For details see the comment at the
+ top. Furthermore, some bookkeeping for compiler and linker flags
+ takes place, see <a href="cmake.html#configurebuild">the section
+ about compile flags</a>.
+ <li> <code>setup_deal_ii.cmake</code>:
+ This file is included immediately after the call to
+ <code>PROJECT(deal.II)</code> and will set up all <i>magic
+ numbers</i> such as names, definitions, relative and absolute
+ paths used in the build system. Most of the definitions are
+ guarded with the help of the <code>SET_IF_EMPTY</code> macro so
+ that it is possible to override the values from the command line.
+ <li> <code>setup_compiler_flags.cmake</code>
+ sets up a suitable set of default compile flag for a known
+ compiler by including the appropriate
+ <code>setup_compiler_flags_*.cmake</code> file. When adding new
+ flags or compiler support, please respect the following note
+
+<pre>
#
# (./cmake/setup_compiler_flags.cmake)
# CMAKE_CXX_FLAGS
# DEAL_II_CXX_FLAGS_DEBUG
# DEAL_II_CXX_FLAGS_RELEASE
- # CMAKE_SHARED_LINKER_FLAGS
- # DEAL_II_SHARED_LINKER_FLAGS_DEBUG
- # DEAL_II_SHARED_LINKER_FLAGS_RELEASE
+ # DEAL_II_LINKER_FLAGS
+ # DEAL_II_LINKER_FLAGS_DEBUG
+ # DEAL_II_LINKER_FLAGS_RELEASE
#
# All modifications shall be guarded with the ENABLE_IF_SUPPORTED
# or ENABLE_IF_LINKS macro, e.g.
#
# ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-fpic")
- # ENABLE_IF_LINKS(CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed")
+ # ENABLE_IF_LINKS(DEAL_II_LINKER_FLAGS "-Wl,--as-needed")
#
# Compiler flags for platform dependent optimization (such as
# -march=native) must always be guarded with
# ./cmake/checks/check_01_system_features.cmake
# ./cmake/checks/check_02_compiler_bugs.cmake
#
- </pre>
- </ul>
- </p>
+</pre>
+ </ul>
+</p>
- <a name="checks"></a>
- <h3> <code>./cmake/checks/check_*.cmake</code> </h3>
+<a name="checks"></a>
+<h3> <code>./cmake/checks/check_*.cmake</code> </h3>
- <p>
- The next step in the configuration process is to include all
- checks residing under <code>./cmake/checks</code>. Currently
- there are:
- <pre>
+<p>
+ The next step in the configuration process is to include all
+ checks residing under <code>./cmake/checks</code>. Currently
+ there are:
+<pre>
+
./cmake/checks/check_01_compiler_features.cmake
- Search for support for compiler dependent features such as stack
trace support, demangler support, etc.
./cmake/checks/check_02_compiler_bugs.cmake
- Check for compiler bugs
- </pre>
- <ul>
- <li>
- A check usually consists of a call to one of the macros below
- that will set up a global variable. Please stick to the naming
- convention <code>HAVE_<..></code>, resp.
- <code>DEAL_II_(HAVE|USE)_<..></code>. <b>It is forbidden to
- use a variable name starting with
- <code>DEAL_II_WITH_<..></code> because this prefix is
- exclusively reserved for the feature mechanism described
- below.</b> For some tests it might be necessary to manipulate <a
- href="#variables">global variables</a>.
- <li>
- A platform check should have a prominent comment explaining what
- it does and why it is there, and should state author and year.
- <li>
- There are a number of readily available platform check macros:
- <pre>
+
+</pre>
+
+<ul>
+ <li>
+ A check usually consists of a call to one of the macros below
+ that will set up a global variable. Please stick to the naming
+ convention <code>HAVE_<..></code>, resp.
+ <code>DEAL_II_(HAVE|USE)_<..></code>. <b>It is forbidden to
+ use a variable name starting with
+ <code>DEAL_II_WITH_<..></code> because this prefix is
+ exclusively reserved for the feature mechanism described
+ below.</b> For some tests it might be necessary to manipulate
+ <a href="#variables">global variables</a>.
+ <li>
+ A platform check should have a prominent comment explaining what
+ it does and why it is there, and should state author and year.
+ <li>
+ There are a number of readily available platform check macros:
+
+<pre>
CHECK_CXX_SOURCE_COMPILES(source variable)
- - Checks whether it is possible to compile _and_ link the code snipet
- <source>. If succesful, variable is set to 1.
+ - Checks whether it is possible to compile _and_ link the code snippet
+ <source>. If successful, variable is set to 1.
CHECK_CXX_SOURCE_RUNS(source variable)
- - variable is set to 1 if <source> coulde be succesfully compiled and
+ - variable is set to 1 if <source> could be successfully compiled and
linked and the resulting program ran and exited without error.
Avoid this macro outside of a DEAL_II_ALLOW_PLATFORM_INTROSPECTION
guard. A sensible fallback should be provided if the check cannot
CHECK_CXX_COMPILER_FLAG(flag variable)
- Sets the variable to 1 if the compiler understands the flag.
- </pre>
- <li> Necessary compiler flags can easily set in the string variable
- <code>CMAKE_REQUIRED_FLAGS</code>. There are two small macros
- that do this job nicely:
- <pre>
+</pre>
+
+ <li> Necessary compiler flags can easily set in the string variable
+ <code>CMAKE_REQUIRED_FLAGS</code>. There are two small macros
+ that do this job nicely:
+<pre>
+
PUSH_TEST_FLAG("-Werror")
CHECK_CXX_SOURCE_COMPILES(...)
POP_TEST_FLAG()
- </pre>
-
- <li> Libraries necessary for linkage can be set in the list variable
- <code>CMAKE_REQUIRED_LIBRARIES</code>. It is best two hard set
- this variable to a specific value and later on cleaning it,
- instead of appending/removing:
- <pre>
-
- SET(CMAKE_REQUIRED_LIBRARIES <a list of libraries>
+</pre>
+
+ <li> Necessary include directories and libraries necessary for
+ linkage can be set in the list variables
+ <code>CMAKE_REQUIRED_INCLUDES</code> and
+ <code>CMAKE_REQUIRED_LIBRARIES</code>. It is best to append these
+ lists and later on reset <code>CMAKE_REQUIRED_*</code> (including
+ <code>CMAKE_REQUIRED_FLAGS</code>) to their default values:
+
+<pre>
+
+ LIST(APPEND CMAKE_REQUIRED_INCLUDES <a list of includes>)
+ LIST(APPEND CMAKE_REQUIRED_LIBRARIES <a list of libraries>)
CHECK_CXX_SOURCE_COMPILES(...)
- SET(CMAKE_REQUIRED_LIBRARIES)
- </pre>
- </ul>
- </p>
-
-
-
- <a name="findmodules"></a>
- <h3> <code>./cmake/modules/Find*.cmake</code> </h3>
-
- <p>
- These are find modules for the <code>configure_*.cmake</code> files
- and the <code>CONFIGURE_FEATURE</code> macro as will explained later.
- It is crucial that a find module behaves correctly. Therefore, the
- following rules are mandatory:
- <ul>
- <li>
- The <i>sole</i> purpose of a find module is to find an external
- library (no deal.II specific dependency checking, no
- compatibility checking).
- <li>
- It should do so by appropriate <code>FIND_LIBRARY</code> and
- <code>FIND_PATH</code> calls. The results of this calls should be the
- only cached variables.
- <li>
- <code>FIND_PACKAGE_HANDLE_STANDARD_ARGS</code> should be used for
- setting <code>FEATURE_FOUND</code> as this already respects the
- <code>QUIET</code> and <code>REQUIRED</code> keywords.
- <li>
- A <code>WARNING</code>, <code>SEND_ERROR</code> or
- <code>FATAL_ERROR</code> must be avoided (the only exception is
- the <code>REQUIRED</code> keyword).
- <li>
- If successful, the following uncached variables might be set:
- <pre>
-
+ RESET_CMAKE_REQUIRED()
+</pre>
+</ul>
+</p>
+
+<a name="findmodules"></a>
+<h3> <code>./cmake/modules/Find*.cmake</code> </h3>
+
+<p>
+ These are find modules for the <code>configure_*.cmake</code> files
+ and the <code>CONFIGURE_FEATURE</code> macro as will explained later.
+ It is crucial that a find module behaves correctly. Therefore, the
+ following rules are mandatory:
+ <ul>
+ <li>
+ The <i>sole</i> purpose of a find module is to find an external
+ library (no deal.II specific dependency checking, no
+ compatibility checking).
+ <li>
+ It should do so by appropriate <code>FIND_LIBRARY</code> and
+ <code>FIND_PATH</code> calls. The results of this calls should be the
+ only cached variables.
+ <li>
+ <code>FIND_PACKAGE_HANDLE_STANDARD_ARGS</code> should be used for
+ setting <code>FEATURE_FOUND</code> as this already respects the
+ <code>QUIET</code> and <code>REQUIRED</code> keywords.
+ <li>
+ A <code>WARNING</code>, <code>SEND_ERROR</code> or
+ <code>FATAL_ERROR</code> must be avoided (the only exception is
+ the <code>REQUIRED</code> keyword).
+ <li>
+ If successful, the following uncached variables might be set:
+
+<pre>
+
FEATURE_FOUND
FEATURE_LIBRARIES
FEATURE_INCLUDE_DIRS
FEATURE_VERSION_MAJOR
FEATURE_VERSION_MINOR
FEATURE_VERSION_SUBMINOR
- </pre>
- There are obviously valid exceptions from this rule, though.
- <li>
- Only "local" variables "<code>_<all lowercase></code>" or
- "global" variables prefixed by <code>FEATURE_</code> may be
- altered. Do not set <code>DEAL_II_*</code> or <code>CMAKE_*</code>
- variables directly!
- <li>
- A hint with <code>FEATURE_DIR</code> can be set up for
- convenience. It is best to start the <code>Find</code> module by
- <pre>
-
- SET_IF_EMPTY(FEATURE_DIR "$ENV{FEATURE_DIR}")
- </pre>
- and use <code>FEATURE_DIR</code> as a hint. If the external
- library could be found, hide it via
- <code>MARK_AS_ADVANCED</code>, if the external library could not
- be found, set a cache value:
- <pre>
-
- SET(FEATURE_DIR "" CACHE PATH "An optional hint to a FEATURE directory")
- </pre>
- </ul>
+</pre>
+There are obviously valid exceptions from this rule, though.
+ <li>
+ Only "local" variables "<code>_<all lowercase></code>" or
+ "global" variables prefixed by <code>FEATURE_</code> may be
+ altered. Do not set <code>DEAL_II_*</code> or <code>CMAKE_*</code>
+ variables directly!
+ <li>
+ A hint with <code>FEATURE_DIR</code> can be set up for
+ convenience. It is best to start the <code>Find</code> module by
+<pre>
- <a name="configure"></a>
- <h3> <code>./cmake/configure/configure_*.cmake</code> </h3>
+ SET_IF_EMPTY(FEATURE_DIR "$ENV{FEATURE_DIR}")
+</pre>
+
+and use <code>FEATURE_DIR</code> as a hint. If the external
+library could be found, hide it via
+<code>MARK_AS_ADVANCED</code>, if the external library could not
+be found, set a cache value:
+<pre>
+
+ SET(FEATURE_DIR "" CACHE PATH "An optional hint to a FEATURE directory")
+</pre>
+ </ul>
- <p>
- The final step in the configuration phase is the setup of features
- (which refer to external or bundled libraries
- <acronym>deal.II</acronym> can optionally interface with.)
- </p>
+ <a name="configure"></a>
+ <h3> <code>./cmake/configure/configure_*.cmake</code> </h3>
+
+<p>
+ The final step in the configuration phase is the setup of features
+ (which refer to external or bundled libraries
+ <acronym>deal.II</acronym> can optionally interface with.)
+
+</p>
<p>
At bare minimum <code>configure_<feature>.cmake</code>
FEATURE_<FEATURE>_DEPENDS (a variable)
- a variable which contains an optional list of other features
- this feature depends on (and which have to be enbled for this feature
+ this feature depends on (and which have to be enabled for this feature
to work.) The features must be given with the full option toggle:
DEAL_II_WITH_[...]
<li>
For internal use, for setting necessary linker flags for the deal.II library:
<ul>
- <li> <code>CMAKE_SHARED_LINKER_FLAGS</code>
- <li> <code>DEAL_II_SHARED_LINKER_FLAGS_DEBUG</code>
- <li> <code>DEAL_II_SHARED_LINKER_FLAGS_RELEASE</code>
+ <li> <code>DEAL_II_LINKER_FLAGS</code>
+ <li> <code>DEAL_II_LINKER_FLAGS_DEBUG</code>
+ <li> <code>DEAL_II_LINKER_FLAGS_RELEASE</code>
</ul>
<li>
</ul>
</p>
-
+
+ <h2>Target definition and installation</h2>
<a name="config.h.in"></a>
<h3> <code>./include/deal.II/base/config.h.in</code> </h3>
two macros:
<pre>
+ #
+ # Glob for all header files associated with the object target:
+ # As this list is only for cosmetic reasons, so that associated header
+ # files show up in IDEs, we don't manage an explicit list (with the
+ # trade-off to have to run "make rebuild_cache" when a new header file
+ # emerges...)
+ #
+ FILE(GLOB _header
+ ${CMAKE_SOURCE_DIR}/include/deal.II/dofs/*.h
+ )
+
#
# A list of source files forming the object target:
#
- SET(src
+ SET(_src
...
dof_tools.cc
)
#
# A list of instantiations that must be expanded:
#
- SET(inst_in_files
+ SET(_inst
...
dof_tools.inst.in
)
# ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/deal_ii_objects_(debug/release)
# so that it is available in global scope.
#
- DEAL_II_ADD_LIBRARY(obj_dofs OBJECT ${src})
+ # Header files and instatiation files (${_header}, ${_inst}) are added
+ # for cosmetic reasons, so that they show up in IDEs.
+ #
+ DEAL_II_ADD_LIBRARY(obj_dofs OBJECT ${_src} ${_header} ${_inst})
#
# This macro will set up an obj_dofs.inst target for expanding all
resides under <code>./cmake/config/template_arguments.in</code>.
</p>
- <hr>
-
+ <hr />
<address>
- <a href="mail.html" target="body">The deal.II Group</a>
+ <a href="../authors.html" target="body">The deal.II Authors</a>
$Date$
</address>
+ <div class="right">
+ <a href="http://validator.w3.org/check?uri=referer" target="_top">
+ <img style="border:0" src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
+ <a href="http://jigsaw.w3.org/css-validator/check/referer" target="_top">
+ <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
+ </div>
+
</body>
</html>
!! file style mismatch detected
</code>
please re-indent the file. SVN may reject those files soon!</p>
+
+ <hr />
+ <address>
+ <a href="../authors.html" target="body">The deal.II Authors</a>
+ $Date$
+ </address>
+ <div class="right">
+ <a href="http://validator.w3.org/check?uri=referer" target="_top">
+ <img style="border:0" src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
+ <a href="http://jigsaw.w3.org/css-validator/check/referer" target="_top">
+ <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
+ </div>
+
</body>
</html>
</head>
<frameset rows="70,*">
- <frame name="title" src="title.html">
- <frameset cols="120,*">
- <frame name="navbar" src="navbar.html">
- <frame name="body" src="toc.html">
+ <frame name="title" src="title.html" frameborder="1">
+ <frameset cols="150,*">
+ <frame name="navbar" src="navbar.html" frameborder="0">
+ <frame name="body" src="toc.html" frameborder="0">
</frameset>
<noframes>
<h1>deal.II Development Information</h1>
<body class="navbar">
<p>
- <a href="../index.html" target="_top">Homepage</a><br />
- <a href="toc.html" target="body">Overview</a>
+ <a href="http://www.dealii.org"target="_top">http://www.dealii.org</a><br />
+ <a href="../index.html" target="_top">Home</a><br />
</p>
<hr>
- <b><small>Writing code</small></b>
+ <p>
+ <a href="../readme.html" target="body">README</a><br />
+ <a href="../users/index.html" target="_top">Users' Corner</a><br />
+ <a href="index.html" target="_top">Developers' Corner</a><br />
+ </p>
+
+ <hr>
+
+ <b><small>Development</small></b>
<p>
- <a href="svn.html" target="body">SVN Archive</a>
- <a href="makefiles.html" target="body">Makefiles</a><br />
- <a href="writing-documentation.html"
- target="body">Documentation</a><br />
+ <a href="svn.html" target="body">SVN Archive</a><br />
+ <a href="cmake-internals.html" target="body">CMake internals</a><br />
+ <a href="writing-documentation.html" target="body">Writing documentation</a><br />
<a href="porting.html" target="body">Porting</a><br />
<a href="../doxygen/deal.II/CodingConventions.html" target="body">Coding conventions</a><br />
- <a href="doxygen.html" target="body">Linking manuals</a><br />
+ <a href="testsuite.html" target="body">Testsuite</a><br />
</p>
<hr>
- <b><small>Resources</small></b>
+ <b><small>Online Resources</small></b>
<p>
<a href="http://www.dealii.org/websvn/log.php?repname=deal.II+Repository&path=%2F&isdir=1&" target="_top">Recent changes</a><br />
- <a href="http://www.dealii.org/mail.html" target="body">Mailing lists</a><br />
- <a href="http://www.dealii.org/testsuite.html" target="body">Test suite</a><br />
- <a href="https://code.google.com/p/dealii/w/list" target="_top">Wiki</a><br />
- <a href="https://code.google.com/p/dealii/issues/list" target="_top">Bug tracker</a><br />
+ <a href="http://www.dealii.org/cgi-bin/regression_quick.pl" target="body">Regression tests</a><br />
+ <a href="http://www.dealii.org//cgi-bin/build.pl" target="body">Build tests</a><br />
+ <a href="http://www.math.tamu.edu/~heister/bench" target="body">Performance tests</a><br />
</p>
<hr>
<title>Porting deal.II</title>
<link href="../screen.css" rel="StyleSheet" media="screen">
<meta name="author" content="the deal.II authors <authors@dealii.org>">
- <meta name="copyright" content="Copyright (C) 2000, 2001, 2002, 2005, 2010, 2012 by the deal.II authors">
+ <meta name="copyright" content="Copyright (C) 2000, 2001, 2002, 2005, 2010, 2012, 2013 by the deal.II authors">
<meta name="date" content="$Date$">
<meta name="svn_id" content="$Id$">
<meta name="keywords" content="deal.II porting">
Consequently, there is a good chance that <acronym>deal.II</acronym>
will run on a reasonably well behaved system besides the ones listed
- in the <a href="readme.html" target="body">ReadMe</a>. Nevertheless,
+ in the <a href="../readme.html" target="body">ReadMe</a>. Nevertheless,
there are cases where some adjustments are necessary.
</p>
href="cmake.html">the documentation</a>.
</p>
- <hr>
+ <hr />
<address>
- <a href="../mail.html" target="body">The deal.II Group</a>
+ <a href="../authors.html" target="body">The deal.II Authors</a>
+ $Date$
</address>
+ <div class="right">
+ <a href="http://validator.w3.org/check?uri=referer" target="_top">
+ <img style="border:0" src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
+ <a href="http://jigsaw.w3.org/css-validator/check/referer" target="_top">
+ <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
+ </div>
</body>
</html>
resolved, you can simply commit the result.
</ol>
</p>
+
+ <hr />
+ <address>
+ <a href="../authors.html" target="body">The deal.II Authors</a>
+ $Date$
+ </address>
+ <div class="right">
+ <a href="http://validator.w3.org/check?uri=referer" target="_top">
+ <img style="border:0" src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
+ <a href="http://jigsaw.w3.org/css-validator/check/referer" target="_top">
+ <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
+ </div>
+
</body>
</html>
RUN_EXAMPLES - defaults to "true"
</pre>
An example configuration file can be found <a
- href="Config.sample">here</a>. Options can be passed either via
+ href="../users/Config.sample">here</a>. Options can be passed either via
environment
<pre>
<h2>The regression tests</h2>
<p>
- deal.II has a testsuite that, at the time this article is written (mid-2011),
- has some 2300 small programs (growing by roughly one per day) that we run
+ deal.II has a testsuite that, at the time this article is written (mid-2013),
+ has some 2,900 small programs (growing by roughly one per day) that we run
every time we make a
change to make sure that no existing functionality is broken. The
expected output is also stored in our subversion archive, and when you
in both cases to make sure that future changes do not break what
we have just checked in. In addition, some machines run the tests
every night and send the results back home; this is then converted
- into <a href="http://www.dealii.org/cgi-bin/regression_quick.pl"
+ into <a href="http://dealii.mathsim.eu/cgi-bin/regression_quick.pl"
target="body">a webpage showing the status of our regression
tests</a>.
</p>
For the testcase, we usually start from a template like this:
<pre>
-//---------------------------- my_new_test.cc ---------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005 by the deal.II authors
+// Copyright (C) 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------- my_new_test.cc ---------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
// a short (a few lines) description of what the program does
contribute!
</p>
-
+ <hr />
<address>
- <a href="../mail.html">The deal.II Group</a></address>
-<div class="right">
- <p>
- <a href="http://validator.w3.org/check?uri=referer"><img border="0"
- src="http://www.w3.org/Icons/valid-html401"
- alt="Valid HTML 4.01!" height="31" width="88"></a>
- </p>
-</div>
+ <a href="../authors.html" target="body">The deal.II Authors</a>
+ $Date$
+ </address>
+ <div class="right">
+ <a href="http://validator.w3.org/check?uri=referer" target="_top">
+ <img style="border:0" src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
+ <a href="http://jigsaw.w3.org/css-validator/check/referer" target="_top">
+ <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
+ </div>
</body>
</html>
<body class="title">
<div class="fixedhead">
<h1 class="head">
- Development with <acronym>deal.II</acronym>
+ Developers' Corner
</h1>
</div>
</body>
</head>
<body>
- <h1>Information on development with <acronym>deal.II</acronym></h1>
-
<p>
- Apart from the online API references (the "manual") and the tutorial,
- which are covered elsewhere, this page gathers some information on
- developing programs based on
- <acronym>deal.II</acronym>, as well as on how to contribute
- to the development of <acronym>deal.II</acronym> itself. In the
- latter case, we encourage you to use the current development version
- instead of a pre-packaged version of <acronym>deal.II</acronym>, as
- described on our <a
- href="http://www.dealii.org/download/">download page</a>.
+ <br />
+ This page provides documentation for deal.II developers. At present, we
+ have the following resources available:
</p>
- <p>
- At present, we have the following resources available:
- </p>
+ <h2>Documentation</h2>
<ul>
<li> <p> Documentation of the <a href="svn.html">SVN Archive</a> and
information on <a href="http://www.dealii.org/websvn/log.php?repname=deal.II+Repository&path=%2F&isdir=1&" target="_top">recent changes to the library</a>.
- <li> <p>
- <a href="cmake.html">deal.II CMake documentation</a>:
- This page provides extensive information about configuration and
- installation with the CMake build system.
-
- <li> <p><a href="cmakelists.html" target="body">Using
- <acronym>deal.II</acronym> in a user project</a>:
- This page covers how to use CMake in your own project.
- An overview of how to retrieve necessary information
- from a <acronym>deal.II</acronym> installation as well as how to
- write a <code>CMakeLists.txt</code> for a client project is given.
- </p>
-
<li> <p>
<a href="cmake-internals.html">Build system internals</a>:
This page provides implementation and development details about
resource gives some hints for porting to unknown platforms.
</p>
- <li> <p><a href="https://code.google.com/p/dealii/issues/list" target="_top">Bugs</a>:
- Though well tested, <acronym>deal.II</acronym> certainly has
- bugs. If you want to report a bug (or enhancement request),
- go to the <a href="https://code.google.com/p/dealii/issues/list"
- target="_top">bug tracking system</a> and enter a new ticket
- for your issue.
- </p>
-
- <li> <p><a href="doxygen.html">Linking your online documentation
- to the deal.II online manual</a>: After spending a lot of time
- writing good documentation for your code and putting it online,
- here we explain how to put links to the deal.II online manual into
- your documentation, so that readers can click through.
- </p>
+ <li> <p><a href="../doxygen/deal.II/CodingConventions.html"
+ target="body">Coding conventions</a>: We try to adhere to a
+ set of coding conventions to ensure that the use of different
+ parts of the library is as uniform as possible. Please read
+ through them if you think about contributing code.
<li> <p><a href="testsuite.html" target="body">Running the testsuite</a>:
<acronym>deal.II</acronym> has a testsuite that we run to
make sure that our tests don't break any existing
functionality. This page explains its use.
</p>
+ </ul>
- <li> <p><a href="../doxygen/deal.II/CodingConventions.html"
- target="body">Coding conventions</a>: We try to adhere to a
- set of coding conventions to ensure that the use of different
- parts of the library is as uniform as possible. Please read
- through them if you think about contributing code.
+ <h2>Resources</h2>
+ <ul>
<li> <p><a
href="http://www.dealii.org/cgi-bin/regression_quick.pl"
target="body">Results of regression tests:</a> Every night,
</p>
</ul>
- <hr>
-
+ <hr />
<address>
- <a href="../mail.html">The deal.II Group</a></address>
-<div class="right">
- <p>
- <a href="http://validator.w3.org/check?uri=referer"><img border="0"
- src="http://www.w3.org/Icons/valid-html401"
- alt="Valid HTML 4.01!" height="31" width="88"></a>
- </p>
-</div>
+ <a href="../authors.html" target="body">The deal.II Authors</a>
+ $Date$
+ </address>
+ <div class="right">
+ <a href="http://validator.w3.org/check?uri=referer" target="_top">
+ <img style="border:0" src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
+ <a href="http://jigsaw.w3.org/css-validator/check/referer" target="_top">
+ <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
+ </div>
</body>
</html>
<li> <em>Typewriter font:</em>
<p>In order to use typewriter font for instance for function
- arguments or variables, use the <code><tt></code> HTML
+ arguments or variables, use the <code><code></code> HTML
tag. For a single word, you can also use the form <code>@p
- one_word_without_spaces</code>.</p>
+ one_word_without_spaces</code>. The <code><tt></code> is obsolete in HTML5</p>
<p>
If you refer to member variables and member functions
</p>
- <hr>
-
+ <hr />
<address>
- <a href="../mail.html">The deal.II Group</a></address>
-<div class="right">
- <p>
- <a href="http://validator.w3.org/check?uri=referer"><img border="0"
- src="http://www.w3.org/Icons/valid-html401"
- alt="Valid HTML 4.01!" height="31" width="88"></a>
- </p>
-</div>
+ <a href="../authors.html" target="body">The deal.II Authors</a>
+ $Date$
+ </address>
+ <div class="right">
+ <a href="http://validator.w3.org/check?uri=referer" target="_top">
+ <img style="border:0" src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
+ <a href="http://jigsaw.w3.org/css-validator/check/referer" target="_top">
+ <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
+ </div>
</body>
</html>
+++ /dev/null
-## ##
-# A simple CMakeLists.txt file for use with deal.II #
-## ##
-
-#
-# Set the name of the project and target:
-#
-SET(TARGET "step-1")
-
-#
-# Declare all source files the target consists of:
-#
-SET(TARGET_SRC
- ${TARGET}.cc
- # You can specify additional files here!
- )
-
-#
-# (Optional)
-# Specify a list of files (file globs) that will be removed
-# with the "make runclean" and "make distclean" targets.
-# If empty, sensible default values will be used.
-#
-SET(CLEAN_UP_FILES
- # a custom list of globs, e.g. *.log *.vtk
- )
-
-#
-# (Optional)
-# A custom command line that should be invoked by "make run". If empty,
-# ./${TARGET} will be invoked.
-#
-SET(TARGET_RUN
- # a custom command line, e.g. mpirun -np 2 ${TARGET}
- )
-
-#
-# It is good practice to specify a version requirement:
-#
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
-
-#
-# Find and import the deal.II project configuration:
-#
-FIND_PACKAGE(deal.II 8.0 REQUIRED
- HINTS
- ${DEAL_II_DIRS} ../ ../../ $ENV{DEAL_II_DIR}
- #
- # If the deal.II library cannot be found (because it is not installed at a
- # default location or your project resides at an uncommon place), you
- # can specify additional hints for search paths here, e.g.
- # "$ENV{HOME}/workspace/deal.II"
- #
- )
-
-#
-# And let deal.II do the rest:
-#
-DEAL_II_INITIALIZE_CACHED_VARIABLES()
-PROJECT(${TARGET})
-DEAL_II_INVOKE_AUTOPILOT()
+++ /dev/null
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/html4/loose.dtd">
-<html>
- <head>
- <title>How to interface with deal.II in your own project</title>
- <link href="../screen.css" rel="StyleSheet">
- <meta name="author" content="the deal.II authors <authors @ dealii.org>">
- <meta name="copyright" content="Copyright (C) 2012, 2013 by the deal.II authors">
- <meta name="date" content="$Date$">
- <meta name="svn_id" content="$Id$">
- <meta name="keywords" content="deal.II">
- </head>
-
- <body>
-
- <h1>How to interface with <acronym>deal.II</acronym> in your own
- project</h1>
-
- <p>
- <table class="tutorial" width="50%">
- <tr><th colspan="2"><b><small>Table of contents</small></b></th></tr>
- <tr><td valign="top">
- <ul>
- <li><a href="#cmake">Example <code>CMakeLists.txt</code> files</a>
- <ul>
- <li><a href="#cmakesimple">Simple <code>CMakeLists.txt</code></a>
- <li><a href="#cmakeadvanced">Advanced <code>CMakeLists.txt</code></a>
- </ul>
- <li><a href="#ext">Advanced setup for <acronym>deal.II</acronym> in a CMake project</a>
- <ul>
- <li><a href="#extfinding">Finding the deal.II library</a>
- <li><a href="#extcmake">deal.IIConfig.cmake</a>
- <li><a href="#extsetup">Setting up necessary configuration variables</a>
- </ul>
- <li><a href="#legacy">Legacy
- <code>Make.global_options</code></a>
- </ul>
- </td>
- </tr>
- </table>
- </p>
-
-
- <a name="cmake"></a>
- <h3> Example <code>CMakeLists.txt</code> files </h3>
-
- <p>
- <code>cmake</code> is the configuration and build tool we use
- in <acronym>deal.II</acronym>. Its advantage is not only that it makes
- configuration of <acronym>deal.II</acronym> itself simpler across
- platforms (compared to the older <code>autoconf/make</code> combination)
- but also that it <i>exports</i> information about the deal.II
- configuration that makes it particularly simple for projects
- using <acronym>deal.II</acronym> to configure and link against it.
- </p>
-
- <p>
- <code>cmake</code> is controlled by input files that by convention are
- called <code>CMakeLists.txt</code>, listing both configuration commands
- as well as dependencies between source files and targets.
- This page presents some <code>CMakeLists.txt</code> examples for
- potential use in your projects. A detailed description of the
- <acronym>deal.II</acronym> project configuration is given in the
- <a href="cmake.html" target="body">deal.II CMake ReadMe</a>.
- </p>
-
- <a name="cmakesimple"></a>
- <h4>Simple CMakeLists.txt</h4>
-
- <p>
- The easiest way to write a <code>CMakeLists.txt</code> file is to use
- an "autopilot" style macro. Here is an example for the step-1
- tutorial program (<a href="CMakeLists.txt.sample"
- target="_top">plain text</a> version) that can be used for simple
- projects:
- <pre>
-
- #
- # Set the name of the project and target:
- #
- SET(TARGET "step-1")
-
- #
- # Declare all source files the target consists of:
- #
- SET(TARGET_SRC
- ${TARGET}.cc
- # You can specify additional files here!
- )
-
- #
- # (Optional)
- # Specify a list of files (file globs) that will be removed
- # with the "make runclean" and "make distclean" targets.
- # If empty, sensible default values will be used.
- #
- SET(CLEAN_UP_FILES
- # a custom list of globs, e.g. *.log *.vtk
- )
-
- #
- # (Optional)
- # A custom command line that should be invoked by "make run". If empty,
- # ./${TARGET} will be invoked.
- #
- SET(TARGET_RUN
- # a custom command line, e.g. mpirun -np 2 ${TARGET}
- )
-
- #
- # It is good practice to specify a version requirement:
- #
- CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
-
- #
- # Find and import the deal.II project configuration:
- #
- FIND_PACKAGE(deal.II 8.0 REQUIRED
- HINTS
- ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}
- #
- # If the deal.II library cannot be found (because it is not installed at a
- # default location or your project resides at an uncommon place), you
- # can specify additional hints for search paths here, e.g.
- # "$ENV{HOME}/workspace/deal.II"
- #
- )
-
- #
- # And let deal.II do the rest:
- #
- DEAL_II_INITIALIZE_CACHED_VARIABLES()
- PROJECT(${TARGET})
- DEAL_II_INVOKE_AUTOPILOT()
- </pre>
-
- This <code>CMakeLists.txt</code> is intended for use with a small
- project and <i>in-source</i> build (i.e., one does not create a separate
- build directory as we recommend for the <acronym>deal.II</acronym> build
- in the <a href="../readme.html#configuration" target="_body">readme
- file</a>). Using this input file, you can run <code>cmake</code> in the
- source directory as follows:
- <pre>
-
- $ cd step-1
- $ cmake .
-
- [...]
-
- ###
- #
- # Successfully set up project step-1 with deal.II-8.0.pre found at
- # /usr/local
- #
- # CMAKE_BUILD_TYPE: Debug
- # TARGET_SRC: step-1.cc
- #
- # You can now run
- # $ make - to compile and link the program
- # $ make run - to (compile, link and) run the program
- #
- # $ make debug - to switch the build type to "Debug"
- # $ make release - to switch the build type to "Release"
- # $ make edit_cache - to change (cached) configuration variables
- # and rerun the configure and generate phases of CMake
- #
- # $ make clean - to remove the generated executable as well as
- # all intermediate compilation files
- # $ make runclean - to remove all output generated by the program
- # $ make distclean - to clean the directory from _all_ generated
- # files (includes clean, runclean and the removal
- # of the generated build system)
- #
- # Have a nice day!
- #
- ###
- </pre>
- </p>
-
- <a name="cmakeadvanced"></a>
- <h4>Advanced CMakeLists.txt</h4>
-
- <p>
- For large projects the simple <code>CMakeLists.txt</code> presented
- above tends to be too inflexible.
- So, if you wish to have more control about targets the
- <code>DEAL_II_SETUP_TARGET</code> macro might be of interest for you.
- Here is a full example, again using the step-1 tutorial program as a
- template:
- <pre>
-
- #
- # It is good practise to specify a version requirement:
- #
- CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
-
- #
- # Find and import the deal.II project configuration:
- #
- FIND_PACKAGE(deal.II 8.0 REQUIRED
- HINTS
- ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}
- #
- # If the deal.II library cannot be found (because it is not installed at a
- # default location or your project resides at an uncommon place), you
- # can specify additional hints for search paths here, e.g.
- # "$ENV{HOME}/workspace/deal.II"
- #
- )
-
- #
- # Initialize cached variables: This will set the compiler and
- # compiler flags to the values deal.II was configured with, as well as,
- # CMAKE_BUILD_TYPE to "Debug".
- # These values can be altered by editing the cache via
- # $ make edit_cache
- #
- DEAL_II_INITIALIZE_CACHED_VARIABLES()
-
- #
- # PROJECT has to be called after DEAL_II_INITIALIZE_CACHED_VARIABLES
- # otherwise CMake will have already set the compiler and compiler
- # flags.
- #
- PROJECT(step-1)
-
- #
- # Specify a target:
- #
- ADD_EXECUTABLE(step-1 step-1.cc)
-
- #
- # DEAL_II_SETUP_TARGET will set up all necessary include paths,
- # preprocessor definitions and the link interface:
- #
- DEAL_II_SETUP_TARGET(step-1)
-
- #
- # (Optional)
- # If you wish to have a "run" target for make, specify one:
- #
- ADD_CUSTOM_TARGET(run
- COMMAND step-1
- COMMENT "Run ${TARGET} with ${CMAKE_BUILD_TYPE} configuration"
- )
- </pre>
- </p>
-
-
- <a name="ext"></a>
- <h3> Advanced setup for <acronym>deal.II</acronym> in a CMake project </h3>
-
- <a name="extfinding"></a>
- <h4> Finding the deal.II library </h4>
-
- <p>
- Finding the <acronym>deal.II</acronym> library should be no more than
- <pre>
-
- FIND_PACKAGE(deal.II REQUIRED)
- </pre>
- in your CMakeLists.txt file. You may have to hint for the location
- of the <code>deal.IIConfig.cmake</code> file. Either by directly
- specifying <code>deal.II_DIR</code> to point to the path were the
- <code>deal.IIConfig.cmake</code> file is located:
- <pre>
-
- cmake -Ddeal.II_DIR=/path/to/the/config/file <...>
- </pre>
- or by specifying a search path via <code>CMAKE_PREFIX_PATH</code>,
- e.g.
- <pre>
-
- cmake -DCMAKE_PREFIX_PATH=~/workspace/local
- </pre>
- In this case <code>deal.IIConfig.cmake</code> will be searched
- for in
- <pre>
-
- ~/workspace/local/
- ~/workspace/local/lib/cmake/deal.II/
- </pre>
- </p>
-
-
- <a name="extcmake"></a>
- <h4> deal.IIConfig.cmake </h4>
-
- <p>
- Importing the deal.IIConfig.cmake file via <code>FIND_PACKAGE</code>
- will set a bunch of variables and macros; all of the form
- <code>DEAL_II_*</code>. There is the usual duplet:
- <pre>
-
- DEAL_II_INCLUDE_DIRS
- DEAL_II_LIBRARIES
- </pre>
- (with <code>debug</code> and <code>optimized</code> keywords. For
- compatibility there is also <code>DEAL_II_LIBRARIES_DEBUG</code>
- and <code>DEAL_II_LIBRARIES_RELEASE</code> only specifying the
- respective set of libraries.)
- </p>
-
- <p>
- Interesting additional variables might be:
- <pre>
-
- DEAL_II_USER_DEFINITIONS
- DEAL_II_USER_DEFINITIONS_DEBUG
- DEAL_II_USER_DEFINITIONS_RELEASE
- DEAL_II_LINKER_FLAGS
- DEAL_II_LINKER_FLAGS_DEBUG
- DEAL_II_LINKER_FLAGS_RELEASE
- DEAL_II_CXX_FLAGS
- DEAL_II_CXX_FLAGS_DEBUG
- DEAL_II_CXX_FLAGS_RELEASE
-
- DEAL_II_TARGET_CONFIG
- DEAL_II_TARGET
- DEAL_II_TARGET_DEBUG
- DEAL_II_TARGET_RELEASE
- </pre>
- </p>
-
-
-
- <a name="extsetup"></a>
- <h4> Setting up necessary configuration variables </h4>
-
- <p>
- For actually using <acronym>deal.II</acronym> in your CMake
- project some configuration steps are necessary. These can be
- either set via <a href="#extsetupmacro">macros</a> or by <a
- href="#extsetuphand">hand</a>:
- <ol>
- <a name="extsetupmacro"></a><li> <b>Configuration with the help of
- two convencience macros:</b>
- <p>
- <code>deal.IIConfig.cmake</code> includes some convenience macros
- to automatically setup all necessary configuration. A fully
- functional, minimal example for the step-1 tutorial program is:
- <pre>
-
- FIND_PACKAGE(deal.II REQUIRED)
-
- DEAL_II_INITIALIZE_CACHED_VARIABLES()
-
- PROJECT(step-1)
-
- ADD_EXECUTABLE(step-1 step-1.cc)
- DEAL_II_SETUP_TARGET(step-1)
- </pre>
- </p>
-
-
- <a name="extsetuphand"></a><li> <b>Configuration by hand:</b>
- <ul>
- <li> Set up all include directories for header files:
- <pre>
-
- INCLUDE_DIRECTORIES(${DEAL_II_INCLUDE_DIRS})
- </pre>
-
- <li>
- deal.II usually ships with an optimized Release and a Debug version
- of the library. So it is a good idea to set up
- <code>CMAKE_BUILD_TYPE</code> accordingly:
- <pre>
-
- SET(CMAKE_BUILD_TYPE "Debug" CACHE
- "Choose the type of build, options are: Debug, Release"
- )
- </pre>
-
- A cached variable ensures that we can later switch the build type
- by editing the cache:
- <pre>
-
- make edit_cache
- </pre>
-
- <li> Often, it is a good idea to use the same compiler and linker
- flags as the deal.II library.
- <pre>
-
- SET(CMAKE_CXX_FLAGS ${DEAL_II_CXX_FLAGS})
- SET(CMAKE_CXX_FLAGS_RELEASE ${DEAL_II_CXX_FLAGS_RELEASE})
- SET(CMAKE_CXX_FLAGS_DEBUG ${DEAL_II_CXX_FLAGS_DEBUG})
- </pre>
- (Optionally you can set up the variables with the
- <code>CACHE</code> to be able to edit them via ccmake or
- make edit_cache.)
-
- <li>
- <i>After</i> this, specify your project name:
- <pre>
-
- PROJECT(myProject)
- </pre>
- This ensures that the compiler detection and platform setup
- that is issued by calling <code>PROJECT(...)</code> will run
- after we have set up our cached variables. This way it is
- our choice of variables that will be set and not the default
- values determined by the <code>PROJECT(...)</code> call.
-
- <li>
- After defining your targets, e.g.
- <pre>
-
- ADD_EXECUTABLE(step-1 step-1.cc)
- </pre>
- you have to specify to link against deal.II and all external
- libraries:
- <pre>
-
- TARGET_LINK_LIBRARIES(step-1 ${DEAL_II_LIBRARIES})
- </pre>
-
- <li> as well as using some preprocessor definitions:
- <pre>
-
- SET_TARGET_PROPERTIES(step-1 PROPERTIES
- COMPILE_DEFINITIONS
- "${DEAL_II_USER_DEFINITIONS}"
- COMPILE_DEFINITIONS_DEBUG
- "${DEAL_II_USER_DEFINITIONS_DEBUG}"
- COMPILE_DEFINITIONS_RELEASE
- "${DEAL_II_USER_DEFINITIONS_RELEASE}"
- )
- </pre>
-
- <li> Optionally, you can set the link flags to the one used by the
- deal.II library:
- <pre>
-
- SET_TARGET_PROPERTIES(step-1 PROPERTIES
- LINK_FLAGS
- "${DEAL_II_LINKER_FLAGS}"
- LINK_FLAGS_DEBUG
- "${DEAL_II_LINKER_FLAGS_DEBUG}"
- LINK_FLAGS_RELEASE
- "${DEAL_II_LINKER_FLAGS_RELEASE}"
- )
- </pre>
- And this it is.
-
- </ul>
-
- <li>
- <b>Exported targets:</b>
-
- <p>
- For an advanced setup in a big CMake project
- <code><a href="#extcmake">deal.IIConfig.cmake</a></code>
- provides information about the <acronym>deal.II</acronym>
- installation with traditional variables, see
- <a href="#extcmake">here</a>, as well as <i>external CMake
- targets</i> with link interface for direct inclusion:
- <pre>
-
- INCLUDE(${DEAL_II_TARGET_CONFIG})
-
- ADD_EXECUTABLE(step-1
- step-1.cc
- ${DEAL_II_TARGET}
- )
- </pre>
- </p>
- </ol>
- </p>
-
-
-
- <a name="legacy"></a>
- <h3> Legacy Make.global_options </h3>
-
- <p>
- Before version 8.0, <acronym>deal.II</acronym> used the
- traditional <code>autoconf/make</code> configuration and build
- system. The interaction between these two programs, as well as
- propagation of information from <acronym>deal.II</acronym> to user
- programs happened through a number of files that were generated within
- the <acronym>deal.II</acronym> directory tree.
- The CMake build system sets up the following compatibility files (if
- <code>DEAL_II_COMPONENT_COMPAT_FILES</code> is set, which is default):
- <pre>
-
- ${CMAKE_INSTALL_PREFIX}
- ./common/Make.global_options
- ./common/scripts/expand_instantiations
- ./common/scripts/make_dependencies
- ./common/scripts/report_features
- </pre>
-
- Therefore, it should be sufficient to set <code>D</code> in the old
- user Makefiles to:
- <pre>
-
- D=/path/install/dir
- </pre>
- where <code>/path/install/dir</code> is the directory set up via
- <code>CMAKE_INSTALL_PREFIX</code> (the path
- <acronym>deal.II</acronym> was installed to).
- </p>
-
-
-
- <hr>
-
- <address>
- <a href="mail.html" target="body">The deal.II Group</a>
- $Date$
- </address>
- </body>
-</html>
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
- <link href="screen.css" rel="StyleSheet" type="text/css">
<title>The deal.II Online Documentation</title>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
+ <link href="screen.css" rel="StyleSheet" type="text/css">
<meta name="author" content="the deal.II authors <authors@dealii.org>">
- <meta name="copyright" content="Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors">
+ <meta name="copyright" content="Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors">
<meta name="date" content="2006/02/07 22:49:01">
<meta name="keywords" content="deal.II">
<meta name="svn_id" content="$Id$">
</head>
- <body>
-
- <h2>Online documentation</h2>
-
- <p>
- <acronym>deal.II</acronym> comes with quite extensive online
- documentation, which falls into several categories. They are
- listed below.
- </p>
-
-
- <h3><a href="readme.html">README</a></h3>
-
- <p>
- First, there is the <a href="readme.html" target="body">README file</a> of
- the library. It gives information on system requirements,
- installation, and copyright.
- </p>
-
- <h3>Tutorials</h3>
-
- <p>
- The <a href="doxygen/tutorial/index.html"
- target="_top">tutorial</a> is
- for new users of the library. It explains the basic elements of
- finite element programs based on the library, and provides small
- example programs. You can also reach the tutorial link from the menu bar
- at the left.
- </p>
-
- <p>
- Note that along with the rest of the documentation, the local HTML pages
- of the tutorials need to be generated first. Please follow the
- instructions in the
- <a href="readme.html" target="body">ReadMe file</a> on how to do
- this.
- </p>
-
-
- <h3>Programming interface</h3>
-
- <p>
- The <a href="doxygen/deal.II/index.html" target="_top">programming
- interface/manual</a> pages are what you will need most often as a
- reference of all classes, functions and variables in the library. They
- are extensively documented (presently more than 5000 pages if
- printed), and generated by <a href="http://www.doxygen.org/"
- target="_top">Doxygen</a>. There is also a quick link to these pages from
- the menu bar at the left.
- </p>
-
- <p>
- The documentation uses many of the features of Doxygen. In particular,
- the link takes you straight to a page that lists <i>modules</i>, a way
- to group classes with similar purposes. This may be what you are probably
- interested in when you are not yet familiar with the library. If you
- already know your way around and want to look up the signature of a
- particular member function, for example, you may go to the class view or
- choose any of the other ways in which Doxygen allows you to navigate
- through the documentation.
- </p>
-
- <p>
- Just as for the tutorials, the API docs need to be generated first,
- if you download <acronym>deal.II</acronym>. Please follow the
- instructions in the
- <a href="readme.html" target="body">ReadMe file</a> on how to do
- this.
- </p>
-
-
- <h3>Development information</h3>
-
- <p>
- If you plan to <a href="development/index.html"
- target="_top">develop your own applications</a> using
- <acronym>deal.II</acronym>, it might be worth to take a look
- at <a href="development/index.html" target="_top">this
- page</a>.
- </p>
-
-
- <h3>Reports</h3>
-
- <p>
- There are a number of papers that describe the overall design or
- individual aspects of <acronym>deal.II</acronym>. Please refer to the
- papers listed at the top of the <a href="publications/index.html"
- target="body">publications page</a> for full references. In addition,
- there are the following reports:
- <ul>
- <li> <p>
- A publication on the
- <a href="reports/dimension-independent/index.html"
- target="body">basics of dimension independent
- programming</a> in <acronym>deal.II</acronym> (by Wolfgang
- Bangerth). This explains some of the fundamentals of the
- library's design, though rather briefly due to the page
- limit imposed for the publication.
- </p>
-
- <p>
- This publication appeared in
- the proceedings of the 16th IMACS World Congress,
- Lausanne, Switzerland, 2000. See the
- <a href="publications/index.html" target="body">publications</a>
- page for the full reference as well as a way to obtain a
- reprint of the original paper as a postscript or PDF file.
- </p>
-
- <li> <p>
- A brief report about the classes involved in the
- <a href="reports/class-hierarchies/index.html"
- target="body">iterators and accessors</a>
- used to access cells in the triangulations and the data
- thereon, such as their geometry, the number of the
- degrees of freedom, data values, etc. You may want to
- read this object or parts of it if you want to know what
- information is available from iterators (by Wolfgang
- Bangerth).
- </p>
-
- <li> <p>
- A brief report on <a href="reports/mapping_q/index.html"
- target="body">mapping</a> functions of higher polynomial
- degrees (by Ralf Hartmann). These allow the realisation
- of higher order boundary approximations. This report
- gives the theoretical background of the
- <code>MappingQ</code> class.
- </p>
-
- <li> <p>
- A report on
- <a href="reports/assemble/assemble.pdf"
- target="body">assembling matrices</a> (by Wolfgang
- Bangerth). This report looks in particular at how
- matrices are assembled for vector-valued problems, and
- how things change if vector-valued finite elements are
- used for which the shape functions have more than one
- non-zero vector component, such as Nedelec or
- Raviart-Thomas elements. There are printable
- versions of the report
- <a href="reports/assemble/assemble.ps"
- target="body">in postscript</a> and
- <a href="reports/assemble/assemble.pdf"
- target="body">PDF format</a>.
- </p>
-
- <li> <p>
- A very detailed report on
- <a href="reports/nedelec/nedelec.pdf"
- target="body">Nedelec elements</a> (by Anna
- Schneebeli, University of Basel, Switzerland). It
- explains the construction and application of Nedelec
- edge elements for H-curl spaces, as used, for example,
- in the numerical solution of the Maxwell equations. It
- also gives numerical results obtained with deal.II.
- There is also a <a href="reports/nedelec/nedelec.ps"
- target="body">postscript version of the report</a>.
- </p>
-
- <li> <p>
- A report on the
- <a href="reports/codimension-one/desimone-heltai-manigrasso.pdf"
- target="body">codimension one</a> capabilities
- of the library (by Antonio DeSimone, Luca Heltai
- and Cataldo Manigrasso, SISSA, Trieste, Italy). It
- explains in detail how to use the
- library for the solution of problems defined on codimension
- one manifolds, such as, for example, Boundary Element Methods.
- </ul>
-
-
- <h3>Publications</h3>
-
- <p>
- A <a href="publications/index.html" target="body">list of
- publications</a> about and based on
- <acronym>deal.II</acronym> can be found on
- <a href="publications/index.html" target="body">this</a> page.
- </p>
-
-
- <h3>Copyright and License</h3>
-
- <p> <acronym>deal.II</acronym> is copyright of the
- <a href="authors.html" target="body">deal.II authors</a>.
- It is a joint effort of the current maintainers, Wolfgang
- Bangerth, Timo Heister, Guido Kanschat, and quite a number of
- contributors. <acronym>deal.II</acronym> is distributed under an
- <a href="http://www.opensource.org" target="_top">OpenSource</a>
- license. The full text of the license can be found in
- <a href="license.html"><tt>license.html</tt></a>.
- </p>
-
- <h3>Contact</h3>
-
- <p>We have a <a href="mail.html">discussion group</a> for discussion
- of issues of general interest to users and developers of
- <acronym>deal.II</acronym>.</p>
-
- <p>More specific questions may be sent to the authors
- immediately at the address <tt>firstName.lastname</tt><i> at
- </i> <tt>dealii.org</tt>.</p>
-
- <div class="right">
- <p>
- <a href="http://validator.w3.org/check?uri=referer"><img border="0"
- src="http://www.w3.org/Icons/valid-html401"
- alt="Valid HTML 4.01!" height="31" width="88"></a>
- </p>
- </div>
- </body>
+<body>
+
+<p>
+ <br />
+ <acronym>deal.II</acronym> comes with quite extensive online
+ documentation, which falls into several categories. They are
+ listed below.
+</p>
+
+<h2><a href="readme.html">ReadMe</a></h2>
+
+<p>
+ First, there is the <a href="readme.html" target="body">README</a> of
+ the library. It gives information on system requirements,
+ installation, and copyright.
+</p>
+
+
+<h2><a href="users/index.html" TARGET="_top">Users' Corner</a></h2>
+
+<p>
+ The <a href="users/index.html" TARGET="_top">Users' Corner</a> provides information about
+ configuration and usage of the library.
+</p>
+
+<div class="quick">
+ <ol>
+ <li><a href="users/cmake.html" target="body">CMake documentation</a></li>
+ <li><a href="users/cmakelists.html" target="body">CMake in user projects</a></li>
+ <li><a href="doxygen/tutorial/index.html" target="_top">Tutorial</a></li>
+ <li><a href="doxygen/deal.II/index.html" target="_top">Manual</a></li>
+ </ol>
+</div>
+
+
+<h2><a href="developers/index.html" TARGET="_top">Developers' Corner</a></h2>
+
+<p>
+ The <a href="developers/index.html" TARGET="_top">Developers' Corner</a> covers
+ topics for advanced users and developers.
+</p>
+
+<div class="quick">
+ <ol>
+ <li><a href="developers/svn.html" target="body">SVN Archive</a></li>
+ <li><a href="developers/cmake-internals.html" target="body">CMake internals</a></li>
+ <li><a href="developers/writing-documentation.html" target="body">Writing documentation</a></li>
+ <li><a href="developers/porting.html" target="body">Porting</a></li>
+ <li><a href="doxygen/deal.II/CodingConventions.html" target="body">Coding conventions</a></li>
+ <li><a href="developers/testsuite.html" target="body">Testsuite</a></li>
+ </ol>
+</div>
+
+
+
+<h2><a href="reports/index.html" target="body">Reports</a></h2>
+
+<p>
+ There are a number of papers that describe the overall design or
+ individual aspects of <acronym>deal.II</acronym>. Please refer to the
+ papers listed at the top of the <a href="publications/index.html"
+ target="body">publications page</a> for full references. In addition,
+ <a href="reports/index.html" target="body">there are technical
+ reports</a>.
+
+<h2><a href="publications/index.html" target="body">Publications</a></h2>
+
+<p>
+ A <a href="publications/index.html" target="body">list of
+ publications</a> about and based on
+ <acronym>deal.II</acronym> can be found on
+ <a href="publications/index.html" target="body">this</a> page.
+</p>
+
+ <hr />
+ <address>
+ <a href="authors.html" target="body">The deal.II Authors</a>
+ $Date$
+ </address>
+ <div class="right">
+ <a href="http://validator.w3.org/check?uri=referer" target="_top">
+ <img style="border:0" src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
+ <a href="http://jigsaw.w3.org/css-validator/check/referer" target="_top">
+ <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
+ </div>
+
+</body>
</html>
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# A glob. I'm sorry
images
${CMAKE_CURRENT_BINARY_DIR}/options.dox
${_doxygen_input}
- COMMENT "Generating documentation via doxygen (This may take a _really_ long time)"
+ COMMENT "Generating documentation via doxygen. This may take a _really_ long time..."
VERBATIM
)
ADD_CUSTOM_TARGET(doxygen ALL
<script type="text/javascript" src="$relpath$jquery.js"></script>
<script type="text/javascript" src="$relpath$dynsections.js"></script>
- <link rel="SHORTCUT ICON" href="http://www.dealii.org/deal.ico">
+ <link rel="SHORTCUT ICON" href="http://www.dealii.org/favicon.ico">
<meta name="author" content="the deal.II authors <authors@dealii.org>">
- <meta name="copyright" content="Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors">
+ <meta name="copyright" content="Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors">
<meta name="deal.II-version" content="@DEAL_II_PACKAGE_VERSION@">
</head>
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
* @defgroup boundary Boundary description for triangulations
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 2007, 2008, 2011 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
* @page CodingConventions Coding conventions used throughout deal.II
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2012, 2013 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
* @defgroup constraints Constraints on degrees of freedom
* Constraints typically come from several sources, for example:
* - If you have Dirichlet-type boundary conditions, $u|_{\partial\Omega}=g$,
* one usually enforces
- * them by requiring that that degrees of freedom on the boundary have
+ * them by requiring that degrees of freedom on the boundary have
* particular values, for example $x_{12}=42$ if the boundary condition
* $g(\mathbf x)$ requires that the finite element solution $u(\mathbf x)$
* at the location of degree
* below. The resulting linear systems are equivalent to those one gets after
* calling the ConstraintMatrix::condense() functions.
*
+ * @note Both ways of applying constraints set the value of the matrix
+ * diagonals to constrained entries to a <i>positive</i> entry of the same
+ * magnitude as the other entries in the matrix. As a consequence, you need to
+ * set up your problem such that the weak form describing the main matrix
+ * contribution is not <i>negative definite</i>. Otherwise, iterative solvers
+ * such as CG will break down or be considerably slower as GMRES.
+ *
* @note While these two ways are <i>equivalent</i>, i.e., the solution of
* linear systems computed via either approach is the same, the linear
* systems themselves do not necessarily have the same matrix and right
* as a result of the way in which we compute them; they are, however, always
* chosen in such a way that the solution to the linear system is the same.
*
- *
* <h4>Condensing matrices and sparsity patterns</h4>
*
* As mentioned above, the first way of using constraints is to build linear
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
* @defgroup distributed Parallel computing with multiple processors using distributed memory
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2005, 2006, 2010, 2011 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
* @defgroup dofs Degrees of Freedom
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2005, 2006 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
* @defgroup Exceptions Exceptions and assertions
* do_something ();
* }
* catch (exception &e) {
- * std::cerr << "Exception occured:" << std::endl
+ * std::cerr << "Exception occurred:" << std::endl
* << e.what ()
* << std::endl;
* do_something_to_reciver ();
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2005, 2006, 2007, 2008, 2011 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
* @defgroup feall Finite elements
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
* @defgroup functions Functions
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
@defgroup geodynamics The geodynamics demonstration suite
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2007 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
* @defgroup geomprimitives Geometric and other primitives
-//-------------------------------------------------------------------------
-// $Id: coding_conventions.h 29312 2013-04-17 13:00:07Z turcksin $
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2013 by the deal.II authors
+// Copyright (C) 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
* @page GlobalDoFIndex When to use types::global_dof_index instead of unsigned int
* can solve now, there is no reason for the number of non-zero entries in a
* sparse matrix to go over four billions. Thus, we still use unsigned int
* for, e.g., row_lengths in the object.
+ * </dd>
*
- *
+ * </dl>
*/
-
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 2005 - 2013 by the deal.II authors
//
-// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// This file is part of the deal.II library.
//
-// 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.
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
//
-//-------------------------------------------------------------------------
+// ---------------------------------------------------------------------
+
/**
* @page DEALGlossary Glossary
* faces and edges. In this case, the boundary object associated with a particular
* boundary indicator is also used to move the new center points of cells back
* onto the manifold that the triangulation describes whenever a cell is refined.
+ *
+ * @note For parallel triangulations of type parallel::distributed::Triangulation,
+ * it is not enough to set boundary indicators only once at the beginning. See
+ * the long discussion on this topic in the class documentation of
+ * parallel::distributed::Triangulation .
* </dd>
*
* @see @ref boundary "The module on boundaries"
* to adding elements or setting them. In some cases, not all processors may
* be adding elements, for example if a processor does not own any cells when
* using a very coarse (initial) mesh. For this reason, compress() takes an
- * argument of type VectorOperation, which can be either ::add, or ::insert.
+ * argument of type VectorOperation, which can be either ::%add, or ::%insert.
* This argument is required for vectors and matrices starting with the 7.3
* release.
*
* is pointing the other direction. There are not very many places in
* application programs where you need this information actually, but
* a few places in the library make use of this. Note that in 2d, the
- * result is always @p true.
+ * result is always @p true. However, while every face in 2d is always
+ * in standard orientation, you can sometimes specify something to
+ * assume that this is not so; an example is the function
+ * DoFTools::make_periodicity_constraints().
*
* There are two other flags that describe the orientation of a face:
* face_flip and face_rotation. Some documentation for these
* // in 3d
* for (cell=dof_handler.begin_active();
* cell!=dof_handler.end(); ++cell)
- * for (unsigned int line=0; line<GeometryInfo<dim>::lines_per_cell; ++l)
+ * for (unsigned int l=0; l<GeometryInfo<dim>::lines_per_cell; ++l)
* if (cell->line(l)->at_boundary())
* {
* do something with this line
* @code
* for (cell=dof_handler.begin_active();
* cell!=dof_handler.end(); ++cell)
- * for (unsigned int line=0; line<GeometryInfo<dim>::lines_per_cell; ++l)
+ * for (unsigned int l=0; l<GeometryInfo<dim>::lines_per_cell; ++l)
* if (cell->line(l)->at_boundary())
* {
* cell->line(l)->set_user_index(42);
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2005, 2006, 2007 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
* @defgroup grid Grid classes
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2005, 2006, 2007, 2011 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
* @defgroup hp hp finite element support
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2007 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
* @page Instantiations Template instantiations
*
* @subsection Inst2p Provided instances
*
- * Like with the classes in section Inst1, the instances provided in the
+ * Like with the classes in section @ref Inst1, the instances provided in the
* library are often listed in the documentation of that class in a form
* similar to this:
@verbatim
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
* @defgroup Integrators Integrators
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2010 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
* @defgroup IO Input/Output
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
@defgroup Iterators Iterators on mesh-like containers
@{
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2006 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2007, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
* @mainpage
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2006, 2007, 2010, 2012 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
* @defgroup memory Memory handling
-//-------------------------------------------------------------------------
-// $Id: lac.h 12034 2006-01-15 21:16:14Z wolf $
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2005, 2006, 2009, 2010 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
* @defgroup mg Multilevel support
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
* @defgroup threads Parallel computing with multiple processors accessing shared memory
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
* This is the namespace in which everything in deal.II is. To avoid prefixing
* every class and function call with the namespace name, the @ref Tutorial
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
* @defgroup numerics Numerical algorithms
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2012 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
* @defgroup Parallel Parallel computing
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2006, 2010 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
* @defgroup Polynomials Polynomials and polynomial spaces
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2006, 2007, 2009, 2010 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2007 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
* @defgroup Quadrature Quadrature formulas
-//-------------------------------------------------------------------------
-// $Id: slepc.h 22855 2011-01-01 15:01:47Z young $
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2011 by the deal.II authors
+// Copyright (C) 2011 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2006, 2007 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
* @defgroup Solvers Linear solver classes
*
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
* A namespace that contains a selection of classes and functions that will be part of the
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2010 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2007 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
* @page Tutorial Tutorial programs
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2007, 2012 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
* @defgroup utilities Utility functions and classes
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2006, 2008 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2011, 2012 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
-
(q, \mathrm{div}\ \mathbf u)
=
- (q,f) + (\mathbf n\cdot\mathbf v, p)_{\partial\Omega}.
+ (q,f) - (\mathbf n\cdot\mathbf v, p)_{\partial\Omega}.
@f}
*
* It is this form that we will later use in assembling the discrete weak form
fe_values[velocities].divergence (j, q)) *
fe_values.JxW(q);
- local_rhs(i) += - fe_values[pressure].value (i, q)
- rhs_values[q] *
- fe_values.JxW(q);
+ local_rhs(i) += fe_values[pressure].value (i, q)
+ rhs_values[q] *
+ fe_values.JxW(q);
}
* @endcode
*
* extractor. For example, <code>fe_values[pressure].gradient(i,q)</code>
* would represent the gradient of the scalar pressure component, which
* is of type <code>Tensor@<1,dim@></code>, whereas the gradient of the
- * velocities components, <code>fe_values[velocities].value(i,q)</code>
+ * velocities components, <code>fe_values[velocities].gradient(i,q)</code>
* is a <code>Tensor@<2,dim@></code>, i.e. a matrix $G_{ij}$ that consits
* of entries $G_{ij}=\frac{\partial\phi_i}{\partial x_j}$. Finally,
* both scalar and vector views can be asked for the second derivatives
\right)_\Omega,
@f}
* where $\varepsilon(\mathbf u) = \frac 12 \left([\nabla\mathbf u] +
- * [\nabla\mathbf u]^2\right)$ is the symmetrized gradient.
+ * [\nabla\mathbf u]^T\right)$ is the symmetrized gradient.
* In the second to last step, we used that the scalar product between
* an arbitrary tensor $\nabla\mathbf u$ and a symmetric tensor
* $\frac 12[\partial_i v_j + \partial_j v_i]$ equals the scalar product
-//-------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2006 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//-------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
/**
* @defgroup Vectors Vector classes
+## ---------------------------------------------------------------------
+## $Id$
+##
+## Copyright (C) 2013 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
ADD_CUSTOM_COMMAND(
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/structure.png
# directories that contain example code fragments that are included (see
# the \include command).
-EXAMPLE_PATH = @CMAKE_BINARY_DIR@/doc/doxygen/tutorial
+EXAMPLE_PATH = @CMAKE_BINARY_DIR@/doc/doxygen/tutorial \
+ @CMAKE_SOURCE_DIR@/examples/doxygen
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
DEAL_II_WITH_ARPACK=1 \
DEAL_II_WITH_METIS=1 \
DEAL_II_WITH_MUMPS=1 \
- DEAL_II_WITH_P4EST=1
+ DEAL_II_WITH_P4EST=1 \
+ DEAL_II_WITH_MPI=1
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
# this tag can be used to specify a list of macro names that should be expanded.
-#---------------------------------------------------------------------------
-# $Id: create_anchors 14782 2007-06-15 16:37:12Z kanschat $
-# Version: $Name$
-#
-# Copyright (C) 2007, 2012 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.
-#
-#---------------------------------------------------------------------------
+## ---------------------------------------------------------------------
+## $Id$
+##
+## Copyright (C) 2007 - 2013 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
# If we find a heading in a .dox file, create an HTML anchor for it.
-#---------------------------------------------------------------------------
-# $Id: intro2toc 14782 2007-06-15 16:37:12Z kanschat $
-# Version: $Name$
-#
-# Copyright (C) 2006, 2007, 2008 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.
-#
-#---------------------------------------------------------------------------
+## ---------------------------------------------------------------------
+## $Id$
+##
+## Copyright (C) 2006 - 2013 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
print " <ul>\n";
-#---------------------------------------------------------------------------
-# $Id$
-# Version: $Name$
-#
-# Copyright (C) 2013 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.
-#
-#---------------------------------------------------------------------------
+## ---------------------------------------------------------------------
+## $Id$
+##
+## Copyright (C) 2013 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
if ($#ARGV != 1) {
print "\nUsage: make_step.pl step cmake_source_dir\n";
-#---------------------------------------------------------------------------
-# $Id$
-# Version: $Name$
-#
-# Copyright (C) 2006, 2007, 2010, 2013 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.
-#
-#---------------------------------------------------------------------------
-
+## ---------------------------------------------------------------------
+## $Id$
+##
+## Copyright (C) 2006 - 2013 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
print " * <a name=\"CommProg\"></a>\n";
-#---------------------------------------------------------------------------
-# $Id$
-# Version: $Name$
-#
-# Copyright (C) 2006, 2007 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.
-#
-#---------------------------------------------------------------------------
+## ---------------------------------------------------------------------
+## $Id$
+##
+## Copyright (C) 2006 - 2013 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
print "\n";
-#---------------------------------------------------------------------------
-# $Id$
-# Version: $Name$
-#
-# Copyright (C) 2006, 2007, 2010 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.
-#
-#---------------------------------------------------------------------------
+## ---------------------------------------------------------------------
+## $Id$
+##
+## Copyright (C) 2006 - 2013 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
print "<a name=\"CommProg\"></a>\n";
print "<h1> The commented program</h1>\n";
-#---------------------------------------------------------------------------
-# $Id$
-# Version: $Name$
-#
-# Copyright (C) 2010, 2011 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.
-#
-#---------------------------------------------------------------------------
+## ---------------------------------------------------------------------
+## $Id$
+##
+## Copyright (C) 2010 - 2013 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
# Remove all comments from the source file
-#---------------------------------------------------------------------------
-# $Id$
-# Version: $Name$
-#
-# Copyright (C) 2006, 2007 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.
-#
-#---------------------------------------------------------------------------
+## ---------------------------------------------------------------------
+## $Id$
+##
+## Copyright (C) 2006 - 2013 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
print " <ul>\n";
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
<title>The deal.II Readme on interfacing to ARPACK</title>
<link href="../screen.css" rel="StyleSheet">
<meta name="author" content="the deal.II authors <authors @ dealii.org>">
- <meta name="copyright" content="Copyright (C) 2010 by the deal.II authors">
- <meta name="date" content="$Date: 2010-05-05 (Thu, 05 May 2010) $">
+ <meta name="copyright" content="Copyright (C) 2010, 2013 by the deal.II authors">
+ <meta name="date" content="$Date$">
<meta name="svn_id" content="$Id: readme-arpack.html$">
<meta name="keywords" content="deal.II">
</head>
<hr>
<address>
- <a href="mail.html">The deal.II Group</a>
+ <a href="../mail.html">The deal.II Group</a>
$Date$
</address>
</body>
<html>
<head>
- <title>The deal.II Readme on interfacing to PETSc and Trilinos</title>
- <link href="screen.css" rel="StyleSheet">
+ <title>The deal.II Readme on interfacing to MUMPS</title>
+ <link href="../screen.css" rel="StyleSheet">
<meta name="author" content="the deal.II authors <authors @ dealii.org>">
<meta name="copyright" content="Copyright (C) 2010, 2011, 2012, 2013 by the deal.II authors">
- <meta name="date" content="$Date: 2010-05-05 (Thu, 05 May 2010) $">
+ <meta name="date" content="$Date$">
<meta name="svn_id" content="$Id: readme-mumps.html$">
<meta name="keywords" content="deal.II">
</head>
<p>
You can override the autodetection by manually specifying
<pre>
+
-DDEAL_II_WITH_MUMPS=OFF|ON
</pre>.
</p>
<hr>
<address>
- <a href="mail.html">The deal.II Group</a>
+ <a href="../mail.html">The deal.II Group</a>
$Date$
</address>
</body>
"http://www.w3.org/TR/REC-html40/frameset.dtd">
<html>
<head>
- <link href="../screen.css" rel="StyleSheet" media="screen">
- <title>The deal.II Readme</title>
+ <title>The deal.II Readme on interfacing to p4est</title>
+ <link href="../screen.css" rel="StyleSheet">
<meta name="author" content="the deal.II authors <authors@dealii.org>">
<meta name="keywords" content="deal.II">
</head>
<p>
You need to install p4est before deal.II. To do so, you can
- download it
- from <a href="http://www.p4est.org/" target="_top">here</a>, copy it to
- a fresh directory into which you should also copy
- the <a href="p4est-setup.sh">p4est-setup.sh script</a> (the one
- from this link, not one you may have gotten from the p4est webpage). Then
- call the script as follows:
- <code>
- <pre>
- ./p4est-setup.sh p4est-x-y-z.tar.gz /path/to/installation
- </pre>
- </code>
+ download it from <a href="http://www.p4est.org/" target="_top">here</a>.
+ You can either choose to manually compile and install p4est (as
+ explained in documentation of p4est), or alternatively use
+ <a href="p4est-setup.sh">a script</a> that will automatically compile
+ and install a debug and optimized version of p4est.
+
+ </p>
+
+ <p>
+ If you want to use the script, copy the tarball to a fresh directory
+ together with the <a href="p4est-setup.sh">p4est-setup.sh script</a>
+ (the one from this link, not one you may have gotten from the p4est
+ webpage). Then call the script as follows:
+ <pre>
+
+ ./p4est-setup.sh p4est-x-y-z.tar.gz /path/to/installation
+ </pre>
where <code>p4est-x-y-z.tar.gz</code> is the name of the p4est
distribution file, and <code>/path/to/installation</code> is a
directory into which you want to install p4est.
</p>
<p>
- After this, you need to configure <acronym>deal.II</acronym>
- using a line like
- <code>
- <pre>
+ In both cases, you can configure <acronym>deal.II</acronym> using a
+ line like
+ <pre>
cmake -DP4EST_DIR=/path/to/installation -DDEAL_II_WITH_P4EST=ON -DDEAL_II_WITH_MPI=ON <...>
- </pre>
- </code>
- Obviously, you can also add additional flags to
- <code>cmake</code> as described in the general <a
- href="../readme.html">ReadMe file</a>.
+ </pre>
+ if the p4est library isn't picked up automatically. Note the presence
+ of <code>/FAST</code> at the end of the path necessary when using
+ the <code>./p4est-setup.sh</code> script to select the release
+ version of p4est. Obviously, you
+ can also add additional flags to <code>cmake</code> as described in
+ the general <a href="../readme.html">ReadMe file</a>.
</p>
<hr>
<address>
- <a href="mail.html">The deal.II Group</a>
+ <a href="../mail.html">The deal.II Group</a>
$Date$
</address>
</body>
<h4>Installing <acronym>deal.II</acronym> with PETSc</h4>
- <p>
- For a general overview of building <acronym>deal.II</acronym> with
- PETSc, first see the <a href="../readme.html">ReadMe file</a>.
+ <p style="color: red"><b>Note:</b> The latest version of PETSc tested is
+ 3.4.2. Major releases after this version may cause problems, so we
+ recommend sticking to this version if at all possible.
</p>
<p>
during configuration.
</p>
- <p>
- <b>Note:</b> PETSc appears not to co-operate
- well when using threads and some programs crash when deal.II is
- compiled in its usual mode supporting multithreading. If you see
- this sort of behavior, disable
- multithreading upon configuration of <acronym>deal.II</acronym>
- using the <code>-DDEAL_II_WITH_THREADS=OFF</code> switch for
- <code>cmake</code>.
- </p>
-
<p><b>Note:</b> <acronym>deal.II</acronym> can be installed with both
PETSc and Trilinos and they do not usually get in their
respective ways. There are, however, occasions where this is not true
cd petsc-x-y-z
export PETSC_DIR=`pwd`
export PETSC_ARCH=x86_64 # or any other identifying text for your machine
- export LD_LIBRARY_PATH=$PETSC_DIR/$PETSC_ARCH/lib:$LD_LIBRARY_PATH
./config/configure.py --with-shared=1 --with-x=0 --with-mpi=1 --download-hypre=1
make
</pre>
<p>
This automatically builds PETSc with both MPI and the algebraic
- multigrid preconditioner package Hypre (which we use in step-40).
+ multigrid preconditioner package Hypre (which we use in step-40).
<br>
Now let PETSc check his own sanity:
<pre>
export SLEPC_DIR=/path/to/slepc-x-y-z
</pre>
+ The <code>cmake</code> installation should then be able to pick
+ up where you installed SLEPc and include it automatically in the
+ deal.II build without any further need for instructions. You
+ will see at the bottom of the <code>cmake</code> output if that
+ is what actually happened.
</p>
+
+
+
<hr>
<!-- TODO: <h4>Using the ARPACK solvers with SLEPc</4> -->
<h5>Installing Trilinos</h5>
<p style="color: red">
- Note: Trilinos versions 10.8.0, 10.8.1, 10.10.2, 10.12.1 are not
- compatible with deal.II. They contain subtle bugs related to (parallel)
- matrices and vectors. Versions tested to work are 10.8.5,
- 10.12.2, and 11.0.3. We recommend only using one of the tested versions
- for the time being.
+ Note: Trilinos versions older than 10.12.2 can cause problems and are
+ therefore not recommended. The newest version tested to work is 11.4.1.
+ Major releases after this version may cause problems, so we recommend
+ sticking to this version if at all possible.
</p>
<p>
reasonable configuration:
<pre>
- cd trilinos-10.12.2
+ cd trilinos-11.4.1
mkdir build
cd build
- cmake -D Trilinos_ENABLE_OPTIONAL_PACKAGES:BOOL=ON \
- -D Trilinos_ENABLE_Sacado:BOOL=ON \
- -D Trilinos_ENABLE_Stratimikos:BOOL=ON \
- -D CMAKE_BUILD_TYPE:STRING=RELEASE \
- -D CMAKE_CXX_FLAGS:STRING="-g -O3" \
- -D CMAKE_C_FLAGS:STRING="-g -O3" \
- -D CMAKE_FORTRAN_FLAGS:STRING="-g -O5" \
- -D Trilinos_EXTRA_LINK_FLAGS:STRING="-lgfortran" \
- -D CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE \
- -D Trilinos_VERBOSE_CONFIGURE:BOOL=FALSE \
- -D TPL_ENABLE_MPI:BOOL=ON \
- -D BUILD_SHARED_LIBS:BOOL=ON \
- -D CMAKE_INSTALL_PREFIX:PATH=$HOME/share/trilinos ..
-
- make
+ cmake -D Trilinos_ENABLE_Sacado=ON \
+ -D Trilinos_ENABLE_Stratimikos=ON \
+ -D CMAKE_BUILD_TYPE=RELEASE \
+ -D CMAKE_CXX_FLAGS="-g -O3" \
+ -D CMAKE_C_FLAGS="-g -O3" \
+ -D CMAKE_FORTRAN_FLAGS="-g -O5" \
+ -D Trilinos_EXTRA_LINK_FLAGS="-lgfortran" \
+ -D CMAKE_VERBOSE_MAKEFILE=FALSE \
+ -D Trilinos_VERBOSE_CONFIGURE=FALSE \
+ -D TPL_ENABLE_MPI=ON \
+ -D BUILD_SHARED_LIBS=ON \
+ -D CMAKE_INSTALL_PREFIX:PATH=$HOME/share/trilinos \
+ ..
+
make install
</pre>
You will need to adjust the path into which you want to install Trilinos
- in the second to last line of the cmake command.
- </p>
-
- <p>
- <b>Using MPI:</b> If you
- want to use Trilinos with MPI on parallel machines,
- use <code>TPL_ENABLE_MPI=ON</code> instead.
+ in the CMAKE_INSTALL_PREFIX line.
</p>
<p>
<b>Parallel builds:</b>
If your computer has more than one processor core, use
- <code>make -jN</code> instead of <code>make</code> in the last two lines
+ <code>make -jN</code> instead of <code>make</code> in the last line
above, where <code>N</code> is the number of processors you have.
</p>
<frameset rows="70,*">
<frame name="title" src="title.html" frameborder="1">
- <frameset cols="120,*">
+ <frameset cols="150,*">
<frame name="navbar" src="navbar.html" frameborder="0">
<frame name="body" src="documentation.html" frameborder="0">
</frameset>
In this document, as well as in the program files, the terms
<i>authors of <acronym>deal.II</acronym></i> and
<i><acronym>deal.II</acronym> authors</i> generally refer to all
- people mentioned at the <a href="authors.html">deal.II Credits</a>
+ people mentioned at the <a href="authors.html">deal.II Authors</a>
page.
These are the maintainers Wolfgang Bangerth, Timo Heister, and Guido
Kanschat and a <i>long</i> list of contributors.
</p>
- <h3>Contributions</h3>
+ <h2>Contributions</h2>
<p>
<b>As a contributor to this project, you agree that any of your
</p>
- <h3>Referencing the library</h3>
+ <h2>Referencing the library</h2>
<p>
In addition to the terms imposed by the LGPL v2.1 or later, we ask
</p>
- <a name="3rdparty">
- <h3>Parts of the deal.II distribution under a separate license</h3>
- </a>
+ <a name="3rdparty"></a>
+ <h2>Parts of the deal.II distribution under a separate license</h2>
<p>
<acronym>deal.II</acronym> comes bundled with copies of
<p>
- <h3>Contact</h3>
+ <h2>Contact</h2>
<p>
For further questions regarding licensing and commercial use please
contact the deal.II maintainers directly via one of the following mail
addresses:
<ul>
- <li>
- TODO
- </li>
<li>
Wolfgang Bangerth < bangerth@gmail.com >
</li>
<li>
- Timo Heister < heister@math.tamu.edu >
+ Timo Heister < heister@clemson.edu >
</li>
<li>
Guido Kanschat < dr.guido.kanschat@gmail.com >
</p>
- <h3>Full license text</h3>
+ <a name="license-text"></a>
+ <h2>Full license text</h2>
<pre>
That's all there is to it!
</pre>
- <hr>
-
+ <hr />
<address>
- The deal.II authors
+ <a href="authors.html" target="body">The deal.II Authors</a>
+ $Date$
</address>
-
<div class="right">
- <p>
- <a href="http://validator.w3.org/check?uri=referer"><img border="0"
- src="http://www.w3.org/Icons/valid-html401"
- alt="Valid HTML 4.01!" height="31" width="88"></a>
- </p>
+ <a href="http://validator.w3.org/check?uri=referer" target="_top">
+ <img style="border:0" src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
+ <a href="http://jigsaw.w3.org/css-validator/check/referer" target="_top">
+ <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
</div>
+
</body>
</html>
--- /dev/null
+#!/bin/perl
+
+my $header=1;
+
+print << 'EOT'
+//----------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1998 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+//----------------------------------------------------------------------
+EOT
+ ;
+
+while(<>)
+{
+ $header=0 unless m/\/\//;
+ next if $header;
+ print;
+}
-//----------------------------------------------------------------------
+// ---------------------------------------------------------------------
// $Id$
//
-// Copyright (C) 1998 - 2013 by the deal.II authors
+// Copyright (C) @YEAR@ by the deal.II authors
//
// This file is part of the deal.II library.
//
// The full text of the license can be found in the file LICENSE at
// the top level of the deal.II distribution.
//
-//----------------------------------------------------------------------
+// ---------------------------------------------------------------------
+
--- /dev/null
+## ---------------------------------------------------------------------
+## $Id$
+##
+## Copyright (C) 2013 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
--- /dev/null
+#!/bin/bash
+
+FILE=$1
+
+FIRST_YEAR=$(grep Copyright $FILE | perl -pi -e 's/.*?(\d{4}).*/\1/')
+if [ "$FIRST_YEAR" = "2013" ] || (! [[ "$FIRST_YEAR" =~ "^[0-9]+$" ]])
+then
+ YEAR="2013"
+else if
+ YEAR="$FIRST_YEAR - 2013"
+fi
+
+sed -e "s/@YEAR@/$YEAR/" doc/license/header-template > /tmp/foobar22.temp
+
+header_lines=1
+on_whitespace=true
+whitespace_detected=false
+while read line
+do
+ if $on_whitespace && [[ $line =~ "^$" ]]
+ then
+ whitespace_detected=true
+ header_lines=$[$header_lines+1]
+ continue
+ else
+ on_whitespace=false
+ fi
+
+ if ! [[ $line =~ "^//.*$" ]]
+ then
+ break
+ else
+ header_lines=$[$header_lines+1]
+ fi
+done < $FILE
+
+if $whitespace_detected
+then
+ echo "$FILE --> whitespace"
+ echo "$FILE --> $header_lines"
+else
+ if [ $header_lines -lt 10 ]
+ then
+ echo "$FILE --> $header_lines"
+ fi
+fi
+
+tail -n+$header_lines $FILE >> /tmp/foobar22.temp
+
+cp /tmp/foobar22.temp $FILE
+
<h2>
Authors
</h2>
+ <p>
Everything you consider a personal matter between you and the authors (like
- flaming them on missing items) should be sent to one of
+ flaming them on missing items) should be sent to one of the maintainers
<ul>
- <li>
- TODO
- </li>
<li>
Wolfgang Bangerth < bangerth@gmail.com >
</li>
<li>
- Timo Heister < heister@math.tamu.edu >
+ Timo Heister < heister@clemson.edu >
</li>
<li>
Guido Kanschat < dr.guido.kanschat@gmail.com >
</ul>
Everything, that is not directly related to the library is to be considered
personal in this respect! <br>
+ </p>
- <hr>
+ <hr />
<address>
- <a href="mail.html" target="body">The deal.II Group</a>
+ <a href="authors.html" target="body">The deal.II Authors</a>
+ $Date$
</address>
<div class="right">
- <p>
- <a href="http://validator.w3.org/check?uri=referer"><img border="0"
- src="http://www.w3.org/Icons/valid-html401"
- alt="Valid HTML 4.01!" height="31" width="88"></a>
- </p>
+ <a href="http://validator.w3.org/check?uri=referer" target="_top">
+ <img style="border:0" src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
+ <a href="http://jigsaw.w3.org/css-validator/check/referer" target="_top">
+ <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
</div>
+
</body>
</html>
<body class="navbar">
<p>
+ <a href="http://www.dealii.org"target="_top">http://www.dealii.org</a><br />
<a href="index.html" target="_top">Home</a><br />
- <a href="http://www.dealii.org"target="_top">dealii.org</a><br />
+ </p>
+
+ <hr>
+
+ <p>
<a href="readme.html" target="body">README</a><br />
+ <a href="users/index.html" target="_top">Users' Corner</a><br />
+ <a href="developers/index.html" target="_top">Developers' Corner</a><br />
</p>
<hr>
+ <b><small>Doxygen and Lectures</small></b>
<p>
<a href="doxygen/tutorial/index.html" target="_top">Tutorial</a><br />
<a href="doxygen/deal.II/index.html" target="_top">Manual</a><br />
<hr>
+ <b><small>Online Resources</small></b>
<p>
<a href="https://code.google.com/p/dealii/wiki/FrequentlyAskedQuestions" target="_top">FAQ</a><br />
<a href="news/news.html" target="body">News</a><br />
<hr>
+ <b><small>Resources</small></b>
<p>
- <a href="development/index.html" target="_top">Development</a><br />
+ <a href="reports/index.html" target="body">Reports</a><br />
<a href="publications/index.html" target="body">Publications</a><br />
<a href="authors.html" target="body">Authors</a> <br />
- <a href="license.html" target="body">License</a>
+ <a href="license.html" target="body">License</a> <br />
+ <a href="mail.html" target="body">Contact</a>
</p>
- <!-- Last modified: 2006/02/07 22:49:06 -->
-
</body>
</html>
New: There is now some support to include and use routines from the
<a href="http://www.cse.clrc.ac.uk/Activity/HSL"
target="_top">Harwell Subroutine Library</a>.
- (See the <a href="../../readme.html#hsl" target="body">ReadMe</a>
- file for more information on installation of HSL
- subroutines.)
<br>
(WB 2001/01/30)
</p>
existence of a Fortran 77 compiler, and sets its path, some
compiler flags and the libraries to be linked in when mixing
C++ and F77 in some variables in the file
- <code>common/Make.global_options</code> (see also
- <a href="../../development/makefiles.html" target="body">this
- page</a>).
+ <code>common/Make.global_options</code>.
<br>
(WB 2000/12/30)
</p>
<code class="class">SparseDirectMA27</code> and
<code class="class">SparseDirectMA47</code>
for the sparse direct solvers MA27 and MA47.
- (See the <a href="../../readme.html#hsl" target="body">ReadMe</a>
- file for more information on installation of HSL
- subroutines.)
<br>
(WB 2001/01/30)
</p>
<br>
As a consequence, if your makefile makes any assumption on the
location of deal.II include files or the name of the deal.II library
- it will need to be changed. The <a
- href="../../development/makefiles.html">sample Makefiles</a> have been
+ it will need to be changed. The sample Makefiles have been
updated for this.
<br>
(WB 2010/10/25)
<li> New: Restructured the internals of <code>PETScWrappers::Precondition*</code>
to allow a PETSc PC object to exist without a solver. New: Use
-<code>Precondition*::vmult()</code> to apply the preconditioner once.
+<code>Precondition*::%vmult()</code> to apply the preconditioner once.
Preconditioners now have a default constructor and an <code>initialize()</code>
function and are no longer initialized in the solver call,
but in the constructor or <code>initialize()</code>.
<br>
(Timo Heister, 2013/02/19)
-<li> New: PETScWrappers::*Matrix::add(other, factor) to
+<li> New: PETScWrappers::*Matrix::%add(other, factor) to
add a scaled other matrix to the current matrix.
<br>
(Jose Javier Munoz Criollo, 2013/02/19)
--- /dev/null
+/**
+ * @page changes_between_7_3_and_8_0 Changes between Version 7.3 and 8.0
+
+<p>
+This is the list of changes made between the release of
+deal.II version 7.3.0 and that of 8.0.0.
+All entries are signed with the names of the authors.
+</p>
+
+
+
+<!-- ----------- INCOMPATIBILITIES ----------------- -->
+
+<a name="incompatible"></a>
+<h3 style="color:red">Incompatibilities</h3>
+
+<p style="color:red">
+Following are a few modifications to the library that unfortunately
+are incompatible with previous versions of the library, but which we
+deem necessary for the future maintainability of the
+library. Unfortunately, some of these changes will require
+modifications to application programs. We apologize for the
+inconvenience this causes.
+</p>
+
+<ol>
+
+<li> Removed: it was possible to call get_dof_indices(), get_dof_values(),
+set_dof_values(), and distribute_local_to_global() for cells that were not
+active, if the finite element only had DoFs on vertices (i.e. Q1). This is
+no longer allowed.
+<br>
+(Timo Heister, 2013/06/02)
+
+<li> Changed: Internal structures of ExceptionBase are now thread safe. The
+Assert macro does not print an exception to deallog any more prior to
+throwing if deal_II_exceptions::abort_on_exception==false. Removed: A
+number of obsolete Exceptions that are not used in the library any more.
+<br>
+(Matthias Maier, 2013/04/16)
+
+<li> Removed: A number of header files that have been deprecated a long time
+ago have been removed. All of them had previously only included the header file
+that had superseded them. To upgrade, simply include the currently used
+header file. This is also backward compatible with deal.II 7.3.
+<br>
+(Guido Kanschat, 2013/04/12)
+
+<li> Removed: The interfaces to the obsolete direct solvers MA27 and MA47 from
+the Harwell Subroutine Library. Support for the HSL routines were not ported to
+the new build system. However, the sparse direct solver UMFPACK remains to be
+supported and is provided as part of the standard deal.II distribution, unlike
+the HSL functions.
+<br>
+(Matthias Maier, 2013/04/01)
+
+<li> Changed: The TimeDependent::end_sweep function with an argument indicating
+the number of threads has been removed. Use the corresponding function without
+an argument. Since the argument had a default value, few users will have used
+this function.
+<br>
+(Wolfgang Bangerth, 2013/03/17)
+
+</ol>
+
+
+<!-- ----------- GENERAL IMPROVEMENTS ----------------- -->
+
+<a name="general"></a>
+<h3>General</h3>
+
+
+<ol>
+ <li> Improvements on the CMake build system: A Working C (or Fortran) compiler
+ is now fully optional; Improved support for static linkage with a toggle
+ "DEAL_II_PREFER_STATIC_LIBS" that will prefer static archives for non system
+ libraries and "DEAL_II_STATIC_EXECUTABLE" that will switch the complete link
+ interface to static linkage.
+ <br>
+ (Matthias Maier, 2013/07/16)
+ </li>
+
+ <li> New: various functions for parallel computations got introduced to
+ make Trilinos and PETSc interfaces similar. Now step-40 can be used with
+ PETSc or Trilinos with just a few changes. This patch also introduces
+ better support for block systems in the PETSc interfaces.
+ <br>
+ (Timo Heister, 2013/07/15)
+ </li>
+
+ <li> New: deal.II can now be compiled to 64-bit global dof indices. To turn
+ this feature on, use the cmake option -DDEAL_II_WITH_64BIT_INDICES=ON. If
+ PETSc and/or Trilinos are used, they must be compiled to support 64-bit
+ indices. To write a code that can use 32-bit and 64-bit indices depending on
+ deal.II compilation option, use types::global_dof_index for all the global
+ dof indices.
+ <br>
+ (Kainan Wang and Bruno Turcksin, 2013/06/05)
+ </li>
+
+ <li> New: All vector classes now have a member function
+ <code>locally_owned_elements</code> that returns an index
+ set indicating which elements of this vector the current
+ processor owns.
+ <br>
+ (Wolfgang Bangerth, 2013/05/24)
+ </li>
+
+
+ <li> New: A new element FE_Q_iso_Q1 has been implemented that is defined by
+ a subdivision of the element into smaller Q1 elements. An element of order
+ @p p is similar to FE_Q of degree @p p with the same numbering of degrees of
+ freedom. The element is useful e.g. for defining a sparser preconditioner
+ matrix for AMG at higher order FE_Q elements or for representing a component
+ of a system of PDEs where higher resolution is preferred over high order.
+ <br>
+ (Martin Kronbichler, 2013/05/14)
+ </li>
+
+ <li> New: The step-49 tutorial program now also has a discussion on
+ what to do once you have a coarse mesh and want to refine it.
+ <br>
+ (Wolfgang Bangerth, 2013/04/03)
+ </li>
+
+ <li> New: The number of threads used by deal.II/TBB can now be limited at
+ run time. Using MPI based code using PETSc/Trilinos no longer requires you
+ to compile the library without threads. See MPI_InitFinalize and
+ MultithreadInfo::set_thread_limit for details.
+ <br>
+ (Timo Heister, 2013/03/26)
+ </li>
+
+ <li> New: The results section of step-36 now explains how to use ARPACK
+ as an alternative to SLEPc as eigenvalue solver.
+ <br>
+ (Juan Carlos Araujo Cabarcas, 2013/03/25)
+ </li>
+
+ <li> New: deal.II now uses <a href="http://www.cmake.org/">CMake</a>
+ as its configuration and build tool. Please read through the
+ readme and other installation files for information about how the
+ installation process has changed.
+ <br>
+ Because this touches the configuration of every external package we
+ interact with, there are a number of other changes as a result:
+ <ul>
+ <li>The minimum supported version for Trilinos is now 10.8.x.
+ <li>We no longer link with different versions of the p4est library
+ in debug and optimized mode. Rather, we now link with the same
+ library in both modes. The p4est installation instructions have
+ been updated.
+ </ul>
+ <br>
+ (Matthias Maier, 2013/03/07)
+ </li>
+</ol>
+
+
+<!-- ----------- SPECIFIC IMPROVEMENTS ----------------- -->
+
+<a name="specific"></a>
+<h3>Specific improvements</h3>
+
+<ol>
+
+<li>New: VectorTools::project and a whole host of similar functions
+are now also available for objects of type hp::DoFHandler.
+<br>
+(Wolfgang Bangerth, 2013/07/21)
+</li>
+
+<li>Fixed: hp::DoFHandler::n_boundary_dofs() had a bug that always led
+to a failed assertion. This is now fixed.
+<br>
+(Wolfgang Bangerth, 2013/07/21)
+</li>
+
+<li>Fixed: VectorTools::project has an option to first project onto the
+boundary. However, the implementation of this option ignored the mapping
+that is provided to the function. This is now fixed.
+<br>
+(Wolfgang Bangerth, 2013/07/16)
+</li>
+
+<li>Improved: The WorkStream class used throughout deal.II is now using
+thread local variables and initializes temporary variables on the thread
+that uses them, leading to better cache locality.
+<br>
+(Wolfgang Bangerth, 2013/07/16)
+</li>
+
+<li>Improved: The "pure" functions in MeshWorker::LocalIntegrator are now implemented and throw
+an exception if not overloaded.
+<br>
+(Guido Kanschat, 2013/07/16)
+</li>
+
+<li> New: The function SparseDirectUMFPACK::Tvmult is now implemented.
+<br>
+(Matthias Maier, 2013/07/03)
+</li>
+
+<li> New: In addition to the FEValuesExtractors::Scalar,
+FEValuesExtractors::Vector, and FEValuesExtractors::SymmetricTensor classes,
+there are now also fully featured FEValuesExtractors::Tensor extractors
+for non-symmetric tensors of rank 2.
+<br>
+(Denis Davydov, 2013/07/02)
+</li>
+
+<li> New: There are now functions Tensor::component_to_unrolled_index()
+and Tensor::unrolled_to_component_indices() in the same way as they
+already exist for the SymmetricTensor class.
+<br>
+(Denis Davydov, 2013/07/02)
+</li>
+
+<li> New: There is now a read-write version of TableIndices::operator[].
+<br>
+(Denis Davydov, 2013/07/02)
+</li>
+
+<li> New: The function parallel::distributed::Triangulation::copy_triangulation() is
+now implemented.
+<br>
+(Martin Steigemann, 2013/07/02)
+</li>
+
+<li> New: TriaRawIterator::operator < (TriaRawIterator&) now implements a total ordering
+relation for cells even on distributed::parallel::Triangulation across processors.
+Additionally, TriaRawAccessor and CellAccessor now have an ordering relation.
+<br>
+(Guido Kanschat, 2013/06/24)
+</li>
+
+<li> New: CellAccessor::id() that returns a unique CellId that
+also works in parallel computations (where level and index is not
+useful).
+<br>
+(Timo Heister, 2013/06/24)
+</li>
+
+<li> New: added ConstantTensorFunction<rank, dim> and ZeroTensorFunction<rank, dim> to provide
+a tensor valued analogue to ConstantFunction and ZeroFunction.
+<br>
+(Matthias Maier, 2013/06/20)
+</li>
+
+<li> Fixed: BlockSparsityPattern::column_number was returning
+wrong values.
+<br>
+(Timo Heister, 2013/06/16)
+</li>
+
+<li> Fixed: The stabilization parameter for the artificial diffusion
+in the step-31 tutorial program has been increased slightly to avoid
+instabilities at later times (<i>t</i> > 60).
+<br>
+(Martin Kronbichler, 2013/06/04)
+</li>
+
+<li> Fixed: If an exception was generated on a task created by
+Threads::new_task, the program would terminate with a segmentation
+fault, leaving little trace of what had happened. This is now handled
+more gracefully.
+<br>
+(Wolfgang Bangerth, 2013/06/02)
+</li>
+
+<li> Changed: subdomain ids can now only be queried/set on active cells.
+Consequently, is_artificial(), is_ghost(), and is_locally_owned() is
+now restricted to active cells.
+<br>
+(Timo Heister, 2013/05/31)
+</li>
+
+<li> Improved: Triangulation::begin(level) and Triangulation::end(level) now return an
+empty iterator range if the level is larger than the maximal locally owned level,
+but still in the global level range of a distributed Triangulation.
+<br>
+(Timo Heister and Guido Kanschat, 2013/05/26)
+</li>
+
+<li> New: The IndexSet::add_indices function that takes another IndexSet
+object now has an additional argument <code>offset</code> that can be used
+to offset the indices of first argument.
+<br>
+(Wolfgang Bangerth, 2013/05/25)
+</li>
+
+<li> New: ConstraintMatrix::distribute is now also implemented for
+arguments of type PETScWrappers::MPI::BlockVector.
+<br>
+(Wolfgang Bangerth, 2013/05/25)
+</li>
+
+<li> Fixed: IndexSet::operator== returned the wrong results
+in some cases.
+<br>
+(Wolfgang Bangerth, 2013/05/25)
+</li>
+
+<li> New: The global function <code>complete_index_set()</code>
+creates and returns an index set of given size that contains
+every single index with this range.
+<br>
+(Wolfgang Bangerth, 2013/05/24)
+</li>
+
+<li> New: All vector classes now have a static member variable
+<code>supports_distributed_data</code> that indicates whether the
+vector class supports data that is distributed across multiple
+processors. This variable is provided as a <i>traits variable</i>
+to allow generic algorithms working on general vector types to
+query the capabilities of the vector class at compile time.
+<br>
+(Wolfgang Bangerth, 2013/05/23)
+</li>
+
+<li> Fixed: FETools::back_interpolate has been revised to work correctly
+also with parallel::distributed::Vector.
+<br>
+(Martin Steigemann, 2013/05/23)
+</li>
+
+<li> Removed: The file <code>mesh_worker/vector_info.h</code> was unused and
+untested. It has thus been removed.
+<br>
+(Wolfgang Bangerth, Guido Kanschat, 2013/05/21)
+</li>
+
+<li> Fixed: The method parallel::distributed::Vector::compress
+(VectorOperation::insert) previously set the elements of ghost elements
+unconditionally on the owning processor, even if they had not been touched.
+This led to a problem in certain library functions where vector entries became
+zero in a spurious way. This is now fixed by discarding the elements in ghost
+entries for the VectorOperation::insert operation. This is legitimate since we
+assume consistency of set elements across processors, so the owning processor
+sets the element already.
+<br>
+(Martin Kronbichler, 2013/05/21)
+</li>
+
+<li> Improved: DoFTools::make_periodicity_constraints now also works
+for meshes where the refinement level of the two sides of the domain
+is not the same, i.e., one side is more refined than the other.
+<br>
+(Wolfgang Bangerth, 2013/05/20)
+</li>
+
+<li> Improved: Through the fields DataOutBase::VtkFlags::time and
+DataOutBase::VtkFlags::cycle, it is now possible to encode the time and/or
+cycle within a nonlinear or other iteration in VTK and VTU files written
+via DataOutBase::write_vtk and DataOutBase::write_vtu.
+<br>
+(Wolfgang Bangerth, 2013/05/12)
+</li>
+
+<li> Fixed: The method ConvergenceTable::evaluate_convergence_rates with
+ reference column did not take the dimension of the reference column into
+ account, leading to wrong logarithmic rates for dim!=2. This can now be fixed
+ by specifying the dimension as a last argument.
+<br>
+(Martin Kronbichler, 2013/05/10)
+</li>
+
+<li> Improved: The functions MatrixTools::create_mass_matrix and
+MatrixTools::create_laplace_matrix take now an optional ConstraintMatrix
+argument that allows to directly apply the constraints. This also helps
+VectorTools::project. Note that not providing constraints remains the default
+and recommended way to ensure consistency when several matrices are combined.
+<br>
+(Martin Kronbichler, 2013/05/08)
+</li>
+
+<li> New: The classes TrilinosWrappers::SparseMatrix and
+TrilinosWrappers::BlockSparseMatrix now fully implement vmult and Tvmult with
+deal.II's own vector classes Vector<double> and
+parallel::distributed::Vector<double>.
+<br>
+(Martin Kronbichler, 2013/05/08)
+</li>
+
+<li> Improved: The matrix-vector product ChunkSparseMatrix::vmult now runs in
+parallel in shared memory.
+<br>
+(Martin Kronbichler, 2013/05/07)
+</li>
+
+<li> New: The class ChunkSparseMatrix and the associated
+ChunkSparsityPattern now offer iterator classes to iterate over rows of the
+matrix in an STL-like way.
+<br>
+(Martin Kronbichler, 2013/05/07)
+</li>
+
+<li> Fixed: The stopping criterion for early exit in SolverBicgstab did not
+work properly for systems with large values, leading to premature exit. This
+is now fixed.
+<br>
+(Martin Kronbichler, 2013/05/07)
+</li>
+
+<li> Changed: The SolverGMRES implementation previously applied two
+iterations of the modified Gram–Schmidt algorithm for
+orthogonalization. In many situations one iteration is enough. The algorithm
+can now detect loss of orthogonality and enables re-orthogonalization only if
+necessary. The second iteration (and, hence, old behavior) can be forced by
+the flag SolverGMRES::AdditionalData::force_re_orthogonalization.
+<br>
+(Martin Kronbichler, 2013/05/06)
+</li>
+
+<li> Changed: FETools::interpolate is now instantiated for all
+vector types, not just dealii::Vector and dealii::BlockVector.
+<br>
+(Wolfgang Bangerth, 2013/05/06)
+</li>
+
+<li> Fixed: setting values in TrilinosWrappers::SparseMatrix
+in parallel was adding the values instead.
+<br>
+(Bruno Turcksin, Timo Heister, 2013/05/03)
+</li>
+
+<li> Fixed: Generate an error if the user tries to refine a cell
+that is already on the maximum level in a distributed triangulation.
+<br>
+(Timo Heister, 2013/05/01)
+</li>
+
+<li> Fixed: The version of ParameterHandler::set that takes a boolean
+as second argument was broken and did not work. This is now fixed.
+<br>
+(Ashkan Dorostkar, Wolfgang Bangerth, 2013/04/30)
+</li>
+
+<li> Fixed: PETScWrappers::VectorBase::print now saves and restores
+the precision
+and width associated with the stream it prints to around setting
+the values passed as arguments.
+<br>
+(Fahad Alrashed, 2013/04/22)
+</li>
+
+<li> Fixed: FullMatrix::print now saves and restores the precision
+and width associated with the stream it prints to around setting
+the values passed as arguments.
+<br>
+(Fahad Alrashed, 2013/04/22)
+</li>
+
+<li> New: LogStream now has member functions LogStream::width,
+LogStream::precision and LogStream::flags that make it look more
+like normal objects of type <code>std::ostream</code>.
+<br>
+(Fahad Alrashed, 2013/04/22)
+</li>
+
+<li> New: SparseDirectUMFPACK has long had the ability to work with
+BlockSparseMatrix objects, but couldn't deal with BlockVector objects.
+This is now fixed.
+<br>
+(Wolfgang Bangerth, 2013/04/21)
+</li>
+
+<li> New: Class TimerOutput::Scope does automatic scope based enter/
+exit_section of a TimerOutput object.
+<br>
+(Timo Heister, 2013/04/18)
+</li>
+
+<li> Fixed: TimerOutput constructed with an MPI_COMM in wall_time
+mode now constructs synchronized Timer objects. This gives reliable
+parallel benchmark timings.
+<br>
+(Timo Heister, 2013/04/18)
+</li>
+
+<li> Improved and Fixed: LogStream (and deallog) now respect std::flush in
+addition to std::endl to write out content to the console/file.
+Furthermore, LogStream::push(...) and LogStream::pop() now work in a thread
+safe manner. Also allow to pop() the prefix "DEAL".
+<br>
+(Matthias Maier, 2013/04/18)
+</li>
+
+<li> Fixed: The HalfHyperShellBoundary class got refining
+the edges that sit at the perimeter of the circular face of the domain
+wrong. This is now fixed.
+<br>
+(Wolfgang Bangerth, Jörg Frohne, 2013/04/17)
+</li>
+
+<li> New: Functions::FEFieldFunction can now deal with
+parallel::distributed::Triangulation objects.
+<br>
+(Wolfgang Bangerth, 2013/04/15)
+</li>
+
+<li> New: There is now a version of SparseMatrix::copy_from that can copy
+from TrilinosWrappers::SparseMatrix.
+<br>
+(Wolfgang Bangerth, Jörg Frohne, 2013/04/15)
+</li>
+
+<li> Improved: The SolverCG implementation now uses only three auxiliary
+vectors, down from previously four. Also, there are some shortcuts in case
+PreconditionIdentity is used that improve the solver's performance.
+<br>
+(Martin Kronbichler, 2013/04/11)
+</li>
+
+<li> Fixed: The results section of step-23 did not show the movie in release 7.3
+due to a poor HTML markup. This is now fixed.
+<br>
+(Wolfgang Bangerth, 2013/04/10)
+</li>
+
+<li> Fixed: It is now possible to use the MeshWorker framework in 1d as well.
+<br>
+(Wolfgang Bangerth, Scott Miller, 2013/04/09)
+</li>
+
+<li> Fixed: It was not possible to create a default-constructed object of
+type Triangulation<1>::face_iterator. This is now fixed.
+<br>
+(Wolfgang Bangerth, Scott Miller, 2013/04/09)
+</li>
+
+<li> New: VectorTools::subtract_mean_value can now be called without a
+boolean mask. The vector type is templatified and instantiated for all
+non distributed vectors.
+<br>
+(Matthias Maier, 2013/04/08)
+</li>
+
+<li> Fixed: It is now possible to call ConvergenceTable::evaluate_convergence_rates
+multiple times.
+<br>
+(Matthias Maier, 2013/04/08)
+</li>
+
+<li> Fixed: GridTools::distort_random (previously called Triangulation::distort_random)
+had a bug where points were only ever moved in <i>positive</i> coordinate
+directions rather than with uniform probability in either direction. The 1d
+implementation also had the problem that it did not move vertices if the
+<i>cell</i> they were on was at the boundary, even if the <i>vertex</i>
+itself was not. All of these problems are now fixed.
+<br>
+(Wolfgang Bangerth, 2013/04/05)
+</li>
+
+<li> New: There is a class VectorFunctionFromTensorFunction that converts
+between objects of type TensorFunction and Function.
+<br>
+(Spencer Patty, 2013/4/2)
+</li>
+
+<li> Fixed: The ParameterHandler class could not deal with parameters named
+<code>"value"</code> (and a few other names). This is now fixed.
+<br>
+(Denis Davydov, Matthias Maier, Wolfgang Bangerth, 2013/3/31)
+</li>
+
+<li> Changed: TimerOutput no longer assumes that sections are not nested
+when outputting percentage and total run time.
+<br>
+(Timo Heister, 2013/3/28)
+</li>
+
+<li> New: MPI_InitFinalize can also initialize PETSc/Slepc when
+not compiling with MPI. This is now the preferred way to initialize
+MPI/PETSc/Slepc in all cases.
+<br>
+(Timo Heister, 2013/3/26)
+</li>
+
+<li> Added/fixed: IterativeInverse::vmult() can now handle vectors
+using a different number type than the matrix type. As usual, the
+number types must be compatible. Addtitionally, the initial guess is
+always set to zero, since starting with the incoming vector makes no
+sense.
+<br>
+(Guido Kanschat, 2013/03/21)
+</li>
+
+<li> Added GridOut::write_svg() to allow for the output of
+two-dimensional triangulations in two space dimensions in the SVG
+format (Scalable Vector Graphics, an generic XML-based vector image
+format developed and maintained by the World Wide Web Consortium W3C).
+This function also provides cell coloring and cell labeling for the
+visualization of basic cell properties. Pespective view is further
+possible and the cell level number may be converted into altitude,
+revealing the inactive cells lying below.
+<br>
+(Christian Wülker, 2013/03/21)
+</li>
+
+<li> Added TimerOutput::reset to remove the collected information so far and
+added a new frequency TimerOutput::never to only output information if
+triggered by print_summary().
+<br>
+(Timo Heister, 2013/03/20)
+</li>
+
+<li> Changed: FEValuesExtractors::Scalar, FEValuesExtractors::Vector and
+FEValuesExtractors::SymmetricTensor could not be default constructed, and
+consequently one could not easily put them into arrays (where they would
+be default constructed when changing the size, and later assigned useful
+values). These classes can now be default constructed to invalid
+values, but can of course not be used in any useful way.
+<br>
+(Wolfgang Bangerth, 2013/03/15)
+</li>
+
+<li> Fixed: FETools::interpolation_difference did not work with PETSc.
+This is now fixed.
+<br>
+(Timo Heister, 2013/03/01)
+</li>
+
+</ol>
+
+
+*/
/**
- * @page changes_after_7_3 Changes after Version 7.3
+// * @page changes_after_8_0 Changes after Version 8.0
<p>
This is the list of changes made after the release of
-deal.II version 7.3.0.
+deal.II version 8.0.0.
All entries are signed with the names of the authors.
</p>
</p>
<ol>
+ <li>
+ Removed: The member function face_to_equivalent_cell_index() in
+ FiniteElementData has been removed. It had been deprecated a while
+ back already. Please use FiniteElement::face_to_cell_index() instead.
+ <br>
+ (Wolfgang Bangerth, 2013/08/09)
+ </li>
-<li> Removed: it was possible to call get_dof_indices(), get_dof_values(),
-set_dof_values(), and distribute_local_to_global() for cells that were not
-active, if the finite element only had DoFs on vertices (i.e. Q1). This is
-no longer allowed.
-<br>
-(Timo Heister, 2013/06/02)
-
-<li> Changed: Internal structures of ExceptionBase are now thread safe. The
-Assert macro does not print an exception to deallog any more prior to
-throwing if deal_II_exceptions::abort_on_exception==false. Removed: A
-number of obsolete Exceptions that are not used in the library any more.
-<br>
-(Matthias Maier, 2013/04/16)
-
-<li> Removed: A number of header files that have been deprecated a long time
-ago have been removed. All of them had previously only included the header file
-that had superseded them. To upgrade, simply include the currently used
-header file. This is also backward compatible with deal.II 7.3.
-<br>
-(Guido Kanschat, 2013/04/12)
-
-<li> Removed: The interfaces to the obsolete direct solvers MA27 and MA47 from
-the Harwell Subroutine Library. Support for the HSL routines were not ported to
-the new build system. However, the sparse direct solver UMFPACK remains to be
-supported and is provided as part of the standard deal.II distribution, unlike
-the HSL functions.
-<br>
-(Matthias Maier, 2013/04/01)
-
-<li> Changed: The TimeDependent::end_sweep function with an argument indicating
-the number of threads has been removed. Use the corresponding function without
-an argument. Since the argument had a default value, few users will have used
-this function.
-<br>
-(Wolfgang Bangerth, 2013/03/17)
-
+ <li>
+ Changed: The typedefs DataOut::cell_iterator and
+ DataOut::active_cell_iterator were previously defined as
+ DoFHandler::(active)_cell_iterator, while they are now
+ Triangulation::(active)_cell_iterator. This is necessary to support DataOut
+ on multiple DoFHandler objects. This affects possible overloading of
+ DataOut::next_cell(cell_iterator). Use the typedef
+ DataOut::(active)_cell_iterator as argument type instead.
+ <br>
+ (Martin Kronbichler, 2013/07/24)
+ </li>
</ol>
<ol>
- <li> New: deal.II can now be compiled to 64-bit global dof indices. To turn
- this feature on, use the cmake option -DDEAL_II_WITH_64BIT_INDICES=ON. If
- PETSc and/or Trilinos are used, they must be compiled to support 64-bit
- indices. To write a code that can use 32-bit and 64-bit indices depending on
- deal.II compilation option, use types::global_dof_index for all the global
- dof indices.
+ <li>
+ Fixed: The DataOutBase::XDMFEntry class now has a proper serialization
+ function to allow for checkpointing.
+ <br>
+ (Eric Heien, 2013/09/27)
+ </li>
+
+ <li>
+ New: DataOutBase::DataOutFilter provides a way to remove duplicate vertices
+ and values from a solution vector when generating output. Currently it only
+ supports HDF5/XDMF output.
<br>
- (Kainan Wang and Bruno Turcksin, 2013/06/05)
+ (Eric Heien, 2013/09/27)
</li>
- <li> New: All vector classes now have a member function
- <code>locally_owned_elements</code> that returns an index
- set indicating which elements of this vector the current
- processor owns.
+ <li>
+ Removed: DataOutBase::HDF5MemStream was removed and the functionality replaced
+ by DataOutBase::DataOutFilter. The user only manipulates these through
+ DataOutBase::write_hdf5_parallel so this change should be transparent.
<br>
- (Wolfgang Bangerth, 2013/05/24)
+ (Eric Heien, 2013/09/27)
</li>
+ <li>
+ New: Like the usual DoFHandler class, the hp::DoFHandler class now also
+ has a cache that makes operations such as <code>cell-@>get_dof_indices(...)</code>
+ faster. This should accelerate many parts of the library that deal with
+ hp finite elements.
+ <br>
+ (Wolfgang Bangerth, 2013/09/10)
+ </li>
- <li> New: A new element FE_Q_iso_Q1 has been implemented that is defined by
- a subdivision of the element into smaller Q1 elements. An element of order
- @p p is similar to FE_Q of degree @p p with the same numbering of degrees of
- freedom. The element is useful e.g. for defining a sparser preconditioner
- matrix for AMG at higher order FE_Q elements or for representing a component
- of a system of PDEs where higher resolution is preferred over high order.
+ <li>
+ New: parallel::distributed::Triangulation now supports periodic boundaries.
+ DoFTools::make_periodicity_constraints and similar functions are now working
+ on parallel::distributed::Triangulation objects.
<br>
- (Martin Kronbichler, 2013/05/14)
+ (Tobin Isaac, Craig Michoski, Daniel Arndt, 2013/09/06)
</li>
- <li> New: The step-49 tutorial program now also has a discussion on
- what to do once you have a coarse mesh and want to refine it.
+ <li>
+ New: It is now possible to compile and link deal.II against LLVM's libcxx. For
+ this, a few issues with C++ standard violations are resolved.
<br>
- (Wolfgang Bangerth, 2013/04/03)
+ (Matthias Maier, 2013/08/09)
</li>
+</ol>
+
+
+<!-- ----------- SPECIFIC IMPROVEMENTS ----------------- -->
+
+<a name="specific"></a>
+<h3>Specific improvements</h3>
- <li> New: The number of threads used by deal.II/TBB can now be limited at
- run time. Using MPI based code using PETSc/Trilinos no longer requires you
- to compile the library without threads. See MPI_InitFinalize and
- MultithreadInfo::set_thread_limit for details.
+<ol>
+ <li>
+ Fixed: ConstraintMatrix would not compress() the IndexSet in the constructor
+ leading to crashes that only happen in release mode. This is now fixed.
<br>
- (Timo Heister, 2013/03/26)
+ (Timo Heister, 2013/09/27)
</li>
- <li> New: The results section of step-36 now explains how to use ARPACK
- as an alternative to SLEPc as eigenvalue solver.
+ <li>
+ Fixed: PetscWrappers::MatrixBase::row_length() no longer worked after recent changes
+ to PETSc (around PETSc release 3.4). This is now fixed.
<br>
- (Juan Carlos Araujo Cabarcas, 2013/03/25)
+ (Wolfgang Bangerth, 2013/09/24)
</li>
- <li> New: deal.II now uses <a href="http://www.cmake.org/">CMake</a>
- as its configuration and build tool. Please read through the
- readme and other installation files for information about how the
- installation process has changed.
+ <li>
+ New: Added write_visit_record that allows writing .visit files with multiple blocks
+ and multiple time steps.
<br>
- Because this touches the configuration of every external package we
- interact with, there are a number of other changes as a result:
- <ul>
- <li>The minimum supported version for Trilinos is now 10.8.x.
- <li>We no longer link with different versions of the p4est library
- in debug and optimized mode. Rather, we now link with the same
- library in both modes. The p4est installation instructions have
- been updated. <blink>TODO TODO TODO</blink>
- </ul>
+ (Fahad Alrashed, 2013/09/21)
+ </li>
+
+ <li>
+ Changed: GridTools::have_same_coarse_mesh was only instantiated for
+ MGDoFHandler arguments in debug mode. This is now fixed.
<br>
- (Matthias Maier, 2013/03/07)
+ (Timo Heister, 2013/09/20)
</li>
-</ol>
+ <li>
+ Changed: GridTools::find_active_cell_around_point now throws the exception
+ GridTools::ExcPointNotFound
+ if the point is outside the Triangulation. This exception can be caught.
+ <br>
+ (Timo Heister, 2013/09/18)
+ </li>
-<!-- ----------- SPECIFIC IMPROVEMENTS ----------------- -->
+ <li>
+ Changed: we now call MPI_Init_thread instead of MPI_Init.
+ <br>
+ (Timo Heister, 2013/09/17)
+ </li>
-<a name="specific"></a>
-<h3>Specific improvements</h3>
+ <li>
+ Enhancement: It is now possible to use the build directory directly without
+ the need to install first. For this, a second copy of all necessary project
+ configuration files (deal.IIConfig.cmake, ..., Make.global_options) are
+ generated and deployed in the build directory. (This is fully compatible with
+ the old possibility to install into the build dir.)
+ <br>
+ (Matthias Maier, 2013/09/15)
+ </li>
-<ol>
-<li> Fixed: The stabilization parameter for the artificial diffusion
-in the step-31 tutorial program has been increased slightly to avoid
-instabilities at later times (<i>t</i> > 60).
-<br>
-(Martin Kronbichler, 2013/06/04)
-</li>
-
-<li> Fixed: If an exception was generated on a task created by
-Threads::new_task, the program would terminate with a segmentation
-fault, leaving little trace of what had happened. This is now handled
-more gracefully.
-<br>
-(Wolfgang Bangerth, 2013/06/02)
-</li>
-
-<li> Changed: subdomain ids can now only be queried/set on active cells.
-Consequently, is_artificial(), is_ghost(), and is_locally_owned() is
-now restricted to active cells.
-<br>
-(Timo Heister, 2013/05/31)
-</li>
-
-<li> Improved: Triangulation::begin(level) and Triangulation::end(level) now return an
-empty iterator range if the level is larger than the maximal locally owned level,
-but still in the global level range of a distributed Triangulation.
-<br>
-(Timo Heister and Guido Kanschat, 2013/05/26)
-</li>
-
-<li> New: The IndexSet::add_indices function that takes another IndexSet
-object now has an additional argument <code>offset</code> that can be used
-to offset the indices of first argument.
-<br>
-(Wolfgang Bangerth, 2013/05/25)
-</li>
-
-<li> New: ConstraintMatrix::distribute is now also implemented for
-arguments of type PETScWrappers::MPI::BlockVector.
-<br>
-(Wolfgang Bangerth, 2013/05/25)
-</li>
-
-<li> Fixed: IndexSet::operator== returned the wrong results
-in some cases.
-<br>
-(Wolfgang Bangerth, 2013/05/25)
-</li>
-
-<li> New: The global function <code>complete_index_set()</code>
-creates and returns an index set of given size that contains
-every single index with this range.
-<br>
-(Wolfgang Bangerth, 2013/05/24)
-</li>
-
-<li> New: All vector classes now have a static member variable
-<code>supports_distributed_data</code> that indicates whether the
-vector class supports data that is distributed across multiple
-processors. This variable is provided as a <i>traits variable</i>
-to allow generic algorithms working on general vector types to
-query the capabilities of the vector class at compile time.
-<br>
-(Wolfgang Bangerth, 2013/05/23)
-</li>
-
-<li> Fixed: FETools::back_interpolate has been revised to work correctly
-also with parallel::distributed::Vector.
-<br>
-(Martin Steigemann, 2013/05/23)
-</li>
-
-<li> Removed: The file <code>mesh_worker/vector_info.h</code> was unused and
-untested. It has thus been removed.
-<br>
-(Wolfgang Bangerth, Guido Kanschat, 2013/05/21)
-</li>
-
-<li> Fixed: The method parallel::distributed::Vector::compress
-(VectorOperation::insert) previously set the elements of ghost elements
-unconditionally on the owning processor, even if they had not been touched.
-This led to a problem in certain library functions where vector entries became
-zero in a spurious way. This is now fixed by discarding the elements in ghost
-entries for the VectorOperation::insert operation. This is legitimate since we
-assume consistency of set elements across processors, so the owning processor
-sets the element already.
-<br>
-(Martin Kronbichler, 2013/05/21)
-</li>
-
-<li> Improved: DoFTools::make_periodicity_constraints now also works
-for meshes where the refinement level of the two sides of the domain
-is not the same, i.e., one side is more refined than the other.
-<br>
-(Wolfgang Bangerth, 2013/05/20)
-</li>
-
-<li> Improved: Through the fields DataOutBase::VtkFlags::time and
-DataOutBase::VtkFlags::cycle, it is now possible to encode the time and/or
-cycle within a nonlinear or other iteration in VTK and VTU files written
-via DataOutBase::write_vtk and DataOutBase::write_vtu.
-<br>
-(Wolfgang Bangerth, 2013/05/12)
-</li>
-
-<li> Fixed: The method ConvergenceTable::evaluate_convergence_rates with
- reference column did not take the dimension of the reference column into
- account, leading to wrong logarithmic rates for dim!=2. This can now be fixed
- by specifying the dimension as a last argument.
-<br>
-(Martin Kronbichler, 2013/05/10)
-</li>
-
-<li> Improved: The functions MatrixTools::create_mass_matrix and
-MatrixTools::create_laplace_matrix take now an optional ConstraintMatrix
-argument that allows to directly apply the constraints. This also helps
-VectorTools::project. Note that not providing constraints remains the default
-and recommended way to ensure consistency when several matrices are combined.
-<br>
-(Martin Kronbichler, 2013/05/08)
-</li>
-
-<li> New: The classes TrilinosWrappers::SparseMatrix and
-TrilinosWrappers::BlockSparseMatrix now fully implement vmult and Tvmult with
-deal.II's own vector classes Vector<double> and
-parallel::distributed::Vector<double>.
-<br>
-(Martin Kronbichler, 2013/05/08)
-</li>
-
-<li> Improved: The matrix-vector product ChunkSparseMatrix::vmult now runs in
-parallel in shared memory.
-<br>
-(Martin Kronbichler, 2013/05/07)
-</li>
-
-<li> New: The class ChunkSparseMatrix and the associated
-ChunkSparsityPattern now offer iterator classes to iterate over rows of the
-matrix in an STL-like way.
-<br>
-(Martin Kronbichler, 2013/05/07)
-</li>
-
-<li> Fixed: The stopping criterion for early exit in SolverBicgstab did not
-work properly for systems with large values, leading to premature exit. This
-is now fixed.
-<br>
-(Martin Kronbichler, 2013/05/07)
-</li>
-
-<li> Changed: The SolverGMRES implementation previously applied two
-iterations of the modified Gram–Schmidt algorithm for
-orthogonalization. In many situations one iteration is enough. The algorithm
-can now detect loss of orthogonality and enables re-orthogonalization only if
-necessary. The second iteration (and, hence, old behavior) can be forced by
-the flag SolverGMRES::AdditionalData::force_re_orthogonalization.
-<br>
-(Martin Kronbichler, 2013/05/06)
-</li>
-
-<li> Changed: FETools::interpolate is now instantiated for all
-vector types, not just dealii::Vector and dealii::BlockVector.
-<br>
-(Wolfgang Bangerth, 2013/05/06)
-</li>
-
-<li> Fixed: setting values in TrilinosWrappers::SparseMatrix
-in parallel was adding the values instead.
-<br>
-(Bruno Turcksin, Timo Heister, 2013/05/03)
-</li>
-
-<li> Fixed: Generate an error if the user tries to refine a cell
-that is already on the maximum level in a distributed triangulation.
-<br>
-(Timo Heister, 2013/05/01)
-</li>
-
-<li> Fixed: The version of ParameterHandler::set that takes a boolean
-as second argument was broken and did not work. This is now fixed.
-<br>
-(Ashkan Dorostkar, Wolfgang Bangerth, 2013/04/30)
-</li>
-
-<li> Fixed: PETScWrappers::VectorBase::print now saves and restores
-the precision
-and width associated with the stream it prints to around setting
-the values passed as arguments.
-<br>
-(Fahad Alrashed, 2013/04/22)
-</li>
-
-<li> Fixed: FullMatrix::print now saves and restores the precision
-and width associated with the stream it prints to around setting
-the values passed as arguments.
-<br>
-(Fahad Alrashed, 2013/04/22)
-</li>
-
-<li> New: LogStream now has member functions LogStream::width,
-LogStream::precision and LogStream::flags that make it look more
-like normal objects of type <code>std::ostream</code>.
-<br>
-(Fahad Alrashed, 2013/04/22)
-</li>
-
-<li> New: SparseDirectUMFPACK has long had the ability to work with
-BlockSparseMatrix objects, but couldn't deal with BlockVector objects.
-This is now fixed.
-<br>
-(Wolfgang Bangerth, 2013/04/21)
-</li>
-
-<li> New: Class TimerOutput::Scope does automatic scope based enter/
-exit_section of a TimerOutput object.
-<br>
-(Timo Heister, 2013/04/18)
-</li>
-
-<li> Fixed: TimerOutput constructed with an MPI_COMM in wall_time
-mode now constructs synchronized Timer objects. This gives reliable
-parallel benchmark timings.
-<br>
-(Timo Heister, 2013/04/18)
-</li>
-
-<li> Improved and Fixed: LogStream (and deallog) now respect std::flush in
-addition to std::endl to write out content to the console/file.
-Furthermore, LogStream::push(...) and LogStream::pop() now work in a thread
-safe manner.
-<br>
-(Matthias Maier, 2013/04/18)
-</li>
-
-<li> Fixed: The HalfHyperShellBoundary class got refining
-the edges that sit at the perimeter of the circular face of the domain
-wrong. This is now fixed.
-<br>
-(Wolfgang Bangerth, Jörg Frohne, 2013/04/17)
-</li>
-
-<li> New: Functions::FEFieldFunction can now deal with
-parallel::distributed::Triangulation objects.
-<br>
-(Wolfgang Bangerth, 2013/04/15)
-</li>
-
-<li> New: There is now a version of SparseMatrix::copy_from that can copy
-from TrilinosWrappers::SparseMatrix.
-<br>
-(Wolfgang Bangerth, Jörg Frohne, 2013/04/15)
-</li>
-
-<li> Improved: The SolverCG implementation now uses only three auxiliary
-vectors, down from previously four. Also, there are some shortcuts in case
-PreconditionIdentity is used that improve the solver's performance.
-<br>
-(Martin Kronbichler, 2013/04/11)
-</li>
-
-<li> Fixed: The results section of step-23 did not show the movie in release 7.3
-due to a poor HTML markup. This is now fixed.
-<br>
-(Wolfgang Bangerth, 2013/04/10)
-</li>
-
-<li> Fixed: It is now possible to use the MeshWorker framework in 1d as well.
-<br>
-(Wolfgang Bangerth, Scott Miller, 2013/04/09)
-</li>
-
-<li> Fixed: It was not possible to create a default-constructed object of
-type Triangulation<1>::face_iterator. This is now fixed.
-<br>
-(Wolfgang Bangerth, Scott Miller, 2013/04/09)
-</li>
-
-<li> New: VectorTools::subtract_mean_value can now be called without a
-boolean mask. The vector type is templatified and instantiated for all
-non distributed vectors.
-<br>
-(Matthias Maier, 2013/04/08)
-</li>
-
-<li> Fixed: It is now possible to call ConvergenceTable::evaluate_convergence_rates
-multiple times.
-<br>
-(Matthias Maier, 2013/04/08)
-</li>
-
-<li> Fixed: GridTools::distort_random (previously called Triangulation::distort_random)
-had a bug where points were only ever moved in <i>positive</i> coordinate
-directions rather than with uniform probability in either direction. The 1d
-implementation also had the problem that it did not move vertices if the
-<i>cell</i> they were on was at the boundary, even if the <i>vertex</i>
-itself was not. All of these problems are now fixed.
-<br>
-(Wolfgang Bangerth, 2013/04/05)
-</li>
-
-<li> New: There is a class VectorFunctionFromTensorFunction that converts
-between objects of type TensorFunction and Function.
-<br>
-(Spencer Patty, 2013/4/2)
-</li>
-
-<li> Fixed: The ParameterHandler class could not deal with parameters named
-<code>"value"</code> (and a few other names). This is now fixed.
-<br>
-(Denis Davydov, Matthias Maier, Wolfgang Bangerth, 2013/3/31)
-</li>
-
-<li> Changed: TimerOutput no longer assumes that sections are not nested
-when outputting percentage and total run time.
-<br>
-(Timo Heister, 2013/3/28)
-</li>
-
-<li> New: MPI_InitFinalize can also initialize PETSc/Slepc when
-not compiling with MPI. This is now the preferred way to initialize
-MPI/PETSc/Slepc in all cases.
-<br>
-(Timo Heister, 2013/3/26)
-</li>
-
-<li> Added/fixed: IterativeInverse::vmult() can now handle vectors
-using a different number type than the matrix type. As usual, the
-number types must be compatible. Addtitionally, the initial guess is
-always set to zero, since starting with the incoming vector makes no
-sense.
-<br>
-(Guido Kanschat, 2013/03/21)
-</li>
-
-<li> Added GridOut::write_svg() to allow for the output of
-two-dimensional triangulations in two space dimensions in the SVG
-format (Scalable Vector Graphics, an generic XML-based vector image
-format developed and maintained by the World Wide Web Consortium W3C).
-This function also provides cell coloring and cell labeling for the
-visualization of basic cell properties. Pespective view is further
-possible and the cell level number may be converted into altitude,
-revealing the inactive cells lying below.
-<br>
-(Christian Wülker, 2013/03/21)
-</li>
-
-<li> Added TimerOutput::reset to remove the collected information so far and
-added a new frequency TimerOutput::never to only output information if
-triggered by print_summary().
-<br>
-(Timo Heister, 2013/03/20)
-</li>
-
-<li> Changed: FEValuesExtractors::Scalar, FEValuesExtractors::Vector and
-FEValuesExtractors::SymmetricTensor could not be default constructed, and
-consequently one could not easily put them into arrays (where they would
-be default constructed when changing the size, and later assigned useful
-values). These classes can now be default constructed to invalid
-values, but can of course not be used in any useful way.
-<br>
-(Wolfgang Bangerth, 2013/03/15)
-</li>
-
-<li> Fixed: FETools::interpolation_difference did not work with PETSc.
-This is now fixed.
-<br>
-(Timo Heister, 2013/03/01)
-</li>
-
-<li> Added DataOutBase::write_svg() to allow for the output of a given
-list of patches in two space dimensions in the SVG format (Scalable Vector
-Graphics, an generic XML-based vector image format developed and maintained
-by the World Wide Web Consortium W3C). An additional dimension (z-direction)
-is employed for the visualization of data values taken from a data vector.
-This function also provides patch coloring for the visual enhancement.
-<br>
-(Christian Wülker, 2013/05/10)
-</li>
+ <li>
+ Fixed: DoFTools::extract_locally_*_dofs now instantiated for hp::DofHandler.
+ <br>
+ (Jean-Paul Pelteret, 2013/09/11)
+ </li>
+
+ <li>
+ Changed: distributed::parallel:BlockVector::operator= now allows importing
+ of ghost values like all other vector types. Also added some new constructors
+ for BlockVector and Vector using IndexSets to mirror the other linear algebra
+ classes.
+ <br>
+ (Timo Heister, 2013/09/04)
+ </li>
+
+ <li>
+ Fixed: VectorTools::compute_no_normal_flux_constraints had a bug that
+ only manifested on complex meshes. This is now fixed.
+ <br>
+ (Chih-Che Chueh, Wolfgang Bangerth, 2013/09/04)
+ </li>
+
+ <li>
+ New: All vector classes now have functions <code>extract_subvector_to()</code>
+ that allow extracting not just a single value but a whole set.
+ <br>
+ (Fahad Alrasched, 2013/09/02)
+ </li>
+
+ <li>
+ Fixed: <code>common/Make.global_options</code> now exports enable-threads
+ correctly, furthermore, <code>lib-suffix</code>, <code>shared-lib-suffix</code>
+ and <code>static-lib-suffix</code> are now exported as well for better legacy
+ support.
+ <br>
+ (Matthias Maier, 2013/08/30)
+ </li>
+
+ <li>
+ New: The ParameterHandler class can now deal with including one parameter
+ file from another.
+ <br>
+ (Wolfgang Bangerth, 2013/08/25)
+ </li>
+
+ <li>
+ New: The method VectorTools::compute_normal_flux_constraints can be used to
+ force a vector finite element function to be normal to the boundary.
+ <br>
+ (Martin Kronbichler, 2013/08/23)
+ </li>
+ <li>
+ Improved: MappingQ now uses the points of the Gauss-Lobatto quadrature
+ formula as support points instead of equispaced ones. This allows its use
+ for high polynomial orders and also gives better interpolation of circular
+ boundaries. Beware that mappings of order three and higher will behave
+ slightly differently now (usually better).
+ <br>
+ (Martin Kronbichler, 2013/08/23)
+ </li>
+
+ <li>
+ Improved: Several .cc files in the deal.II directory have been split in
+ order to better utilize multiple processors when compiling in parallel and
+ reduce memory requirements of the compilation stage.
+ <br>
+ (Martin Kronbichler, 2013/08/22)
+ </li>
+
+ <li>
+ Fixed: The ParameterHandler::declare_entry() did not check that the
+ default value of a parameter indeed satisfies the pattern given for this
+ parameter (despite a statement in the documentation that this checking
+ would happen). This is now fixed.
+ <br>
+ (Wolfgang Bangerth, 2013/08/21)
+ </li>
+
+ <li>
+ New: Patterns::List and Patterns::Map now accept a string
+ different than the default comma that denotes the separator
+ between entries of the list or map.
+ <br>
+ (Wolfgang Bangerth, 2013/08/21)
+ </li>
+
+ <li>
+ Fixed: Some operations in the MappingQ class are now done in higher
+ precision arithmetic to mitigate the ill-conditioning that appears
+ when using mappings of high order (say, order 6 or 8 or 10).
+ <br>
+ (Juan Carlos Araujo Cabarcas, 2013/08/20)
+ </li>
+
+ <li>
+ Fixed: The SLEPcWrappers classes could not be compiled for 64-bit
+ indices. This is now fixed.
+ <br>
+ (Denis Davydov, Wolfgang Bangerth, 2013/08/20)
+ </li>
+
+ <li>
+ Fixed: SolutionTransfer used to crash whenever one transfered in the hp
+ context between cells that use FE_Nothing and FE_Q. This is now fixed.
+ <br>
+ (Krzyszof Bzowski, Wolfgang Bangerth, 2013/08/18)
+ </li>
+
+ <li>
+ Fixed: Under some circumstances (see http://code.google.com/p/dealii/issues/detail?id=82)
+ the DoFTools::make_periodicity_constraints() function could create cycles in
+ the ConstraintMatrix object. This is now fixed.
+ <br>
+ (David Emerson, Wolfgang Bangerth, 2013/08/16)
+ </li>
+
+ <li>
+ New: There is now a function ConstraintMatrix::are_identity_constrained().
+ <br>
+ (Wolfgang Bangerth, 2013/08/16)
+ </li>
+
+ <li>
+ New: TableHandler::write_text() now also supports output in
+ org-mode (http://orgmode.org/) format via a new entry in the
+ TableHandler::TextOutputFormat enumeration.
+ <br>
+ (Oleh Krehel, 2013/08/15)
+ </li>
+
+ <li>
+ New: There are now global functions <code>scalar_product</code>
+ that compute the scalar product (double contraction) between
+ tensors of rank 2.
+ <br>
+ (Scott Miller, 2013/08/14)
+ </li>
+
+ <li>
+ Fixed: Creating objects of type MappingQ was previously only possible
+ for low order polynomials. For orders higher than around 6, one ran
+ into assertions that tested for internal consistency. These assertions
+ have now been appropriately relaxes for the growth of round-off errors
+ with growing polynomial degrees.
+ <br>
+ (Juan Carlos Araujo Cabarcas, Wolfgang Bangerth, 2013/08/14)
+ </li>
+
+ <li>
+ New: MappingQEulerian is now also instantiated for vector elements
+ of type TrilinosWrappers::Vector as well as the MPI and block
+ variants.
+ <br>
+ (Armin Ghajar Jazi, 2013/08/14)
+ </li>
+
+ <li>
+ Fixed: The FiniteElement::face_to_cell_index() function had a bug
+ that made it work incorrectly for elements that have more than one
+ degree of freedom per line (in 2d) or per quad (in 3d). This is now
+ fixed for the most common cases, namely the FE_Q elements as well
+ as elements composed of FESystem elements. For all other cases, an
+ exception is generated reporting that this case is not implemented.
+ If you run into this, let us know.
+ <br>
+ (Wolfgang Bangerth, 2013/08/10)
+ </li>
+
+ <li>
+ New: DataOutBase::VtkFlags now has a flag
+ DataOutBase::VtkFlags::print_date_and_time that can be used to suppress output
+ of date and time in output files. This is useful in test suites where a newer
+ run at a different time produces differences against previously stored files,
+ even though the actual data is exactly the same.
+ <br>
+ (Oleh Krehel, 2013/08/06)
+ </li>
+
+ <li>
+ Fixed: The various block matrix classes are all derived from BlockMatrixBase
+ which had race conditions when the set() or add() functions were called from
+ different threads. This is now fixed.
+ <br>
+ (Wolfgang Bangerth, 2013/08/05)
+ </li>
+
+ <li>
+ Fixed: various fixes with assignment and reinit of PETScWrappers::MPI::Vector.
+ <br>
+ (Timo Heister, 2013/08/05)
+ </li>
+
+ <li>Fixed: An assertion wrongly triggered in
+ DoFTools::make_hanging_node_constraints when used with a particular
+ combination of FESystem elements containing FE_Nothing. This is now fixed.
+ <br>
+ (Denis Davydov, Wolfgang Bangerth, 2013/08/01)
+ </li>
+
+ <li>
+ New: Add has_ghost_elements() for PETScWrappers::MPI::BlockVector and
+ TrilinosWrappers::MPI::BlockVector.
+ <br>
+ (Timo Heister, 2013/08/01)
+ </li>
+
+ <li>
+ SparsityTools::distribute_sparsity_pattern did not work correctly for
+ block systems, this has been fixed (function has a different signature).
+ <br>
+ (Timo Heister, 2013/07/31)
+ </li>
+
+ <li>Fixed: When typing <code>make run</code> in the step-32 directory,
+ the program was executed with <code>mpirun -np 2 ./step-32</code>. This
+ assumes that a program <code>mpirun</code> exists, but also does that
+ deal.II was in fact compiled with MPI support on. Neither was intended.
+ This is now fixed.
+ <br>
+ (Wolfgang Bangerth, 2013/07/24)
+ </li>
+
+ <li>New: The DataOut, DataOutFaces, and DataOutRotation classes now allow
+ the output of data vectors using different DoFHandler objects (based on the
+ same triangulation), by new functions add_data_vector. This is used in the
+ step-31 tutorial program which avoids creating a joint DoFHandler just for
+ output.
+ <br>
+ (Martin Kronbichler, 2013/07/24)
+ </li>
+
+ <li>Changed: GridGenerator used to be a class with only static members
+ but is now a namespace, like all other similar constructs in deal.II.
+ <br>
+ (Wolfgang Bangerth, 2013/07/24)
+ </li>
+
+ <li>Changed: In GridGenerator, several functions had erroneously been changed
+ to take an argument of type <code>size_type</code> rather than <code>unsigned
+ int</code>. <code>GridGenerator::size_type</code> was a typedef to
+ types::global_dof_index, which for most users was <code>unsigned int</code>
+ anyway, but could also be set to be a 64-bit integer type. In any case, the
+ change has been reverted and these functions take just a regular
+ <code>unsigned int</code> again.
+ <br>
+ (Wolfgang Bangerth, 2013/07/24)
+ </li>
</ol>
<dt><strong>Recent changes</strong></dt>
<dd>
Changes in the library since the last major release are
- <strong><a href="../doxygen/deal.II/changes_after_7_3.html">here.</a></strong>
+ <strong><a href="../doxygen/deal.II/changes_after_8_0.html">here.</a></strong>
</dd>
</p>
<dl>
+ <dt>
+ <strong style="color:red">2013/07/24: Version 8.0 released</strong>
+ </dt>
+ <dd>
+ deal.II version 8.0 was released today. This is a major new
+ release, featuring the conversion of the configuration and
+ build system to <a href="http://www.cmake.org/">CMake</a>,
+ support for parallel computations with more than 4 billion
+ unknowns, and many more. A full list of changes can be
+ found <a href="../doxygen/deal.II/changes_between_7_3_and_8_0.html"
+ target="body">here</a>.
+ <br>
+ deal.II can be downloaded at
+ <a href="https://code.google.com/p/dealii/downloads/list"
+ target="_top">this site</a>.
+ </dd>
+
<dt>
<strong>2013/06/05: 64-bit version of deal.II</strong>
</dt>
<dd>
Because the global dof index variables in deal.II were of type
- unsigned int, it was not possible to create a dof_handler with more than
- 4.3 billions of unknowns. The 64-bit version of deal.II uses unsigned long
- long int and thus, allows for 18e18 unknowns.
+ unsigned int, it was not possible to create a dof_handler with more than
+ 4.3 billions of unknowns. The 64-bit version of deal.II uses unsigned long
+ long int and thus, allows for 18e18 unknowns.
</dd>
</dt>
<dd>
After having used Autoconf as the configuration and build system
- since the beginning of deal.II in 1997, we have now switch to
+ since the beginning of deal.II in 1997, we have now switched to
<a href="http://www.cmake.org/">CMake</a>. This implementation,
contributed by Matthias Maier of Heidelberg University, has taken
more than half a year, consists of more than 10,000 lines, and
library that, among much other functionality, offers some
sparse direct solvers. We have added support for an
interface to these solvers to the library.
- (See the <a href="../readme.html#hsl" target="body">ReadMe</a>
- file for more information on installation of HSL
- subroutines.)
</dd>
<dt>
submitted, 2013.
</li>
+ <li> G. Alam
+ <br>
+ <strong>Fast iterative solution of large scale statistical
+ inverse problems
+ </strong>
+ <br>
+ Master Thesis, Stockholm University, 2013.
+ </li>
+
+ <li> J. C. Araujo-Cabarcas
+ <br>
+ <strong>Numerical methods for glacial isostatic adjustment models
+ </strong>
+ <br>
+ MSc thesis, Uppsala University, Uppsala, Sweden, 2013.
+ </li>
+
+ <li> P. Argul, G. Ruocci, F. Freddi, K. Benzarti
+ <br>
+ <strong>An improved damage modelling to deal with the variability of
+ fracture mechanisms in FRP reinforced concrete structures
+ </strong>
+ <br>
+ International Journal of Adhesion and Adhesives 45 , 7-20, 2013.
+ </li>
+
+ <li> D. Arndt
+ <br>
+ <strong>Augmented Taylor-Hood Elements for Incompressible Flow
+ </strong>
+ <br>
+ Msc thesis, University of Göttingen, Germany, 2013.
+ </li>
+
+ <li> A. Barker, T. Rees, M. Stoll
+ <br>
+ <strong>A fast solver for an H<sub>1</sub> regularized
+ PDE-constrained optimization problem</strong>
+ <br>
+ submitted, 2013.
+ </li>
+
+ <li> S. Bartels, R. H. Nochetto, A. J. Salgado
+ <br>
+ <strong>A total variation diminishing interpolation operator
+ and applications</strong>
+ <br>
+ submitted, 2013.
+ </li>
+
+ <li> P. Benner, M. Stoll
+ <br>
+ <strong>Optimal control for Allen-Cahn equations enhanced by model predictive control</strong>
+ <br>
+ Preprint, MPI Magdeburg, 2013.
+ </li>
+
<li> A. Bonito, R. DeVore, R. H. Nochetto
<br>
<strong>Adaptive Finite Element Methods for Elliptic Problems with Discontinuous Coefficients</strong>
<li> A. Bonito, I. Kyza, R. H. Nochetto
<br>
- <strong>A DG approach to higher order ALE formulations in
- time</strong>
+ <strong>A dG Approach to Higher Order ALE Formulations in Time
+ </strong>
<br>
- submitted, 2013.
+ 2012 Barrett Lectures, The IMA Volume in Mathematics and its Applications, Vol. 157, 36 pages, 2013, Springer.
+ </li>
+
+ <li> A. Bonito, I. Kyza, R. H. Nochetto
+ <br>
+ <strong>Time-discrete higher order ALE formulations: A
+ priori error analysis</strong>
+ <br>
+ Numer. Math., 23 pages, 2013, 10.1007/s00211-013-0539-3.
+ </li>
+
+ <li> A. Bonito, I. Kyza, R. H. Nochetto
+ <br>
+ <strong>Time-discrete higher order ALE formulations: Stability</strong>
+ <br>
+ SIAM J. Numer. Anal., 51(1), 577--608, 2013.
</li>
<li> J. Bosch, M. Stoll, P. Benner
Preprint 13/01, MPI Magdeburg, 2013.
</li>
+ <li> J. Bosch, D. Kay, M. Stoll, A. J. Wathen
+ <br>
+ <strong>Fast solvers for Cahn-Hilliard inpainting</strong>
+ <br>
+ Technical report 1705, The Mathematical Institute,
+ University of Oxford; submitted, 2013.
+ </li>
+
+ <li> A. Cangiani, J. Chapman, E. Georgoulis, M. Jensen
+ <br>
+ <strong>Implementation of the Continuous-Discontinuous
+ Galerkin Finite Element Method</strong>
+ <br>
+ Numerical Mathematics and Advanced Applications 2011,
+ pp. 315-322, 2013.
+ </li>
+
<li> T. Carraro, J. Joos
<br>
<strong>Parameter estimation for a reconstructed SOFC
arXiv:1301.6580v0, 2013.
</li>
+ <li> C.-C. Chueh, N. Djilali, W. Bangerth
+ <br>
+ <strong>An h-adaptive Operator Splitting Method for
+ Two-phase Flow in 3D Heterogeneous Porous Media</strong>
+ <br>
+ SIAM Journal on Scientific Computing, vol. 35, pp. B149-175, 2013.
+ </li>
+
+ <li> D. Devaud
+ <br>
+ <strong>Adaptive Methods for the Stokes System with Discontinuous Viscosities
+ </strong>
+ <br>
+ MSc thesis, EPFL, 2013.
+ </li>
+
+ <li> T. Dohnal, W. Dörfler
+ <br>
+ <strong>Coupled Mode Equation Modeling for Out-of-Plane Gap
+ Solitons in 2D Photonic Crystals</strong>
+ <br>
+ Multiscale Modeling and Simulation, vol. 11, pp. 162-191, 2013.
+ </li>
+
+ <li> I. Donev
+ <br>
+ <strong>Time Dependent Finite Element Simulations of a Generalized Oldroyd-B Fluid
+ </strong>
+ <br>
+ MSc Thesis, University of Cape Town, 2013.
+ </li>
+
<li> W. Dörfler, S. Findeisen
<br>
<strong>Numerical optimization of a waveguide transition
Communications in Computational Physics, accepted, 2013.
</li>
+ <li> E. Emmrich, A. Wróblewska-Kamińska
+ <br>
+ <strong>Convergence of a Full Discretization of Quasi-linear Parabolic Equations in Isotropic and Anisotropic Orlicz Spaces
+ </strong>
+ <br>
+ SIAM Journal on Numerical Analysis, vol. 51, pp. 1163-1184, 2013.
+ </li>
+
+ <li> J. Fang, X. Gao, A. Zhou
+ <br>
+ <strong>A finite element recovery approach to eigenvalue
+ approximations with applications to electronic structure
+ calculations
+ </strong>
+ <br>
+ Journal of Scientific Computing, vol. 55, pp. 432-454, 2013.
+ </li>
+
+ <li> T. Fankhauser, T. Wihler, M. Wirz
+ <br>
+ <strong>The hp-adaptive FEM based on continuous Sobolev embeddings: Isotropic
+ refinements</strong>
+ <br>
+ Computers & Mathematics with Applications (in press), 2013.
+ </li>
+
+ <li> F. Freddi, G. Royer-Carfagni
+ <br>
+ <strong>Plastic flow as an energy minimization problem. Numerical
+ Experiments
+ </strong>
+ <br>
+ Journal of Elasticity, in press, 2013.
+ </li>
+
+ <li> A. Geringer, B. Lenhof, S. Diebels
+ <br>
+ <strong>Macroscopic modeling of foams: an order-parameter
+ approach vs. a micropolar model
+ </strong>
+ <br>
+ Technische Mechanik, vol. 33, pp. 87-96, 2013.
+ </li>
+
<li> F. Gimbel
<br>
<strong>Modelling and numerical simulation of contact and lubrication
arXiv:1303.5362, submitted, 2013.
</li>
+ <li>
+ <a href="http://ganymed.iwr.uni-heidelberg.de/~hartmann/"
+ target="_top">R. Hartmann</a>
+ <br>
+ <strong>Higher-order and adaptive discontinuous Galerkin
+ methods with shock-capturing applied to transonic turbulent
+ delta wing flow
+ </strong>
+ <br>
+ International Journal for Numerical Methods in Fluids,
+ vol. 72, pp. 883-894, 2013.
+ </li>
+
+ <li> T. Heister, G. Rapin
+ <br>
+ <strong>Efficient augmented Lagrangian-type preconditioning
+ for the Oseen problem using Grad-Div stabilization</strong>
+ <br>
+ Int. J. Num. Meth. Fluids, 71, 118–134, 2013
+ (<a href="http://dx.doi.org/10.1002/fld.3654">DOI</a>)
+ </li>
+
<li> M. Hinze, U. Mathes
<br>
<strong>Model order reduction for networks of ODE and PDE systems
pp 92-101, 2013.
</li>
+ <li> S. Joshi, J, Walton
+ <br>
+ <strong>Reconstruction of the residual stresses in a hyperelastic body using ultrasound techniques
+ </strong>
+ <br>
+ International Journal on Engineering Science, vol. 70,
+ pp. 46-72, 2013.
+ </li>
+
+ <li> S. Kim
+ <br>
+ <strong>Analysis of the convected Helmholtz equation with a
+ uniform mean flow in a waveguide with complete radiation
+ boundary conditions
+ </strong>
+ <br>
+ Journal of Mathematical Analysis and Applications,
+ in press,
+ <!-- http://www.sciencedirect.com/science/article/pii/S0022247X1300749X -->
+ 2013.
+ </li>
+
+ <li> N. Klein
+ <br>
+ <strong>Consistent FE-Analysis of elliptic Variational Inequalities
+ </strong>
+ <br>
+ PhD thesis, University of Siegen, Germany, 2013.
+ </li>
+
<li> T. Krüger
<br>
<strong>Regularization-based fictitious domain methods
PhD thesis, University of Siegen, Germany, 2013.
</li>
+ <li> K. Kumar, M.F. Wheeler, T. Wick
+ <br>
+ <strong>Reactive flow in a thin channel
+and reaction-induced boundary movement in
+a monolithic ALE framework
+ </strong>
+ <br>
+ submitted to SISC, 2013.
+ </li>
+
+ <li> B. Lenhof, A. Geringer, S. Diebels
+ <br>
+ <strong>Macroscopic modeling of size effects in foams using
+ an order parameter
+ </strong>
+ <br>
+ Generalized Continua as Models for Materials,
+ Advanced Structured Materials, vol. 22, pp. 237-254, 2013.
+ </li>
+
<li> S. H. Lim
<br>
<strong>Numerical Simulation of Two-phase Heat Flow and Transient
Undergraduate honors thesis, University of Michigan, Ann Arbor, 2013.
</li>
+ <li> A. Mikelic, M.F. Wheeler, T. Wick
+ <br>
+ <strong>A phase field approach to the fluid filled fracture surrounded by a poroelastic medium
+ </strong>
+ <br>
+ submitted, ICES preprint on http://www.ices.utexas.edu/research/reports/
+ </li>
+
+ <li> A. Mola, L. Heltai, A. DeSimone
+ <br>
+ <strong>A stable and adaptive semi-Lagrangian potential
+ model for unsteady and nonlinear ship-wave
+ interactions</strong>
+ <br>
+ Engineering Analysis with Boundary Elements, vol. 37,
+ pp. 128-143, 2013.
+ </li>
+
<li> R. H. Nochetto, A. J. Salgado, I. Tomas
<br>
<strong>The micropolar Navier-Stokes equations: A priori error analysis</strong>
arXiv:1303.7005, submitted, 2013.
</li>
+ <li> T. Povall
+ <br>
+ <strong>Single Crystal Plasticity at Finite Strains: A Computational Investigation of Hardening Relations</strong>
+ <br>
+ MSc Thesis, University of Cape Town, 2013.
+ </li>
+
+ <li> T. Reis, W. Wollner
+ <br>
+ <strong>Iterative solution of operator Lyapunov equations
+ arising in heat transfer
+ </strong>
+ <br>
+ 2013 European Control Conference, Zurich Switzerland,
+ pp. 41-46, 2013.
+ </li>
+
+ <li> T. Richter, T. Wick
+ <br>
+ <strong>Optimal Control and Parameter Estimation for Stationary Fluid-Structure Interaction Problems
+ </strong>
+ <br>
+ SISC, accepted in May, 2013.
+ </li>
+
<li> S. Roy, L. Heltai, D. Drapaca, F. Costanzo
<br>
<strong>An immersed finite element method approach for brain biomechanics</strong>
(eds.), Spinger Verlag, pp. 293-303, 2013.
</li>
+ <li> M. Sagebaum, N. R. Gauger, U. Naumann, J. Lotz, K. Leppkes
+ <br>
+ <strong>Algorithmic differentiation of a complex C++ code with underlying libraries
+ </strong>
+ <br>
+ Procedia Computer Science, vol. 18, pp. 208-217, 2013.
+ </li>
+
+ <li> P. Siehr
+ <br>
+ <strong>Stabilisierungsmethoden für die Stokes-Gleichungen
+ </strong>
+ <br>
+ Bachelor thesis, University of Heidelberg, Germany, 2013.
+ </li>
+
+ <li>
+ M. Steigemann, B. Schramm
+ <br>
+ <strong>Precise computation and error control of stress
+ intensity factors and certain integral characteristics in
+ anisotropic inhomogeneous materials
+ </strong>
+ <br>
+ International Journal of Fracture, vol. 182, pp. 67-91, 2013.
+ </li>
+
+ <li> M. Stoll, T. Breiten
+ <br>
+ <strong>A low-rank in time approach to PDE-constrained optimization</strong>
+ <br>
+ Max Planck Institute Magdeburg, Preprint MPIMD/13-08, 2013.
+ </li>
+
<li> N. Vakulin, R. Shaw, T. Livingston
<br>
<strong>ELEC 490, final report: High performance computing with GPUs
2013
</li>
+ <li> A. Vidal-Ferrandiz, R. Fayez, D. Ginestar, G. Verdú
+ <br>
+ <strong>Solution of the Lambda modes problem of a nuclear
+ power reactor using an h-p finite element method
+ </strong>
+ <br>
+ Conference abstract, Mathematical Modelling in Engineering &
+ Human Behaviour 2013, 2013.
+ </li>
+
+ <li> T. Wick, A. H. Elsheikh, M.F. Wheeler
+ <br>
+ <strong>Parameter Estimation for the Coupled Biot-Lam\'e-Navier Problem in Subsurface Modeling
+ </strong>
+ <br>
+ ARMA Conference in San Francisco, Jun 23-26, 2013.
+ </li>
+
+ <li> J. Weinbub, K. Rupp, S. Selberherr
+ <br>
+ <strong>ViennaX: a parallel plugin execution framework for
+ scientific computing
+ </strong>
+ <br>
+ Engineering with Computers, DOI 10.1007/s00366-013-0314-1, February 2013.
+ </li>
+
+ <li> T. Wick
+ <br>
+ <strong>Flapping and Contact FSI Computations with the
+ Fluid-Solid Interface-Tracking/Interface-Capturing Technique
+ and Mesh Adaptivity
+ </strong>
+ <br>
+ Comp. Mech., DOI: 10.1007/s00466-013-0890-3, 2013.
+ </li>
+
+ <li> T. Wick
+ <br>
+ <strong>Coupling of fully Eulerian and arbitrary Lagrangian-Eulerian
+ methods for fluid-structure interaction computations
+ </strong>
+ <br>
+ Comp. Mech., DOI: 10.1007/s00466-013-0866-3, 2013.
+ </li>
+
+ <li> T. Wick
+ <br>
+ <strong>Solving monolithic fluid-structure interaction
+ problems in arbitrary
+ Lagrangian Eulerian coordinates
+ with the deal.II library
+ </strong>
+ <br>
+ ANS, vol. 1, pp. 1-19, 2013. http://www.archnumsoft.org/
+ </li>
+
+ <li> T. Wick
+ <br>
+ <strong>Fully Eulerian fluid-structure interaction for time-dependent problems
+ </strong>
+ <br>
+ Comp. Methods Appl. Mech. Engrg., vol. 255, pp. 14-26, 2013.
+ </li>
+
+ <li> J. Willems
+ <br>
+ <strong>Robust Multilevel Solvers for High-Contrast Anisotropic
+ Multiscale Problems
+ </strong>
+ <br>
+ Journal of Computational and Applied Mathematics, 251:47-60, 2013, doi:10.1016/j.cam.2013.03.030.
+ </li>
+
+ <li> J. Willems
+ <br>
+ <strong>Spectral Coarse Spaces in Robust Two-Level Schwartz Methods
+ </strong>
+ <br>
+ O. Iliev, S. Margenov, P. Minev, P. Vassilevski, L. Zikatanov, editors, Numerical Solution of Partial Differential Equations: Theory, Algorithms and their Applications, 303-326, Springer Proceedings in Mathematics & Statistics, Springer, 2013.
+ </li>
+
<li> S. Yoon, Y. T. Kang
<br>
<strong>Mass transfer enhancement in non-Brownian particle
pp. 114-124, 2013.
</li>
+ <li> <a href="http://www.ippt.gov.pl/~tyoung"
+ target="_top">T. D. Young</a>
+ <br>
+ <strong>A finite basis grid analysis of the Hartree-Fock wavefunction method for one- and two-electron atoms
+ </strong>
+ <br>
+ AIP Conf. Proc., Accepted, 2013.
+ </li>
+
<li> <a href="http://www.ippt.gov.pl/~tyoung"
target="_top">T. D. Young</a>, E. Romero, J. E. Roman
<br>
<!-- http://www-m1.ma.tum.de/bin/view/Lehrstuhl/PublikationenUlbrich -->
</li>
- <li> A. Bonito, I. Kyza, R. H. Nochetto
- <br>
- <strong>Time-discrete higher order ALE formulations: a
- priori error analysis</strong>
- <br>
- Numer. Math., to appear, 2012.
- </li>
-
- <li> A. Bonito, I. Kyza, R. H. Nochetto
- <br>
- <strong>Time-discrete higher order ALE formulations: stability</strong>
- <br>
- SIAM J. Numer. Anal., to appear, 2012.
- </li>
-
<li>
M. Braack, G. Lube, L. Röhe
<br>
PhD Thesis, Karlsruhe Institute of Technology (KIT), 2012.
</li>
- <li> A. Cangiani, J. Chapman, E. Georgoulis, M. Jensen
- <br>
- <strong>Implementation of the Continuous-Discontinuous
- Galerkin Finite Element Method</strong>
- <br>
- arXiv:1201.2878v1 [math.NA], 2012.
- <!-- http://www2.le.ac.uk/departments/mathematics/extranet/staff-material/staff-profiles/eg64/publications -->
- <!-- http://arxiv.org/abs/1201.2878 -->
- </li>
-
<li> A. Cangiani, J. Chapman, E. Georgoulis, M. Jensen
<br>
<strong>On Local Super-Penalization of Interior Penalty Discontinuous Galerkin Methods</strong>
Electrochimica Acta, Volume 77, pp. 309-314, 2012.
</li>
- <li> C.-C. Chueh, N. Djilali, W. Bangerth
- <br>
- <strong>An h-adaptive Operator Splitting Method for
- Two-phase Flow in 3D Heterogeneous Porous Media</strong>
- <br>
- Preprint, Institute for Applied Mathematics and
- Computational Science, Texas A&M University, 2012.
- </li>
-
<li> A. Demlow, A. H. Georgoulis
<br>
<strong>Pointwise a posteriori error control for
Journal of the Electrochemical Society, 159(5), B1-B10, 2012.
</li>
- <li> T. Dohnal, W. Dörfler
- <br>
- <strong>Coupled Mode Equation Modeling for Out-of-Plane Gap
- Solitons in 2D Photonic Crystals</strong>
- <br>
- arXiv:1202.3583v1 [nlin.PS], 2012.
- </li>
-
<li> Y. Efendiev, J. Galvis, R. Lazarov, J. Willems
<br>
<strong>Robust domain decomposition preconditioners for abstract
Journal of Computational Physics, vol. 231, pp. 3166–3180, 2012.
</li>
- <li> J. Fang, X. Gao, A. Zhou
- <br>
- <strong>A finite element recovery approach to eigenvalue
- approximations with applications to electronic structure
- calculations
- </strong>
- <br>
- Journal of Scientific Computing, in press, 2012.
- <!-- http://link.springer.com/article/10.1007/s10915-012-9640-5?LI=true# -->
- </li>
-
<li> T. Fankhauser
<br>
<strong>An hp-adaptive strategy based on smoothness
Submitted to ACM Trans. Math. Softw., 2011.
</li>
+ <li> C. Goll, T. Wick, W. Wollner
+ <br>
+ <strong>DOpElib: Differential Equations and Optimization Environment;
+A Goal Oriented Software Library for Solving PDEs and Optimization Problems with PDEs
+ </strong>
+ <br>
+ submitted in Dec 2012.
+ </li>
+
<li> N. Gupta, N. Nataraj
<br>
<strong>A posteriori error estimates for an optimal control
Springer. In press.
</li>
- <li> T. Heister, G. Rapin
- <br>
- <strong>Efficient augmented Lagrangian-type preconditioning
- for the Oseen problem using Grad-Div stabilization</strong>
- <br>
- Int. J. Num. Meth. Fluids, 2013, 71, 118–134.
- (<a href="http://dx.doi.org/10.1002/fld.3654">DOI</a>)
- </li>
-
<li> L. Heltai, S. Roy, F. Costanzo
<br>
<strong>A Fully Coupled Immersed Finite Element Method for
Journal of the Mechanics and Physics of Solids, vol. 60, pp. 1221-1239, 2012.
</li>
- <li> A. Mola, L. Heltai, A. DeSimone
- <br>
- <strong>A stable and adaptive semi-Lagrangian potential
- model for unsteady and nonlinear ship-wave
- interactions</strong>
- <br>
- arXiv:1203.3384v1 [math.NA], 2012.
- </li>
-
<li> C. Neuen, M. Griebel, J. Hamaekers
<br>
<strong>Multiscale simulation of ion migration for battery system
50<sup>th</sup> AIAA Aerospace Sciences Meeting, AIAA 2012-458, 2012.
</li>
- <li> J. Willems
- <br>
- <strong>Robust multilevel methods for general symmetric positive
- definite operators
- </strong>
- <br>
- RICAM Report 2012-06, 2012.
- </li>
- <li> J. Willems
- <br>
- <strong>Robust multilevel methods for high-contrast anisotropic
- multiscale problems
- </strong>
+ <li> T. Wick
+ <br>
+ <strong>Goal-oriented mesh adaptivity for fluid-structure interaction with application to heart-valve settings
+ </strong>
<br>
- RICAM Report 2012-07, 2012.
- </li>
+ Arch. Mech. Engrg., vol. 59, pp. 73-99, 2012.
+ </li>
+
+
<li> J. Willems
<br>
- <strong>Spectral coarse spaces in robust two-level methods
+ <strong>Robust multilevel methods for general symmetric positive
+ definite operators
</strong>
<br>
- RICAM Report 2012-20, 2012.
+ RICAM Report 2012-06, 2012.
</li>
<li> S. Yoon, M. A. Walkley, O. G. Harlen
Comp. Geosc., vol. 15, pp. 647-659, 2011.
</li>
- <li> T. Wick
- <br>
- <strong>Fluid-Structure Interaction based on Monolithic Variational
- Formulations with Different Types of Pseudo-Structure Extension
- </strong>
- <br>
- submitted, 2010
- </li>
-
<li> T. Wick
<br>
<strong>Fluid-structure interactions using different mesh motion techniques
Computers and Structures, vol. 89, pp. 1456-1467, 2011.
</li>
- <li> T. Wick
- <br>
- <strong>Solving Monolithic Fluid-Structure Interaction Problems in
- Arbitrary Lagrangian Eulerian Coordinates with the deal.II Library
- </strong>
- <br>
- IWR Report, University of Heidelberg, Germany, 2011.
- </li>
-
<li> T. Wick
<br>
<strong>Adaptive finite element simulation of fluid-structure
Diploma Thesis, University of Heidelberg, Germany, 2010
</li>
- <li>
- T. Wick
- <br>
- <strong>Monolithic Fluid-Structure Interaction Modelling for
- a Long Axis Heart Valve Simulation
- </strong>
- <br>
- Preprint, IWR Heidelberg, Germany, 2010
- </li>
-
<li> <a href="http://www.ippt.gov.pl/~tyoung"
target="_top">T. D. Young</a>, R. Armiento
<Br>
basis
</strong>
<br>
- In George Maroulis and Theodore E. Simos, editors,
- Computational Methods in Science and Engineering: Advances in
- Computational Science, number 1108, New York, USA, Mar
- 2009. Proceedings of the International Conference on Computational
- Methods in Sciences and Engineering, American Institute of Physics
- Conference Proceedings, 2009.
+ AIP Conf. Proc., vol. 1148, pp. 285-289 2009.
</li>
<li> R. Ziegler, B. Brendel, A. Schipper, R. Harbers, M. van Beek,
</li>
</ol>
- <hr>
-
- <address>
- <a href="../mail.html">The deal.II Group</a></address>
+ <hr />
+ <address>
+ <a href="authors.html" target="body">The deal.II Authors</a>
+ </address>
+ <div class="right">
+ <a href="http://validator.w3.org/check?uri=referer" target="_top">
+ <img style="border:0" src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
+ <a href="http://jigsaw.w3.org/css-validator/check/referer" target="_top">
+ <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
+ </div>
</body>
</html>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/html4/loose.dtd">
-<html>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>The deal.II Readme</title>
- <link href="screen.css" rel="StyleSheet">
- <meta name="author" content="the deal.II authors <authors @ dealii.org>">
- <meta name="copyright" content="Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors">
- <meta name="date" content="$Date$">
- <meta name="svn_id" content="$Id$">
- <meta name="keywords" content="deal.II">
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+ <link href="screen.css" rel="StyleSheet"/>
+ <meta name="author" content="the deal.II authors <authors@dealii.org>"/>
+ <meta name="copyright" content="Copyright (C) 1998 - 2013 by the deal.II authors"/>
+ <meta name="date" content="$Date$"/>
+ <meta name="svn_id" content="$Id$"/>
+ <meta name="keywords" content="deal.II"/>
</head>
<body>
<h2 align="center" style="color: red">
- <strong class="red">Note: Current development sources
- use <a href="http://www.cmake.org" target="_top">CMake</a> to
- build <acronym>deal.II</acronym>. For using the previous build
+ <strong class="red">Note: <acronym>deal.II</acronym> uses
+ <a href="http://www.cmake.org" target="_top">CMake</a> to
+ configure and build. For using the previous build
system used until <acronym>deal.II</acronym> version 7.3, see
<a href="http://www.dealii.org/7.3.0/readme.html"
target="_top">the old ReadMe file</a>.
</h2>
- <h1>Installation instructions and further information
- on <acronym>deal.II</acronym> </h1>
-
- <table class="tutorial" width="60%">
- <tr><th colspan="2"><b><small>Table of contents</small></b></th></tr>
- <tr><td valign="top">
- <ul>
- <li> <a href="#prerequisites">System requirements</a>
- <ul>
- <li> <a href="#supported">Supported platforms</a>
- <li> <a href="#additional-software">Additional software requirements</a>
- </ul>
- <li> <a href="#installation">Installation</a>
- <ul>
- <li> <a href="#unpacking">Unpacking</a>
- <li> <a href="#configuration">Configuring and building the library</a>
- <li> <a href="#documentation">Configuring and building the documentation</a>
- <li> <a href="#configuration-options">Configuration options</a>
- <ul>
- <li> <a href="#optional">Selecting optional behavior</a>
- <li> <a href="#optional-software">Optional interfaces to
- other software packages</a>
- <li> <a href="#conf-details">More information on configuring
- and building the library</a>
- </ul>
- </ul>
- <li> <a href="#problems">Problems, questions, mailing lists</a>
- <li> <a href="#license">License</a>
- </ul>
- </td>
- </tr>
- </table>
-
-
- <a name="prerequisites"></a>
- <h2>System requirements</h2>
-
- <a name="supported"></a>
- <h3>Supported platforms</h3>
-
- <p>
- <acronym>deal.II</acronym> is mostly developed on Linux using the
- <a href="http://gcc.gnu.org">GCC</a> compiler. However, it is not
- platform specific and we strive to keep the source code C++
- Standard compliant.
- </p>
-
- <p>
- <acronym>deal.II</acronym> supports at least the following
- platforms:
- <ul>
- <li>GNU/Linux: GCC version 4.0 or later;
- Clang version 3.0 or later; ICC version 12 or later
- <li>Mac OS X: GCC version 4.0 or later; Clang version 3.0 or later
- (Please see the <a href="https://code.google.com/p/dealii/w/list"
- target="_top">deal.II Wiki</a> for installation issues)
- <li>Windows: <a href="http://www.cygwin.com"
- target="_top">Cygwin</a> with recent GCC or Clang versions.
- Native Windows support with recent <a
- href="http://www.mingw.org/">MinGW</a> compiler. For <a
- href="https://code.google.com/p/dealii/wiki/Windows"
- target="_top">installing on Windows</a>, please refer to
- additional information on the <a
- href="https://code.google.com/p/dealii/w/list"
+<h1>Installation instructions and further information
+ on <acronym>deal.II</acronym> </h1>
+
+<div class="toc">
+ <ol>
+ <li> <a href="#prerequisites">System requirements</a>
+ <ol>
+ <li> <a href="#supported">Supported platforms</a></li>
+ <li> <a href="#additional-software">Additional software requirements</a></li>
+ </ol>
+ </li>
+ <li> <a href="#installation">Installation</a>
+ <ol>
+ <li> <a href="#unpacking">Unpacking</a></li>
+ <li> <a href="#configuration">Configuring and building the library</a></li>
+ <li> <a href="#documentation">Configuring and building the documentation</a></li>
+ <li> <a href="#configuration-options">Configuration options</a>
+ <ol>
+ <li> <a href="#optional">Selecting optional behavior</a></li>
+ <li> <a href="#optional-software">Optional interfaces to
+ other software packages</a></li>
+ <li> <a href="#conf-details">More information on configuring
+ and building the library</a></li>
+ </ol>
+ </li>
+ </ol>
+ </li>
+ <li> <a href="#problems">Problems, questions, mailing lists</a></li>
+ <li> <a href="#license">License</a></li>
+ </ol>
+</div>
+
+<a name="prerequisites"/>
+<h2>System requirements</h2>
+
+<a name="supported"/>
+<h3>Supported platforms</h3>
+
+<p>
+ <acronym>deal.II</acronym> is mostly developed on Linux using the
+ <a href="http://gcc.gnu.org">GCC</a> compiler. However, it is not
+ platform specific and we strive to keep the source code C++ Standard
+ compliant.
+</p>
+
+<p>
+ <acronym>deal.II</acronym> supports at least the following
+ platforms:
+</p>
+<ul>
+ <li>GNU/Linux: GCC version 4.0 or later;
+ Clang version 3.0 or later; ICC version 12 or later</li>
+ <li>Mac OS X: GCC version 4.0 or later; Clang version 3.0 or later
+ (Please see the <a href="https://code.google.com/p/dealii/w/list"
+ target="_top">deal.II Wiki</a> for installation issues)</li>
+ <li>Windows: <a href="http://www.cygwin.com"
+ target="_top">Cygwin</a> with recent GCC or Clang versions.
+ Native Windows support with recent
+ <a href="http://www.mingw.org/">MinGW</a> compiler.
+ For <a href="https://code.google.com/p/dealii/wiki/Windows"
+ target="_top">installing on Windows</a>, please refer to
+ additional information on the <a href="https://code.google.com/p/dealii/w/list"
target="_top">deal.II Wiki</a> and have a look at the <a
href="https://code.google.com/p/dealii/issues/list">bug
- tracker</a>!
- </ul>
- Most other combinations of POSIX-style operating systems and C++
- Standard compliant compilers should also work. <i>If they don't,
- please report it as a bug.</i>
- </p>
+ tracker</a>!</li>
+</ul>
+<p>
+ Most other combinations of POSIX-style operating systems and C++
+ Standard compliant compilers should also work. <i>If they don't,
+ please report it as a bug.</i>
+</p>
- <p>
- Please note that the Microsoft Visual C++ compiler, that is widely
- used on Microsoft Windows, is not supported. If you need a native
- Windows target, use the MinGW compiler instead.
- </p>
+<p>
+ Please note that the Microsoft Visual C++ compiler, that is widely
+ used on Microsoft Windows, is not supported. If you need a native
+ Windows target, use the MinGW compiler instead.
+</p>
- <a name="additional-software"></a>
- <h3>Additional software requirements</h3>
+<a name="additional-software"></a>
+<h3>Additional software requirements</h3>
<p>
In order to compile and use <acronym>deal.II</acronym>
you need to have the following programs installed:
</p>
<ul>
- <li> <p>
- <a href="http://www.cmake.org/" target="_top">CMake</a> version 2.8.8 or later
- </p>
-
- <li> <p>
- <a href="http://www.gnu.org/software/make/" target="_top">GNU make</a>, version
- 3.78 or later (or any other generator supported by CMake)
- </p>
+ <li>
+ <a href="http://www.cmake.org/" target="_top">CMake</a> version 2.8.8 or later
+ </li>
+
+ <li>
+ <a href="http://www.gnu.org/software/make/" target="_top">GNU make</a>, version
+ 3.78 or later (or any other generator supported by CMake)
+ </li>
- <li> <p>
- For generating the documentation:
- <a href="http://www.perl.org/" target="_top">Perl 5.x</a>,
- <a href="http://www.doxygen.org/" target="_top">doxygen</a>
- and <code>dot</code>, which is part of the
- <a href="http://www.graphviz.org" target="_top">GraphViz</a>
- package
- </p>
+ <li>
+ For generating the documentation:
+ <a href="http://www.perl.org/" target="_top">Perl 5.x</a>,
+ <a href="http://www.doxygen.org/" target="_top">doxygen</a>
+ and <code>dot</code>, which is part of the
+ <a href="http://www.graphviz.org" target="_top">GraphViz</a>
+ package
+ </li>
- <li> <p>
+ <li>
For debugging programs, we have found that the
<a href="http://www.gnu.org/software/gdb/" target="_top">GNU
debugger GDB</a> is an invaluable tool. GDB is a text-based tool
like <a href="http://www.kdevelop.org/" target="_top">kdevelop</a>
or <a href="http://eclipse.org/" target="_top">Eclipse</a> have built
in debuggers as well.
- </p>
+ </li>
<li> <p>
- The library generates output in formats readable by
- <a href="http://www.ucc.ie/gnuplot/gnuplot-faq.html" target="_top">GNUPLOT</a>,
- <a href="http://www-xdiv.lanl.gov/XCM/gmv/" target="_top">GMV
- (general mesh viewer)</a>,
- <a href="http://www.amtec.com" target="_top">Tecplot</a> (ASCII and binary),
- <a href="http://public.kitware.com/VTK/"
- target="_top">Visualization Toolkit (Vtk)</a>,
- <a href="http://www.avs.com" target="_top">AVS Explorer</a>,
- <a href="http://www.opendx.org" target="_top">Open DX</a>,
- <a href="http://www.povray.org" target="_top">Povray</a>,
- and directly to Encapsulated Postscript.
- </p>
+ The library generates output in formats readable by
+ <a href="http://www.ucc.ie/gnuplot/gnuplot-faq.html" target="_top">GNUPLOT</a>,
+ <a href="http://www-xdiv.lanl.gov/XCM/gmv/" target="_top">GMV
+ (general mesh viewer)</a>,
+ <a href="http://www.amtec.com" target="_top">Tecplot</a> (ASCII and binary),
+ <a href="http://public.kitware.com/VTK/"
+ target="_top">Visualization Toolkit (Vtk)</a>,
+ <a href="http://www.avs.com" target="_top">AVS Explorer</a>,
+ <a href="http://www.opendx.org" target="_top">Open DX</a>,
+ <a href="http://www.povray.org" target="_top">Povray</a>,
+ and directly to Encapsulated Postscript.
+ </p>
+
<p>
<code>gnuplot</code>
and a postscript viewer (for <code>eps</code>) should be
converted into output (without references to cells, nodes,
types of finite elements, and the like).
</p>
+ </li>
</ul>
-
-
-
- <a name="installation"></a>
+ <a name="installation"/>
<h2>Installation</h2>
-
- <a name="unpacking"></a>
+
+ <a name="unpacking"/>
<h3>Unpacking</h3>
<p>
The whole library usually comes as a <code>tar.gz</code> file,
which is a file archive compressed with gzip. After downloading it,
unpack it using either
- <pre>
-
- gunzip deal.II-X.Y.Z.tar.gz
- tar xf deal.II-X.Y.Z.tar
- </pre>
- or, if you have GNU tar with
- <pre>
-
- tar -xvf deal.II-X.Y.Z.tar.gz
- </pre>
- <b>Note:</b> You will want to hang on to the source files
- of <acronym>deal.II</acronym> after installation as it makes developing
- much simpler. Consequently, you should do the steps above in a permanent
- directory, not on <code>/tmp</code> as one often does when installing
- software.
</p>
+<pre>
+ gunzip deal.II-X.Y.Z.tar.gz
+ tar xf deal.II-X.Y.Z.tar
+</pre>
+<p>or, if you have GNU tar with</p>
+<pre>
+ tar -xvf deal.II-X.Y.Z.tar.gz
+</pre>
+
+<p><b>Note:</b> You will want to hang on to the source files
+ of <acronym>deal.II</acronym> after installation as it makes
+ developing much simpler. Consequently, you should do the steps above
+ in a permanent directory, not on <code>/tmp</code> as one often does
+ when installing software.
+</p>
<a name="configuration"></a>
<h3>Configuring and building the library</h3>
<a href="http://www.cmake.org/" target="_top">CMake</a>
integrated configuration and build system. Unpacking will create a
subdirectory <tt>deal.II/</tt> in the current directory. Then do the
- following steps:
- <pre>
-
- mkdir build
- cd build
- cmake -DCMAKE_INSTALL_PREFIX=/path/install/dir ../deal.II
- make
- make install
- </pre>
- These steps compile, link and install the deal.II library. The
- whole process should take between a few minutes and an hour, depending
- on your machine.
- </p>
+ following steps:</p>
+
+<pre>
+ mkdir build
+ cd build
+ cmake -DCMAKE_INSTALL_PREFIX=/path/to/install/dir ../deal.II
+ make install
+</pre>
+
+<p>
+ These steps compile, link and install the deal.II library. The
+ whole process should take between a few minutes and an hour, depending
+ on your machine.
+</p>
<p>
- <b>Note:</b>
+ <b>Note:</b></p>
<ul>
- <li> <code>/path/install/dir</code> is the directory which deal.II
+ <li> <code>/path/to/install/dir</code> is the directory which deal.II
should be installed into. This can be a directory in your home
directory (e.g., <code>~/bin/deal.II</code>) or a directory
- such as <code>/usr/local</code> if you have root privileges.
+ such as <code>/usr/local</code> if you have root privileges.
+ Another option is to use something like <code>`pwd`/../installed/</code> (note the
+ backticks). Make sure the installation directory is not the same
+ as the location where you unpacked <tt>deal.II/</tt>.
+ </li>
<li> If your machine has multiple processors, use <code>make
- -jN</code> in the last two steps, where <code>N</code> is the
+ -jN</code> in the last step, where <code>N</code> is the
number of simultaneous build processes you want <code>make</code>
to use at any given time. Allowing <code>make</code> to use
more simultaneous build processes (assuming you have that many
processor cores) will greatly lower the build time.
+ </li>
<li> If you do not intend to modify the <acronym>deal.II</acronym>
sources and recompile things, then you can remove
the <code>build/</code> directory after the last step.
+ </li>
<li> In principle, after installing <acronym>deal.II</acronym>, you
can remove the source directory as well (i.e., the directory into
files around anyway, for one reason: When
debugging you often end up with assertions for which you'd like to
see the place in the library's source files that triggered it.
+ </li>
<li> The <acronym>deal.II</acronym> <code>CMake</code> system can accept a
significant number of configuration parameters. See the
discussion <a href="#configuration-options">below</a>.
+ </li>
<li> If you are changing part of the <acronym>deal.II</acronym>
code itself, you can re-compile the library using only the
However, this sometimes leads to surprising results and you may
not get exactly what you were hoping for. For more information,
see <a href="development/cmake.html">here</a>.
-
+ </li>
</ul>
- </p>
<p>
The commands above build and install the <acronym>deal.II</acronym>
libraries in two variants:
- <ul>
- <li>
- <p><i>Debug mode</i>: This version of the
- library is compiled with compiler flags so
- that the library contains information that can be used by debuggers.
- </p>
-
- <p>
- In addition, this library contains a great number of safety
- checks on most arguments of all functions you could possibly call.
- These assertions have proven to be an
- invaluable means to finding programming bugs since they will
- almost always abort your program if something goes wrong. In our
- experience, more than ninety per cent of all errors are invalid
- parameters (such as vectors having the wrong size, etc.) and they
- are usually found almost instantaneously, displaying the file
- name and line number of where the problem occurred.
- </p>
-
+ </p>
+ <ul>
+ <li>
+ <p><i>Debug mode</i>: This version of the
+ library is compiled with compiler flags so
+ that the library contains information that can be used by debuggers.
+ </p>
+
+ <p>
+ In addition, this library contains a great number of safety
+ checks on most arguments of all functions you could possibly call.
+ These assertions have proven to be an
+ invaluable means to finding programming bugs since they will
+ almost always abort your program if something goes wrong. In our
+ experience, more than ninety per cent of all errors are invalid
+ parameters (such as vectors having the wrong size, etc.) and they
+ are usually found almost instantaneously, displaying the file
+ name and line number of where the problem occurred.
+ </p>
+ </li>
+
<li> <i>Optimized mode</i>: You will want to link with this version of
the library once you know that your program is working as
expected. It does not contain the safety checks any more
and is compiled with aggressive compiler optimizations. The
resulting executables are smaller and will run between 2 and 10
times faster than the debug executables.
- </p>
+ </li>
</ul>
- </p>
<p>
At this point, you have generated everything necessary to write
be found at the <a href="http://www.dealii.org/" target="_top">
http://www.dealii.org/</a> domain can also be generated locally. To do
so, invoke <code>cmake</code> in the build instructions above as follows:
- <pre>
-
- cmake -DDEAL_II_COMPONENT_DOCUMENTATION=ON -DCMAKE_INSTALL_PREFIX=/path/install/dir ../deal.II
- </pre>
- For this to succeed, you will need <a href="http://www.perl.org/"
- target="_top">Perl 5.x</a>,
- <a href="http://www.doxygen.org/" target="_top">doxygen</a>
- and <code>dot</code> (which is part of
- the <a href="http://www.graphviz.org" target="_top">GraphViz</a>
- package) to be installed.
</p>
+
+<pre>
+ cmake -DDEAL_II_COMPONENT_DOCUMENTATION=ON -DCMAKE_INSTALL_PREFIX=/path/install/dir ../deal.II
+</pre>
+
+<p>
+ For this to succeed, you will need <a href="http://www.perl.org/"
+ target="_top">Perl 5.x</a>,
+ <a href="http://www.doxygen.org/" target="_top">doxygen</a>
+ and <code>dot</code> (which is part of
+ the <a href="http://www.graphviz.org" target="_top">GraphViz</a>
+ package) to be installed.
+</p>
<p>
Upon calling <code>make</code> and <code>make install</code>, this will
paths.</b>
However, this behavior can be changed using command line switches to
the initial call to <code>cmake</code>. A detailed description
- can be found <a href="development/cmake.html">here</a>.
+ can be found here: <a href="development/cmake.html">Detailed build system description</a>.
</p>
<p>
options.
</p>
- <a name="optional">
- <h4>Selecting optional behavior</h4></a>
+ <a name="optional"/>
+ <h4>Selecting optional behavior</h4>
<ul>
<li>
threading off by passing the <code>-DDEAL_II_WITH_THREADS=OFF</code>
argument to <code>cmake</code>.
</p>
+ </li>
<li>
<p>
specifically do not want to use it, then
pass <code>-DDEAL_II_WITH_MPI=OFF</code>.
</p>
+ </li>
<li>
<p>
<code>-DDEAL_II_COMPONENT_PARAMETER_GUI=ON</code>. Beware of the
fact that <code>parameter_gui</code> needs development packages for Qt.
</p>
+ </li>
+
+ <li>
+ <p>
+ <i>64bit indices</i>: By default, deal.II use unsigned int (32bit)
+ indices for degrees of freedom, using
+ the <code>types::global_dof_index</code> type. This limits the number of
+ unknowns to approximately four
+ billions. If larger problem must be solved, pass the
+ <code>-DDEAL_II_WITH_64BIT_INDICES=ON</code> argument to
+ <code>cmake</code>. You will not be able to solve problems of this size on
+ a single machine, but only when using clusters of computers and linear
+ algebra packages PETSc or Trilinos.
+ To use this option with PETSc, PESTc must be compiled
+ with the option <code>--with-64-bit-indices</code>. To use this option
+ with Trilinos, Trilinos 11.2 or later is needed (there is a bug in
+ Trilinos 11.0 that prevents the use of 64bit indices).
+ </p>
+ </li>
</ul>
- <a name="optional-software"></a>
+ <a name="optional-software"/>
<h4>Optional interfaces to other software packages</h4>
<p>
can be configured.
</p>
- <p>
- <b>Notes:</b>
+ <p><b>Notes:</b></p>
<ul>
<li>
<b>The majority of libraries mentioned below should be readily
e.g. ending in <code>-dev</code> or <code>-devel</code>.
After that <code>cmake</code> will automatically find the
library and use it.</b>
+ </li>
<li>
Configuring the interface to a self compiled package,
say <code>foo</code> can usually be done by specifying
you invoke <code>cmake</code> in a fresh build directory.
Any value passed on the command line wins over a value that
may be found in an environment variable.
+ </li>
<li>
To explicitly enable or disable support for
a library <code>foo</code> use the argument
<code>-DDEAL_II_WITH_FOO=ON</code> resp.
<code>-DDEAL_II_WITH_FOO=OFF</code> for <code>cmake</code>.
+ </li>
</ul>
- </p>
<dl>
- <a name="ARPACK"></a>
- <dt><a href="http://www.caam.rice.edu/software/ARPACK/" target="_top">ARPACK</a></dt>
+ <dt><a name="ARPACK"/>
+ <a href="http://www.caam.rice.edu/software/ARPACK/" target="_top">ARPACK</a></dt>
<dd>
<p>
<a href="http://www.caam.rice.edu/software/ARPACK/"
scale eigenvalue problems.
<a href="http://www.caam.rice.edu/software/ARPACK/" target="_top">ARPACK</a>
should be readily packaged by most Linux distributions.
- (Don't forget to install a develpment version of the library).
+ (Don't forget to install a development version of the library).
To use a self compiled version, specify
<code>-DARPACK_DIR=/path/to/arpack</code> on the command line.
</p>
</dd>
- <a name="blas"></a>
<dt>
+ <a name="blas"></a>
<a href="http://www.netlib.org/blas/" target="_top">BLAS</a>,
<a href="http://www.netlib.org/lapack/" target="_top">LAPACK</a>
</dt>
matrices.
Both libraries should be packaged by almost all Linux
distributions and found automatically whenever available.
- (You might have to install develpment versions of the libraries
+ (You might have to install development versions of the libraries
for <acronym>deal.II</acronym> being able to use them).
For details on how to set up <acronym>deal.II</acronym> with a
non standard BLAS/LAPACK implementation, see the
</p>
</dd>
- <a name="functionparser"></a>
- <dt><a href="http://warp.povusers.org/FunctionParser/">FunctionParser</a></dt>
+ <dt>
+ <a name="functionparser"></a>
+ <a href="http://warp.povusers.org/FunctionParser/">FunctionParser</a>
+ </dt>
<dd>
<p>
<a href="http://warp.povusers.org/FunctionParser/">FunctionParser</a>
</p>
</dd>
- <a name="HDF5"></a>
- <dt><a href="http://www.hdfgroup.org/HDF5/">HDF5</a></dt>
+
+ <dt><a name="HDF5"></a><a href="http://www.hdfgroup.org/HDF5/">HDF5</a></dt>
<dd>
<p>
The <a href="http://www.hdfgroup.org/HDF5/">HDF5 library</a>
format.
<a href="http://www.hdfgroup.org/HDF5/">HDF5</a> should be
readily packaged by most Linux distributions. (Don't forget
- to install a develpment version of the library).
+ to install a development version of the library).
To use a self compiled version, specify
<code>-DHDF5_DIR=/path/to/hdf5</code> on the command line.
</p>
</dd>
- <a name="metis"></a>
- <dt><a href="http://glaros.dtc.umn.edu/gkhome/metis/metis/overview"
+
+ <dt><a name="metis"></a><a href="http://glaros.dtc.umn.edu/gkhome/metis/metis/overview"
target="_top">METIS</a></dt>
<dd>
<p>
</p>
</dd>
- <a name="mumps"></a>
- <dt><a href="http://mumps.enseeiht.fr" target="_top">MUMPS</a></dt>
+
+ <dt><a name="mumps"></a><a href="http://mumps.enseeiht.fr" target="_top">MUMPS</a></dt>
<dd>
<p>
<a href="http://mumps.enseeiht.fr" target="_top">MUMPS</a>
across nodes of a cluster.
<a href="http://mumps.enseeiht.fr" target="_top">MUMPS</a>
should be readily packaged by most Linux distributions.
- (Don't forget to install a develpment version of the library).
+ (Don't forget to install a development version of the library).
To use a self compiled version, provide the
<code>-DMUMPS_DIR=/path/to/mumps</code> argument to <code>cmake</code>.
For a detailed description on how to compile MUMPS (and
</p>
</dd>
- <a name="netcdf"></a>
- <dt><a href="http://www.unidata.ucar.edu/software/netcdf/" target="_top">NetCDF</a></dt>
+
+ <dt><a name="netcdf"></a><a href="http://www.unidata.ucar.edu/software/netcdf/" target="_top">NetCDF</a></dt>
<dd>
- <p>
- <a href="http://www.unidata.ucar.edu/software/netcdf/"
- target="_top">NetCDF</a> is a library that provides services for
- reading and writing mesh data (and many other
- things). <acronym>deal.II</acronym> can use it to read meshes via
- one of the functions of the <code>GridIn</code> class.
- <a href="http://www.unidata.ucar.edu/software/netcdf/"
- target="_top">NetCDF</a> should be readily packaged by most
- Linux distributions. (Don't forget to install a develpment
- version of the library). To use a self compiled version, pass
- <code>-DNETCDF_DIR=/path/to/netcdf</code> to <code>cmake</code>.
+ <a href="http://www.unidata.ucar.edu/software/netcdf/"
+ target="_top">NetCDF</a> is a library that provides services for
+ reading and writing mesh data (and many other
+ things). <acronym>deal.II</acronym> can use it to read meshes via
+ one of the functions of the <code>GridIn</code> class.
+ <a href="http://www.unidata.ucar.edu/software/netcdf/"
+ target="_top">NetCDF</a> should be readily packaged by most
+ Linux distributions. (Don't forget to install a development
+ version of the library). To use a self compiled version, pass
+ <code>-DNETCDF_DIR=/path/to/netcdf</code> to <code>cmake</code>.
</dd>
- <a name="p4est"></a>
- <dt><a href="http://www.p4est.org/" target="_top">p4est</a></dt>
+
+ <dt><a name="p4est"></a><a href="http://www.p4est.org/" target="_top">p4est</a></dt>
<dd>
<p>
<a href="http://www.p4est.org/" target="_top">p4est</a>
</p>
</dd>
- <a name="petsc"></a>
- <dt><a href="http://www.mcs.anl.gov/petsc/"
+
+ <dt><a name="petsc"></a><a href="http://www.mcs.anl.gov/petsc/"
target="_top">PETSc</a></dt>
<dd>
<p>
<a href="http://www.mcs.anl.gov/petsc/" target="_top">PETSc</a>
is already packaged by some Linux distributions and should be
found automatically if present. (Don't forget to install a
- develpment version of the library). To use a self compiled
+ development version of the library). To use a self compiled
version of PETSc, add <code>-DPETSC_DIR=/path/to/petsc
-DPETSC_ARCH=architecture</code> to the argument list for
<code>cmake</code>. The values for these arguments must be
</p>
</dd>
- <a name="slepc"></a>
- <dt><a href="http://www.grycap.upv.es/slepc/" target="_top">SLEPc</a></dt>
+
+ <dt><a name="slepc"></a><a href="http://www.grycap.upv.es/slepc/" target="_top">SLEPc</a></dt>
<dd>
<p>
<a href="http://www.grycap.upv.es/slepc/"
</p>
</dd>
- <a name="tbb"></a>
- <dt><a href="http://www.threadingbuildingblocks.org/"
+
+ <dt><a name="tbb"></a><a href="http://www.threadingbuildingblocks.org/"
target="_top">Threading Building Blocks (TBB)</a></dt>
<dd>
<p>
</p>
</dd>
- <a name="trilinos"></a>
- <dt><a href="http://trilinos.sandia.gov" target="_top">Trilinos</a></dt>
+
+ <dt><a name="trilinos"></a><a href="http://trilinos.sandia.gov" target="_top">Trilinos</a></dt>
<dd>
<p>
<a href="http://trilinos.sandia.gov" target="_top">Trilinos</a> is a
</p>
</dd>
- <a name="umfpack"></a>
- <dt><a href="http://www.cise.ufl.edu/research/sparse/umfpack/"
+
+ <dt><a name="umfpack"></a><a href="http://www.cise.ufl.edu/research/sparse/umfpack/"
target="_top">UMFPACK</a></dt>
<dd>
<p>
</dl>
- <a name="conf-details"></a>
+ <a name="conf-details"/>
<h4>More information on configuring and building the library</h4>
<p>
information.
</p>
<p>
- Please note:
+ Please note:</p>
<ul>
<li>
Detailed license information can be found following
<a href="license.html" target="body">this link</a>.
+ </li>
<li>
<b>As a contributor to this project, you agree that any of your
contributions be licensed under the same terms and conditions as
the license of the deal.II project granted to you.</b>
+ </li>
<li>
We, <a href="authors.html">the deal.II authors</a>, do not require
copyright assignments for contributions. This means that the
copyright for code contributions in the deal.II project is held by
its respective contributors who have each agreed to release their
contributed code under the terms of the LGPL v2.1 or later.
+ </li>
<li>
In addition to the terms imposed by the LGPL (version 2.1 or
later), we ask for the courtesy that scientific publications
presenting results obtained with this libraries acknowledge its
use. Please cite one of the papers referenced
<a href="publications/index.html">here</a>.
+ </li>
<li>
<acronym>deal.II</acronym> can interface with a number of <a
href="#optional-software">other packages</a> that you either
target="_top">FunctionParser</a>, courtesy of their authors.
These are also covered by their own licenses; please refer to
their webpages for more information.
+ </li>
</ul>
- <hr>
+ <hr />
+ <address>
+ <a href="authors.html" target="body">The deal.II Authors</a>
+ $Date$
+ </address>
+ <div class="right">
+ <a href="http://validator.w3.org/check?uri=referer" target="_top">
+ <img style="border:0" src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
+ <a href="http://jigsaw.w3.org/css-validator/check/referer" target="_top">
+ <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
+ </div>
- <address>
- <a href="mail.html" target="body">The deal.II Group</a>
- $Date$
- </address>
</body>
</html>
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+ <head>
+ <title>The deal.II Online Documentation</title>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
+ <link href="../screen.css" rel="StyleSheet" type="text/css">
+ <meta name="author" content="the deal.II authors <authors@dealii.org>">
+ <meta name="copyright" content="Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors">
+ <meta name="date" content="2006/02/07 22:49:01">
+ <meta name="keywords" content="deal.II">
+ <meta name="svn_id" content="$Id$">
+ </head>
+<body>
+
+<h1>Reports</h1>
+
+<p>
+ There are a number of papers that describe the overall design or
+ individual aspects of <acronym>deal.II</acronym>. Please refer to the
+ papers listed at the top of the <a href="publications/index.html"
+ target="body">publications page</a> for full references. In addition,
+ there are the following reports:
+ <ul>
+ <li>
+ <p>
+ A publication on the
+ <a href="reports/dimension-independent/index.html"
+ target="body">basics of dimension independent
+ programming</a> in <acronym>deal.II</acronym> (by Wolfgang
+ Bangerth). This explains some of the fundamentals of the
+ library's design, though rather briefly due to the page
+ limit imposed for the publication.
+ </p>
+
+ <p>
+ This publication appeared in
+ the proceedings of the 16th IMACS World Congress,
+ Lausanne, Switzerland, 2000. See the
+ <a href="publications/index.html" target="body">publications</a>
+ page for the full reference as well as a way to obtain a
+ reprint of the original paper as a postscript or PDF file.
+ </p>
+ </li>
+
+ <li>
+ A brief report about the classes involved in the
+ <a href="reports/class-hierarchies/index.html"
+ target="body">iterators and accessors</a>
+ used to access cells in the triangulations and the data
+ thereon, such as their geometry, the number of the
+ degrees of freedom, data values, etc. You may want to
+ read this object or parts of it if you want to know what
+ information is available from iterators (by Wolfgang
+ Bangerth).
+ </li>
+
+ <li>
+ A brief report on <a href="reports/mapping_q/index.html"
+ target="body">mapping</a> functions of higher polynomial
+ degrees (by Ralf Hartmann). These allow the realisation
+ of higher order boundary approximations. This report
+ gives the theoretical background of the
+ <code>MappingQ</code> class.
+ </li>
+
+ <li>
+ A report on
+ <a href="reports/assemble/assemble.pdf"
+ target="body">assembling matrices</a> (by Wolfgang
+ Bangerth). This report looks in particular at how
+ matrices are assembled for vector-valued problems, and
+ how things change if vector-valued finite elements are
+ used for which the shape functions have more than one
+ non-zero vector component, such as Nedelec or
+ Raviart-Thomas elements. There are printable
+ versions of the report
+ <a href="reports/assemble/assemble.ps"
+ target="body">in postscript</a> and
+ <a href="reports/assemble/assemble.pdf"
+ target="body">PDF format</a>.
+ </li>
+
+ <li>
+ A very detailed report on
+ <a href="reports/nedelec/nedelec.pdf"
+ target="body">Nedelec elements</a> (by Anna
+ Schneebeli, University of Basel, Switzerland). It
+ explains the construction and application of Nedelec
+ edge elements for H-curl spaces, as used, for example,
+ in the numerical solution of the Maxwell equations. It
+ also gives numerical results obtained with deal.II.
+ There is also a <a href="reports/nedelec/nedelec.ps"
+ target="body">postscript version of the report</a>.
+ </li>
+
+ <li>
+ A report on the
+ <a href="reports/codimension-one/desimone-heltai-manigrasso.pdf"
+ target="body">codimension one</a> capabilities of the library
+ (by Antonio DeSimone, Luca Heltai and Cataldo Manigrasso,
+ SISSA, Trieste, Italy). It explains in detail how to use the
+ library for the solution of problems defined on codimension
+ one manifolds, such as, for example, Boundary Element
+ Methods.
+ </li>
+ </ul>
+
+ <hr />
+ <address>
+ <a href="authors.html" target="body">The deal.II Authors</a>
+ </address>
+ <div class="right">
+ <a href="http://validator.w3.org/check?uri=referer" target="_top">
+ <img style="border:0" src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
+ <a href="http://jigsaw.w3.org/css-validator/check/referer" target="_top">
+ <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
+ </div>
+</body>
+</html>
margin: 10px;
padding: 0;
font-family: sans-serif;
+ counter-reset: section;
}
body.title {
font-size: 12px;
}
+div.toc {
+ width: 50%;
+ color: black;
+ border: 1px solid #aaa;
+ background-color: #f9f9f9;
+ padding: 5px;
+ font-size: 88%;
+}
+
+div.toc:before {
+ display: block;
+ content: "Table of contents";
+ text-align: center;
+ font-size: 88%;
+ font-weight: bold;
+}
+
+div.quick {
+ width: 30%;
+ color: black;
+ border: 1px solid #aaa;
+ background-color: #f9f9f9;
+ padding: 5px;
+ font-size: 88%;
+}
+
+div.quick:before {
+ display: block;
+ content: "Quick links";
+ text-align: center;
+ font-size: 88%;
+ font-weight: bold;
+}
+
frameset {
background-color: white;
border-color: black;
}
h1 {
- font-size: 175%;
+ font-size: 175%;
+ counter-reset: section;
}
h2 {
font-size: 150%;
+ counter-reset: subsection;
}
h3 { font-size: 140%;
padding-top: 1.5em;
padding-bottom: 0.17em;
border-bottom: 1px dashed #aaaaaa; }
+
h4 { font-size: 110%;
border-bottom: none;
font-weight: bold;
font-weight: bold;
}
+h2:before {
+ counter-increment: section;
+ content: counter(section) ". ";
+}
+
+h3:before {
+ counter-increment: subsection;
+ content: counter(section) "." counter(subsection) ". ";
+}
+
div.right {
text-align: right;
}
margin: 0.3em 0 0 1.5em;
padding:0;
}
+
ol {
line-height: 1.5em;
margin: 0.3em 0 0 3.2em;
padding:0;
list-style-image: none;
}
-li { margin-bottom: 0.1em; }
+
+li {
+ margin-bottom: 0.1em;
+}
+
dt {
font-weight: bold;
margin-bottom: 0.1em;
line-height: 1.1em;
}
+pre.cmake {
+ padding: 1em;
+ text-align: left;
+ text-indent: 0;
+ border: 1px solid #d06fab;
+ color: Black;
+ background-color: #f9f9f9;
+ line-height: 1.1em;
+}
+
+pre.sample {
+ padding: 1em;
+ text-align: left;
+ text-indent: 0;
+ border: 1px dashed #2f6fab;
+ color: Black;
+ background-color: #f9f9f9;
+ line-height: 1.1em;
+}
+
table.navbar { }
table.tutorial {
color: black;
text-decoration: line-through;
}
+.todo:before {
+ content: "TODO: ";
+}
+
+.todo {
+ color: Red;
+}
+
.deprecated {
text-decoration: line-through;
}
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
+
+FIND_PACKAGE(deal.II 8.0 REQUIRED
+ HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}
+ )
+DEAL_II_INITIALIZE_CACHED_VARIABLES()
+
+PROJECT(myproject)
+
+ADD_EXECUTABLE(mycode mycode.cc)
+DEAL_II_SETUP_TARGET(mycode)
--- /dev/null
+FIND_PACKAGE(deal.II 8.0 REQUIRED
+ HINTS
+ ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}
+ # You can specify additional hints for search paths here, e.g.
+ # $ENV{HOME}/workspace/deal.II
+ )
+
+# Set the name of the project and target:
+SET(TARGET "step-1")
+
+# Declare all source files the target consists of:
+SET(TARGET_SRC
+ step-1.cc
+ # You can specify additional files here!
+ )
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
+DEAL_II_INITIALIZE_CACHED_VARIABLES()
+PROJECT(${TARGET} CXX)
+DEAL_II_INVOKE_AUTOPILOT()
--- /dev/null
+FIND_PACKAGE(deal.II 8.0 REQUIRED
+ HINTS
+ ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}
+ # You can specify additional hints for search paths here, e.g.
+ # $ENV{HOME}/workspace/deal.II
+ )
+
+# Set the name of the project and target:
+SET(TARGET "step-1")
+
+# Declare all source files the target consists of:
+SET(TARGET_SRC
+ step-1.cc
+ # You can specify additional files here!
+ )
+
+# Specify a list of files (file globs) that will be removed
+# with the "make runclean" and "make distclean" targets.
+# (If empty, sensible default values will be used.)
+SET(CLEAN_UP_FILES
+ # a custom list of globs, e.g. *.log *.vtk
+ )
+
+# A custom command line that should be invoked by "make run".
+# (If empty, ./${TARGET} will be invoked.)
+SET(TARGET_RUN
+ # a custom command line, e.g. mpirun -np 2 ${TARGET}
+ )
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
+DEAL_II_INITIALIZE_CACHED_VARIABLES()
+PROJECT(${TARGET} CXX)
+DEAL_II_INVOKE_AUTOPILOT()
# "C Compiler."
# )
#
+# SET(CMAKE_Fortran_COMPILER "" CACHE STRING
+# "Fortran Compiler."
+# )
+#
# SET(CMAKE_CXX_FLAGS "" CACHE STRING
# "The user supplied cache variable will be appended _at the end_ of the auto generated CMAKE_CXX_FLAGS variable"
# )
# "The user supplied cache variable will be appended _at the end_ of the auto generated DEAL_II_CXX_FLAGS_RELEASE variable"
# )
#
-# SET(CMAKE_SHARED_LINKER_FLAGS "" CACHE STRING
-# "The user supplied cache variable will be appended _at the end_ of the auto generated CMAKE_SHARED_LINKER_FLAGS variable"
+# SET(DEAL_II_LINKER_FLAGS "" CACHE STRING
+# "The user supplied cache variable will be appended _at the end_ of the auto generated DEAL_II_LINKER_FLAGS variable"
# )
#
-# SET(DEAL_II_SHARED_LINKER_FLAGS_DEBUG "" CACHE STRING
-# "The user supplied cache variable will be appended _at the end_ of the auto generated DEAL_II_SHARED_LINKER_FLAGS_DEBUG variable"
+# SET(DEAL_II_LINKER_FLAGS_DEBUG "" CACHE STRING
+# "The user supplied cache variable will be appended _at the end_ of the auto generated DEAL_II_LINKER_FLAGS_DEBUG variable"
# )
#
-# SET(DEAL_II_SHARED_LINKER_FLAGS_RELEASE "" CACHE STRING
-# "The user supplied cache variable will be appended _at the end_ of the auto generated DEAL_II_SHARED_LINKER_FLAGS_RELEASE variable"
+# SET(DEAL_II_LINKER_FLAGS_RELEASE "" CACHE STRING
+# "The user supplied cache variable will be appended _at the end_ of the auto generated DEAL_II_LINKER_FLAGS_RELEASE variable"
# )
#
# SET(BUILD_SHARED_LIBS "ON" CACHE BOOL
# "Build a shared library"
# )
#
+# SET(DEAL_II_PREFER_STATIC_LIBS "OFF" CACHE BOOL
+# "Prefer static libraries over dynamic libraries when searching for features and corresponding link interface"
+# )
+#
+# OPTION(DEAL_II_STATIC_EXECUTABLE "OFF" CACHE BOOL
+# "Provide a link interface that is suitable for static linkage of executables. Enabling this option forces BUILD_SHARED_LIBS=OFF and DEAL_II_PREFER_STATIC_LIBS=ON"
+# )
+#
# SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH "ON" CACHE BOOL
# "Set the rpath of the library to the external link pathes on installation"
# )
# BLA_VENDOR will also be recognized by FindLAPACK.cmake.
#
# If your BLAS/LAPACK installation resides at a non system location, specify
-# a hint with CMAKE_PREFIX_PATH.
+# a hint with LAPACK_DIR and BLAS_DIR, or CMAKE_PREFIX_PATH:
+#
+# SET(LAPACK_DIR "..." CACHE PATH
+# "The preferred installation prefix for searching for LAPACK"
+# )
+#
+# SET(BLAS_DIR "..." CACHE PATH
+# "The preferred installation prefix for searching for BLAS"
+# )
#
#
# Manual setup:
# SET(METIS_FOUND TRUE CACHE BOOL "")
# SET(METIS_LIBRARIES "library;and;semicolon;separated;list;of;link;interface" CACHE STRING "")
# SET(METIS_INCLUDE_DIRS "semicolon;separated;list;of;include;dirs" CACHE STRING "")
+# SET(METIS_VERSION "x.y.z" CACHE STRING "")
+# SET(METIS_VERSION_MAJOR "x" CACHE STRING "")
+# SET(METIS_VERSION_MINOR "y" CACHE STRING "")
+# SET(METIS_VERSION_SUBMINOR "z" CACHE STRING "")
#
# conservative. Only the current compiler and the variable MPI_CXX_COMPILER
# is used to find MPI. (MPI_CXX_COMPILER takes precedence.)
#
+# (MPI_C_COMPILER and MPI_Fortran_COMPILER are considered, too)
+#
+#
# DEAL_II_WITH_MPI=ON will trigger a more sophisticated search for MPI.
#
# The best way to force a specific MPI implementation to be used is to set
-# CMAKE_C_COMPILER and CMAKE_CXX_COMPILER to the appropriate MPI wrapper
-# (See above).
+# CMAKE_CXX_COMPILER, CMAKE_C_COMPILER and CMAKE_Fortran_COMPILER to the
+# appropriate MPI wrapper (See above).
#
# Alternatively, specify the mpi wrapper that will be queried for the mpi
# link interface:
#
# SET(MPI_CXX_COMPILER "mpicxx" CACHE STRING "")
#
+# SET(MPI_C_COMPILER "mpicc" CACHE STRING "")
+# SET(MPI_Fortran_COMPILER "mpif90" CACHE STRING "")
+#
#
# Manual setup:
#
# SET(MPI_CXX_COMPILE_FLAGS "..." CACHE STRING "")
# SET(MPI_CXX_LINK_FLAGS "..." CACHE STRING "")
#
+# Additionally:
+#
+# SET(MPI_C_LIBRARIES "library;and;semicolon;separated;list;of;link;interface" CACHE STRING "")
+# SET(MPI_Fortran_LIBRARIES "library;and;semicolon;separated;list;of;link;interface" CACHE STRING "")
+#
+#
#
# SET(P4EST_LIBRARIES "library;and;semicolon;separated;list;of;link;interface" CACHE STRING "")
# SET(P4EST_INCLUDE_DIRS "semicolon;separated;list;of;include;dirs" CACHE STRING "")
# SET(P4EST_WITH_MPI TRUE CACHE BOOL "")
+# SET(P4EST_VERSION "x.y.z.p" CACHE STRING "")
+# SET(P4EST_VERSION_MAJOR "x" CACHE STRING "")
+# SET(P4EST_VERSION_MINOR "y" CACHE STRING "")
+# SET(P4EST_VERSION_SUBMINOR "z" CACHE STRING "")
+# SET(P4EST_VERSION_PATCH "p" CACHE STRING "")
#
# SET(PETSC_VERSION_MAJOR "x" CACHE STRING "")
# SET(PETSC_VERSION_MINOR "y" CACHE STRING "")
# SET(PETSC_VERSION_SUBMINOR "z" CACHE STRING "")
+# SET(PETSC_VERSION_PATCH "" CACHE STRING "")
# SET(PETSC_WITH_MPI_UNI FALSE CACHE BOOL "")
#
# SET(SLEPC_VERSION_MAJOR "x" CACHE STRING "")
# SET(SLEPC_VERSION_MINOR "y" CACHE STRING "")
# SET(SLEPC_VERSION_SUBMINOR "z" CACHE STRING "")
+# SET(SLEPC_VERSION_PATCH "" CACHE STRING "")
# SET(SLEPC_WITH_MPI_UNI FALSE CACHE BOOL "")
#
<acronym>deal.II</acronym> CMake build system.
</p>
- <p>
- <table class="tutorial" width="50%">
- <tr><th colspan="2"><b><small>Table of contents</small></b></th></tr>
- <tr><td valign="top">
- <ul>
- <li><a href="#operating">Operating cmake</a>
- <ul>
- <li><a href="#operatingmanip">Manipulating the cache</a>
- <li><a href="#operatingccmake"><code>ccmake</code> and special build targets </a>
- <li><a href="#operatingshortcuts">Shortcuts</a>
- </ul>
- <li><a href="#configure">Configuration options</a>
- <ul>
- <li><a href="#configurefeature">Feature configuration</a>
- <li><a href="#configureautoconf">Autoconfiguration</a>
- <li><a href="#configureext">External library locations</a>
- <li><a href="#configureoverride">Manual override</a>
- <li><a href="#configurecomp">Component selection</a>
- <li><a href="#configurebuild">Build configuration</a>
- <li><a href="#compiler">Selecting a compiler</a>
- <li><a href="#configureinstall">Installation</a>
- </ul>
- <li><a href="#advanced">Initial cache file and advanced options</a>
- <li><a href="#compiling">Compiling only certain parts</a>
- </ul>
- </td>
- </tr>
- </table>
- </p>
-
+ <div class="toc">
+ <ol>
+ <li><a href="#operating">Operating cmake</a>
+ <ol>
+ <li><a href="#operatingmanip">Manipulating the cache</a></li>
+ <li><a href="#operatingccmake"><code>ccmake</code> and special build targets </a></li>
+ <li><a href="#operatingshortcuts">Shortcuts</a></li>
+ </ol>
+ </li>
+ <li><a href="#configure">Configuration options</a>
+ <ol>
+ <li><a href="#configurefeature">Feature configuration</a></li>
+ <li><a href="#configureautoconf">Autoconfiguration</a></li>
+ <li><a href="#configureext">External library locations</a></li>
+ <li><a href="#configureoverride">Manual override</a></li>
+ <li><a href="#configurecomp">Component selection</a></li>
+ <li><a href="#configurebuild">Build configuration</a></li>
+ <li><a href="#compiler">Selecting a compiler</a></li>
+ <li><a href="#configureinstall">Installation</a></li>
+ </ol>
+ </li>
+ <li><a href="#advanced">Initial cache file and advanced options</a></li>
+ <li><a href="#compiling">Compiling only certain parts</a></li>
+ </ol>
+ </div>
+
<a name="operating"></a>
- <h3>Operating cmake</h3>
+ <h2>Operating cmake</h2>
<p>
When configuring <acronym>deal.II</acronym> by
</pre>
switches off support for the METIS library that may have been
automatically detected during the first invocation of
- <code>cmake</code> and enables support for Trilinos by enablind
+ <code>cmake</code> and enables support for Trilinos by enabling
<code>DEAL_II_WITH_TRILINOS</code> and setting
<code>TRILINOS_DIR</code>.
</p>
<a name="operatingmanip"></a>
- <h4> Manipulating the cache </h4>
+ <h3> Manipulating the cache </h3>
<p>
A cached variable can be set on the command line via
</p>
<a name="operatingccmake"></a>
- <h4> <code>ccmake</code> and special build targets </h4>
+ <h3> <code>ccmake</code> and special build targets </h3>
<p>
A very convenient way to alter the configuration is to use the graphical
</p>
<a name="operatingshortcuts"></a>
- <h4> Shortcuts </h4>
+ <h3> Shortcuts </h3>
<p>
All variables starting with <code>WITH_</code> will be automatically
</p>
<a name="configure"></a>
- <h3>Configuration options</h3>
+ <h2>Configuration options</h2>
<p>
The various configuration options of the
<a name="configurefeature"></a>
- <h4>Feature configuration</h4>
+ <h3>Feature configuration</h3>
<p>
<acronym>deal.II</acronym> provides (optional) interfaces to quite
<a name="configureautoconf"></a>
- <h4> Autoconfiguration </h4>
+ <h3> Autoconfiguration </h3>
<p>
As long as <code>DEAL_II_WITH_<FEATURE></code> is
<a name="configureext"></a>
- <h4> External library locations </h4>
+ <h3> External library locations </h3>
<p>
External libraries will be searched depending on hints in the following
<pre>
ARPACK_DIR,
+ BOOST_DIR,
HDF5_DIR,
+ LAPACK_DIR (and BLAS_DIR),
METIS_DIR,
MUMPS_DIR (and SCALAPACK_DIR, BLACS_DIR),
P4EST_DIR (and SC_DIR),
Alternatively, cached variables set by the
<code>Find<Module></code> mechanism may be set,
hinted or overwritten directly (variable names are highly
- dependend on the actual library). You can get a list via
+ dependent on the actual library). You can get a list via
<pre>
make edit_cache
<code>-NOTFOUND</code> and may be set by hand.
</p>
+ <h4>Library conflicts</h4>
+ <p>Caveat: if you have a set of standard libraries in the default
+ location, say <code>/usr/lib</code> and a set of
+ private versions of the same libraries, for instance because you
+ need different revisions sometimes, in your own library directory,
+ you may receive an error message of the form:</p>
+
+<pre>
+
+ CMake Warning at source/CMakeLists.txt:65 (ADD_LIBRARY):
+ Cannot generate a safe runtime search path for target deal_II.g because
+ files in some directories may conflict with libraries in implicit
+ directories:
+
+ runtime library [libtbb.so.2] in /usr/lib may be hidden by files in:
+ /my/private/lib
+
+ Some of these libraries may not be found correctly.
+
+</pre>
+
+<p>This is not a problem of CMake or deal.II, but rather a general
+ Linux problem. In order to fix this, you have two options:</p>
+<ol>
+<li>Choose all libraries either from your private directory or from
+ the standard one.</li>
+<li>Install all your private library versions in different directories.</li>
+</ol>
+
<a name="configureoverride"></a>
- <h4> Manual override </h4>
+ <h3> Manual override </h3>
<p><b>Warning:</b> Do not do this unless absolutely necessary!</p>
<p>
It is possible to override the CMake find mechanism for external
<a name="configurecomp"></a>
- <h4> Component selection </h4>
+ <h3> Component selection </h3>
<p>
The following options control which components of
<a name="configurebuild"></a>
- <h4> Build configuration </h4>
+ <h3> Build configuration </h3>
<p>
The <code>cmake</code> variable <code>CMAKE_BUILD_TYPE</code>
<code>BUILD_SHARED_LIBS</code>: If set (default),
<acronym>deal.II</acronym> will be linked as a shared library
+ <li>
+ <code>DEAL_II_PREFER_STATIC_LIBS</code> (defaults to off): If set
+ to true, static archives will be preferred over dynamic libraries when
+ searching for features and corresponding link interface.
+
+ <li>
+ <code>DEAL_II_STATIC_EXECUTABLE</code> (defaults to off):
+ If set to true, <acronym>deal.II</acronym> will be configured in
+ a way to provide a link interface that is suitable for static
+ linkage of executables. Enabling this option forces
+ <code>BUILD_SHARED_LIBS=OFF</code> and
+ <code>DEAL_II_PERFER_STATIC_LIBS</code>.
+
<li>
<code>CMAKE_INSTALL_RPATH_USE_LINK_PATH</code>: If set
(default), the <acronym>deal.II</acronym> library will be
<a name="compiler"></a>
- <h4> Selecting a compiler </h4>
+ <h3> Selecting a compiler </h3>
</p>
Compilers can be switched either by command line or by setting
- <code>CMAKE_(C|CXX)_COMPILER</code>:
+ <code>CMAKE_(C|CXX|Fortran)_COMPILER</code>:
<pre>
CC=mpicc CXX=mpicxx cmake <...>
- cmake -DCMAKE_C_COMPILER="mpicc" -DCMAKE_CXX_COMPILER="mpicxx" <...>
+ cmake -DCMAKE_C_COMPILER="mpicc" -DCMAKE_CXX_COMPILER="mpicxx" -DCMAKE_Fortran_COMPILER="mpif90" <...>
</pre>
Please note that
<ul>
<li>
The compiler <i>must</i> be specified at the very first
- invokation of <code>cmake</code>.
+ invocation of <code>cmake</code>.
<li>
- The specified C and CXX compilers must be the same compiler
- brand and the same compiler version.
+ A working CXX compiler is needed. It is optional to provide a C
+ or Fortran compiler.
</ul>
</p>
<p>
- deal.II will configure sensible default <code>CFLAGS</code> and
- <code>CXXFLAGS</code> depending on platform, compiler and build
- target. There are two options to override this behaviour:
+ deal.II will configure sensible default <code>CXXFLAGS</code>
+ depending on platform, compiler and build target. There are two
+ options to override this behaviour:
<ol>
<li>
<a name="configureinstall"></a>
- <h4> Installation </h4>
+ <h3> Installation </h3>
<p>
the location,
<a name="advanced"></a>
- <h3>Initial cache file and advanced options</h3>
+ <h2>Initial cache file and advanced options</h2>
A sample configuration file for preloading the CMake cache with
<pre>
<a name="compiling"></a>
- <h3> Compiling only certain parts </h3>
+ <h2> Compiling only certain parts </h2>
<p>
<p>
will be installed, see <a href="#configurebuild">this section</a>.
</p>
-
- <hr>
-
+ <hr />
<address>
- <a href="mail.html" target="body">The deal.II Group</a>
+ <a href="../authors.html" target="body">The deal.II Authors</a>
$Date$
</address>
+ <div class="right">
+ <a href="http://validator.w3.org/check?uri=referer" target="_top">
+ <img style="border:0" src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
+ <a href="http://jigsaw.w3.org/css-validator/check/referer" target="_top">
+ <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
+ </div>
+
</body>
</html>
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+ <head>
+ <title>How to use CMake to configure your projects with deal.II</title>
+ <link href="../screen.css" rel="StyleSheet">
+ <meta name="author" content="the deal.II authors <authors @ dealii.org>">
+ <meta name="copyright" content="Copyright (C) 2012, 2013 by the deal.II authors">
+ <meta name="date" content="$Date$">
+ <meta name="svn_id" content="$Id$">
+ <meta name="keywords" content="deal.II">
+ </head>
+
+<body>
+<h1>How to use CMake to configure your projects with <acronym>deal.II</acronym></h1>
+
+<div class="toc">
+ <ol>
+ <li><a href="#cmakesimple">Simple <code>CMakeLists.txt</code></a>
+ <ol>
+ <li><a href="#cmakesimple.multiple">Adding multiple executable targets</a></li>
+ <li><a href="#cmakesimple.libs">Adding libraries and common source files</a></li>
+ <li><a href="#cmakesimple.build_type">Switching build types</a></li>
+ <li><a href="#cmakesimple.run">Adding a "run" target</a></li>
+ </ol>
+ </li>
+ <li><a href="#cmakeadvanced">Advanced <code>CMakeLists.txt</code></a>
+ <ol>
+ <li><a href="#cmakeadvanced.layout">Source directory layout</a></li>
+ <li><a href="#cmakeadvanced.control">Control statements</a></li>
+ <li><a href="#cmakeadvanced.globs">File globs</a></li>
+ <li><a href="#cmakeadvanced.setup_target"><code>DEAL_II_SETUP_TARGET</code> revisited</a></li>
+ <li><a href="#cmakeadvanced.cached_variables"><code>DEAL_II_INITIALIZE_CACHED_VARIABLES</code> revisited</a></li>
+ <li><a href="#cmakeadvanced.properties">Customizing include directories and compile definitions</a></li>
+ <li><a href="#cmakeadvanced.external_libraries">External libraries</a></li>
+ <li><a href="#cmakeadvanced.run">The "run" target revisited</a></li>
+ <li><a href="#cmakeadvanced.install">Install a project</a></li>
+ </ol>
+ </li>
+ <li><a href="#cmakeauto">Autopilot style <code>CMakeLists.txt</code></li>
+ <li><a href="#dealiiconfig"><code>deal.IIConfig.cmake</code></a></li>
+ <li><a href="#legacy">Legacy <code>Make.global_options</code></a></li>
+ </ol>
+</div>
+
+<p>
+ <code>cmake</code> is the configuration and build tool we use
+ in <acronym>deal.II</acronym>. Its advantage is not only that it makes
+ configuration of <acronym>deal.II</acronym> itself simpler across
+ platforms (compared to the older <code>autoconf/make</code> combination)
+ but also that it <i>exports</i> information about the deal.II
+ configuration that makes it particularly simple for projects
+ using <acronym>deal.II</acronym> to configure and link against it.
+</p>
+
+<p>
+ <code>cmake</code> is controlled by input files that by convention are
+ called <code>CMakeLists.txt</code>, listing both configuration commands
+ as well as dependencies between source files and targets.
+ This page presents some <code>CMakeLists.txt</code> examples for
+ potential use in your projects. (A detailed description of the
+ <acronym>deal.II</acronym> project configuration is given in the
+ <a href="cmake.html" target="body">deal.II CMake ReadMe</a>.)
+</p>
+
+<a name="cmakesimple"></a>
+<h2>Simple CMakeLists.txt</h2>
+
+<p>
+ In this section, we start out with a minimal <code>CMakeLists.txt</code>
+ based on the <code>DEAL_II_SETUP_TARGET</code> macro. This method gives
+ full control of what's happening and is easily extensible to more complex
+ projects, as exemplified in the subsections here and later in the section
+ on <a href="cmakeadvanced">advanced topics</a>. Here is a full example
+ (<a href="CMakeLists.txt.sample" target="_top">plain text</a>
+ version):
+
+<pre class="cmake">
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
+
+FIND_PACKAGE(deal.II 8.0 REQUIRED
+ HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}
+ )
+DEAL_II_INITIALIZE_CACHED_VARIABLES()
+
+PROJECT(myproject)
+
+ADD_EXECUTABLE(mycode mycode.cc)
+DEAL_II_SETUP_TARGET(mycode)
+</pre>
+
+<p>
+ The first line of this code makes sure that a sufficiently high
+ version of CMake is installed. 2.8.8 is the minimal version required
+ to set up <acronym>deal.II</acronym>, therefore it is safe to use this
+ number here.
+</p>
+
+<p>
+ Next, we find our deal.II installation with the help of the
+ <code>FIND_PACKAGE</code> command. In this case requiring at least
+ version 8.0, which is the first version using CMake. The
+ <code>HINTS</code> are a list of directories where the install directory
+ of deal.II is likely to be found. First, the location possibly defined in
+ the CMake variable <code>DEAL_II_DIR</code> is considered. After that, we
+ check whether we are in a subdirectory (first and second level) of the
+ deal.II installation and otherwise use the environment variable
+ <code>DEAL_II_DIR</code>. If all of these hints fail the default system
+ locations <code>/usr/</code> and <code>/usr/local/</code> are considered.
+ The list after <code>HINTS</code> can be changed according to your
+ preferences.
+</p>
+
+<p>
+ After finding the deal.II project, we fetch a set of cached variables
+ with the <a href="#cmakeadvanced.cached_variables">
+ <code>DEAL_II_INITIALIZE_CACHED_VARIABLES</code></a> macro. You
+ can inspect these for instance with <code>ccmake</code>.
+</p>
+
+<p>
+ Every <code>CMakeLists.txt</code> must contain a project definition,
+ which we do next.
+</p>
+
+<p>
+ Finally, the last two lines define the executable that is to be produced
+ and its source code. The <a href="#cmakeadvanced.setup_target">
+ <code>DEAL_II_SETUP_TARGET</code></a> macro will set up necessary
+ incllude directories, compile defintions and the link interface.
+</p>
+
+<a name="cmakesimple.multiple"></a>
+<h3>Adding multiple executable targets</h3>
+
+<p>
+ In order to specify multiple executable targets, simply repeat
+ the last two lines of the simple <code>CMakeLists.txt</code>:
+</p>
+
+<pre class="cmake">
+ADD_EXECUTABLE(mycode2 mycode2.cc)
+DEAL_II_SETUP_TARGET(mycode2)
+
+ADD_EXECUTABLE(mycode3 mycode3.cc)
+DEAL_II_SETUP_TARGET(mycode3)
+</pre>
+
+If the list gets longer, consider using
+a <a href="#cmakeadvanced.foreach">loop</a>, possibly
+with <a href="#cmakeadvanced.glob">GLOB</a>.
+
+ <a name="cmakesimple.libs"></a>
+ <h3>Adding libraries and common source files</h3>
+
+ <p>
+ Adding a library is as simple as adding an executable target. We
+ specify the library name and then have to tell cmake that the
+ executables depend on it. The code in the simple file below the
+ project definition accordingly changes for instance to:
+ </p>
+
+<pre class="cmake">
+ADD_LIBRARY(mylib libsrc1.cc libsrc2.cc libsrc3.cc)
+DEAL_II_SETUP_TARGET(mylib)
+
+ADD_EXECUTABLE(mycode mycode.cc)
+DEAL_II_SETUP_TARGET(mycode)
+TARGET_LINK_LIBRARIES(mycode mylib)
+</pre>
+
+<p>When you have <a href="#cmakesimple.multiple">multiple targets</a>,
+repeat the last line of code for each of them. Accordingly,
+a <a href="#cmakeadvanced.foreach">loop</a> becomes even more
+attractive.</p>
+
+<p>If you only have a single file or few files with common source
+code, an alternative to creating a library might be the option:</p>
+
+<pre class="cmake">
+ADD_EXECUTABLE(mycode mycode.cc common.cc)
+DEAL_II_SETUP_TARGET(mycode)
+
+ADD_EXECUTABLE(mycode2 mycode2.cc common.cc)
+DEAL_II_SETUP_TARGET(mycode2)
+</pre>
+
+<p>You should be aware though that in this case <code>common.cc</code> will
+be compiled for each target, not only once. If you want to avoid this and
+still don't want to use a shared library or static archive, another option
+is to create an <code>OBJECT</code> "library":</p>
+
+<pre class="cmake">
+ADD_LIBRARY(common OBJECT common.cc)
+DEAL_II_SETUP_TARGET(common)
+
+ADD_EXECUTABLE(mycode mycode.cc $<TARGET_OBJECTS:common>)
+DEAL_II_SETUP_TARGET(mycode)
+
+ADD_EXECUTABLE(mycode2 mycode2.cc $<TARGET_OBJECTS:common>)
+DEAL_II_SETUP_TARGET(mycode2)
+</pre>
+This will compile <code>common.cc</code> once for the object target
+<code>common</code> and link the resulting object file into the two
+executables.
+
+<a name="cmakesimple.build_type"></a>
+<h3>Switching build types</h3>
+
+<p> The build type is controlled via the variable
+<code>CMAKE_BUILD_TYPE</code>. If it is set to <code>Debug</code>
+executables and libraries specified in your <code>CMakeLists.txt</code>
+file will be compiled in debug mode and linked against the debug version of
+the deal.II library. Contrary <code>Release</code> will build in optimized
+mode and link against the optimized release version of deal.II. You can set
+<code>CMAKE_BUILD_TYPE</code> with the help of <code>ccmake</code> or via
+<code>cmake</code> on the command line: </p>
+
+<pre class="cmake">
+$ cmake -DCMAKE_BUILD_TYPE="Debug" .
+
+$ cmake -DCMAKE_BUILD_TYPE="Release" .
+</pre>
+
+Alternatively, you can specify custom targets to switch the build type and
+compile automatically:
+
+<pre class="cmake">
+ADD_CUSTOM_TARGET(debug
+ COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR}
+ COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all
+ COMMENT "Switch CMAKE_BUILD_TYPE to Debug"
+ )
+
+ADD_CUSTOM_TARGET(release
+ COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR}
+ COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all
+ COMMENT "Switch CMAKE_BUILD_TYPE to Release"
+ )
+</pre>
+With that, switching the build type and compiling the project can be done
+very conveniently via:
+<pre class="cmake">
+$ make debug
+
+$ make release
+</pre>
+
+<a name="cmakesimple.run"></a>
+<h3>Adding a "run" target</h3>
+
+<p> If you wish to have a "run" target for make, like in the deal.II
+tutorial, specify one this way (obviously, a single "run" target can only
+run a single executable): </p>
+
+<pre class="cmake">
+ADD_CUSTOM_TARGET(run COMMAND mycode
+ COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration"
+ )
+</pre>
+
+
+<a name="cmakeadvanced"></a>
+<h2> Advanced <code>CMakeLists.txt</code></h2>
+
+<p>This section covers some advanced topics for a user
+<code>CMakeLists.txt</code> file.</p>
+
+<a name="cmakeadvanced.layout"></a>
+<h3>Source directory layout</h3>
+
+<p>For complex projects it is desirable to organize source code and header
+files in subdirectories. Assume the following project structure with a
+library "mylib" and an executable "mycode":
+
+<pre class="cmake">
+mylib/source/*.cc
+mylib/include/*.h
+
+mycode/source/*.cc
+mycode/include/*.h
+</pre>
+
+In this case the top level <code>CMakeLists.txt</code> file may be:
+<pre class="cmake">
+# top level CMakeLists.txt
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
+FIND_PACKAGE(deal.II 8.0 REQUIRED)
+
+DEAL_II_INITIALIZE_CACHED_VARIABLES()
+PROJECT(myproject)
+
+ADD_SUBDIRECTORY(mylib)
+ADD_SUBDIRECTORY(mycode)
+</pre>
+The <code>ADD_SUBDIRECTORY</code> statement will include the CMakeLists.txt
+file in the specified subdirectory. In our case:
+
+<pre class="cmake">
+# mylib/CMakeLists.txt
+
+INCLUDE_DIRECTORIES(include)
+
+ADD_LIBRARY(mylib
+ source/mylib1.cc
+ source/mylib2.cc
+ )
+
+DEAL_II_SETUP_TARGET(mylib)
+</pre>
+
+We have to add the directory <code>include</code> for the header files to
+the current include directories with the <code>INCLUDE_DIRECTORIES</code>
+statement (see <a href="#cmakeadvanced.properties">this section</a> for
+details). The corresponding configuration file for the executable looks
+like:
+
+<pre class="cmake">
+# mycode/CMakeLists.txt
+
+INCLUDE_DIRECTORIES(
+ include
+ ${CMAKE_SOURCE_DIR}/mylib/include
+ )
+
+ADD_EXECUTABLE(mycode source/mycode.cc)
+DEAL_II_SETUP_TARGET(mycode)
+
+TARGET_LINK_LIBRARIES(mycode mylib)
+</pre>
+
+<p>
+Please note that <code>CMakeLists.txt</code> files have directory scope.
+Any manipulation of properties and variables have only effect in the
+current directory (and subdirectories, included with
+<code>ADD_SUBDIRECTORY</code>. The level above will not be affected.
+Therefore, we have to specify the include directories for "mylib" again in
+the subdirectory <code>mycode</code> - this time with full path
+<code>${CMAKE_SOURCE_DIR}/mylib/include</code>.
+</p>
+
+<p>
+CMake defines the following variables for access to important directories:
+
+<pre class="cmake">
+CMAKE_SOURCE_DIR
+ - the source directory (i.e. the directory of the top level
+ CMakeLists.txt file)
+
+CMAKE_BINARY_DIR
+ - the (top level) build directory
+
+CMAKE_CURRENT_SOURCE_DIR
+ - the current source directory, i.e. location of the currently processed
+ CMakeLists.txt file (top level or included via ADD_SUBDIRECTORY)
+
+CMAKE_CURRENT_BINARY_DIR
+ - the build (sub)directory corresponding to CMAKE_CURRENT_SOURCE_DIR
+</pre>
+
+</p>
+
+<a name="cmakeadvanced.control"></a>
+<h3>Control statements</h3>
+
+<p>Control statements in CMake take the following form:
+<pre class="cmake">
+IF(<expression>)
+ ...
+ENDIF()
+</pre>
+or in long form:
+<pre class="cmake">
+IF(<expression1>)
+ ...
+ELSEIF(<expression2>)
+ ...
+ELSE()
+ ...
+ENDIF()
+</pre>
+Please note the (somehow uncommon) empty, opening and closing brackets
+behind <code>ELSE()</code> and <code>ENDIF()</code>.
+<code><expression></code> can take a multitude of different forms,
+have a look at the
+<a href="http://cmake.org/cmake/help/v2.8.8/cmake.html">CMake
+documentation</a> for a complete list. Important examples are:
+<pre class="cmake">
+IF(${variable})
+ - the body will be evaluated if the variable "variable" is defined and
+ synonymous to true, e.g. 1, TRUE, ON, YES (modulo case insensitivity)
+
+IF(variable MATCHES <regular expression>)
+ - the body will be evaluated if the variable "variable" is defined and
+ matches the specified regular expression
+
+IF("${variable}" STREQUAL "foobar")
+ - the body will be evaluated if both strings are equal. Note that
+ "${variable}" will be replaced by the content of the (string)
+ variable "variable"
+</pre>
+<p>An expression can be negated by prefixing <code>NOT</code>:</p>
+<pre class="cmake">
+IF(NOT <expression>)
+ ...
+ENDIF()
+</pre>
+
+<p>Loops are implemented with the help of <code>WHILE</code> and
+<code>FOR</code> statements. The former takes the same
+<code><expression></code> as the <code>IF</code> statement:</p>
+<pre class="cmake">
+WHILE(<expression>)
+ ...
+ENDWHILE()
+</pre>
+Given a variable <code>list</code> containing a list, the individual
+elements <code>element</code> can be accessed with a <code>FOREACH</code>
+statement:
+<pre class="cmake">
+FOREACH(element ${list})
+ ...
+ENDFOREACH
+</pre>
+Note: It is also possible to specify the list directly:
+<pre class="cmake">
+FOREACH(element foo bar baz)
+ # The variable element will iterate through foo, bar and baz.
+ENDFOREACH
+</pre>
+
+
+<a name="cmakeadvanced.globs"></a>
+<h3>File globs</h3>
+
+<p>A very common task is to pick up a list of source files from a
+directory. You can either manage a list of source files in
+<code>CMakeLists.txt</code> by hand, e.g. by manually updating all source
+files for a given target, or you can use a glob to automate this process.
+The following example will pick up every source file under
+<code>SOURCE_DIR/sources/</code> and add it to an executable:</p>
+
+<pre class="cmake">
+FILE(GLOB sources ${CMAKE_SOURCE_DIR}/source/*.cc)
+ADD_EXECUTABLE(mycode ${sources})
+</pre>
+
+<p>Please be aware of one caveat of this approach: Due to the fact that
+CMake is a <i>build system generator</i> the resulting build configuration
+(for make) has no way to detect whether a new source file was added (or
+removed) and that it has to call back to cmake. So, after adding a new
+source file you have to touch a <code>CMakeLists.txt</code> file or to run
+<code>cmake .</code> again by hand.
+
+
+<a name="cmakeadvanced.setup_target"></a>
+<h3><code>DEAL_II_SETUP_TARGET</code> revisited</h3>
+<p>
+The <code>DEAL_II_SETUP_TARGET</code> macro is responsible for setting up a
+target to compile and link against deal.II. It will <i>append</i> the
+<code>INCLUDE_DIRECTORIES</code> property with the location of the deal.II
+include directories, and the compile definitions and linker flags property
+<code>COMPILE_DEFINITIONS</code> and <code>LINK_FLAGS</code> by their
+respective values (depending on build type and available debug and/or
+optimized flavor of the library).
+</p>
+<p>
+Except in the case of an object library, the specified target will be set
+up to link against deal.II (and its transitive link interface) as well.
+</p>
+
+
+<a name="cmakeadvanced.cached_variables"></a>
+<h3><code>DEAL_II_INITIALIZE_CACHED_VARIABLES</code> revisited</h3>
+
+<p>
+The <code>DEAL_II_INITIALIZE_CACHED_VARIABLES</code> macro is responsible
+for setting up cached variables and has to invoked before the
+<code>PROJECT</code> call:
+<pre class="cmake">
+FIND_PACKAGE(deal.II 8.0 REQUIRED)
+
+DEAL_II_INITIALIZE_CACHED_VARIABLES()
+
+PROJECT(myproject)
+</pre>
+The macro will set an uninitialized <code>CMAKE_BUILD_TYPE</code> variable
+to <code>Debug</code> (or <code>Release</code> if the debug library is not
+available). If <code>CMAKE_BUILD_TYPE</code> is specified it will
+automatically be reset if the given value is unsupported by the deal.II
+installation.
+</p>
+<p>
+Furthermore, this macro sets the C++ compiler and the compile flags to
+default values (the same values that were used to compile deal.II itself).
+These are <code>CMAKE_CXX_COMPILER</code> and <code>CMAKE_CXX_FLAGS</code>,
+as well as - depending on the configuration -
+<code>DEAL_II_FLAGS_DEBUG</code>, or <code>DEAL_II_FLAGS_RELEASE</code>, or
+both.
+</p>
+
+<a name="cmakeadvanced.properties"></a>
+<h3>Customizing include directories and compile definitions</h3>
+
+<p>
+You can specify custom include directories and compile definitions prior to
+a target definition on a per directory basis (have a look at the <a
+href="http://cmake.org/cmake/help/v2.8.8/cmake.html">CMake
+documentation</a> for further details):
+
+<pre class="cmake">
+INCLUDE_DIRECTORIES(include1 include2)
+
+ADD_DEFINITIONS(-DFOO -DBAR="BAZ")
+
+ADD_EXECUTABLE(...) # or ADD_LIBRARY(...)
+</pre>
+</p>
+
+<a name="cmakeadvanced.external_libraries"></a>
+<h3>External libraries</h3>
+
+<p>
+For external libraries that provide a CMake project configuration or where
+a CMake find module is available, including this external library in your
+project is more or less straightforward. E.g. to require an external
+project "foo" at least of version 8.0 write:
+<pre class="cmake">
+FIND_PACKAGE(foo 8.0 REQUIRED)
+</pre>
+Alternatively, the version number and <code>REQUIRED</code> keyword can be
+omitted. (Depending on the external library) the project configuration or
+find macro will usually define variables like <code>FOO_INCLUDE_DIRS</code>
+and <code>FOO_LIBRARIES</code> that can be directly used in your
+<code>CMakeLists.txt</code> file:
+
+<pre class="cmake">
+INCLUDE_DIRECTORIES(${FOO_INCLUDE_DIRS})
+
+ADD_EXECUTABLE(mycode mycode.cc)
+DEAL_II_SETUP_TARGET(mycode)
+
+TARGET_LINK_LIBRARIES(mycode ${FOO_LIBRARIES})
+</pre>
+The first statement will set up the include directories for the following
+targets as explained above. The last statement with
+<code>TARGET_LINK_LIBRARIES</code> will <i>add</i> the libraries in the
+<code>FOO_LIBRARIES</code> variable to the link interface of the target
+<code>mycode</code>.
+</p>
+
+<a name="cmakeadvanced.run"></a>
+<h3>The "run" target revisited</h3>
+
+<p>The simple run statement as explained <a
+href="#cmakesimple.run">above</a> will run the generated executable in the
+build directory. Sometimes it is more desirable to run the executable in a
+dedicated <code>run</code> directory within in the build directory which is
+a copy of a skeleton <code>run</code> folder from the source directory:
+
+<pre class="cmake">
+# Copy folder run from the source to the build directory:
+FILE(COPY ${CMAKE_SOURCE_DIR}/run DESTINATION ${CMAKE_BINARY_DIR})
+
+ADD_EXECUTABLE(mycode mycode.cc)
+SET_PROPERTY(TARGET mycode
+ PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run
+ )
+ADD_CUSTOM_TARGET(run
+ COMMAND mycode
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/run
+ )
+</pre>
+Here, we modify the <code>RUNTIME_OUTPUT_DIRECTORY</code> property of our
+target so that the executable is linked inside our designated
+<code>run</code> folder, so that it is conveniently available as an
+executable inside the run folder. Furthermore, we specify a
+<code>WORKING_DIRECTORY</code> for the <code>run</code> target, so that
+<code>make run</code> invokes the executable inside the intendet run
+directory.
+</p>
+
+<a name="cmakeadvanced.install"></a>
+<h3>Install a project</h3>
+
+<p>If you want the <code>make install</code> to install your project to
+<code>CMAKE_INSTALL_PREFIX</code> (that may be set on command line or in
+the cache during the configuration stage), add appropriate
+<code>INSTALL</code> statements. To install e.g. a project consisting of a
+library and an executable as well as a run folder:
+
+<pre class="cmake">
+# [...] all the target definitions
+
+INSTALL(TARGETS mylib DESTINATION lib)
+INSTALL(TARGETS mycode DESTINATION bin)
+
+INSTALL(DIRECTORY run DESTINATION share/mycode/run)
+</pre>
+
+<a name="cmakesauto"></a>
+<h2>Autopilot style CMakeLists.txt</h2>
+
+<p>
+ If you want a make interface similar to the deal.II library and
+ its tutorial, namely maker targets for debug and release
+ versions, running the code and cleaning, the easiest way to
+ write a <code>CMakeLists.txt</code> file may be to use
+ an "autopilot" style macro. Here is a minimalistic example for the
+ step-1 tutorial program (<a href="CMakeLists.txt.sample2"
+ target="_top">plain text</a> version) that can be used for simple
+ projects:
+</p>
+
+<pre class="cmake">
+FIND_PACKAGE(deal.II 8.0 REQUIRED
+ HINTS
+ ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}
+ # You can specify additional hints for search paths here, e.g.
+ # $ENV{HOME}/workspace/deal.II
+)
+
+# Set the name of the project and target:
+SET(TARGET "step-1")
+
+# Declare all source files the target consists of:
+SET(TARGET_SRC
+ step-1.cc
+ # You can specify additional files here!
+)
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
+DEAL_II_INITIALIZE_CACHED_VARIABLES()
+PROJECT(${TARGET} CXX)
+DEAL_II_INVOKE_AUTOPILOT()
+</pre>
+
+
+ This <code>CMakeLists.txt</code> is intended for use with a small
+ project and <i>in-source</i> build (i.e., one does not create a separate
+ build directory as we recommend for the <acronym>deal.II</acronym> build
+ in the <a href="../readme.html#configuration" target="_body">readme
+ file</a>). Using this input file, you can run <code>cmake</code> in the
+ source directory as follows:
+
+<pre class="sample">
+$ cd step-1
+$ cmake .
+
+[...]
+
+###
+#
+# Successfully set up project step-1 with deal.II-99.99.svn30300 found at
+# /usr
+#
+# CMAKE_BUILD_TYPE: Debug
+#
+# You can now run
+# $ make - to compile and link the program
+# $ make run - to (compile, link and) run the program
+#
+# $ make debug - to switch the build type to Debug
+# $ make release - to switch the build type to Release
+#
+# $ make edit_cache - to change (cached) configuration variables
+# and rerun the configure and generate phases of CMake
+#
+# $ make strip_comments - strip the source files in this
+# directory off the documentation comments
+# $ make clean - to remove the generated executable as well as
+# all intermediate compilation files
+# $ make runclean - to remove all output generated by the program
+# $ make distclean - to clean the directory from _all_ generated
+# files (includes clean, runclean and the removal
+# of the generated build system)
+#
+# $ make help - to view this message again
+#
+# Have a nice day!
+#
+###
+</pre>
+
+ There are two additional configuration options (in addition to
+ <code>TARGET</code> and <code>TARGET_SRC</code>) that can be set via
+ variables before <code>DEAL_II_INVOKE_AUTOPILOT()</code> is called
+ (<a href="CMakeLists.txt.sample3" target="_top">plain text</a> version):
+
+<pre class="cmake">
+# (Optional)
+# Specify a list of files (file globs) that will be removed
+# with the "make runclean" and "make distclean" targets.
+# (If empty, sensible default values will be used.)
+SET(CLEAN_UP_FILES
+ # a custom list of globs, e.g. *.log *.vtk
+)
+
+# (Optional)
+# A custom command line that should be invoked by "make run".
+# (If empty, ./${TARGET} will be invoked.)
+SET(TARGET_RUN
+ # a custom command line, e.g. mpirun -np 2 ${TARGET}
+)
+</pre>
+
+
+<a name="dealiiconfig"></a>
+<h2> <code>deal.IIConfig.cmake</code> </h2>
+
+<p>
+ Importing the deal.IIConfig.cmake file via <code>FIND_PACKAGE</code>
+ will set the following variables and macros; all of the form
+ <code>DEAL_II_*</code>:
+</p>
+<pre class="cmake">
+#
+# General package information:
+#
+
+DEAL_II_PACKAGE_NAME
+DEAL_II_PACKAGE_VERSION - the full package version string, e.g. "8.1.pre"
+DEAL_II_PACKAGE_VENDOR
+DEAL_II_PACKAGE_DESCRIPTION
+
+DEAL_II_VERSION - version string without suffix, e.g. "8.1"
+DEAL_II_VERSION_MAJOR - the major number, e.g. "8"
+DEAL_II_VERSION_MINOR - the minor version number, e.g. "1"
+
+DEAL_II_BUILD_TYPE - the configured build type, e.g. "DebugRelease"
+DEAL_II_BUILD_TYPES - an all caps list of available configurations,
+ e.g. "DEBUG;RELEASE"
+
+#
+# Information about component locations:
+#
+
+DEAL_II_PATH
+DEAL_II_CMAKE_MACROS_RELDIR
+DEAL_II_COMMON_RELDIR
+DEAL_II_DOCREADME_RELDIR
+DEAL_II_DOCHTML_RELDIR
+DEAL_II_EXAMPLES_RELDIR
+DEAL_II_EXECUTABLE_RELDIR
+DEAL_II_INCLUDE_RELDIR
+DEAL_II_LIBRARY_RELDIR
+DEAL_II_PROJECT_CONFIG_RELDIR
+
+DEAL_II_BUILD_DIR - true if deal.II was picked up from a build
+ dir, false if the configuration is from an installation
+
+#
+# Compiler and linker configuration
+#
+
+DEAL_II_CXX_COMPILER - the compiler used to compile deal.II
+
+DEAL_II_CXX_FLAGS - compile flags for all configurations
+DEAL_II_CXX_FLAGS_DEBUG - _additional_ compile flags for the debug configuration
+DEAL_II_CXX_FLAGS_RELEASE - _additional_ compile flags for the release configuration
+
+DEAL_II_LINKER_FLAGS - link flags for all configurations
+DEAL_II_LINKER_FLAGS_DEBUG - _additional_ link flags for debug configuration
+DEAL_II_LINKER_FLAGS_RELEASE - _additional_ link flags for release configuration
+
+DEAL_II_USER_DEFINITIONS - compile definitions for all configurations
+DEAL_II_USER_DEFINITIONS_DEBUG - _additional_ compile definitions for debug configuration
+DEAL_II_USER_DEFINITIONS_RELEASE - _additional_ compile definitions for release configuration
+
+DEAL_II_STATIC_EXECUTABLE - true if the link interface is set up to
+ compile resulting executables statically
+
+#
+# Information about include directories and libraries
+#
+
+DEAL_II_INCLUDE_DIRS
+
+DEAL_II_LIBRARIES_DEBUG - a list of the full link interface for the debug configuration
+DEAL_II_LIBRARIES_RELEASE - a list of the full link interface for the release configuration
+DEAL_II_LIBRARIES - full list of libraries with "debug" and "optimized" keywords
+
+#
+# Information about library targets
+#
+
+DEAL_II_TARGET_CONFIG - the target config file
+
+DEAL_II_TARGET_DEBUG - the name of the debug target that is available after inclusion
+ of the target config file
+DEAL_II_TARGET_RELEASE - the name of the release target
+DEAL_II_TARGET - full list of targets with "debug" and "optimized" keywords
+
+#
+# Feature configuration: The following booleans are set to "ON" or "OFF" depending
+# on the current feature configuration:
+#
+
+DEAL_II_WITH_64BIT_INDICES
+DEAL_II_WITH_ARPACK
+DEAL_II_WITH_BOOST
+DEAL_II_WITH_FUNCTIONPARSER
+DEAL_II_WITH_HDF5
+DEAL_II_WITH_LAPACK
+DEAL_II_WITH_METIS
+DEAL_II_WITH_MPI
+DEAL_II_WITH_MUMPS
+DEAL_II_WITH_NETCDF
+DEAL_II_WITH_P4EST
+DEAL_II_WITH_PETSC
+DEAL_II_WITH_SLEPC
+DEAL_II_WITH_THREADS
+DEAL_II_WITH_TRILINOS
+DEAL_II_WITH_UMFPACK
+DEAL_II_WITH_ZLIB
+</pre>
+
+ <a name="legacy"></a>
+ <h2> Legacy Make.global_options </h2>
+
+ <p>
+ Before version 8.0, <acronym>deal.II</acronym> used the
+ traditional <code>autoconf/make</code> configuration and build
+ system. The interaction between these two programs, as well as
+ propagation of information from <acronym>deal.II</acronym> to user
+ programs happened through a number of files that were generated within
+ the <acronym>deal.II</acronym> directory tree.
+ The CMake build system sets up the following compatibility files (if
+ <code>DEAL_II_COMPONENT_COMPAT_FILES</code> is set, which is default):
+ <pre>
+
+ ${CMAKE_INSTALL_PREFIX}
+ ./common/Make.global_options
+ ./common/scripts/expand_instantiations
+ ./common/scripts/make_dependencies
+ ./common/scripts/report_features
+ </pre>
+
+ Therefore, it should be sufficient to set <code>D</code> in the old
+ user Makefiles to:
+ <pre>
+
+ D=/path/install/dir
+ </pre>
+ where <code>/path/install/dir</code> is the directory set up via
+ <code>CMAKE_INSTALL_PREFIX</code> (the path
+ <acronym>deal.II</acronym> was installed to).
+ </p>
+
+ <hr />
+ <address>
+ <a href="../authors.html" target="body">The deal.II Authors</a>
+ $Date$
+ </address>
+ <div class="right">
+ <a href="http://validator.w3.org/check?uri=referer" target="_top">
+ <img style="border:0" src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
+ <a href="http://jigsaw.w3.org/css-validator/check/referer" target="_top">
+ <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
+ </div>
+
+ </body>
+</html>
<p>deal.II has an extensive reference documentation generated
by <a href="http://www.doxygen.org">Doxygen</a>. One of the many
- features of Doxygen is, that all class names, function noames and so
+ features of Doxygen is, that all class names, function names and so
on are cross-linked in the documentation, and a single click
suffices to jump to the documentation of an object.</p>
</li>
</ol>
- <hr>
-
+ <hr />
<address>
- <a href="../mail.html">The deal.II Group</a></address>
-
+ <a href="../authors.html" target="body">The deal.II Authors</a>
+ $Date$
+ </address>
+ <div class="right">
+ <a href="http://validator.w3.org/check?uri=referer" target="_top">
+ <img style="border:0" src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
+ <a href="http://jigsaw.w3.org/css-validator/check/referer" target="_top">
+ <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
+ </div>
</body>
</html>
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN"
+ "http://www.w3.org/TR/REC-html40/frameset.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
+ <title>deal.II Development Information</title>
+ <link href="../screen.css" type="text/css" rel="StyleSheet">
+ <link rel="SHORTCUT ICON" href="../deal.ico">
+ <meta name="author" content="the deal.II authors <authors@dealii.org>">
+ <meta name="copyright" content="Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2007, 2012 by the deal.II authors">
+ <meta name="date" content="$Date$">
+ <meta name="svn_id" content="$Id$">
+ <meta http-equiv="content-language" content="en">
+</head>
+
+<frameset rows="70,*">
+ <frame name="title" src="title.html" frameborder="1">
+ <frameset cols="150,*">
+ <frame name="navbar" src="navbar.html" frameborder="0">
+ <frame name="body" src="toc.html" frameborder="0">
+ </frameset>
+ <noframes>
+ <h1>deal.II Development Information</h1>
+ Your browser does not seem to understand frames. A version of this
+ page that does not use frames can be found at
+ <a href="toc.html">toc.html</a>.
+ </noframes>
+</frameset>
+</html>
+
+
+
+
+
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
+ <title>deal.II Development Navigation Bar</title>
+ <link href="../screen.css" rel="StyleSheet">
+ <meta name="author" content="the deal.II authors <authors@dealii.org>">
+ <meta name="copyright" content="Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2012, 2013 by the deal.II authors">
+ <meta name="date" content="$Date$">
+ <meta name="svn_id" content="$Id$">
+ <meta http-equiv="content-language" content="en">
+ </head>
+<body class="navbar">
+
+ <p>
+ <a href="http://www.dealii.org"target="_top">http://www.dealii.org</a><br />
+ <a href="../index.html" target="_top">Home</a><br />
+ </p>
+
+ <hr>
+
+ <p>
+ <a href="../readme.html" target="body">README</a><br />
+ <a href="index.html" target="_top">Users' Corner</a><br />
+ <a href="../developers/index.html" target="_top">Developers' Corner</a><br />
+ </p>
+
+ <hr>
+
+ <b><small>Documentation</small></b>
+
+ <p>
+ <a href="cmake.html" target="body">CMake documentation</a><br />
+ <a href="cmakelists.html" target="body">CMake in user projects</a><br />
+ <a href="doxygen.html" target="body">Linking manuals</a><br />
+ </p>
+
+ <hr>
+
+ <b><small>Doxygen</small></b>
+ <p>
+ <a href="../doxygen/tutorial/index.html" target="_top">Tutorial</a><br />
+ <a href="../doxygen/deal.II/index.html" target="_top">Manual</a><br />
+ <a href="http://www.math.tamu.edu/~bangerth/videos.html"
+ target="_top">Video lectures</a><br />
+ </p>
+
+ <hr>
+
+ <b><small>Online Resources</small></b>
+ <p>
+ <a href="https://code.google.com/p/dealii/wiki/FrequentlyAskedQuestions" target="_top">FAQ</a><br />
+ <a href="news/news.html" target="body">News</a><br />
+ <a href="http://www.dealii.org/download/" target="body">Download</a><br />
+ <a href="http://www.dealii.org/mail.html" target="body">Mailing list</a><br />
+ <a href="https://code.google.com/p/dealii/w/list" target="_top">Wiki</a><br />
+ <a href="https://code.google.com/p/dealii/issues/list" target="_top">Bug tracker</a><br />
+ </p>
+
+</body>
+</html>
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
+ <title>deal.II Tutorial</title>
+ <link href="../screen.css" rel="StyleSheet">
+ <meta name="author" content="the deal.II authors <authors@dealii.org>">
+ <meta name="copyright" content="Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2012 by the deal.II authors">
+ <meta name="date" content="$Date$">
+ <meta name="svn_id" content="$Id$">
+ <meta name="keywords" content="deal dealii finite elements fem triangulation">
+ <meta http-equiv="content-language" content="en">
+</head>
+
+<body class="title">
+ <div class="fixedhead">
+ <h1 class="head">
+ Users' Corner
+ </h1>
+ </div>
+</body>
+</html>
+
+
+
+
+
+
+
+
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
+ <title>The deal.II Development Page</title>
+ <link href="../screen.css" rel="StyleSheet">
+ <meta name="author" content="the deal.II authors <authors@dealii.org>">
+ <meta name="copyright" content="Copyright (C) 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2012, 2013 by the deal.II authors">
+ <meta name="date" content="$Date$">
+ <meta name="svn_id" content="$Id$">
+ <meta name="keywords" content="deal dealii finite elements fem triangulation">
+ <meta http-equiv="content-language" content="en">
+</head>
+ <body>
+
+ <p>
+ <br />
+ This page gathers some information on developing programs based on
+ <acronym>deal.II</acronym>, as well as on how to configure and use
+ <acronym>deal.II</acronym>. At present, we have the following resources
+ available:
+ </p>
+
+
+ <h2>Documentation</h2>
+
+ <ul>
+
+ <li> <p>
+ <a href="cmake.html">deal.II CMake documentation</a>:
+ This page provides extensive information about configuration and
+ installation with the CMake build system.
+
+ <li> <p><a href="cmakelists.html" target="body">Using CMake and
+ <acronym>deal.II</acronym> in a user project</a>:
+ This page covers how to use CMake in your own project.
+ An overview of how to retrieve necessary information
+ from a <acronym>deal.II</acronym> installation as well as how to
+ write a <code>CMakeLists.txt</code> for a client project is given.
+ </p>
+
+ <li> <p><a href="doxygen.html">Linking your online documentation
+ to the deal.II online manual</a>: After spending a lot of time
+ writing good documentation for your code and putting it online,
+ here we explain how to put links to the deal.II online manual into
+ your documentation, so that readers can click through.
+ </p>
+
+ <li> <p><a href="https://code.google.com/p/dealii/issues/list" target="_top">Bugs</a>:
+ Though well tested, <acronym>deal.II</acronym> certainly has
+ bugs. If you want to report a bug (or enhancement request),
+ go to the <a href="https://code.google.com/p/dealii/issues/list"
+ target="_top">bug tracking system</a> and enter a new ticket
+ for your issue.
+ </p>
+
+ </ul>
+
+
+ <h2>Tutorials</h2>
+
+ <p>
+ The <a href="../doxygen/tutorial/index.html"
+ target="_top">tutorial</a> is
+ for new users of the library. It explains the basic elements of
+ finite element programs based on the library, and provides small
+ example programs. You can also reach the tutorial link from the menu bar
+ at the left.
+ </p>
+
+ <p>
+ Note that along with the rest of the documentation, the local HTML pages
+ of the tutorials need to be generated first. Please follow the
+ instructions in the
+ <a href="../readme.html" target="body">ReadMe</a> on how to do
+ this.
+ </p>
+
+
+ <h2>Programming interface</h2>
+
+ <p>
+ The <a href="../doxygen/deal.II/index.html" target="_top">programming
+ interface/manual</a> pages are what you will need most often as a
+ reference of all classes, functions and variables in the library. They
+ are extensively documented (presently more than 5000 pages if
+ printed), and generated by <a href="http://www.doxygen.org/"
+ target="_top">Doxygen</a>. There is also a quick link to these pages from
+ the menu bar at the left.
+ </p>
+
+ <p>
+ The documentation uses many of the features of Doxygen. In particular,
+ the link takes you straight to a page that lists <i>modules</i>, a way
+ to group classes with similar purposes. This may be what you are probably
+ interested in when you are not yet familiar with the library. If you
+ already know your way around and want to look up the signature of a
+ particular member function, for example, you may go to the class view or
+ choose any of the other ways in which Doxygen allows you to navigate
+ through the documentation.
+ </p>
+
+ <p>
+ Just as for the tutorials, the API docs need to be generated first,
+ if you download <acronym>deal.II</acronym>. Please follow the
+ instructions in the
+ <a href="../readme.html" target="body">ReadMe</a> on how to do
+ this.
+ </p>
+
+ <hr />
+ <address>
+ <a href="../authors.html" target="body">The deal.II Authors</a>
+ $Date$
+ </address>
+ <div class="right">
+ <a href="http://validator.w3.org/check?uri=referer" target="_top">
+ <img style="border:0" src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"></a>
+ <a href="http://jigsaw.w3.org/css-validator/check/referer" target="_top">
+ <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"></a>
+ </div>
+
+ </body>
+</html>
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
IF(DEAL_II_COMPONENT_EXAMPLES)
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005-2006, 2012 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
// See documentation of BlockMatrixArray for documentation of this example
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006-2007 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
// See documentation of BlockCompressedSparsityPattern for documentation of this example
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005-2006, 2010, 2012 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
// See documentation of ProductMatrix for documentation of this example
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005-2006, 2010, 2012 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
// See documentation of ThetaTimestepping for documentation of this example
-/* $Id$
+/* ---------------------------------------------------------------------
+ * $Id$
*
- * Copyright (C) 1999-2003, 2005-2007, 2009, 2011-2013 by the deal.II authors
+ * Copyright (C) 1999 - 2013 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.
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
*/
+
// @sect3{Include files}
// The most fundamental class in the library is the Triangulation class, which
// We then fill it with a ring domain. The center of the ring shall be the
// point (1,0), and inner and outer radius shall be 0.5 and 1. The number of
// circumferential cells could be adjusted automatically by this function,
- // but we choose to set it explicitely to 10 as the last argument:
+ // but we choose to set it explicitly to 10 as the last argument:
const Point<2> center (1,0);
const double inner_radius = 0.5,
outer_radius = 1.0;
@code
set style data lines
set size 0.721, 1
-set nokey
+unset key
plot [-1:1][-1:1] "ball0_mapping_q1.dat"
@endcode
or using one of the other filenames. The second line makes sure that
Computation of Pi by the area:
==============================
Degree = 1
-cells eval.pi error
-5 1.9999999999999998 1.1416e+00 -
-20 2.8284271247461898 3.1317e-01 1.87
-80 3.0614674589207178 8.0125e-02 1.97
-320 3.1214451522580520 2.0148e-02 1.99
-1280 3.1365484905459389 5.0442e-03 2.00
-5120 3.1403311569547521 1.2615e-03 2.00
+cells eval.pi error
+ 5 1.9999999999999993 1.1416e+00 -
+ 20 2.8284271247461894 3.1317e-01 1.87
+ 80 3.0614674589207178 8.0125e-02 1.97
+ 320 3.1214451522580520 2.0148e-02 1.99
+ 1280 3.1365484905459393 5.0442e-03 2.00
+ 5120 3.1403311569547534 1.2615e-03 2.00
Degree = 2
-cells eval.pi error
-5 3.1045694996615869 3.7023e-02 -
-20 3.1391475703122276 2.4451e-03 3.92
-80 3.1414377167038303 1.5494e-04 3.98
-320 3.1415829366419019 9.7169e-06 4.00
-1280 3.1415920457576907 6.0783e-07 4.00
-5120 3.1415926155921126 3.7998e-08 4.00
+cells eval.pi error
+ 5 3.1045694996615865 3.7023e-02 -
+ 20 3.1391475703122271 2.4451e-03 3.92
+ 80 3.1414377167038303 1.5494e-04 3.98
+ 320 3.1415829366419015 9.7169e-06 4.00
+ 1280 3.1415920457576911 6.0783e-07 4.00
+ 5120 3.1415926155921139 3.7998e-08 4.00
Degree = 3
-cells eval.pi error
-5 3.1465390309173475 4.9464e-03 -
-20 3.1419461263297386 3.5347e-04 3.81
-80 3.1416154689089382 2.2815e-05 3.95
-320 3.1415940909713274 1.4374e-06 3.99
-1280 3.1415927436051230 9.0015e-08 4.00
-5120 3.1415926592185492 5.6288e-09 4.00
+cells eval.pi error
+ 5 3.1410033851499310 5.8927e-04 -
+ 20 3.1415830393583861 9.6142e-06 5.94
+ 80 3.1415925017363837 1.5185e-07 5.98
+ 320 3.1415926512106722 2.3791e-09 6.00
+ 1280 3.1415926535525962 3.7197e-11 6.00
+ 5120 3.1415926535892140 5.7923e-13 6.00
Degree = 4
-cells eval.pi error
-5 3.1418185737113964 2.2592e-04 -
-20 3.1415963919525050 3.7384e-06 5.92
-80 3.1415927128397780 5.9250e-08 5.98
-320 3.1415926545188264 9.2903e-10 5.99
-1280 3.1415926536042722 1.4479e-11 6.00
-5120 3.1415926535899668 1.7343e-13 6.38
-
+cells eval.pi error
+ 5 3.1415871927401127 5.4608e-06 -
+ 20 3.1415926314742437 2.2116e-08 7.95
+ 80 3.1415926535026228 8.7170e-11 7.99
+ 320 3.1415926535894529 3.4036e-13 8.00
+ 1280 3.1415926535897927 2.9187e-16 10.19
+ 5120 3.1415926535897944 1.3509e-15 -2.21
Computation of Pi by the perimeter:
===================================
Degree = 1
-cells eval.pi error
-5 2.8284271247461903 3.1317e-01 -
-20 3.0614674589207183 8.0125e-02 1.97
-80 3.1214451522580524 2.0148e-02 1.99
-320 3.1365484905459393 5.0442e-03 2.00
-1280 3.1403311569547525 1.2615e-03 2.00
-5120 3.1412772509327729 3.1540e-04 2.00
+cells eval.pi error
+ 5 2.8284271247461898 3.1317e-01 -
+ 20 3.0614674589207178 8.0125e-02 1.97
+ 80 3.1214451522580520 2.0148e-02 1.99
+ 320 3.1365484905459393 5.0442e-03 2.00
+ 1280 3.1403311569547525 1.2615e-03 2.00
+ 5120 3.1412772509327729 3.1540e-04 2.00
Degree = 2
-cells eval.pi error
-5 3.1248930668550599 1.6700e-02 -
-20 3.1404050605605454 1.1876e-03 3.81
-80 3.1415157631807014 7.6890e-05 3.95
-320 3.1415878042798613 4.8493e-06 3.99
-1280 3.1415923498174538 3.0377e-07 4.00
-5120 3.1415926345932004 1.8997e-08 4.00
+cells eval.pi error
+ 5 3.1248930668550594 1.6700e-02 -
+ 20 3.1404050605605449 1.1876e-03 3.81
+ 80 3.1415157631807014 7.6890e-05 3.95
+ 320 3.1415878042798617 4.8493e-06 3.99
+ 1280 3.1415923498174534 3.0377e-07 4.00
+ 5120 3.1415926345932004 1.8997e-08 4.00
Degree = 3
-cells eval.pi error
-5 3.1442603311164286 2.6677e-03 -
-20 3.1417729561193588 1.8030e-04 3.89
-80 3.1416041192612365 1.1466e-05 3.98
-320 3.1415933731961760 7.1961e-07 3.99
-1280 3.1415926986118001 4.5022e-08 4.00
-5120 3.1415926564043946 2.8146e-09 4.00
+cells eval.pi error
+ 5 3.1414940401456057 9.8613e-05 -
+ 20 3.1415913432549156 1.3103e-06 6.23
+ 80 3.1415926341726914 1.9417e-08 6.08
+ 320 3.1415926532906893 2.9910e-10 6.02
+ 1280 3.1415926535851360 4.6571e-12 6.01
+ 5120 3.1415926535897203 7.2845e-14 6.00
Degree = 4
-cells eval.pi error
-5 3.1417078926581086 1.1524e-04 -
-20 3.1415945317216001 1.8781e-06 5.94
-80 3.1415926832497720 2.9660e-08 5.98
-320 3.1415926540544636 4.6467e-10 6.00
-1280 3.1415926535970535 7.2602e-12 6.00
-5120 3.1415926535899010 1.0805e-13 6.07
+cells eval.pi error
+ 5 3.1415921029432576 5.5065e-07 -
+ 20 3.1415926513737600 2.2160e-09 7.96
+ 80 3.1415926535810712 8.7218e-12 7.99
+ 320 3.1415926535897594 3.3668e-14 8.02
+ 1280 3.1415926535897922 1.0617e-15 4.99
+ 5120 3.1415926535897931 1.0061e-16 3.40
@endcode
-One of the immediate observations from the output is that in all cases
-the values converge quickly to the true value of
-$\pi=3.141592653589793238462643$. Note that for the $Q_4$ mapping, the last
-number is correct to 13 digits in both computations, which is already
-quite a lot. However, also note that for the $Q_1$ mapping, even on the
-finest grid the accuracy is significantly worse than on the coarse
-grid for a $Q_4$ mapping!
+One of the immediate observations from the output is that in all cases the
+values converge quickly to the true value of
+$\pi=3.141592653589793238462643$. Note that for the $Q_4$ mapping, we are
+already in the regime of roundoff errors and the convergence rate levels off,
+which is already quite a lot. However, also note that for the $Q_1$ mapping,
+even on the finest grid the accuracy is significantly worse than on the coarse
+grid for a $Q_3$ mapping!
-The last column of the output shows the convergence order, in powers
-of the mesh width $h$. In the introduction, we had stated that
-the convergence order for a $Q_p$ mapping should be
-$h^{p+1}$. However, in the example shown, the $Q_2$ and $Q_4$
-mappings show a convergence order of $h^{p+2}$! This at
-first surprising fact is readily explained by the particular boundary
-we have chosen in this example. In fact, the circle is described by the function
-$\sqrt{1-x^2}$, which has the series expansion
-$1-x^2/2-x^4/8-x^6/16+\ldots$
-around $x=0$. Thus, for the quadratic mapping where the
-truncation error of the quadratic approximation should be cubic, there
-is no such term but only a quartic one, which raises the convergence
-order to 4, instead of 3. The same happens for the $Q_4$ mapping.
+The last column of the output shows the convergence order, in powers of the
+mesh width $h$. In the introduction, we had stated that the convergence order
+for a $Q_p$ mapping should be $h^{p+1}$. However, in the example shown, the
+order is rather $h^{2p}$! This at first surprising fact is explained by the
+properties of the $Q_p$ mapping. At order <i>p</i>, it uses support points
+that are based on the <i>p</i>+1 point Gauss-Lobatto quadrature rule that
+selects the support points in such a way that the quadrature rule converges at
+order 2<i>p</i>. Even though these points are here only used for interpolation
+of a <i>p</i>th order polynomial, we get a superconvergence effect when
+numerically evaluating the integral that actually gives this high order of
+convergence.
-/* Author: Wolfgang Bangerth, Ralf Hartmann, University of Heidelberg, 2001 */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2001 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Authors: Wolfgang Bangerth, Ralf Hartmann, University of Heidelberg, 2001
+ */
-/* $Id$ */
-/* */
-/* Copyright (C) 2001-2004, 2006-2007, 2011-2012 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. */
// The first of the following include files are probably well-known by now and
// need no further explanation.
// will generate Gnuplot output, which consists of a set of lines
// describing the mapped triangulation. By default, only one line
// is drawn for each face of the triangulation, but since we want
- // to explicitely see the effect of the mapping, we want to have
+ // to explicitly see the effect of the mapping, we want to have
// the faces in more detail. This can be done by passing the
// output object a structure which contains some flags. In the
// present case, since Gnuplot can only draw straight lines, we
solutions of Laplace's equation are only in $H^1$, which does not allow for
the definition of point values because it is not a subset of the continuous
functions. Therefore, even though fixing one node is allowed for
- discretitized functions, it is not for continuous functions, and one can
+ discretized functions, it is not for continuous functions, and one can
often see this in a resulting error spike at this point in the numerical
solution.
consider the objects describing mappings as a black box which you need not
worry about, because their only uses seem to be to be passed to places deep
inside the library where functions know how to handle them (i.e. in the
-<code>FEValues</code> classes and their descendents).
+<code>FEValues</code> classes and their descendants).
The tricky point in this program is the use of the mean value
constraint. Fortunately, there is a class in the library which knows how to
case to use a higher order mapping, not because it improves the order
of convergence but just to reduce the constant before the convergence
order. On the other hand, using a cubic mapping only improves the
-result further insignicantly, except for the case of very coarse
+result further insignificantly, except for the case of very coarse
grids.
-/* Author: Wolfgang Bangerth, University of Heidelberg, 2001 */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2001 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Wolfgang Bangerth, University of Heidelberg, 2001
+ */
-/* $Id$ */
-/* */
-/* Copyright (C) 2001-2004, 2006, 2009, 2011-2012 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. */
// As usual, the program starts with a rather long list of include files which
// you are probably already used to by now:
// the mean value of the degrees of freedom on the boundary shall be
// zero. For this, we first want a list of those nodes which are actually
// at the boundary. The <code>DoFTools</code> class has a function that
- // returns an array of boolean values where <code>true</code> indicates
+ // returns an array of Boolean values where <code>true</code> indicates
// that the node is at the boundary. The second argument denotes a mask
// selecting which components of vector valued finite elements we want to
// be considered. This sort of information is encoded using the
-/* Author: Guido Kanschat, Texas A&M University, 2009 */
-
-/* $Id$ */
-/* */
-/* Copyright (C) 2010-2013 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. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2009 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Guido Kanschat, Texas A&M University, 2009
+ */
+
// The first few files have already been covered in previous examples and will
// thus not be further commented on:
In previous examples, you have seen how the library itself is broken
-up into several complexes each building atop the underying ones, but
+up into several complexes each building atop the underlying ones, but
relatively independent of the other ones:
<ol>
<li>the triangulation class complex, with associated iterator classes;
documentation, which would bring that to maybe 1200 lines. Yet, compared to
the applications listed above, this is still small, as they are 20 to
25 times as large. For programs as large, a proper design right from
-the start is thus indispensible. Otherwise, it will have to be
+the start is thus indispensable. Otherwise, it will have to be
redesigned at one point in its life, once it becomes too large to be
manageable.
and when to reload it again; if this is not done in an organized
fashion, then you end up with data released too early, loaded too
late, or not released at all). Although the present example program
-thus draws from sevelar years of experience, it is certainly not
+thus draws from several years of experience, it is certainly not
without flaws in its design, and in particular might not be suited for
an application where the objective is different. It should serve as an
inspiration for writing your own application in a modular way, to
-/* Author: Wolfgang Bangerth, University of Heidelberg, 2001, 2002 */
-
-/* $Id$ */
-/* */
-/* Copyright (C) 2001-2004, 2006-2009, 2011-2013 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. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2001 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Wolfgang Bangerth, University of Heidelberg, 2001, 2002
+ */
// As in all programs, we start with a list of include files from the library,
// macros. We use this mechanism here again.
//
// From this, the actual declaration of this class should be evident. Note
- // that of course even if we do not list a destructor explicitely, an
+ // that of course even if we do not list a destructor explicitly, an
// implicit destructor is generated from the compiler, and it is virtual
// just as the one of the base class.
template <int dim>
// The second of this pair of functions takes a range of cell iterators,
// and assembles the system matrix on this part of the domain. Since it's
// actions have all been explained in previous programs, we do not comment
- // on it any more, except for one pointe below.
+ // on it any more, except for one point below.
template <int dim>
void
Solver<dim>::assemble_matrix (LinearSystem &linear_system,
// lead to deadlocks. A similar situation arises, when one changes
// the code to have a return statement somewhere in the middle of
// the locked block, and forgets that before we call
- // <code>return</code>, we also have to unlock the mutex. This all
- // is not be a problem here, but we want to show the general
+ // <code>return</code>, we also have to unlock the mutex. All this
+ // is no problem here, but we want to show the general
// technique to cope with these problems nevertheless: have an
// object that upon initialization (i.e. in its constructor) locks
// the mutex, and on running the destructor unlocks it again. This
// will always be unlocked when we exit this part of the program,
// whether the operation completed successfully or not, whether the
// exit path was something we implemented willfully or whether the
- // function was exited by an exception that we did not forsee.
+ // function was exited by an exception that we did not foresee.
//
// deal.II implements the scoped locking pattern in the
// Treads::Mutex::ScopedLock class: it takes the mutex in the
// @sect4{Local refinement by the Kelly error indicator}
// The second class implementing refinement strategies uses the Kelly
- // refinemet indicator used in various example programs before. Since this
+ // refinement indicator used in various example programs before. Since this
// indicator is already implemented in a class of its own inside the
// deal.II library, there is not much t do here except cal the function
// computing the indicator, then using it to select a number of cells for
</td>
</tr>
</table>
-Note the assymetry of the grids compared with those we obtained for
+Note the asymmetry of the grids compared with those we obtained for
the point evaluation, which is due to the directionality of the
x-derivative for which we tailored the refinement criterion.
-/* Author: Wolfgang Bangerth, ETH Zurich, 2002 */
-
-/* $Id$ */
-/* */
-/* Copyright (C) 2002-2013 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. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2002 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Wolfgang Bangerth, ETH Zurich, 2002
+ */
// Start out with well known things...
// afterwards...
double point_derivative = 0;
- // ...then have some objects of which the meaning wil become clear
+ // ...then have some objects of which the meaning will become clear
// below...
QTrapez<dim> vertex_quadrature;
FEValues<dim> fe_values (dof_handler.get_fe(),
// We will then implement two such classes, for the evaluation of a point
// value and of the derivative of the solution at that point. For these
// functionals we already have the corresponding evaluation objects, so they
- // are comlementary.
+ // are complementary.
namespace DualFunctional
{
// @sect4{The DualFunctionalBase class}
// Finally, we have by now only integrated the gradients of the shape
// functions, not taking their mean value. We fix this by dividing by
// the measure of the volume over which we have integrated:
- rhs.scale (1./total_volume);
+ rhs /= total_volume;
}
// Next we have the function that is called to estimate the error on a
// subset of cells. The function may be called multiply if the library was
- // configured to use multi-threading. Here it goes:
+ // configured to use multithreading. Here it goes:
template <int dim>
void
WeightedResidual<dim>::
// Then calculate the start cell for this thread. We let the different
// threads run on interleaved cells, i.e. for example if we have 4
- // threads, then the first thread treates cells 0, 4, 8, etc, while the
+ // threads, then the first thread treats cells 0, 4, 8, etc, while the
// second threads works on cells 1, 5, 9, and so on. The reason is that
// it takes vastly more time to work on cells with hanging nodes than on
// regular cells, but such cells are not evenly distributed across the
// element solution at the quadrature points on the other side of the
// face, i.e. from the neighboring cell.
//
- // For this, do a sanity check before: make sure that the neigbor
+ // For this, do a sanity check before: make sure that the neighbor
// actually exists (yes, we should not have come here if the neighbor
// did not exist, but in complicated software there are bugs, so better
// check this), and if this is not the case throw an error.
Assert (cell->neighbor(face_no).state() == IteratorState::valid,
ExcInternalError());
// If we have that, then we need to find out with which face of the
- // neighboring cell we have to work, i.e. the <code>home-many</code>the
+ // neighboring cell we have to work, i.e. the <code>how-many'th</code> the
// neighbor the present cell is of the cell behind the present face. For
// this, there is a function, and we put the result into a variable with
// the name <code>neighbor_neighbor</code>:
const unsigned int
neighbor_neighbor = cell->neighbor_of_neighbor (face_no);
- // Then define an abbreviation for the neigbor cell, initialize the
+ // Then define an abbreviation for the neighbor cell, initialize the
// <code>FEFaceValues</code> object on that cell, and extract the
// gradients on that cell:
const active_cell_iterator neighbor = cell->neighbor(face_no);
ExcInternalError());
// Then find out which neighbor the present cell is of the adjacent
- // cell. Note that we will operator on the children of this adjacent
+ // cell. Note that we will operate on the children of this adjacent
// cell, but that their orientation is the same as that of their mother,
- // i.e. the neigbor direction is the same.
+ // i.e. the neighbor direction is the same.
const unsigned int
neighbor_neighbor = cell->neighbor_of_neighbor (face_no);
// Finally, we have a variable that denotes the maximum number of
// degrees of freedom we allow for the (primal) discretization. If it is
- // exceeded, we stop the process of solving and intermittend mesh
+ // exceeded, we stop the process of solving and intermittent mesh
// refinement. Its default value is 20,000.
unsigned int max_degrees_of_freedom;
right boundary values, the Newton update $\delta u^{n}$ should have zero
boundary conditions, in order to have the right boundary condition after
adding both. In the first Newton step, we are starting with the solution
-$u^{0}\equiv 0$, the Newton update still has to deliever the right boundary
+$u^{0}\equiv 0$, the Newton update still has to deliver the right boundary
condition to the solution $u^{1}$.
<h3>Weak formulation of the problem</h3>
Starting with the strong formulation above, we get the weak formulation by multiplying
-both sides of the PDE with a testfunction $\varphi$ and integrating by parts on both sides:
+both sides of the PDE with a test function $\varphi$ and integrating by parts on both sides:
@f[
\left( \nabla \varphi , \frac{1}{(1+|\nabla u^{n}|^{2})^{\frac{1}{2}}}\nabla
\delta u^{n} \right)-\left(\nabla \varphi ,\frac{\nabla u^{n} \cdot \nabla
\delta u^{n}=\sum_{j=0}^{N-1} U_{j} \varphi_{j}
@f]
-Using the basis functions as testfunctions and defining $a_{n}:=\frac{1}
-{\sqrt{1+|\nabla u^{n}|^{2}}}$, we can rewrite the weak formualtion:
+Using the basis functions as test functions and defining $a_{n}:=\frac{1}
+{\sqrt{1+|\nabla u^{n}|^{2}}}$, we can rewrite the weak formulation:
@f[
\sum_{j=0}^{N-1}\left[ \left( \nabla \varphi_{i} , a_{n} \nabla \varphi_{j} \right) -
\nabla u^{n}\right) \qquad \forall i=0,\dots ,N-1
@f]
-where the solution $\delta u^{n}$ is given by the coefficents $\delta U^{n}_{j}$.
+where the solution $\delta u^{n}$ is given by the coefficients $\delta U^{n}_{j}$.
This linear system of equations can be rewritten as:
@f[
It is clearly visible, that the solution minimizes the surface
after each refinement. The solution converges to a picture one
-would imagine a soapbubble to be that is located inside a wire loop
+would imagine a soap bubble to be that is located inside a wire loop
that is bent like
the boundary. Also it is visible, how the boundary
is smoothed out after each refinement. On the coarse mesh,
-/* $Id$ */
-/* Author: Sven Wetterauer, University of Heidelberg, 2012 */
-
-/* $Id$ */
-/* */
-/* Copyright (C) 2012 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. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2012 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Sven Wetterauer, University of Heidelberg, 2012
+ */
+
// @sect3{Include files}
#include <fstream>
#include <iostream>
-// We will use adaptive mesh refinement between Newton interations. To do so,
+// We will use adaptive mesh refinement between Newton iterations. To do so,
// we need to be able to work with a solution on the new mesh, although it was
// computed on the old one. The SolutionTransfer class transfers the solution
// from the old to the new mesh:
#include <deal.II/numerics/solution_transfer.h>
-// We then open a namepsace for this program and import everything from the
+// We then open a namespace for this program and import everything from the
// dealii namespace into it, as in previous programs:
namespace Step15
{
// $\delta u^n$, and one for the current iterate $u^n$.
// - The <code>setup_system</code> function takes an argument that denotes whether
// this is the first time it is called or not. The difference is that the
- // first time around we need to distributed degrees of freedom and set the
+ // first time around we need to distribute the degrees of freedom and set the
// solution vector for $u^n$ to the correct size. The following times, the
// function is called after we have already done these steps as part of
// refining the mesh in <code>refine_mesh</code>.
// For the assembly of the linear system, we have to obtain the values
// of the previous solution's gradients at the quadrature
// points. There is a standard way of doing this: the
- // FEValues::get_function function takes a vector that represents a
- // finite element field defined on a DoFHandler, and evaluates the
- // gradients of this field at the quadrature points of the cell with
- // which the FEValues object has last been reinitialized. The values
- // of the gradients at all quadrature points are then written into the
- // second argument:
+ // FEValues::get_function_gradients function takes a vector that
+ // represents a finite element field defined on a DoFHandler, and
+ // evaluates the gradients of this field at the quadrature points of the
+ // cell with which the FEValues object has last been reinitialized.
+ // The values of the gradients at all quadrature points are then written
+ // into the second argument:
fe_values.get_function_gradients(present_solution,
old_solution_gradients);
const unsigned int dofs_per_cell = fe.dofs_per_cell;
const unsigned int n_q_points = quadrature_formula.size();
- Vector<double> cell_rhs (dofs_per_cell);
+ Vector<double> cell_residual (dofs_per_cell);
std::vector<Tensor<1, dim> > gradients(n_q_points);
std::vector<types::global_dof_index> local_dof_indices (dofs_per_cell);
endc = dof_handler.end();
for (; cell!=endc; ++cell)
{
- cell_rhs = 0;
+ cell_residual = 0;
fe_values.reinit (cell);
// The actual computation is much as in
gradients[q_point]);
for (unsigned int i = 0; i < dofs_per_cell; ++i)
- cell_rhs(i) -= (fe_values.shape_grad(i, q_point)
+ cell_residual(i) -= (fe_values.shape_grad(i, q_point)
* coeff
* gradients[q_point]
* fe_values.JxW(q_point));
cell->get_dof_indices (local_dof_indices);
for (unsigned int i=0; i<dofs_per_cell; ++i)
- residual(local_dof_indices[i]) += cell_rhs(i);
+ residual(local_dof_indices[i]) += cell_residual(i);
}
// At the end of this function we also have to deal with the hanging node
// As discussed in the introduction, Newton's method frequently does not
// converge if we always take full steps, i.e., compute $u^{n+1}=u^n+\delta
// u^n$. Rather, one needs a damping parameter (step length) $\alpha^n$ and
- // set $u^{n+1}=u^n+\alpha^n\; delta u^n$. This function is the one called
+ // set $u^{n+1}=u^n+\alpha^n\delta u^n$. This function is the one called
// to compute $\alpha^n$.
//
// Here, we simply always return 0.1. This is of course a sub-optimal
-/* Author: Guido Kanschat, University of Heidelberg, 2003 */
-/* Baerbel Janssen, University of Heidelberg, 2010 */
-/* Wolfgang Bangerth, Texas A&M University, 2010 */
-
-/* $Id$ */
-/* */
-/* Copyright (C) 2003-2004, 2006-2013 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. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2003 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Authors: Guido Kanschat, University of Heidelberg, 2003
+ * Baerbel Janssen, University of Heidelberg, 2010
+ * Wolfgang Bangerth, Texas A&M University, 2010
+ */
+
// As discussed in the introduction, most of this program is copied almost
// verbatim from step-6, which itself is only a slight modification of
#include <deal.II/numerics/data_out.h>
#include <deal.II/numerics/error_estimator.h>
-// These, now, are the include necessary for the multi-level methods. The
+// These, now, are the include necessary for the multilevel methods. The
// first two declare classes that allow us to enumerate degrees of freedom not
// only on the finest mesh level, but also on intermediate levels (that's what
// the MGDoFHandler class does) as well as allow to access this information
class LaplaceProblem
{
public:
- LaplaceProblem (const unsigned int deg);
+ LaplaceProblem (const unsigned int degree);
void run ();
private:
const unsigned int degree;
// The following four objects are the only additional member variables,
- // compared to step-6. They first three represent the operators that act
+ // compared to step-6. The first three represent the operators that act
// on individual levels of the multilevel hierarchy, rather than on the
// finest mesh as do the objects above while the last object stores
// information about the boundary indices on each level and information
// Now for the things that concern the multigrid data structures. First,
- // we resize the multi-level objects to hold matrices and sparsity
+ // we resize the multilevel objects to hold matrices and sparsity
// patterns for every level. The coarse level is zero (this is mandatory
// right now but may change in a future revision). Note that these
// functions take a complete, inclusive range here (not a starting index
// @sect4{LaplaceProblem::assemble_system}
- // The following function assembles the linear system on the finesh level of
+ // The following function assembles the linear system on the finest level of
// the mesh. It is almost exactly the same as in step-6, with the exception
// that we don't eliminate hanging nodes and boundary values after
// assembling, but while copying local contributions into the global
// integration core is the same as above, but the loop below will go over
// all existing cells instead of just the active ones, and the results must
// be entered into the correct matrix. Note also that since we only do
- // multi-level preconditioning, no right-hand side needs to be assembled
+ // multilevel preconditioning, no right-hand side needs to be assembled
// here.
//
// Before we go there, however, we have to take care of a significant amount
// that are located on interfaces between adaptively refined levels, and
// those that lie on the interface but also on the exterior boundary of
// the domain. As in many other parts of the library, we do this by using
- // boolean masks, i.e. vectors of booleans each element of which indicates
+ // Boolean masks, i.e. vectors of Booleans each element of which indicates
// whether the corresponding degree of freedom index is an interface DoF
// or not. The <code>MGConstraints</code> already computed the information
// for us when we called initialize in <code>setup_system()</code>.
// The indices just identified will later be used to decide where the
// assembled value has to be added into on each level. On the other hand,
// we also have to impose zero boundary conditions on the external
- // boundary of each level. But this the <code>MGConstraints</code> knows
- // it. So we simply ask for them by calling <code>get_boundary_indices
- // ()</code>. The third step is to construct constraints on all those
+ // boundary of each level. But this the <code>MGConstraints</code> knows.
+ // So we simply ask for them by calling <code>get_boundary_indices()</code>.
+ // The third step is to construct constraints on all those
// degrees of freedom: their value should be zero after each application
// of the level operators. To this end, we construct ConstraintMatrix
// objects for each level, and add to each of these constraints for each
MGTransferPrebuilt<Vector<double> > mg_transfer(hanging_node_constraints, mg_constrained_dofs);
// Now the prolongation matrix has to be built. This matrix needs to take
// the boundary values on each level into account and needs to know about
- // the indices at the refinement egdes. The <code>MGConstraints</code>
+ // the indices at the refinement edges. The <code>MGConstraints</code>
// knows about that so pass it as an argument.
mg_transfer.build_matrices(mg_dof_handler);
MESSAGE(FATAL_ERROR "
Error! The deal.II library found at ${DEAL_II_PATH} was not configured with
DEAL_II_WITH_PETSC = ON
-which is required for this tutorial step."
+One or all of these are OFF in your installation but are required for this tutorial step."
)
ENDIF()
-/* Author: Wolfgang Bangerth, University of Texas at Austin, 2000, 2004 */
-
-/* $Id$ */
-/* */
-/* Copyright (C) 2000, 2004-2009, 2011-2012 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. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2000 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Wolfgang Bangerth, University of Texas at Austin, 2000, 2004
+ */
// First the usual assortment of header files we have already used in previous
// communicator object that only links a subset of all processes), and call
// the Utilities helper functions to determine the number of processes and
// where the present one fits into this picture. In addition, we make sure
- // that output is only generated by the (globally) first process. As,
- // this_mpi_process is determined after creation of pcout, we cannot set the
- // condition through the constructor, i.e. by pcout(std::cout,
- // this_mpi_process==0), but set the condition separately.
+ // that output is only generated by the (globally) first process. As
+ // <code>this_mpi_process</code> is determined after creation of pcout, we
+ // cannot set the condition through the constructor, i.e. by
+ // <code>pcout(std::cout, this_mpi_process==0)</code>, but set the
+ // condition separately.
template <int dim>
ElasticProblem<dim>::ElasticProblem ()
:
cell->get_dof_indices (local_dof_indices);
hanging_node_constraints
.distribute_local_to_global(cell_matrix, cell_rhs,
- local_dof_indices,
- system_matrix, system_rhs);
+ local_dof_indices,
+ system_matrix, system_rhs);
}
// Now compress the vector and the system matrix:
// The last argument to the call just performed allows for some
// optimizations. It controls whether we should also delete the column
// corresponding to a boundary node, or keep it (and passing
- // <code>true</code> as above means: yes, do eliminate the column). If we
+ // <code>true</code> means: yes, do eliminate the column). If we
// do, then the resulting matrix will be symmetric again if it was before;
// if we don't, then it won't. The solution of the resulting system should
// be the same, though. The only reason why we may want to make the system
// to the present process, but then we need to distribute the refinement
// indicators into a distributed vector so that all processes have the
// values of the refinement indicator for all cells. But then, in order for
- // each process to refine its copy of the mesh, they need to have acces to
+ // each process to refine its copy of the mesh, they need to have access to
// all refinement indicators locally, so they have to copy the global vector
// back into a local one. That's a little convoluted, but thinking about it
// quite straightforward nevertheless. So here's how we do it:
// <code>local_error_per_cell</code> vector. The elements of this vector
// for cells not on the present process are zero. However, since all
// processes have a copy of a copy of the entire triangulation and need to
- // keep these copies in synch, they need the values of refinement
+ // keep these copies in sync, they need the values of refinement
// indicators for all cells of the triangulation. Thus, we need to
// distribute our results. We do this by creating a distributed vector
// where each process has its share, and sets the elements it has
MESSAGE(FATAL_ERROR "
Error! The deal.II library found at ${DEAL_II_PATH} was not configured with
DEAL_II_WITH_PETSC = ON
-which is required for this tutorial step."
+One or all of these are OFF in your installation but are required for this tutorial step."
)
ENDIF()
simulating problems in which the deformation becomes <i>large</i>.
@note The model we will consider below is not founded on anything that
-would be mathematical sound: we will consider a model in which we
+would be mathematically sound: we will consider a model in which we
produce a small deformation, deform the physical coordinates of the
body by this deformation, and then consider the next loading step
again as a linear problem. This isn't consistent, since the assumption
corresponding stress update. However, the rotational component does not
necessarily induce a nonzero stress update (think, in 2d, for example of the
situation where $\Delta\mathbf{u}=(y, -x)^T$, with which $\varepsilon(\Delta
-\mathbf{u})=0$). Nevertheless, if the the material was pre-stressed in a certain
+\mathbf{u})=0$). Nevertheless, if the the material was prestressed in a certain
direction, then this direction will be rotated along with the material. To
this end, we have to define a rotation matrix $R(\Delta \mathbf{u}^n)$ that
describes, in each point the rotation due to the displacement increments. It
Converter from deal.II intermediate format to other graphics formats.
-Usage: ./\step-19 [-p parameter_file] list_of_input_files [-x output_format] output_file
+Usage: ./\step-19 [-p parameter_file] list_of_input_files [-x output_format] -o output_file
-examples/\step-18> ../\step-19/\step-19 solution-0001.0000.d2 -x gmv solution-0001.0000.gmv
-examples/\step-18> ../\step-19/\step-19 solution-0002.0000.d2 -x gmv solution-0002.0000.gmv
+examples/\step-18> ../\step-19/\step-19 solution-0001.0000.d2 -x gmv -o solution-0001.0000.gmv
+examples/\step-18> ../\step-19/\step-19 solution-0002.0000.d2 -x gmv -o solution-0002.0000.gmv
[...]
@endcode
Of course, since we have run the program only in sequential mode, we
-/* Author: Wolfgang Bangerth, University of Texas at Austin, 2000, 2004, 2005 */
-
-/* $Id$ */
-/* */
-/* Copyright (C) 2000, 2004-2009, 2011-2012 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. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2000 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Wolfgang Bangerth, University of Texas at Austin, 2000, 2004, 2005
+ */
// First the usual list of header files that have already been used in
// in the form $C_{ijkl} = \mu (\delta_{ik} \delta_{jl} + \delta_{il}
// \delta_{jk}) + \lambda \delta_{ij} \delta_{kl}$. This tensor maps
// symmetric tensor of rank 2 to symmetric tensors of rank 2. A function
- // implementing its creation for given values of the Lame constants lambda
- // and mu is straightforward:
+ // implementing its creation for given values of the Lame constants $\lambda$
+ // and $\mu$ is straightforward:
template <int dim>
SymmetricTensor<4,dim>
get_stress_strain_tensor (const double lambda, const double mu)
// the system, direct what has to be solved in each time step, a function
// that solves the linear system that arises in each timestep (and returns
// the number of iterations it took), and finally output the solution
- // vector on the currect mesh:
+ // vector on the correct mesh:
void create_coarse_grid ();
void setup_system ();
// One difference of this program is that we declare the quadrature
// formula in the class declaration. The reason is that in all the other
// programs, it didn't do much harm if we had used different quadrature
- // formulas when computing the matrix and the righ hand side, for
+ // formulas when computing the matrix and the right hand side, for
// example. However, in the present case it does: we store information in
// the quadrature points, so we have to make sure all parts of the program
// agree on where they are and how many there are on each cell. Thus, let
// @sect4{The public interface}
- // The next step is the definition of constructors and descructors. There
+ // The next step is the definition of constructors and destructors. There
// are no surprises here: we choose linear and continuous finite elements
// for each of the <code>dim</code> vector components of the solution, and a
// Gaussian quadrature formula with 2 points in each coordinate
// The next function is the one that sets up the data structures for a given
// mesh. This is done in most the same way as in step-17: distribute the
// degrees of freedom, then sort these degrees of freedom in such a way that
- // each processor gets a contiguous chunk of them. Note that subdivions into
+ // each processor gets a contiguous chunk of them. Note that subdivisions into
// chunks for each processor is handled in the functions that create or
// refine grids, unlike in the previous example program (the point where
// this happens is mostly a matter of taste; here, we chose to do it when
// adaptively refined).
//
// With this data structure, we can then go to the PETSc sparse matrix and
- // tell it to pre-allocate all the entries we will later want to write to:
+ // tell it to preallocate all the entries we will later want to write to:
system_matrix.reinit (mpi_communicator,
sparsity_pattern,
local_dofs_per_process,
cell->get_dof_indices (local_dof_indices);
hanging_node_constraints
- .distribute_local_to_global (cell_matrix, cell_rhs,
+ .distribute_local_to_global (cell_matrix, cell_rhs,
local_dof_indices,
- system_matrix, system_rhs);
+ system_matrix, system_rhs);
}
// Now compress the vector and the system matrix:
system_matrix.compress(VectorOperation::add);
system_rhs.compress(VectorOperation::add);
-
+
// The last step is to again fix up boundary values, just as we already
// did in previous programs. A slight complication is that the
// <code>apply_boundary_values</code> function wants to have a solution
subdomain_id (subdomain_id)
{}
- virtual typename DoFHandler<dim>::cell_iterator
+ virtual typename DataOut<dim>::cell_iterator
first_cell ()
{
- typename DoFHandler<dim>::active_cell_iterator
+ typename DataOut<dim>::active_cell_iterator
cell = this->dofs->begin_active();
while ((cell != this->dofs->end()) &&
(cell->subdomain_id() != subdomain_id))
return cell;
}
- virtual typename DoFHandler<dim>::cell_iterator
- next_cell (const typename DoFHandler<dim>::cell_iterator &old_cell)
+ virtual typename DataOut<dim>::cell_iterator
+ next_cell (const typename DataOut<dim>::cell_iterator &old_cell)
{
if (old_cell != this->dofs->end())
{
return
++(FilteredIterator
- <typename DoFHandler<dim>::active_cell_iterator>
+ <typename DataOut<dim>::active_cell_iterator>
(predicate,old_cell));
}
else
// As a last piece of data, let us also add the partitioning of the domain
// into subdomains associated with the processors if this is a parallel
// job. This works in the exact same way as in the step-17 program:
- std::vector<unsigned int> partition_int (triangulation.n_active_cells());
+ std::vector<types::subdomain_id> partition_int (triangulation.n_active_cells());
GridTools::get_subdomain_association (triangulation, partition_int);
const Vector<double> partitioning(partition_int.begin(),
partition_int.end());
// <code>cell-@>vertex_dof_index(v,d)</code> function that returns the index
// of the <code>d</code>th degree of freedom at vertex <code>v</code> of the
// given cell. In the present case, displacement in the k-th coordinate
- // direction corresonds to the kth component of the finite element. Using a
+ // direction corresponds to the k-th component of the finite element. Using a
// function like this bears a certain risk, because it uses knowledge of the
// order of elements that we have taken together for this program in the
// <code>FESystem</code> element. If we decided to add an additional
// variable, for example a pressure variable for stabilization, and happened
// to insert it as the first variable of the element, then the computation
- // below will start to produce non-sensical results. In addition, this
+ // below will start to produce nonsensical results. In addition, this
// computation rests on other assumptions: first, that the element we use
// has, indeed, degrees of freedom that are associated with vertices. This
// is indeed the case for the present Q1 element, as would be for all Qp
// To put this into larger perspective, we note that if we had previously
// available stresses in our model (which we assume do not exist for the
// purpose of this program), then we would need to interpolate the field of
- // pre-existing stresses to the quadrature points. Likewise, if we were to
+ // preexisting stresses to the quadrature points. Likewise, if we were to
// simulate elasto-plastic materials with hardening/softening, then we would
// have to store additional history variables like the present yield stress
// of the accumulated plastic strains in each quadrature
// displacement update so that the material in its new configuration
// accommodates for the difference between the external body and boundary
// forces applied during this time step minus the forces exerted through
- // pre-existing internal stresses. In order to have the pre-existing
+ // preexisting internal stresses. In order to have the preexisting
// stresses available at the next time step, we therefore have to update the
- // pre-existing stresses with the stresses due to the incremental
+ // preexisting stresses with the stresses due to the incremental
// displacement computed during the present time step. Ideally, the
// resulting sum of internal stresses would exactly counter all external
// forces. Indeed, a simple experiment can make sure that this is so: if we
// three matrices should be symmetric, it is not due to floating
// point round off: we get an asymmetry on the order of 1e-16 of
// the off-diagonal elements of the result. When assigning the
- // result to a <code>SymmetricTensor</code>, the constuctor of
+ // result to a <code>SymmetricTensor</code>, the constructor of
// that class checks the symmetry and realizes that it isn't
// exactly symmetric; it will then raise an exception. To avoid
// that, we explicitly symmetrize the result to make it exactly
subsection DX output parameters
- # A boolean field indicating whether neighborship information between cells
+ # A Boolean field indicating whether neighborship information between cells
# is to be written to the OpenDX output file
set Write neighbors = true
end
end
subsection Povray output parameters
- # Whether camera and lightling information should be put into an external
+ # Whether camera and lighting information should be put into an external
# file "data.inc" or into the POVRAY input file
set Include external file = true
-/* Author: Luca Heltai, Wolfgang Bangerth, 2005 */
-
-/* $Id$ */
-/* */
-/* Copyright (C) 2005-2006, 2011-2012 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. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2005 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Luca Heltai, Wolfgang Bangerth, 2005
+ */
// @sect4{Preliminaries}
// this program, I realized that there aren't all that many parameters this
// program can usefully ask for, or better, it turned out: declaring and
// querying these parameters was already done centralized in one place of
- // the libray, namely the <code>DataOutInterface</code> class that handles
+ // the library, namely the <code>DataOutInterface</code> class that handles
// exactly this -- managing parameters for input and output.
//
// So the second function call in this function is to let the
// with the subsection name, I like to use curly braces to force my editor
// to indent everything that goes into this sub-section by one level of
// indentation. In this sub-section, we shall have two entries, one that
- // takes a boolean parameter and one that takes a selection list of
+ // takes a Boolean parameter and one that takes a selection list of
// values, separated by the '|' character:
prm.enter_subsection ("Dummy subsection");
{
// Finally, let us note that if we were interested in the values
// of the parameters declared above in the dummy subsection, we
// would write something like this to extract the value of the
- // boolean flag (the <code>prm.get</code> function returns the
+ // Boolean flag (the <code>prm.get</code> function returns the
// value of a parameter as a string, whereas the
// <code>prm.get_X</code> functions return a value already
// converted to a different type):
prm.get_bool ("Dummy generate output");
}
prm.leave_subsection ();
- // We would assign the result to a variable, or course, but don't
+ // We would assign the result to a variable, of course, but don't
// here in order not to generate an unused variable that the
// compiler might warn about.
//
to indicate two slightly different, but related things. The first is that we'd
like to represent the finite element solution as a linear combination of shape
function, in the form $u_h(\mathbf x) = \sum_{j=0}^{N-1} U_j \varphi_j(\mathbf
-x)$. Here, $U_j$ is a vector of expension coefficients. Because we don't know
+x)$. Here, $U_j$ is a vector of expansion coefficients. Because we don't know
their values yet (we will compute them as the solution of a linear or
nonlinear system), they are called "unknowns" or "degrees of freedom". The
second meaning of the term con be explained as follows: A mathematical
number of nonzero entries per row is five, and therefore independent of the
total size of the matrix.) Sparsity is one of the distinguishing feature of
the finite element method compared to, say, approximating the solution of a
-partial differential equation using a Taylor expension and matching
+partial differential equation using a Taylor expansion and matching
coefficients, or using a Fourier basis.
In practical terms, it is the sparsity of matrices that enables us to solve
patterns. We can visualize them using <a
href="http://www.gnuplot.info/">GNUPLOT</a> (one of the simpler visualization
programs; maybe not the easiest to use since it is command line driven, but
-also universally available on all linux and other unix-like systems):
+also universally available on all Linux and other Unix-like systems):
@code
examples/\step-2> gnuplot
-/* Author: Wolfgang Bangerth, University of Heidelberg, 1999 */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 1999 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Wolfgang Bangerth, University of Heidelberg, 1999
+ */
-/* $Id$ */
-/* */
-/* Copyright (C) 1999-2003, 2006, 2008-2012 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. */
// The first few includes are just like in the previous program, so do not
// require additional comments:
// least as long as that of the <code>DoFHandler</code>; one way to make sure
// this is so is to make it static as well, in order to prevent its preemptive
// destruction. (However, the library would warn us if we forgot about this
-// and abort the program if that occured. You can check this, if you want, by
+// and abort the program if that occurred. You can check this, if you want, by
// removing the 'static' declaration.)
void distribute_dofs (DoFHandler<2> &dof_handler)
{
the x-velocity has to increase to get the flow through the narrow part,
something that can easily be seen in the left image. The middle image
represents inward flow in y-direction at the left end of the domain, and
-outward flow in y-directino at the right end of the domain.
+outward flow in y-direction at the right end of the domain.
Realistic flow computations for ground water or oil reservoir simulations will
not use a constant permeability. Here's a first, rather simple way to change
this situation: we use a permeability that decays very rapidly away from a
-central flowline until it hits a background value of 0.001. This is to mimick
+central flowline until it hits a background value of 0.001. This is to mimic
the behavior of fluids in sandstone: in most of the domain, the sandstone is
-homogenous and, while permeably to fluids, not overly so; on the other stone,
+homogeneous and, while permeable to fluids, not overly so; on the other stone,
the stone has cracked, or faulted, along one line, and the fluids flow much
-easier along this large crask. Here is how we could implement something like
+easier along this large crack. Here is how we could implement something like
this:
@code
template <int dim>
-/* Author: Wolfgang Bangerth, Texas A&M University, 2005, 2006 */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2005 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Wolfgang Bangerth, Texas A&M University, 2005, 2006
+ */
-/* $Id$ */
-/* */
-/* Copyright (C) 2005-2008, 2010-2013 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. */
// @sect3{Include files}
// binding simpler elements together into one larger element. In the present
// case, we want to couple a single RT(degree) element with a single
// DQ(degree) element. The constructor to <code>FESystem</code> that does
- // this requires us to specity first the first base element (the
+ // this requires us to specify first the first base element (the
// <code>FE_RaviartThomas</code> object of given degree) and then the number
// of copies for this base element, and then similarly the kind and number
- // of <code>FE_DGQ</code> elements. Note that the Raviart Thomas element
+ // of <code>FE_DGQ</code> elements. Note that the Raviart-Thomas element
// already has <code>dim</code> vector components, so that the coupled
// element will have <code>dim+1</code> vector components, the first
// <code>dim</code> of which correspond to the velocity variable whereas the
// used here, the Gauss points happen to be superconvergence points in
// which the pointwise error is much smaller (and converges with higher
// order) than anywhere else. These are therefore not particularly good
- // points for ingration. To avoid this problem, we simply use a
+ // points for integration. To avoid this problem, we simply use a
// trapezoidal rule and iterate it <code>degree+2</code> times in each
// coordinate direction (again as explained in step-7):
QTrapez<1> q_trapez;
// The main function we stole from step-6 instead of step-4. It is almost
// equal to the one in step-6 (apart from the changed class names, of course),
// the only exception is that we pass the degree of the finite element space
-// to the constructor of the mixed laplace problem (here, we use zero-th order
+// to the constructor of the mixed Laplace problem (here, we use zero-th order
// elements).
int main ()
{
Here, $p=p(\mathbf x, t), S=S(\mathbf x, t)$ are now time dependent
functions: while at every time instant the flow field is in
equilibrium with the pressure (i.e. we neglect dynamic
-accellerations), the saturation is transported along with the flow and
+accelerations), the saturation is transported along with the flow and
therefore changes over time, in turn affected the flow field again
through the dependence of the first equation on $S$.
because they consist of a network of interconnected pores. However, this
microscopic scale is out of the range of today's computer simulations, and we
have to be content with simulating things on the scale of meters. On that
-scale, however, fluid transport typically happens through a network of crasks
-in the rock, rather than throuh pores. However, cracks often result from
+scale, however, fluid transport typically happens through a network of cracks
+in the rock, rather than through pores. However, cracks often result from
external stress fields in the rock layer (for example from tectonic faulting)
and the cracks are therefore roughly aligned. This leads to a situation where
the permeability is often orders of magnitude larger in the direction parallel
"step-20":
<ul>
<li>A function that models a single, winding crack that snakes through the
- domain. In analgy to step-20, but taking care of the slightly
+ domain. In analogy to step-20, but taking care of the slightly
different geometry we have here, we describe this by the following function:
@f[
k(\mathbf x)
-/* Author: Yan Li, Wolfgang Bangerth, Texas A&M University, 2006 */
-
-/* $Id$ */
-/* */
-/* Copyright (C) 2006-2013 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. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2006 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Authors: Yan Li, Wolfgang Bangerth, Texas A&M University, 2006
+ */
+
// This program is an adaptation of step-20 and includes some technique of DG
// methods from step-12. A good part of the program is therefore very similar
MESSAGE(FATAL_ERROR "
Error! The deal.II library found at ${DEAL_II_PATH} was not configured with
DEAL_II_WITH_UMFPACK = ON
-which is required for this tutorial step."
+One or all of these are OFF in your installation but are required for this tutorial step."
)
ENDIF()
</ol>
Despite this wealth of possibilities, we will only use Dirichlet and
-(homogenous) Neumann boundary conditions in this tutorial program.
+(homogeneous) Neumann boundary conditions in this tutorial program.
<h3>Discretization</h3>
represent an exact inverse of the matrix $A$. Consequently, preconditioning
with the ILU will still require more than one iteration, unlike
preconditioning with the sparse direct solver. The inner solver will therefore
-take more time when multiplying with the Schur complement, a tradeoff
+take more time when multiplying with the Schur complement, a trade-off
unavoidable.
</ol>
@endcode
From hereon, we can refer to the type <code>typename
-InnerPreconditioner@<dim@>::type</code> and automatically get the correct
+InnerPreconditioner@<dim@>::%type</code> and automatically get the correct
preconditioner class. Because of the similarity of the interfaces of the two
classes, we will be able to use them interchangeably using the same syntax in
all places.
</a>
Frequently, a sparse matrix contains a substantial amount of elements that
-acutally are zero when we are about to start a linear solve. Such elements are
+actually are zero when we are about to start a linear solve. Such elements are
introduced when we eliminate constraints or implement Dirichlet conditions,
where we usually delete all entries in constrained rows and columns, i.e., we
set them to zero. The fraction of elements that are present in the sparsity
consumption. Likewise, the implementation of the decomposition step in the
SparseILU class was very inefficient and has been replaced by one that is
about 10 times faster. Even the vmult function of the SparseILU has been
-improved to save about twenty precent of time. Small improvements were
+improved to save about twenty percent of time. Small improvements were
applied here and there. Moreover, the ConstraintMatrix object has been used
to eliminate a lot of entries in the sparse matrix that are eventually going
to be zero, see <a href="#constraint-matrix">the section on using advanced
steps in the program. Observe how the grid is refined in regions
where the solution rapidly changes: On the upper boundary, we have
Dirichlet boundary conditions that are -1 in the left half of the line
-and 1 in the right one, so there is an aprupt change at $x=0$. Likewise,
+and 1 in the right one, so there is an abrupt change at $x=0$. Likewise,
there are changes from Dirichlet to Neumann data in the two upper
corners, so there is need for refinement there as well:
this case of VisIt) to show vector data; this is the result of us
declaring the velocity components of the finite element in use to be a
set of vector components, rather than independent scalar components in
-the <code>StokesProblem@<dim@>::output_results</code> function of this
+the <code>StokesProblem@<dim@>::%output_results</code> function of this
tutorial program.
<img src="http://www.dealii.org/images/steps/developer/step-22.3d.solution.png" alt="">
-The isocountours shown here as well are those of the pressure
+The isocontours shown here as well are those of the pressure
variable, showing the singularity at the point of discontinuous
velocity boundary conditions.
always around five, both in two and three dimensions.) To summarize, most work
is spent on solving linear systems with the same matrix $A$ over and over again.
What makes this look even worse is the fact that we
-actually invert a matrix that is about 95 precent the size of the total system
-matrix and stands for 85 precent of the non-zero entries in the sparsity
+actually invert a matrix that is about 95 percent the size of the total system
+matrix and stands for 85 percent of the non-zero entries in the sparsity
pattern. Hence, the natural question is whether it is reasonable to solve a
linear system with matrix $A$ for about 15 times when calculating the solution
to the block system.
Another idea to improve the situation even more would be to choose a
preconditioner that makes CG for the (0,0) matrix $A$ converge in a
mesh-independent number of iterations, say 10 to 30. We have seen such a
-canditate in step-16: multigrid.
+candidate in step-16: multigrid.
<h5>Block Schur complement preconditioner</h5>
Even with a good preconditioner for $A$, we still
vice versa.
<a href="http://en.wikipedia.org/wiki/GMRES#Comparison_with_other_solvers">Wikipedia</a>'s
article on the GMRES method gives a comparative presentation.
-A more comprehensive and well-founded comparsion can be read e.g. in the book by
+A more comprehensive and well-founded comparison can be read e.g. in the book by
J.W. Demmel (Applied Numerical Linear Algebra, SIAM, 1997, section 6.6.6).
For our specific problem with the ILU preconditioner for $A$, we certainly need
complicated than the examples shown above, but it is not hard to accommodate
for that.
-For example, by using the folllowing modification of the boundary values
+For example, by using the following modification of the boundary values
function
@code
template <int dim>
-/* Author: Wolfgang Bangerth, Texas A&M University, 2008 */
-
-/* $Id$ */
-/* */
-/* Copyright (C) 2008-2012 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. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2008 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Wolfgang Bangerth, Texas A&M University, 2008
+ */
// @sect3{Include files}
// As in step-20 and most other example programs, the next task is to define
// the data for the PDE: For the Stokes problem, we are going to use natural
- // boundary values on parts of the boundary (i.e. homogenous Neumann-type)
+ // boundary values on parts of the boundary (i.e. homogeneous Neumann-type)
// for which we won't have to do anything special (the homogeneity implies
// that the corresponding terms in the weak form are simply zero), and
// boundary conditions on the velocity (Dirichlet-type) on the rest of the
// Note that we initialize the triangulation with a MeshSmoothing argument,
// which ensures that the refinement of cells is done in a way that the
// approximation of the PDE solution remains well-behaved (problems arise if
- // grids are too unstructered), see the documentation of
+ // grids are too unstructured), see the documentation of
// <code>Triangulation::MeshSmoothing</code> for details.
template <int dim>
StokesProblem<dim>::StokesProblem (const unsigned int degree)
// require allocating more memory than necessary but isn't suitable for
// use as a basis of SparseMatrix or BlockSparseMatrix objects; in a
// second step we then copy this object into an object of
- // BlockSparsityPattern. This is entirely analgous to what we already did
+ // BlockSparsityPattern. This is entirely analogous to what we already did
// in step-11 and step-18.
//
// There is one snag again here, though: it turns out that using the
// After the discussion in the introduction and the definition of the
// respective classes above, the implementation of the <code>solve</code>
- // function is rather straigt-forward and done in a similar way as in
+ // function is rather straight-forward and done in a similar way as in
// step-20. To start with, we need an object of the
// <code>InverseMatrix</code> class that represents the inverse of the
// matrix A. As described in the introduction, the inverse is generated with
// An alternative that is cheaper to build, but needs more iterations
// afterwards, would be to choose a SSOR preconditioner with factor
// 1.2. It needs about twice the number of iterations, but the costs for
- // its generation are almost neglible.
+ // its generation are almost negligible.
SparseILU<double> preconditioner;
preconditioner.initialize (system_matrix.block(1,1),
SparseILU<double>::AdditionalData());
// objects we already know - so we simply multiply $p$ by $B^T$, subtract
// the right hand side and multiply by the inverse of $A$. At the end, we
// need to distribute the constraints from hanging nodes in order to
- // obtain a constistent flow field:
+ // obtain a consistent flow field:
{
system_matrix.block(0,1).vmult (tmp, solution.block(1));
tmp *= -1;
Both of these methods have advantages and disadvantages.
Traditionally, people have preferred the method of lines, since it
allows to use the very well developed machinery of high-order ODE
-solvers avaiable for the rather stiff ODEs resulting from this
+solvers available for the rather stiff ODEs resulting from this
approach, including step length control and estimation of the temporal
error.
solution changes as time progresses. For example, for the wave
equation, we may have a single wave travelling through the domain,
where the solution is smooth or even constant in front of and behind
-the wave &mdash& adaptivity would be really useful for such cases, but the
+the wave — adaptivity would be really useful for such cases, but the
key is that the area where we need to refine the mesh changes from
time step to time step!
down time stepping schemes. Note that we do not have boundary
conditions for $v$ at first. However, we could enforce $v=\frac{\partial
g}{\partial t}$ on the boundary. It turns out in numerical examples that this
-as actually necessary: without doing so the solution doesn't look particularly
+is actually necessary: without doing so the solution doesn't look particularly
wrong, but the Crank-Nicolson scheme does not conserve energy if one doesn't
enforce these boundary conditions.
\\
A^{n,n-1}_{ij} &=& (\nabla\phi_i^n, \nabla\phi_j^{n-1}),
\\
- F^n_{ij} &=& (f^n,\phi_i^n),
+ F^n_{i} &=& (f^n,\phi_i^n),
\\
- F^{n-1}_{ij} &=& (f^{n-1},\phi_i^n).
+ F^{n-1}_{i} &=& (f^{n-1},\phi_i^n).
@f}
If we solve these two equations, we can move the solution one step
is what we set the time step to. The fact that we set the time step and mesh
size individually in two different places is error prone: it is too easy to
refine the mesh once more but forget to also adjust the time step. @ref
-step_24 "step-24" shows a better way how to keep these things in synch.
+step_24 "step-24" shows a better way how to keep these things in sync.
<h3>The test case</h3>
To make such a change, we would have to compute the mass and Laplace
matrices with a variable coefficient. Fortunately, this isn't too hard: the
- functions MatrixTools::create_laplace_matrix and
- MatrixTools::create_vector_tools have additional default parameters that can
+ functions MatrixCreator::create_laplace_matrix and
+ MatrixCreator::create_mass_matrix have additional default parameters that can
be used to pass non-constant coefficient functions to them. The required
changes are therefore relatively small. On the other hand, care must be
taken again to make sure the time step is within the allowed range.
-/* Author: Wolfgang Bangerth, Texas A&M University, 2006 */
-
-/* $Id$ */
-/* Version: $Name: $ */
-/* */
-/* Copyright (C) 2006-2009, 2011-2012 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. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2006 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Wolfgang Bangerth, Texas A&M University, 2006
+ */
// @sect3{Include files}
// Here are the only three include files of some new interest: The first one
// is already used, for example, for the
// VectorTools::interpolate_boundary_values and
-// VectorTools::apply_boundary_values functions. However, we here use another
+// MatrixTools::apply_boundary_values functions. However, we here use another
// function in that class, VectorTools::project to compute our initial values
// as the $L^2$ projection of the continuous initial values. Furthermore, we
// use VectorTools::create_right_hand_side to generate the integrals
// mass and Laplace matrices, although it would have only taken copying the
// relevant code from any number of previous tutorial programs. Rather, we
// want to focus on the things that are truly new to this program and
-// therefore use the MatrixTools::create_mass_matrix and
-// MatrixTools::create_laplace_matrix functions. They are declared here:
+// therefore use the MatrixCreator::create_mass_matrix and
+// MatrixCreator::create_laplace_matrix functions. They are declared here:
#include <deal.II/numerics/matrix_tools.h>
// Finally, here is an include file that contains all sorts of tool functions
sparsity_pattern.compress();
// Then comes a block where we have to initialize the 3 matrices we need
- // in the course of the program: the mass matrix, the laplace matrix, and
+ // in the course of the program: the mass matrix, the Laplace matrix, and
// the matrix $M+k^2\theta^2A$ used when solving for $U^n$ in each time
// step.
//
homogeneous acoustic properties. The basic acoustic generation equation in an
acoustically homogeneous medium can be described as follows: if $u$ is the
vector-valued displacement, then tissue certainly reacts to changes in
-pressure by accelleration:
+pressure by acceleration:
@f[
\rho \frac{\partial^2}{\partial t^2}u(t,\mathbf r) =
-\nabla p(t,\mathbf r).
v = \frac{\partial\bar{p}}{\partial t}
@f]
-With the second variables, one then transform the forward problem into
+With the second variable, one then transforms the forward problem into
two separate equations:
@f{eqnarray*}
\bar{p}_{t} - v & = & 0 \\
results from the use of absorbing boundary conditions.
Above two equations can be rewritten in a matrix form with the pressure and its derivative as
-an unknown vecotor:
+an unknown vector:
@f[
\left(\begin{array}{cc}
M & -k\theta M \\
values evaluated at each detector location to disk. We then
draw them in plots. Experimental data were also collected for comparison.
Currently our experiments have only been done in two dimensions by
-circually scanning a single detector. The tissue sample here is a thin slice
+circularly scanning a single detector. The tissue sample here is a thin slice
in the X-Y plane (Z=0), and we assume that signals from other Z directions
won't contribute to the data. Consequently, we only have to compare
our experimental data with two dimensional simulated data.
circular mesh we use (see for example step-6 for a view of the
coarse mesh) is not isotropic either. The net result is that the signal fronts
are not sinusoidal unless the mesh is sufficiently fine. The right image is a
-lot better in this respect, though artificts in the form of trailing spurious
+lot better in this respect, though artifacts in the form of trailing spurious
waves can still be seen.
-/* Author: Xing Jin, Wolfgang Bangerth, Texas A&M University, 2006 */
-
-/* $Id$ */
-/* Copyright (C) 2006-2009, 2011-2012 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. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2006 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Xing Jin, Wolfgang Bangerth, Texas A&M University, 2006
+ */
// @sect3{Include files}
// pressure. In the physical setting considered in this program, these are
// small absorbers, which we model as a series of little circles where we
// assume that the pressure surplus is one, whereas no absorption and
- // therefore no pressure surplus is anywhere else. This is how we do things
+ // therefore no pressure surplus is everywhere else. This is how we do things
// (note that if we wanted to expand this program to not only compile but
// also to run, we would have to initialize the sources with
// three-dimensional source locations):
//
// A first observation would be that this matrix is much sparser than the
// regular mass matrix, since none of the shape functions with purely
- // interior support contributes to this matrix. We could therefore
+ // interior support contribute to this matrix. We could therefore
// optimize the storage pattern to this situation and build up a second
// sparsity pattern that only contains the nonzero entries that we
// need. There is a trade-off to make here: first, we would have to have a
// consumption of the program, the introduction of a few temporary vectors
// isn't doing much harm.
//
- // The only changes to this function are: First, that we do not have to
+ // The only changes to this function are: first, that we do not have to
// project initial values for the velocity $v$, since we know that it is
// zero. And second that we evaluate the solution at the detector locations
// computed in the constructor. This is done using the
\mbox{ Find } \delta u^n_l \mbox{ s.t. } F'(u^n_l)\delta u^n_l = -F(u^n_l)
\mbox{, set } u^n_{l+1} = u^n_l + \delta u^n_l.
\f}
-The iteration can be initialized with the old time step, i.e. $u^{n,0} =
-u^{n-1}$, and eventually it will produce a solution to the first equation of
-the split formulation (see above). For the time discretizaion of the
+The iteration can be initialized with the old time step, i.e. $u^n_0 = u^{n-1}$,
+and eventually it will produce a solution to the first equation of
+the split formulation (see above). For the time discretization of the
sine-Gordon equation under consideration here, we have that
\f{eqnarray*}
F(u^n_l) &=& \left[ 1-k^2\theta^2\Delta \right] u^n_l -
&\mbox{ Find}& \delta u^n_l \in H^1(\Omega) \mbox{ s.t. }
\left( F'(u^n_l)\delta u^n_l, \varphi \right)_{\Omega}
= -\left(F(u^n_l), \varphi \right)_{\Omega} \;\forall\varphi\in H^1(\Omega),
- \mbox{ set } u^n_{l+1} = u^n_l + \delta u^n_l,\; u^{n,0} = u^{n-1}.\\
+ \mbox{ set } u^n_{l+1} = u^n_l + \delta u^n_l,\; u^n_0 = u^{n-1}.\\
&\mbox{ Find}& v^n \in H^1(\Omega) \mbox{ s.t. }
\left( v^n, \varphi \right)_{\Omega} = \left( v^{n-1}, \varphi \right)_{\Omega}
- k\theta\left( \nabla u^n, \nabla\varphi \right)_{\Omega}
letter the vector of coefficients (in the nodal basis) of a function
denoted by the same letter in lower case; e.g., $u^n = \sum_{i=1}^N
U^n_i \varphi_i$ where $U^n \in {R}^N$ and $u^n \in
-H^1(\Omega)$. Thus, the finite-dimensional version of the variational fomulation requires that we solve the following matrix equations at each time step:
+H^1(\Omega)$. Thus, the finite-dimensional version of the variational formulation requires that we solve the following matrix equations at each time step:
@f{eqnarray*}
F_h'(U^{n,l})\delta U^{n,l} &=& -F_h(U^{n,l}), \qquad
U^{n,l+1} = U^{n,l} + \delta U^{n,l}, \qquad U^{n,0} = U^{n-1}; \\
\f{eqnarray*}
F_h(U^{n,l}) &=& \left[ M+k^2\theta^2A \right] U^{n,l} -
\left[ M-k^2\theta(1-\theta)A \right] U^{n-1} - k MV^{n-1}
- + k^2\theta S(u^{n,l}, u^{n-1}),\\
+ + k^2\theta S(u^n_l, u^{n-1}),\\
F_h'(U^{n,l}) &=& M+k^2\theta^2A
- - k^2\theta^2N(u^{n,l},u^{n-1})
+ - k^2\theta^2N(u^n_l,u^{n-1})
\f}
Again, note that the first matrix equation above is, in fact, the
-defition of an iterative procedure, so it is solved multiple times
+definition of an iterative procedure, so it is solved multiple times
until a stopping criterion is met. Moreover, $M$ is the mass matrix,
i.e. $M_{ij} = \left( \varphi_i,\varphi_j \right)_{\Omega}$, $A$ is
the Laplace matrix, i.e. $A_{ij} = \left( \nabla \varphi_i, \nabla
What solvers can we use for the first equation? Let's look at the matrix we
have to invert:
@f[
- (M-k^2\theta^2N)_{ij} =
+ (M+k^2\theta^2(A-N))_{ij} =
\int_\Omega (1-k^2\theta^2 \cos \alpha)
- \varphi_i\varphi_j \; dx,
+ \varphi_i\varphi_j \; dx+\int_\Omega \nabla\varphi_i\nabla\varphi_j \; dx,
@f]
for some $\alpha$ that depends on the present and previous solution. First,
note that the matrix is symmetric. In addition, if the time step $k$ is small
-/* Author: Ivan Christov, Wolfgang Bangerth, Texas A&M University, 2006 */
-
-/* $Id$ */
-/* Copyright (C) 2006-2009, 2011-2012 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. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2006 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Ivan Christov, Wolfgang Bangerth, Texas A&M University, 2006
+ */
// @sect3{Include files and global variables}
// @sect4{SineGordonProblem::assemble_system}
- // This functions assembles the system matrix and right-hand side vector for
+ // This function assembles the system matrix and right-hand side vector for
// each iteration of Newton's method. The reader should refer to the
// Introduction for the explicit formulas for the system matrix and
// right-hand side.
{
// First we assemble the Jacobian matrix $F'_h(U^{n,l})$, where $U^{n,l}$
// is stored in the vector <code>solution</code> for convenience.
- system_matrix = 0;
system_matrix.copy_from (mass_matrix);
system_matrix.add (std::pow(time_step*theta,2), laplace_matrix);
system_matrix.add (-std::pow(time_step*theta,2), tmp_matrix);
// Then, we compute the right-hand side vector $-F_h(U^{n,l})$.
+ //
+ // We have to first build up the matrix
+ // $M+k^2\theta^2 A$, which we put into <code>tmp_matrix</code>
+ // use it to compute a contribution to the right hand side vector, and
+ // then build the matrix $M-k^2\theta(1-\theta) A$. We could
+ // build it in the same way as before, i.e., using code like
+ // @code
+ // tmp_matrix.copy_from (mass_matrix);
+ // tmp_matrix.add (-std::pow(time_step,2)*theta*(1-theta), laplace_matrix);
+ // @endcode
+ // but we can save the expense of the <code>copy_from</code> operation
+ // by starting from what is already in the <code>tmp_matrix</code>
+ // variable (i.e., $M+k^2\theta^2 A$) and subtracting from this
+ // $k^2\theta^2 A+k^2\theta(1-\theta) A=k^2\theta A$ when computing the
+ // second matrix:
system_rhs = 0;
- tmp_matrix = 0;
tmp_matrix.copy_from (mass_matrix);
tmp_matrix.add (std::pow(time_step*theta,2), laplace_matrix);
tmp_matrix.vmult (tmp_vector, solution);
system_rhs += tmp_vector;
- tmp_matrix = 0;
- tmp_matrix.copy_from (mass_matrix);
- tmp_matrix.add (-std::pow(time_step,2)*theta*(1-theta), laplace_matrix);
- tmp_vector = 0;
+ tmp_matrix.add(-std::pow(time_step, 2) * theta, laplace_matrix);
+
tmp_matrix.vmult (tmp_vector, old_solution);
system_rhs -= tmp_vector;
system_rhs.add (-time_step, M_x_velocity);
- tmp_vector = 0;
compute_nl_term (old_solution, solution, tmp_vector);
system_rhs.add (std::pow(time_step,2)*theta, tmp_vector);
// integrate these terms exactly. It is usually sufficient to just make sure
// that the right hand side is integrated up to the same order of accuracy
// as the discretization scheme is, but it may be possible to improve on the
- // constant in the asympotitic statement of convergence by choosing a more
+ // constant in the asymptotic statement of convergence by choosing a more
// accurate quadrature formula.
template <int dim>
void SineGordonProblem<dim>::compute_nl_term (const Vector<double> &old_data,
const Vector<double> &new_data,
Vector<double> &nl_term) const
{
+ nl_term = 0;
const QGauss<dim> quadrature_formula (3);
FEValues<dim> fe_values (fe, quadrature_formula,
update_values |
for (; cell!=endc; ++cell)
{
+ local_nl_term = 0;
// Once we re-initialize our <code>FEValues</code> instantiation to
// the current cell, we make use of the
// <code>get_function_values</code> routine to get the values of the
for (unsigned int i=0; i<dofs_per_cell; ++i)
nl_term(local_dof_indices[i]) += local_nl_term(i);
-
- local_nl_term = 0;
}
}
// @sect4{SineGordonProblem::compute_nl_matrix}
// This is the second function dealing with the nonlinear scheme. It
- // computes the matrix $N(\cdot,\cdot)$, whicih appears in the nonlinear
+ // computes the matrix $N(\cdot,\cdot)$, which appears in the nonlinear
// term in the Jacobian of $F(\cdot)$. Just as <code>compute_nl_term</code>,
// we must allow this function to receive as input an "old" and a "new"
// solution, which we again call $w_{\mathrm{old}}$ and $w_{\mathrm{new}}$
for (; cell!=endc; ++cell)
{
+ local_nl_matrix = 0;
// Again, first we re-initialize our <code>FEValues</code>
// instantiation to the current cell.
fe_values.reinit (cell);
for (unsigned int j=0; j<dofs_per_cell; ++j)
nl_matrix.add(local_dof_indices[i], local_dof_indices[j],
local_nl_matrix(i,j));
-
- local_nl_matrix = 0;
}
}
PreconditionSSOR<> preconditioner;
preconditioner.initialize(system_matrix, 1.2);
- solution_update = 0;
cg.solve (system_matrix, solution_update,
system_rhs,
preconditioner);
{
make_grid_and_dofs ();
- // To aknowledge the initial condition, we must use the function $u_0(x)$
+ // To acknowledge the initial condition, we must use the function $u_0(x)$
// to compute $U^0$. To this end, below we will create an object of type
// <code>InitialValues</code>; note that when we create this object (which
// is derived from the <code>Function</code> class), we set its internal
laplace_matrix.vmult (tmp_vector, solution);
M_x_velocity.add (-time_step*theta, tmp_vector);
- tmp_vector = 0;
laplace_matrix.vmult (tmp_vector, old_solution);
M_x_velocity.add (-time_step*(1-theta), tmp_vector);
- tmp_vector = 0;
compute_nl_term (old_solution, solution, tmp_vector);
M_x_velocity.add (-time_step, tmp_vector);
-/* Author: Wolfgang Bangerth, Texas A&M University, 2013 */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Wolfgang Bangerth, Texas A&M University, 2013
+ */
-/* $Id$ */
-/* */
-/* Copyright (C) 2013 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 <deal.II/base/utilities.h>
#include <deal.II/base/quadrature_lib.h>
void solve_time_step();
void output_results() const;
void refine_mesh (const unsigned int min_grid_level,
- const unsigned int max_grid_level);
+ const unsigned int max_grid_level);
Triangulation<dim> triangulation;
FE_Q<dim> fe;
dof_handler.distribute_dofs(fe);
std::cout << std::endl
- << "==========================================="
- << std::endl
- << "Number of active cells: " << triangulation.n_active_cells()
+ << "==========================================="
<< std::endl
- << "Number of degrees of freedom: " << dof_handler.n_dofs()
+ << "Number of active cells: " << triangulation.n_active_cells()
<< std::endl
- << std::endl;
+ << "Number of degrees of freedom: " << dof_handler.n_dofs()
+ << std::endl
+ << std::endl;
constraints.clear ();
DoFTools::make_hanging_node_constraints (dof_handler,
MatrixCreator::create_mass_matrix(dof_handler,
QGauss<dim>(fe.degree+1),
mass_matrix,
- (const Function<dim>*)0,
+ (const Function<dim> *)0,
constraints);
MatrixCreator::create_laplace_matrix(dof_handler,
QGauss<dim>(fe.degree+1),
laplace_matrix,
- (const Function<dim>*)0,
+ (const Function<dim> *)0,
constraints);
solution.reinit(dof_handler.n_dofs());
// too high a mesh level.
template <int dim>
void HeatEquation<dim>::refine_mesh (const unsigned int min_grid_level,
- const unsigned int max_grid_level)
+ const unsigned int max_grid_level)
{
Vector<float> estimated_error_per_cell (triangulation.n_active_cells());
cell != triangulation.end(); ++cell)
cell->clear_refine_flag ();
for (typename Triangulation<dim>::active_cell_iterator
- cell = triangulation.begin_active(min_grid_level);
- cell != triangulation.end_active(min_grid_level); ++cell)
+ cell = triangulation.begin_active(min_grid_level);
+ cell != triangulation.end_active(min_grid_level); ++cell)
cell->clear_coarsen_flag ();
// SolutionTransfer class and we have to prepare the solution vectors that
// should be transferred to the new grid (we will lose the old grid once
// we have done the refinement so the transfer has to happen concurrently
- // with refinement). What we definetely need are the current and the old
+ // with refinement). What we definitely need are the current and the old
// temperature (BDF-2 time stepping requires two old solutions). Since the
// SolutionTransfer objects only support to transfer one object per dof
// handler, we need to collect the two temperature solutions in one data
std::cout << "Time step " << timestep_number << " at t=" << time
<< std::endl;
- tmp.reinit (solution.size());
- forcing_terms.reinit (solution.size());
+ tmp.reinit (solution.size());
+ forcing_terms.reinit (solution.size());
mass_matrix.vmult(system_rhs, old_solution);
(pre_refinement_step < n_adaptive_pre_refinement_steps))
{
refine_mesh (initial_global_refinement,
- initial_global_refinement + n_adaptive_pre_refinement_steps);
+ initial_global_refinement + n_adaptive_pre_refinement_steps);
++pre_refinement_step;
- std::cout << std::endl;
+ std::cout << std::endl;
goto start_time_iteration;
}
else if ((timestep_number > 0) && (timestep_number % 5 == 0))
refine_mesh (initial_global_refinement,
- initial_global_refinement + n_adaptive_pre_refinement_steps);
+ initial_global_refinement + n_adaptive_pre_refinement_steps);
old_solution = solution;
}
-/* Author: Wolfgang Bangerth, Texas A&M University, 2006, 2007 */
-
-/* $Id$ */
-/* */
-/* Copyright (C) 2006-2012 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. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2006 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Wolfgang Bangerth, Texas A&M University, 2006, 2007
+ */
+
// @sect3{Include files}
[For those who wonder how this can be achieved in practice without
inadvertently getting slightly larger than one and triggering a nuclear bomb:
first, fission processes happen on different time scales. While most neutrons
-are releases very quickly after a fission event, a small number of neutrons
+are released very quickly after a fission event, a small number of neutrons
are only released by daughter nuclei after several further decays, up to 10-60
seconds after the fission was initiated. If one is therefore slightly beyond
$k_{\mathrm{eff}}=1$, one therefore has many seconds to react until all the
<li> If the cell $K$ is active on mesh $g$, but not $g'$, then the
basis functions $\varphi_{g'}^j$ are only defined either on the children
$K_c,0\le c<2^{\texttt{dim}}$, or on children of these children if cell $K$
- is refined more than once more on mesh $g'$.
+ is refined more than once on mesh $g'$.
Let us assume for a second that $K$ is only once more refined on mesh $g'$
than on mesh $g$. Using the fact that we use embedded finite element spaces
<img src="http://www.dealii.org/images/steps/developer/step-28.grid-1.9.order2.png" alt="">
-We see that the grid of thermal group is much finner than the one of fast group.
+We see that the grid of thermal group is much finer than the one of fast group.
The solutions on these grids are, (Note: flux are normalized with total fission
source equal to 1)
mesh iteration of polynomial order 3 minus 2e-10. We see that h-adaptive calculations
deliver an algebraic convergence. And the higher polynomial order is, the faster mesh
iteration converges. In our problem, we need smaller number of DoFs to achieve same
-accuracy with higher polynoimal order.
+accuracy with higher polynomial order.
-/* Author: Yaqi Wang, Texas A&M University, 2009, 2010 */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2009 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Yaqi Wang, Texas A&M University, 2009, 2010
+ */
-/* $Id$ */
-/* */
-/* Copyright (C) 2009-2012 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. */
// @sect3{Include files}
// arrays. It takes the number of energy groups as an argument (an throws an
// error if that value is not equal to two, since at presently only data for
// two energy groups is implemented; however, using this, the function
- // remains flexible and extendible into the future). In the member
+ // remains flexible and extendable into the future). In the member
// initialization part at the beginning, it also resizes the arrays to their
// correct sizes.
//
ConstraintMatrix hanging_node_constraints;
- // @sect5{Private member functionss}
+ // @sect5{Private member functions}
//
// There is one private member function in this class. It recursively
// walks over cells of two meshes to compute the cross-group right hand
// groups. First we call <code>get_finest_common_cells</code> to obtain this
// list of pairs of common cells from both meshes. Both cells in a pair may
// not be active but at least one of them is. We then hand each of these
- // cell pairs off to a function tha computes the right hand side terms
+ // cell pairs off to a function that computes the right hand side terms
// recursively.
//
// Note that ingroup coupling is handled already before, so we exit the
MESSAGE(FATAL_ERROR "
Error! The deal.II library found at ${DEAL_II_PATH} was not configured with
DEAL_II_WITH_UMFPACK = ON
-which is required for this tutorial step."
+One or all of these are OFF in your installation but are required for this tutorial step."
)
ENDIF()
The original purpose of this program is to simulate the focussing properties
of an ultrasound wave generated by a transducer lens with variable
geometry. Recent applications in medical imaging use ultrasound waves not only
-for imaging porposes, but also to excite certain local effects in a
+for imaging purposes, but also to excite certain local effects in a
material, like changes in optical properties, that can then be measured by
other imaging techniques. A vital ingredient for these methods is the ability
to focus the intensity of the ultrasound wave in a particular part of the
will pass through the boundary as if it wasn't here whereas the remaining
fraction of the wave will be reflected back into the domain.
-If we are willing to accept this as a suffient approximation to an absorbing boundary we finally arrive at the following problem for $u$:
+If we are willing to accept this as a sufficient approximation to an absorbing boundary we finally arrive at the following problem for $u$:
@f{eqnarray*}
-\omega^2 u - c^2\Delta u &=& 0, \qquad x\in\Omega,\\
c (n\cdot\nabla u) + i\,\omega\,u &=&0, \qquad x\in\Gamma_2,\\
radius slightly greater than $d$; this shape should lead to a focusing of the sound
wave at the center of the circle. Varying $d$ changes the "focus" of the lens
and affects the spatial distribution of the intensity of $u$, where our main
-concern is how well $|u|=\sqrt{v^2+w^2}$ is.focussed.
+concern is how well $|u|=\sqrt{v^2+w^2}$ is focussed.
In the program below, we will implement the complex-valued Helmholtz equations
using the formulation with split real and imaginary parts. We will also
is ${\cal O}(BN)$. This also explains why the program does run in 3d
as well (after changing the dimension on the
<code>UltrasoundProblem</code> object), but scales very badly and
-takes extraordinate patience before it finishes solving the linear
+takes extraordinary patience before it finishes solving the linear
system on a mesh with appreciable resolution, even though all the
other parts of the program scale very nicely.
-/* Author: Moritz Allmaras, Texas A&M University, 2007 */
-
-/* $Id$ */
-/* Copyright (C) 2007-2008, 2010-2012 by the deal.II authors and M. Allmaras */
-/* */
-/* 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. */
-
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2007 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Moritz Allmaras, Texas A&M University, 2007
+ */
// @sect3{Include files}
{}
- // The actual prostprocessing happens in the following function. Its inputs
+ // The actual postprocessing happens in the following function. Its inputs
// are a vector representing values of the function (which is here
// vector-valued) representing the data vector given to
// DataOut::add_data_vector, evaluated at all evaluation points where we
ExcDimensionMismatch (computed_quantities[i].size(), 1));
Assert(uh[i].size() == 2, ExcDimensionMismatch (uh[i].size(), 2));
- computed_quantities[i](0) = sqrt(uh[i](0)*uh[i](0) + uh[i](1)*uh[i](1));
+ computed_quantities[i](0) = std::sqrt(uh[i](0)*uh[i](0) + uh[i](1)*uh[i](1));
}
}
// At this point, it is important to keep in mind that we are
// dealing with a finite element system with two
// components. Due to the way we constructed this FESystem,
- // namely as the cartesian product of two scalar finite
+ // namely as the Cartesian product of two scalar finite
// element fields, each shape function has only a single
// nonzero component (they are, in deal.II lingo, @ref
// GlossPrimitive "primitive"). Hence, each shape function
common structure that almost all following tutorial programs will use:
<ul>
<li> <code>make_grid()</code>: This is what one could call a
- <i>pre-processing function</i>. As its name suggests, it sets up the
+ <i>preprocessing function</i>. As its name suggests, it sets up the
object that stores the triangulation. In later examples, it could also
deal with boundary conditions, geometries, etc.
<li> <code>setup_system()</code>: This then is the function in which all the
other data structures are set up that are needed to solve the
problem. In particular, it will initialize the DoFHandler object and
correctly size the various objects that have to do with the linear
- algebra. This function is often separated from the pre-processing
+ algebra. This function is often separated from the preprocessing
function above because, in a time dependent program, it may be called
at least every few time steps whenever the mesh
is adaptively refined (something we will see how to do in step-6). On
- the other hand, setting up the mesh itself in the pre-processing
+ the other hand, setting up the mesh itself in the preprocessing
function above is done only once at the beginning of the program and
is, therefore, separated into its own function.
<li> <code>assemble_system()</code>: This, then is where the contents of the
following tutorial programs.
+<h3> A note on types </h3>
+
+deal.II defines a number of integral %types via <code>typedef</code>s in
+namespace types. In particular, in this program you will see
+types::global_dof_index in a couple of places: an integer type that is used to
+denote the <i>global</i> index of a degree of freedom, i.e., the index of a
+particular degree of freedom within the DoFHandler object that is defined on
+top of a triangulation (as opposed to the index of a particular degree of
+freedom within a particular cell). For the current program
+(as well as almost all of the tutorial programs), you will have a few thousand
+to maybe a few million unknowns globally (and, for $Q_1$ elements, you will
+have 4 <i>locally on each cell</i> in 2d and 8 in 3d). Consequently, a data
+type that allows to store sufficiently large numbers for global DoF indices is
+<code>unsigned int</code> given that it allows to store numbers between 0 and
+slightly more than 4 billion (on most systems, where integers are 32-bit). In
+fact, this is what types::global_dof_index is.
+
+So, why not just use <code>unsigned int</code> right away? deal.II used to do
+this until version 7.3. However, deal.II supports very large computations (via
+the framework discussed in step-40) that may have more than 4 billion unknowns
+when spread across a few thousand processors. Consequently, there are
+situations where <code>unsigned int</code> is not sufficiently large and we
+need a 64-bit unsigned integral type. To make this possible, we introduced
+types::global_dof_index which by default is defined as simply <code>unsigned
+int</code> whereas it is possible to define it as <code>unsigned long long
+int</code> if necessary, by passing a particular flag during configuration
+(see the ReadMe file).
+
+This covers the technical aspect. But there is also a documentation purpose:
+everywhere in the library and codes that are built on it, if you see a place
+using the data type types::global_dof_index, you immediately know that the
+quantity that is being referenced is, in fact, a global dof index. No such
+meaning would be apparent if we had just used <code>unsigned int</code> (which
+may also be a local index, a boundary indicator, a material id,
+etc.). Immediately knowing what a variable refers to also helps avoid errors:
+it's quite clear that there must be a bug if you see an object of type
+types::global_dof_index being assigned to variable of type
+types::subdomain_id, even though they are both represented by unsigned
+integers and the compiler will, consequently, not complain.
+
+In more practical terms what the presence of this type means is that during
+assembly, we create a $4\times 4$ matrix (in 2d, using a $Q_1$ element) of the
+contributions of the cell we are currently sitting on, and then we need to add
+the elements of this matrix to the appropriate elements of the global (system)
+matrix. For this, we need to get at the global indices of the degrees of
+freedom that are local to the current cell, for which we will always use the
+following piece of the code:
+@code
+ cell->get_dof_indices (local_dof_indices);
+@endcode
+where <code>local_dof_indices</code> is declared as
+@code
+ std::vector<types::global_dof_index> local_dof_indices (fe.dofs_per_cell);
+@endcode
+The name of this variable might be a bit of a misnomer -- it stands for "the
+global indices of those degrees of freedom locally defined on the current
+cell" -- but variables that hold this information are universally named this
+way throughout the library.
+
+@note types::global_dof_index is not the only type defined in this
+namespace. Rather, there is a whole family, including types::subdomain_id,
+types::boundary_id, and types::material_id. All of these are
+<code>typedef</code>s for integer data types but, as explained above, they are
+used throughout the library so that (i) the intent of a variable becomes more
+easily discerned, and (ii) so that it becomes possible to change the actual
+type to a larger one if necessary without having to go through the entire
+library and figure out whether a particular use of <code>unsigned int</code>
+corresponds to, say, a material indicator.
values for those faces that have zero boundary indicator, and leave
those faces alone that have a different boundary indicator. What
this then does is to impose Dirichlet boundary conditions on the
- former, and homogenous Neumann conditions on the latter (i.e. zero
+ former, and homogeneous Neumann conditions on the latter (i.e. zero
normal derivative of the solution, unless one adds additional terms
to the right hand side of the variational equality that deal with
potentially non-zero Neumann conditions). You will see this if you
<code>LaplaceProblem::LaplaceProblem</code>.
<li>Convergence of the mean: A different way to see that the solution
- actually converges (to something &mdash we can't tell whether it's really
+ actually converges (to something — we can't tell whether it's really
the correct value!) is to compute the mean of the solution. To this end, add
the following code to <code>LaplaceProblem::output_results</code>:
@code
-/* Author: Wolfgang Bangerth, 1999, Guido Kanschat, 2011 */
-
-/* $Id$ */
-/* */
-/* Copyright (C) 1999-2004, 2006-2008, 2010-2012 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. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 1999 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Authors: Wolfgang Bangerth, 1999,
+ * Guido Kanschat, 2011
+ */
// @sect3{Many new include files}
// mentioned, we use the implied Q1 mapping, rather than specifying one
// ourselves explicitly. Finally, we have to tell it what we want it to
// compute on each cell: we need the values of the shape functions at the
- // quadrature points (for the right hand side $(\varphi,f)$), their
+ // quadrature points (for the right hand side $(\varphi_i,f)$), their
// gradients (for the matrix entries $(\nabla \varphi_i, \nabla
// \varphi_j)$), and also the weights of the quadrature points and the
// determinants of the Jacobian transformations from the reference cell to
update_values | update_gradients | update_JxW_values);
// The advantage of this approach is that we can specify what kind of
// information we actually need on each cell. It is easily understandable
- // that this approach can significant speed up finite element computations,
+ // that this approach can significantly speed up finite element computations,
// compared to approaches where everything, including second derivatives,
- // normal vectors to cells, etc are computed on each cell, regardless
+ // normal vectors to cells, etc are computed on each cell, regardless of
// whether they are needed or not.
- // For use further down below, we define two short cuts for values that will
+ // For use further down below, we define two shortcuts for values that will
// be used very frequently. First, an abbreviation for the number of degrees
// of freedom on each cell (since we are in 2D and degrees of freedom are
// associated with vertices only, this number is four, but we rather want to
//
// Secondly, we also define an abbreviation for the number of quadrature
// points (here that should be four). In general, it is a good idea to use
- // their symbolic names instead of hard-coding these number even if you know
+ // their symbolic names instead of hard-coding these numbers even if you know
// them, since you may want to change the quadrature formula and/or finite
// element at some time; the program will just work with these changes,
// without the need to change anything in this function.
// through dofs_per_cell-1). However, when we transfer the result into the
// global matrix, we have to know the global numbers of the degrees of
// freedom. When we query them, we need a scratch (temporary) array for
- // these numbers:
+ // these numbers (see the discussion at the end of the introduction for
+ // the type, types::global_dof_index, used here):
std::vector<types::global_dof_index> local_dof_indices (dofs_per_cell);
// Now for the loop over all cells. We have seen before how this works, so
usual code found in application programs will need modifications to exploit
the features of meshes which were created using anisotropic
refinement. For those interested in how deal.II evolved, it may be of
-interest that the losening of such invariants required some
+interest that the loosening of such invariants required some
incompatible changes. For example, the library used to have a member
GeometryInfo<dim>::children_per_cell that specified how many children
a cell has once it is refined. For isotropic refinement, this number
consequently been removed. It has now been replaced by
GeometryInfo<dim>::max_children_per_cell which specifies the
<i>maximum</i> number of children a cell can have. How many children a
-refined cell has was previously available as static informtion, but
+refined cell has was previously available as static information, but
now it depends on the actual refinement state of a cell and can be
retrieved using the function call <code>cell-@>n_children()</code>,
a call that works equally well for both isotropic and anisotropic
coarse mesh can decrease performance significantly for real world
problems. However, that is not always the case. Considering boundary layers in
compressible viscous flows, for example, the mesh is always aligned with the
-anisotropic features, thus anisotropic refinement will almost alway increase the
+anisotropic features, thus anisotropic refinement will almost always increase the
efficiency of computations on adapted grids for these cases.
-/* Author: Tobias Leicht, 2007 */
-
-/* $Id$ */
-/* Version: $Name$ */
-/* */
-/* Copyright (C) 2007-2008, 2011-2012 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. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2007 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Tobias Leicht, 2007
+ */
+
// The deal.II include files have already been covered in previous examples
// and will thus not be further commented on.
// in the left part of the domain at a velocity that matches the one coming
// in from the right. In the circular part the magnitude of the flow
// velocity is proportional to the distance from the origin. This is a
- // difference to step-12, where the magnitude was 1 evereywhere. the new
+ // difference to step-12, where the magnitude was 1 everywhere. the new
// definition leads to a linear variation of $\beta$ along each given face
// of a cell. On the other hand, the solution $u(x,y)$ is exactly the same
// as before.
anisotropic(anisotropic),
// As beta is a linear function, we can choose the degree of the
// quadrature for which the resulting integration is correct. Thus, we
- // choose to use <code>degree+1</code> gauss points, which enables us to
+ // choose to use <code>degree+1</code> Gauss points, which enables us to
// integrate exactly polynomials of degree <code>2*degree+1</code>, enough
// for all the integrals we will perform in this program.
quadrature (degree+1),
// Case b), we decide that there are finer cells as neighbors
// by asking the face, whether it has children. if so, then
// there must also be finer cells which are children or
- // farther offsprings of our neighbor.
+ // farther offspring of our neighbor.
if (face->has_children())
{
// We need to know, which of the neighbors faces points in
(neighbor->level() < cell->level() &&
neighbor->index() == cell->index())))
{
- // Here we know, that the neigbor is not coarser so we
+ // Here we know, that the neighbor is not coarser so we
// can use the usual @p neighbor_of_neighbor
// function. However, we could also use the more
// general @p neighbor_face_no function.
triangulation.execute_coarsening_and_refinement ();
}
- // Once an error indicator has been evaluated and the cells with largerst
+ // Once an error indicator has been evaluated and the cells with largest
// error are flagged for refinement we want to loop over the flagged cells
- // again to decide whether they need isotropic refinemnt or whether
+ // again to decide whether they need isotropic refinement or whether
// anisotropic refinement is more appropriate. This is the anisotropic jump
// indicator explained in the introduction.
template <int dim>
endc=dof_handler.end();
for (; cell!=endc; ++cell)
- // We only need to consider cells which are flaged for refinement.
+ // We only need to consider cells which are flagged for refinement.
if (cell->refine_flag_set())
{
Point<dim> jump;
std::vector<double> u (fe_v_face.n_quadrature_points);
std::vector<double> u_neighbor (fe_v_face.n_quadrature_points);
- // The four cases of different neighbor relations senn in
+ // The four cases of different neighbor relations seen in
// the assembly routines are repeated much in the same way
// here.
if (face->has_children())
// present subface...
typename DoFHandler<dim>::cell_iterator neighbor_child = cell->neighbor_child_on_subface(face_no,subface_no);
Assert (!neighbor_child->has_children(), ExcInternalError());
- // ... and reinit the respective FEFaceValues und
+ // ... and reinit the respective FEFaceValues and
// FESubFaceValues objects.
fe_v_subface.reinit (cell, face_no, subface_no);
fe_v_face_neighbor.reinit (neighbor_child, neighbor2);
fe_v_subface.get_function_values(solution2, u);
fe_v_face_neighbor.get_function_values(solution2, u_neighbor);
// as well as the quadrature weights, multiplied by
- // the jacobian determinant.
+ // the Jacobian determinant.
const std::vector<double> &JxW = fe_v_subface.get_JxW_values ();
// Now we loop over all quadrature points
for (unsigned int x=0; x<fe_v_subface.n_quadrature_points; ++x)
// first coordinate direction on the unit cell,
// the second two faces are orthogonal to the
// second coordinate direction and so on, so we
- // accumulate these values ito vectors with
+ // accumulate these values into vectors with
// <code>dim</code> components.
jump[face_no/2]+=std::fabs(u[x]-u_neighbor[x])*JxW[x];
// We also sum up the scaled weights to obtain
// Now we loop over the <code>dim</code> coordinate directions of
// the unit cell and compare the average jump over the faces
- // orthogional to that direction with the average jumnps over faces
- // orthogonal to the remining direction(s). If the first is larger
+ // orthogonal to that direction with the average jumps over faces
+ // orthogonal to the remaining direction(s). If the first is larger
// than the latter by a given factor, we refine only along hat
// axis. Otherwise we leave the refinement flag unchanged, resulting
// in isotropic refinement.
MESSAGE(FATAL_ERROR "
Error! The deal.II library found at ${DEAL_II_PATH} was not configured with
DEAL_II_WITH_TRILINOS = ON
-which is required for this tutorial step."
+One or all of these are OFF in your installation but are required for this tutorial step."
)
ENDIF()
melting point, $\eta$ may change by orders of magnitude over the typical range
of temperatures.
-We note that the Stokes equation above could be non-dimensionalized by
+We note that the Stokes equation above could be nondimensionalized by
introducing the <a target="_top"
href="http://en.wikipedia.org/wiki/Rayleigh_number">Rayleigh
number</a> $\mathrm{Ra}=\frac{\|g\| \beta \rho}{\eta \kappa} \delta T L^3$ using a
conductivity and a time scale of relevance to affect the evolution of the
earth's interior and surface structure.
+@note If you are interested in using the program as the basis for your own
+experiments, you will also want to take a look at its continuation in
+step-32. Furthermore, step-32 later was developed into the much larger open
+source code Aspect (see http://aspect.dealii.org/ ) that can solve realistic
+problems and that you may want to investigate before trying to morph step-31
+into something that can solve whatever you want to solve.
<h3>%Boundary and initial conditions</h3>
numerical viscosity $\nu(T)$ is temperature-dependent, so the equation
we want to solve is nonlinear in <i>T</i> — not what one desires from a
simple method to stabilize an equation, and even less so if we realize
-that $\nu(T)$ is non-differentiable in <i>T</i>. However, there is no
+that $\nu(T)$ is nondifferentiable in <i>T</i>. However, there is no
reason to despair: we still have to discretize in time and we can
treat the term explicitly.
temperature at the current time in the same way as we have discussed
the advection works in the section on time stepping.
-The form for non-uniform time steps that we will have to use in
+The form for nonuniform time steps that we will have to use in
reality is a bit more complicated (which is why we showed the simpler
form above first) and reads:
@f{eqnarray*}
introduction of step-22 and fixes one component of the velocity
while allowing flow to be %parallel to the boundary. There remain
<code>dim-1</code> components to be fixed, namely the tangential components of
-the normal stress; for these, we choose homogenous conditions which means that
+the normal stress; for these, we choose homogeneous conditions which means that
we do not have to anything special. Initial conditions are only necessary for
the temperature field, and we choose it to be constant zero.
close to the bottom of the domain, imitating three candles. The fluid located
at these sources, initially at rest, is then heated up and as the temperature
rises gains buoyancy, rising up; more fluid is dragged up and through the
-sources, leading to three hote plumes that rise up until they are captured by
+sources, leading to three hot plumes that rise up until they are captured by
the recirculation of fluid that sinks down on the outside, replacing the air
that rises due to heating.
if we state the CFL condition as the requirement that the time step be
small enough so that the distance transport advects in each time step
is no longer than one <i>grid point</i> away (which for $Q_1$ elements
-is $h_K$, but for $Q_2$ elements is $h_K/2$). It turns out that $\beta$
-needs to be sligthly larger for obtaining stable results also late in
+is $h_K$, but for $Q_2$ elements is $h_K/2$). It turns out that $\beta$
+needs to be slightly larger for obtaining stable results also late in
the simulation at times larger than 60, so we actually choose it as
$\beta = 0.034$ in the code.
is, of course, to make it faster and/or increase the resolution of the
program, in particular in 3d. This is the topic of the step-32
tutorial program which will implement strategies to solve this problem in
-%parallel on a cluster.
+%parallel on a cluster. It is also the basis of the much larger open
+source code Aspect (see http://aspect.dealii.org/ ) that can solve realistic
+problems and that constitutes the further development of step-32.
Another direction would be to make the fluid flow more realistic. The program
was initially written to simulate various cases simulating the convection of
-/* Author: Martin Kronbichler, Uppsala University,
- Wolfgang Bangerth, Texas A&M University 2007, 2008 */
-
-/* $Id$ */
-/* */
-/* Copyright (C) 2007-2013 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. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2007 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Authors: Martin Kronbichler, Uppsala University,
+ * Wolfgang Bangerth, Texas A&M University 2007, 2008
+ */
+
// @sect3{Include files}
// same as in step-22. Regarding the details, though, there are some
// differences.
- // The first thing is that we don't set any non-homogenous boundary
+ // The first thing is that we don't set any nonhomogeneous boundary
// conditions on the velocity, since as is explained in the introduction we
// will use no-flux conditions $\mathbf{n}\cdot\mathbf{u}=0$. So what is
// left are <code>dim-1</code> conditions for the tangential part of the
// normal component of the stress tensor, $\textbf{n} \cdot [p \textbf{1} -
- // \eta\varepsilon(\textbf{u})]$; we assume homogenous values for these
+ // \eta\varepsilon(\textbf{u})]$; we assume homogeneous values for these
// components, i.e. a natural boundary condition that requires no specific
// action (it appears as a zero term in the right hand side of the weak
// form).
//
// Secondly, we catch any exceptions that the solver may have thrown. The
// reason is as follows: When debugging a program like this one
- // occasionally makes a mistake of passing an indefinite or non-symmetric
+ // occasionally makes a mistake of passing an indefinite or nonsymmetric
// matrix or preconditioner to the current class. The solver will, in that
// case, not converge and throw a run-time exception. If not caught here
// it will propagate up the call stack and may end up in
// detail in the results section of this tutorial program. The second is the
// exponent $\alpha$; $\alpha=1$ appears to work fine for the current
// program, even though some additional benefit might be expected from
- // chosing $\alpha = 2$. Finally, there is one thing that requires special
+ // choosing $\alpha = 2$. Finally, there is one thing that requires special
// casing: In the first time step, the velocity equals zero, and the formula
// for $\nu|_K$ is not defined. In that case, we return $\nu|_K=5\cdot 10^3
// \cdot h_K$, a choice admittedly more motivated by heuristics than
// dofs. Consequently, there will be no data written at positions of
// constrained degrees of freedom, so we can let the
// DoFTools::make_sparsity_pattern function omit these entries by setting
- // the last boolean flag to <code>false</code>. Once the sparsity pattern
+ // the last Boolean flag to <code>false</code>. Once the sparsity pattern
// is ready, we can use it to initialize the Trilinos matrices. Since the
// Trilinos matrices store the sparsity pattern internally, there is no
// need to keep the sparsity pattern around after the initialization of
// Next, we set some more options of the AMG preconditioner. In
// particular, we need to tell the AMG setup that we use quadratic basis
// functions for the velocity matrix (this implies more nonzero elements
- // in the matrix, so that a more rubust algorithm needs to be chosen
+ // in the matrix, so that a more robust algorithm needs to be chosen
// internally). Moreover, we want to be able to control how the coarsening
// structure is build up. The way the Trilinos smoothed aggregation AMG
// does this is to look which matrix entries are of similar size as the
// diagonal entry in order to algebraically build a coarse-grid
// structure. By setting the parameter <code>aggregation_threshold</code>
- // to 0.02, we specify that all entries that are more than two precent of
+ // to 0.02, we specify that all entries that are more than two percent of
// size of some diagonal pivots in that row should form one coarse grid
- // point. This parameter is rather ad-hoc, and some fine-tuning of it can
+ // point. This parameter is rather ad hoc, and some fine-tuning of it can
// influence the performance of the preconditioner. As a rule of thumb,
// larger values of <code>aggregation_threshold</code> will decrease the
// number of iterations, but increase the costs per iteration. A look at
//
// Finally, we also initialize the preconditioner for the inversion of the
// pressure mass matrix. This matrix is symmetric and well-behaved, so we
- // can chose a simple preconditioner. We stick with an incomple Cholesky
+ // can chose a simple preconditioner. We stick with an incomplete Cholesky
// (IC) factorization preconditioner, which is designed for symmetric
// matrices. We could have also chosen an SSOR preconditioner with
// relaxation factor around 1.2, but IC is cheaper for our example. We
// Next comes the declaration of vectors to hold the old and older
// solution values (as a notation for time levels <i>n-1</i> and
// <i>n-2</i>, respectively) and gradients at quadrature points of the
- // current cell. We also declarate an object to hold the temperature right
- // hande side values (<code>gamma_values</code>), and we again use
+ // current cell. We also declare an object to hold the temperature right
+ // hand side values (<code>gamma_values</code>), and we again use
// shortcuts for the temperature basis functions. Eventually, we need to
// find the temperature extrema and the diameter of the computational
// domain which will be used for the definition of the stabilization
// according to the discussion in the introduction using the dedicated
// function. With that at hand, we can get into the loop over
// quadrature points and local rhs vector components. The terms here
- // are quite lenghty, but their definition follows the time-discrete
+ // are quite lengthy, but their definition follows the time-discrete
// system developed in the introduction of this program. The BDF-2
// scheme needs one more term from the old time step (and involves
// more complicated factors) than the backward Euler scheme that is
// There is a snatch here. The formula contains a division by the maximum
// value of the velocity. However, at the start of the computation, we
// have a constant temperature field (we start with a constant
- // temperature, and it will be non-constant only after the first time step
+ // temperature, and it will be nonconstant only after the first time step
// during which the source acts). Constant temperature means that no
// buoyancy acts, and so the velocity is zero. Dividing by it will not
// likely lead to anything good.
// This function writes the solution to a VTK output file for visualization,
// which is done every tenth time step. This is usually quite a simple task,
// since the deal.II library provides functions that do almost all the job
- // for us. In this case, the situation is a bit more complicated, since we
- // want to visualize both the Stokes solution and the temperature as one
- // data set, but we have done all the calculations based on two different
- // DoFHandler objects, a situation the DataOut class usually used for output
- // is not prepared to deal with. The way we're going to achieve this
- // recombination is to create a joint DoFHandler that collects both
- // components, the Stokes solution and the temperature solution. This can be
- // nicely done by combining the finite elements from the two systems to form
- // one FESystem, and let this collective system define a new DoFHandler
- // object. To be sure that everything was done correctly, we perform a
- // sanity check that ensures that we got all the dofs from both Stokes and
- // temperature even in the combined system.
- //
- // Next, we create a vector that will collect the actual solution
- // values. Since this vector is only going to be used for output, we create
- // it as a deal.II vector that nicely cooperate with the data output
- // classes. Remember that we used Trilinos vectors for assembly and solving.
+ // for us. There is one new function compared to previous examples: We want
+ // to visualize both the Stokes solution and the temperature as one data
+ // set, but we have done all the calculations based on two different
+ // DoFHandler objects. Luckily, the DataOut class is prepared to deal with
+ // it. All we have to do is to not attach one single DoFHandler at the
+ // beginning and then use that for all added vector, but specify the
+ // DoFHandler to each vector separately. The rest is done as in step-22. We
+ // create solution names (that are going to appear in the visualization
+ // program for the individual components). The first <code>dim</code>
+ // components are the vector velocity, and then we have pressure for the
+ // Stokes part, whereas temperature is scalar. This information is read out
+ // using the DataComponentInterpretation helper class. Next, we actually
+ // attach the data vectors with their DoFHandler objects, build patches
+ // according to the degree of freedom, which are (sub-) elements that
+ // describe the data for visualization programs. Finally, we set a file name
+ // (that includes the time step number) and write the vtk file.
template <int dim>
void BoussinesqFlowProblem<dim>::output_results () const
{
if (timestep_number % 10 != 0)
return;
- const FESystem<dim> joint_fe (stokes_fe, 1,
- temperature_fe, 1);
- DoFHandler<dim> joint_dof_handler (triangulation);
- joint_dof_handler.distribute_dofs (joint_fe);
- Assert (joint_dof_handler.n_dofs() ==
- stokes_dof_handler.n_dofs() + temperature_dof_handler.n_dofs(),
- ExcInternalError());
-
- Vector<double> joint_solution (joint_dof_handler.n_dofs());
-
- // Unfortunately, there is no straight-forward relation that tells us how
- // to sort Stokes and temperature vector into the joint vector. The way we
- // can get around this trouble is to rely on the information collected in
- // the FESystem. For each dof in a cell, the joint finite element knows to
- // which equation component (velocity component, pressure, or temperature)
- // it belongs – that's the information we need! So we step through
- // all cells (with iterators into all three DoFHandlers moving in synch),
- // and for each joint cell dof, we read out that component using the
- // FiniteElement::system_to_base_index function (see there for a
- // description of what the various parts of its return value contain). We
- // also need to keep track whether we're on a Stokes dof or a temperature
- // dof, which is contained in
- // <code>joint_fe.system_to_base_index(i).first.first</code>. Eventually,
- // the dof_indices data structures on either of the three systems tell us
- // how the relation between global vector and local dofs looks like on the
- // present cell, which concludes this tedious work.
- //
- // There's one thing worth remembering when looking at the output: In our
- // algorithm, we first solve for the Stokes system at time level
- // <i>n-1</i> in each time step and then for the temperature at time level
- // <i>n</i> using the previously computed velocity. These are the two
- // components we join for output, so these two parts of the output file
- // are actually misaligned by one time step. Since we consider graphical
- // output as only a qualititative means to understand a solution, we
- // ignore this $\mathcal{O}(h)$ error.
- {
- std::vector<types::global_dof_index> local_joint_dof_indices (joint_fe.dofs_per_cell);
- std::vector<types::global_dof_index> local_stokes_dof_indices (stokes_fe.dofs_per_cell);
- std::vector<types::global_dof_index> local_temperature_dof_indices (temperature_fe.dofs_per_cell);
-
- typename DoFHandler<dim>::active_cell_iterator
- joint_cell = joint_dof_handler.begin_active(),
- joint_endc = joint_dof_handler.end(),
- stokes_cell = stokes_dof_handler.begin_active(),
- temperature_cell = temperature_dof_handler.begin_active();
- for (; joint_cell!=joint_endc; ++joint_cell, ++stokes_cell, ++temperature_cell)
- {
- joint_cell->get_dof_indices (local_joint_dof_indices);
- stokes_cell->get_dof_indices (local_stokes_dof_indices);
- temperature_cell->get_dof_indices (local_temperature_dof_indices);
-
- for (unsigned int i=0; i<joint_fe.dofs_per_cell; ++i)
- if (joint_fe.system_to_base_index(i).first.first == 0)
- {
- Assert (joint_fe.system_to_base_index(i).second
- <
- local_stokes_dof_indices.size(),
- ExcInternalError());
- joint_solution(local_joint_dof_indices[i])
- = stokes_solution(local_stokes_dof_indices[joint_fe.system_to_base_index(i).second]);
- }
- else
- {
- Assert (joint_fe.system_to_base_index(i).first.first == 1,
- ExcInternalError());
- Assert (joint_fe.system_to_base_index(i).second
- <
- local_temperature_dof_indices.size(),
- ExcInternalError());
- joint_solution(local_joint_dof_indices[i])
- = temperature_solution(local_temperature_dof_indices[joint_fe.system_to_base_index(i).second]);
- }
- }
- }
-
- // Next, we proceed as we've done in step-22. We create solution names
- // (that are going to appear in the visualization program for the
- // individual components), and attach the joint dof handler to a DataOut
- // object. The first <code>dim</code> components are the vector velocity,
- // and then we have pressure and temperature. This information is read out
- // using the DataComponentInterpretation helper class. Next, we attach the
- // solution values together with the names of its components to the output
- // object, and build patches according to the degree of freedom, which are
- // (sub-) elements that describe the data for visualization
- // programs. Finally, we set a file name (that includes the time step
- // number) and write the vtk file.
- std::vector<std::string> joint_solution_names (dim, "velocity");
- joint_solution_names.push_back ("p");
- joint_solution_names.push_back ("T");
-
- DataOut<dim> data_out;
-
- data_out.attach_dof_handler (joint_dof_handler);
-
+ std::vector<std::string> stokes_names (dim, "velocity");
+ stokes_names.push_back ("p");
std::vector<DataComponentInterpretation::DataComponentInterpretation>
- data_component_interpretation
- (dim+2, DataComponentInterpretation::component_is_scalar);
+ stokes_component_interpretation
+ (dim+1, DataComponentInterpretation::component_is_scalar);
for (unsigned int i=0; i<dim; ++i)
- data_component_interpretation[i]
+ stokes_component_interpretation[i]
= DataComponentInterpretation::component_is_part_of_vector;
- data_out.add_data_vector (joint_solution, joint_solution_names,
- DataOut<dim>::type_dof_data,
- data_component_interpretation);
+ DataOut<dim> data_out;
+ data_out.add_data_vector (stokes_dof_handler, stokes_solution,
+ stokes_names, stokes_component_interpretation);
+ data_out.add_data_vector (temperature_dof_handler, temperature_solution,
+ "T");
data_out.build_patches (std::min(stokes_degree, temperature_degree));
std::ostringstream filename;
// SolutionTransfer class and we have to prepare the solution vectors that
// should be transferred to the new grid (we will lose the old grid once
// we have done the refinement so the transfer has to happen concurrently
- // with refinement). What we definetely need are the current and the old
+ // with refinement). What we definitely need are the current and the old
// temperature (BDF-2 time stepping requires two old solutions). Since the
// SolutionTransfer objects only support to transfer one object per dof
// handler, we need to collect the two temperature solutions in one data
# You can specify additional files here!
)
-# A custom command line to run the program
-SET(TARGET_RUN mpirun -np 2 ${TARGET})
-
# Define the output that should be cleaned:
SET(CLEAN_UP_FILES *.vtu *.pvtu *.visit)
DEAL_II_WITH_MPI = ON
DEAL_II_WITH_P4EST = ON
DEAL_II_WITH_TRILINOS = ON
-which is required for this tutorial step."
+One or all of these are OFF in your installation but are required for this tutorial step."
)
ENDIF()
<b>
M. Kronbichler, T. Heister, W. Bangerth:
<i>High Accuracy Mantle Convection Simulation through Modern Numerical
- Methods</i>, Geophysical Journal International, 2012, 191, 12-29.
+ Methods</i>, Geophysical Journal International, 2012, 191, 12-29.
<a href="http://dx.doi.org/10.1111/j.1365-246X.2012.05609.x">[DOI]</a>
</b>
+
+The continuation of development of this program has led to the much larger
+open source code Aspect (see http://aspect.dealii.org/ ) which is much more
+flexible in solving many kinds of related problems.
</i>
reason back there is that everything was nicely balanced: velocities
were on the order of one, the pressure likewise, the viscosity was
one, and the domain had a diameter of $\sqrt{2}$. As a result, while
-non-sensical, nothing bad happened. On the other hand, as we will explain
+nonsensical, nothing bad happened. On the other hand, as we will explain
below, things here will not be that simply scaled: $\eta$ will be around
$10^{21}$, velocities on the order of $10^{-8}$, pressure around $10^8$, and
the diameter of the domain is $10^7$. In other words, the order of magnitude
matrix and preconditioner. Because it is annoying and error prone, we will
recover the unscaled pressure immediately following the solution of the linear
system, i.e., the solution vector's pressure component will immediately be
-un-scaled to retrieve the physical pressure. Since the solver uses the fact that
+unscaled to retrieve the physical pressure. Since the solver uses the fact that
we can use a good initial guess by extrapolating the previous solutions, we
also have to scale the pressure immediately <i>before</i> solving.
with the unreasonably coarse mesh chosen for these experiments, around
time $t=10^{15}$ seconds the plumes of hot material that have been
rising towards the cold outer boundary and have then spread sideways
-are starting to get close to each other, squezzing out the cold
-material inbetween. This creates a layer of cells into which fluids
+are starting to get close to each other, squeezing out the cold
+material in-between. This creates a layer of cells into which fluids
flows from two opposite sides and flows out toward a third, apparently
a scenario that then produce these instabilities without sufficient
stabilization. Second: In step-31, we used
physics would have to be implemented, and several other aspects are
currently missing from this program as well. We will come back to this
issue in the results section again, but state for now that providing a
-realistic description is a goal of the <i>Apect</i> code in
+realistic description is a goal of the <i>Aspect</i> code in
development at the time of writing this.
As a reminder, let us again state the equations we want to solve are these:
entry</a>). In Kelvin, we therefore choose $T_0=(4000+273)\text{K}$,
$T_1=(500+273)\text{K}$ as boundary conditions at the inner and outer edge.
- In addition to this, we also have to specifiy some initial conditions for
+ In addition to this, we also have to specify some initial conditions for
the temperature field. The real temperature field of the earth is quite
complicated as a consequence of the convection that has been going on for
more than four billion years -- in fact, it is the properties of this
@f]
- There are two problems with this, however: (i) The Earth is not homogenous,
+ There are two problems with this, however: (i) The Earth is not homogeneous,
i.e. the density $\rho$ depends on $\mathbf x$; in fact it is not even a
function that only depends on the radius $r=\|\mathbf x\|$. In reality, gravity therefore
does not always decrease as we get deeper: because the earth core is so much
changes as temperature and pressure change: depending on temperature and
pressure, different crystal configurations are thermodynamically favored
over others, even if the chemical composition of the mantle were
- homogenous. For example, the common mantle material MgSiO<sub>3</sub> exists
+ homogeneous. For example, the common mantle material MgSiO<sub>3</sub> exists
in its <a target="_top"
href="http://en.wikipedia.org/wiki/Perovskite_(structure)">perovskite
structure</a> throughout most of the mantle, but in the lower mantle the
program just because one wants to play with a single parameter (think, for
example, of parameter studies determining the best values of the
stabilization constants discussed above), in particular given that it takes
- a non-trivial amount of time to re-compile programs of the current size. To
+ a nontrivial amount of time to re-compile programs of the current size. To
just give an overview of the kinds of parameters we have moved from fixed
values into the input file, here is a listing of a typical
<code>\step-32.prm</code> file:
trivial. An additional complexity is introduced by the fact that one may
want to change the number of processors between runs, for example because
one may wish to continue computing on a mesh that is finer than the one used
- to pre-compute a starting temperature field at an intermediate time.
+ to precompute a starting temperature field at an intermediate time.
<li> <b>Predictive postprocessing:</b> The point of computations like this is
not simply to solve the equations. Rather, it is typically the exploration
here, namely the KellyErrorEstimator applied to the temperature, is
able to.
</ul>
+
+
+<h3> Possible extensions </h3>
+
+There are many ways to extend the current program. However, rather than
+discussing them here, let us point to the much larger open
+source code Aspect (see http://aspect.dealii.org/ ) that constitutes the
+further development of step-32 and that already includes many such possible
+extensions.
-/* Author: Martin Kronbichler, Uppsala University,
- Wolfgang Bangerth, Texas A&M University,
- Timo Heister, University of Goettingen, 2008-2011 */
-/* */
-/* Copyright (C) 2008-2012 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. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2008 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Authors: Martin Kronbichler, Uppsala University,
+ * Wolfgang Bangerth, Texas A&M University,
+ * Timo Heister, University of Goettingen, 2008-2011
+ */
+
// @sect3{Include files}
// In the following namespace, we define the various pieces of equation data
// that describe the problem. This corresponds to the various aspects of
- // making the problem at least slightly realistc and that were exhaustively
+ // making the problem at least slightly realistic and that were exhaustively
// discussed in the description of the testcase in the introduction.
//
// We start with a few coefficients that have constant values (the comment
namespace EquationData
{
const double eta = 1e21; /* Pa s */
- const double kappa = 1e-6; /* m / s */
+ const double kappa = 1e-6; /* m^2 / s */
const double reference_density = 3300; /* kg / m^3 */
const double reference_temperature = 293; /* K */
const double expansion_coefficient = 2e-5; /* 1/K */
// block. The three code blocks of the <code>vmult</code> function implement
// the multiplications with the three blocks of this preconditioner matrix
// and should be self explanatory if you have read through step-31 or the
- // discussion of compositing solvers in step-20.
+ // discussion of composing solvers in step-20.
namespace LinearSolvers
{
template <class PreconditionerA, class PreconditionerMp>
}
// Following this, we can compute constraints for the solution vectors,
- // including hanging node constraints and homogenous and inhomogenous
+ // including hanging node constraints and homogeneous and inhomogeneous
// boundary values for the Stokes and temperature fields. Note that as for
// everything else, the constraint objects can not hold <i>all</i>
// constraints on every processor. Rather, each processor needs to store
}
- // The <code>output_results()</code> function does mostly what the
- // corresponding one did in to step-31, in particular the merging data from
- // the two DoFHandler objects (for the Stokes and the temperature parts of
- // the problem) into one. There is one minor change: we make sure that each
- // processor only works on the subdomain it owns locally (and not on ghost
- // or artificial cells) when building the joint solution vector. The same
- // will then have to be done in DataOut::build_patches(), but that function
- // does so automatically.
+ // The <code>output_results()</code> function has a similar task to the one
+ // in step-31. However, here we are going to demonstrate a different
+ // technique on how to merge output from different DoFHandler objects. The
+ // way we're going to achieve this recombination is to create a joint
+ // DoFHandler that collects both components, the Stokes solution and the
+ // temperature solution. This can be nicely done by combining the finite
+ // elements from the two systems to form one FESystem, and let this
+ // collective system define a new DoFHandler object. To be sure that
+ // everything was done correctly, we perform a sanity check that ensures
+ // that we got all the dofs from both Stokes and temperature even in the
+ // combined system. We then combine the data vectors. Unfortunately, there
+ // is no straight-forward relation that tells us how to sort Stokes and
+ // temperature vector into the joint vector. The way we can get around this
+ // trouble is to rely on the information collected in the FESystem. For each
+ // dof on a cell, the joint finite element knows to which equation component
+ // (velocity component, pressure, or temperature) it belongs – that's the
+ // information we need! So we step through all cells (with iterators into
+ // all three DoFHandlers moving in sync), and for each joint cell dof, we
+ // read out that component using the FiniteElement::system_to_base_index
+ // function (see there for a description of what the various parts of its
+ // return value contain). We also need to keep track whether we're on a
+ // Stokes dof or a temperature dof, which is contained in
+ // joint_fe.system_to_base_index(i).first.first. Eventually, the dof_indices
+ // data structures on either of the three systems tell us how the relation
+ // between global vector and local dofs looks like on the present cell,
+ // which concludes this tedious work. We make sure that each processor only
+ // works on the subdomain it owns locally (and not on ghost or artificial
+ // cells) when building the joint solution vector. The same will then have
+ // to be done in DataOut::build_patches(), but that function does so
+ // automatically.
//
// What we end up with is a set of patches that we can write using the
// functions in DataOutBase in a variety of output formats. Here, we then
}
}
+ joint_solution.compress(VectorOperation::insert);
IndexSet locally_relevant_joint_dofs(joint_dof_handler.n_dofs());
DoFTools::extract_locally_relevant_dofs (joint_dof_handler, locally_relevant_joint_dofs);
MESSAGE(FATAL_ERROR "
Error! The deal.II library found at ${DEAL_II_PATH} was not configured with
DEAL_II_WITH_TRILINOS = ON
-which is required for this tutorial step."
+One or all of these are OFF in your installation but are required for this tutorial step."
)
ENDIF()
The output are the derivatives $\frac{\partial c(a,b)}{\partial a},
\frac{\partial c(a,b)}{\partial b}$ of $c(a,b)=2a+\cos(ab)$ at $a=1,b=2$.
-It should be noted that Sacado provides more auto-differentation capabilities than the small subset
+It should be noted that Sacado provides more auto-differentiation capabilities than the small subset
used in this program. However, understanding the example above is
enough to understand the use of Sacado in this Euler flow program.
within the example.
<h3> Adaptivity </h3>
-The example uses an ad-hoc refinement indicator that shows some usefulness in shock-type problems, and
+The example uses an ad hoc refinement indicator that shows some usefulness in shock-type problems, and
in the downhill flow example included. We refine according to the squared gradient of the density.
Hanging nodes are handled by computing the numerical flux across cells that are of differing
refinement levels, rather than using the ConstraintMatrix class as in
-/* Author: David Neckels, Boulder, Colorado, 2007, 2008 */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2007 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: David Neckels, Boulder, Colorado, 2007, 2008
+ */
-/* $Id$ */
-/* */
-/* Copyright (C) 2007-2012 by the deal.II authors and David Neckels */
-/* */
-/* 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. */
// @sect3{Include files}
{
// We prescribe the velocity (we are dealing with a particular
// component here so that the average of the velocities is
- // orthogonal to the surface normal. This creates sensitivies of
+ // orthogonal to the surface normal. This creates sensitivities of
// across the velocity components.
Sacado::Fad::DFad<double> vdotn = 0;
for (unsigned int d = 0; d < dim; d++)
// This is the only function worth commenting on. When generating graphical
// output, the DataOut and related classes will call this function on each
- // cell, with values, gradients, hessians, and normal vectors (in case we're
+ // cell, with values, gradients, Hessians, and normal vectors (in case we're
// working on faces) at each quadrature point. Note that the data at each
// quadrature point is itself vector-valued, namely the conserved
// variables. What we're going to do here is to compute the quantities we're
// interested in at each quadrature point. Note that for this we can ignore
- // the hessians ("dduh") and normal vectors; to avoid compiler warnings
+ // the Hessians ("dduh") and normal vectors; to avoid compiler warnings
// about unused variables, we comment out their names.
template <int dim>
void
// we allow up to <code>max_n_boundaries</code> boundary indicators to be
// used in the input file, and each of these boundary indicators can be
// associated with an inflow, outflow, or pressure boundary condition,
- // with inhomogenous boundary conditions being specified for each
+ // with homogeneous boundary conditions being specified for each
// component and each boundary indicator separately.
//
// The data structure used to store the boundary indicators is a bit
// This final set of member variables (except for the object holding all
// run-time parameters at the very bottom and a screen output stream that
// only prints something if verbose output has been requested) deals with
- // the inteface we have in this program to the Trilinos library that
+ // the interface we have in this program to the Trilinos library that
// provides us with linear solvers. Similarly to including PETSc matrices
// in step-17, step-18, and step-19, all we need to do is to create a
// Trilinos sparse matrix instead of the standard deal.II class. The
// whereas all the other ones remain dependent functions. These are
// precisely the local degrees of freedom just extracted. All calculations
// that reference them (either directly or indirectly) will accumulate
- // sensitivies with respect to these variables.
+ // sensitivities with respect to these variables.
//
// In order to mark the variables as independent, the following does the
// trick, marking <code>independent_local_dof_values[i]</code> as the
// (\mathbf{z}_i)_{\text{component\_i}})_K$, where integrals are
// understood to be evaluated through summation over quadrature points.
//
- // We initialy sum all contributions of the residual in the positive
+ // We initially sum all contributions of the residual in the positive
// sense, so that we don't need to negative the Jacobian entries. Then,
// when we sum into the <code>right_hand_side</code> vector, we negate
// this residual.
// Now assemble the face term in exactly the same way as for the cell
// contributions in the previous function. The only difference is that if
// this is an internal face, we also have to take into account the
- // sensitivies of the residual contributions to the degrees of freedom on
+ // sensitivities of the residual contributions to the degrees of freedom on
// the neighboring cell:
std::vector<double> residual_derivatives (dofs_per_cell);
for (unsigned int i=0; i<fe_v.dofs_per_cell; ++i)
// Note that the number of the output file is determined by keeping a
// counter in the form of a static variable that is set to zero the first
// time we come to this function and is incremented by one at the end of
- // each invokation.
+ // each invocation.
template <int dim>
void ConservationLaw<dim>::output_results () const
{
std::exit(1);
}
- Utilities::System::MPI_InitFinalize mpi_initialization (argc, argv);
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int);
ConservationLaw<2> cons (argv[1]);
cons.run ();
MESSAGE(FATAL_ERROR "
Error! The deal.II library found at ${DEAL_II_PATH} was not configured with
DEAL_II_WITH_FUNCTIONPARSER = ON
-which is required for this tutorial step."
+One or all of these are OFF in your installation but are required for this tutorial step."
)
ENDIF()
\mathbf{\tilde{v}}=\nabla\phi,
\f]
and so the second part of Euler equations above can be rewritten
-as the homogenous Laplace equation for the unknown $\phi$:
+as the homogeneous Laplace equation for the unknown $\phi$:
\f{align*}
\label{laplace}
\Delta\phi &= 0 \qquad &&\text{in}\ \mathbb{R}^n\backslash\Omega,
If this were a production code rather than a demonstration of principles,
there are techniques that are available to not store full matrices but instead
store only those entries that are large and/or relevant. In the literature on
-boundary element methods, a plethory of methods is available that allows to
+boundary element methods, a plethora of methods is available that allows to
determine which elements are important and which are not, leading to a
significantly sparser representation of these matrices that also facilitates
rapid evaluations of the scalar product between vectors and matrices. This not
<img src="http://www.dealii.org/images/steps/developer/step-34_2d.png" alt="">
while in three dimensions we show first the potential on the surface,
-together with a contur plot,
+together with a contour plot,
<img src="http://www.dealii.org/images/steps/developer/step-34_3d.png" alt="">
-/* Author: Luca Heltai, Cataldo Manigrasso, 2009 */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2009 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Luca Heltai, Cataldo Manigrasso, 2009
+ */
-/* $Id$ */
-/* */
-/* Copyright (C) 2009-2012 by 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. */
// @sect3{Include files}
// @sect4{BEMProblem::BEMProblem and BEMProblem::read_parameters}
- // The constructor initializes the variuous object in much the same way as
+ // The constructor initializes the various object in much the same way as
// done in the finite element programs such as step-4 or step-6. The only
// new ingredient here is the ParsedFunction object, which needs, at
// construction time, the specification of the number of components.
// the current cell, a deviation from the usual finite element
// integrals). The integral that we need to perform is singular if one
// of the local degrees of freedom is the same as the support point
- // $i$. A the beginning of the loop we therefore check wether this is
+ // $i$. A the beginning of the loop we therefore check whether this is
// the case, and we store which one is the singular index:
for (unsigned int i=0; i<dh.n_dofs() ; ++i)
{
// Singular integration requires a careful selection of the quadrature
// rules. In particular the deal.II library provides quadrature rules which
- // are taylored for logarithmic singularities (QGaussLog, QGaussLogR), as
+ // are tailored for logarithmic singularities (QGaussLog, QGaussLogR), as
// well as for 1/R singularities (QGaussOneOverR).
//
// Singular integration is typically obtained by constructing weighted
// consideration also the second part of the integral.
//
// A similar reasoning should be done in the three dimensional case, since
- // the singular quadrature is taylored on the inverse of the radius $r$ in
+ // the singular quadrature is tailored on the inverse of the radius $r$ in
// the reference cell, while our singular function lives in real space,
// however in the three dimensional case everything is simpler because the
// singularity scales linearly with the determinant of the
MESSAGE(FATAL_ERROR "
Error! The deal.II library found at ${DEAL_II_PATH} was not configured with
DEAL_II_WITH_UMFPACK = ON
-which is required for this tutorial step."
+One or all of these are OFF in your installation but are required for this tutorial step."
)
ENDIF()
-/* Author: Abner Salgado, Texas A&M University 2009 */
-
-/* $Id$ */
-/* */
-/* Copyright (C) 2009-2012 by 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. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2009 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Abner Salgado, Texas A&M University 2009
+ */
// @sect3{Include files}
// The implementation of a diffusion step. Note that the expensive operation
// is the diffusion solve at the end of the function, which we have to do
- // once for each velocity component. To accellerate things a bit, we allow
+ // once for each velocity component. To accelerate things a bit, we allow
// to do this in %parallel, using the Threads::new_task function which makes
// sure that the <code>dim</code> solves are all taken care of and are
// scheduled to available processors: if your machine has more than one
// pieces of data into a single DoFHandler object, and then use that to
// drive graphical output.
//
- // We will not elaborate on this process here, but rather refer to step-31
- // and step-32, where a similar procedure is used (and is documented) to
+ // We will not elaborate on this process here, but rather refer to step-32,
+ // where a similar procedure is used (and is documented) to
// create a joint DoFHandler object for all variables.
//
// Let us also note that we here compute the vorticity as a scalar quantity
Error! The deal.II library found at ${DEAL_II_PATH} was not configured with
DEAL_II_WITH_PETSC = ON
DEAL_II_WITH_SLEPC = ON
-which is required for this tutorial step."
+One or all of these are OFF in your installation but are required for this tutorial step."
)
ENDIF()
Schrödinger equation which models the motion of particles in an
external potential $V(\mathbf x)$. The particle is described by a wave
function $\Psi(\mathbf x)$ that satisfies a relation of the
-(non-dimensionalized) form
+(nondimensionalized) form
@f{align*} [-\Delta + V(\mathbf x)]
\Psi(\mathbf x) &= \varepsilon \Psi(\mathbf x) \qquad &&\text{in}\
\Omega\quad, \\ \Psi &= 0 &&\text{on}\ \partial\Omega\quad.
In order to numerically find solutions to this equation, i.e. a set of
pairs of eigenvalues/eigenfunctions, we use the usual finite element
-approach of multiplying the equation from the left with testfunctions,
+approach of multiplying the equation from the left with test functions,
integrating by parts, and searching for solutions in finite
dimensional spaces by approximating $\Psi(\mathbf
x)\approx\Psi_h(\mathbf x)=\sum_{j}\phi_j(\mathbf x)\tilde\psi_j$,
the various eigenfunctions we want to compute. Moreover, the
<code>main</code> function, which has the top-level control over
everything here, initializes and finalizes the interface to SLEPc and
-PETSc simultaneouly via <code>SlepcInitialize</code> and
+PETSc simultaneously via <code>SlepcInitialize</code> and
<code>SlepFinalize</code>.</li>
<li>We use PETSc matrices and vectors as in step-17 and
machine architecture. However, for larger grids and with a larger
number of degrees-of-freedom, we may want to run our application on
parallel architectures. A parallel implementation of the above code
-can be particularily useful here since the generalized eigenspectrum
+can be particularly useful here since the generalized eigenspectrum
problem is somewhat more expensive to solve than the standard problems
considered in most of the earlier tutorials. Fortunately, modifying the above
program to be MPI compliant is a relatively straightforward
-/* Author: Toby D. Young, Polish Academy of Sciences, */
-/* Wolfgang Bangerth, Texas A&M University */
-/* $Id$*/
-/* */
-/* Copyright (C) 2009, 2011-2013 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. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2009 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Authors: Toby D. Young, Polish Academy of Sciences,
+ * Wolfgang Bangerth, Texas A&M University
+ */
// @sect3{Include files}
MESSAGE(FATAL_ERROR "
Error! The deal.II library found at ${DEAL_II_PATH} was not configured with
DEAL_II_WITH_LAPACK = ON
-which is required for this tutorial step."
+One or all of these are OFF in your installation but are required for this tutorial step."
)
ENDIF()
This example shows how to implement a matrix-free method, that is, a
method that does not explicitly store the matrix elements, for a
second-order Poisson equation with variable coefficients on a
-hypercube. The eliptic equation will be solved with a multigrid
+hypercube. The elliptic equation will be solved with a multigrid
method.
The major motivation for matrix-free methods is the fact that today
for (unsigned int q=0; q<n_q_points; ++q)
{
- // apply the tranpose inverse Jacobian of the mapping
+ // apply the transposed inverse Jacobian of the mapping
Tensor<1,dim> temp;
for (unsigned int d=0; d<dim; ++d)
temp[d] = temp_vector(q*dim+d);
linear elements, but faster for all higher order elements thanks to the
reduced complexity due to the tensor product structure and due to less memory
transfer during computations. The impact of reduced memory transfer is
-particularly beneficial when working on a multi-core processor where several
+particularly beneficial when working on a multicore processor where several
processing units share access to memory. In that case, an algorithm which is
computation bound will show almost perfect parallel speedup, whereas an
algorithm that is bound by memory transfer might not achieve similar speedup
-/* $Id$ */
-/* Author: Katharina Kormann, Martin Kronbichler, Uppsala University, 2009-2012 */
-
-/* $Id$ */
-/* */
-/* Copyright (C) 2009-2013 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. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2009 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Authors: Katharina Kormann, Martin Kronbichler, Uppsala University, 2009-2012
+ */
+
// First include the necessary files from the deal.II library.
#include <deal.II/base/quadrature_lib.h>
// would have to have two classes like the current one for each of the
// operators (maybe with a common base class). However, in that case, we
// would not store a MatrixFree object in this class to avoid doing the
- // expensive work of pre-computing everything MatrixFree stores
+ // expensive work of precomputing everything MatrixFree stores
// twice. Rather, we would keep this object in the main class and simply
// store a reference.
//
// @sect4{Initialization}
- // Once we have created the multi-grid dof_handler and the constraints, we
- // can call the reinit function for each level of the multi-grid routine
+ // Once we have created the multigrid dof_handler and the constraints, we
+ // can call the reinit function for each level of the multigrid routine
// (and the active cells). The main purpose of the reinit function is to
// setup the <code> MatrixFree </code> instance for the problem. Also, the
// coefficient is evaluated. For this, we need to activate the update flag
{
data.cell_loop (&LaplaceOperator::local_apply, this, dst, src);
- const std::vector<types::global_dof_index> &
+ const std::vector<unsigned int> &
constrained_dofs = data.get_constrained_dofs();
for (unsigned int i=0; i<constrained_dofs.size(); ++i)
dst(constrained_dofs[i]) += src(constrained_dofs[i]);
diagonal_values = diagonal;
- const std::vector<types::global_dof_index> &
+ const std::vector<unsigned int> &
constrained_dofs = data.get_constrained_dofs();
for (unsigned int i=0; i<constrained_dofs.size(); ++i)
diagonal_values(constrained_dofs[i]) = 1.0;
typedef PreconditionChebyshev<LevelMatrixType,Vector<double> > SMOOTHER;
MGSmootherPrecondition<LevelMatrixType, SMOOTHER, Vector<double> >
- mg_smoother;
+ mg_smoother;
// Then, we initialize the smoother with our level matrices and the
// mandatory additional data for the Chebyshev smoother. We use quite a
MappingQ that will automatically obtain the boundary description from the
Triangulation. The mapping object will then be passed to the appropriate
functions, and we will get a boundary description for half circles or half
-spheres that is pre-defined in the library.
+spheres that is predefined in the library.
The rest of the program follows closely step-4 and, as far as computing the
error, step-7. Some aspects of this program, in particular the use of two
Note that the only essential addition has been the three lines marked with
asterisks. It is worth pointing out one other thing here, though: because we
-un-attach the manifold description from the surface mesh, whenever we use a
+detach the manifold description from the surface mesh, whenever we use a
mapping object in the rest of the program, it has no curves boundary
description to go on any more. Rather, it will have to use the implicit,
StraightBoundary class that is used on all parts of the boundary not
-explicitly assigned a different mannifold object. Consequently, whether we use
+explicitly assigned a different manifold object. Consequently, whether we use
MappingQ(2), MappingQ(15) or MappingQ1, each cell of our mesh will be mapped
using a bilinear approximation.
-/* Authors: Andrea Bonito, Sebastian Pauletti. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2010 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Authors: Andrea Bonito, Sebastian Pauletti.
+ */
-/* $Id$ */
-/* */
-/* Copyright (C) 2010-2012 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. */
// @sect3{Include files}
// boundary of the domain -- this is what we did in step-11, for
// example. However, here we have a curved domain, not just a curved
// boundary, and while we can approximate it with bilinearly mapped cells,
- // it is really only prodent to use a higher order mapping for all
+ // it is really only prudent to use a higher order mapping for all
// cells. Consequently, this class has a member variable of type MappingQ;
// we will choose the polynomial degree of the mapping equal to the
// polynomial degree of the finite element used in the computations to
<h1>Results</h1>
<h2>Logfile output</h2>
-First, the program produces the usual logfile here stored in <tt>deallog</tt>. It reads (with ommission of intermediate steps)
+First, the program produces the usual logfile here stored in <tt>deallog</tt>. It reads (with omission of intermediate steps)
@code
DEAL::Element: FE_DGQ<2>(3)
-/* Author: Guido Kanschat, Texas A&M University, 2009 */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2010 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Guido Kanschat, Texas A&M University, 2009
+ */
-/* $Id$ */
-/* */
-/* Copyright (C) 2010-2013 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. */
// The include files for the linear algebra: A regular SparseMatrix, which in
// turn will include the necessary files for SparsityPattern and Vector
{
public:
void cell(MeshWorker::DoFInfo<dim> &dinfo,
- typename MeshWorker::IntegrationInfo<dim> &info) const;
+ typename MeshWorker::IntegrationInfo<dim> &info) const;
void boundary(MeshWorker::DoFInfo<dim> &dinfo,
- typename MeshWorker::IntegrationInfo<dim> &info) const;
+ typename MeshWorker::IntegrationInfo<dim> &info) const;
void face(MeshWorker::DoFInfo<dim> &dinfo1,
- MeshWorker::DoFInfo<dim> &dinfo2,
- typename MeshWorker::IntegrationInfo<dim> &info1,
- typename MeshWorker::IntegrationInfo<dim> &info2) const;
+ MeshWorker::DoFInfo<dim> &dinfo2,
+ typename MeshWorker::IntegrationInfo<dim> &info1,
+ typename MeshWorker::IntegrationInfo<dim> &info2) const;
};
// ourselves. Similarly, we implement Nitsche boundary conditions and the
// interior penalty fluxes between cells.
//
- // The boundary und flux terms need a penalty parameter, which should be
+ // The boundary and flux terms need a penalty parameter, which should be
// adjusted to the cell size and the polynomial degree. A safe choice of
// this parameter for constant coefficients can be found in
// LocalIntegrators::Laplace::compute_penalty() and we use this below.
void cell(MeshWorker::DoFInfo<dim> &dinfo, typename MeshWorker::IntegrationInfo<dim> &info) const;
void boundary(MeshWorker::DoFInfo<dim> &dinfo, typename MeshWorker::IntegrationInfo<dim> &info) const;
void face(MeshWorker::DoFInfo<dim> &dinfo1,
- MeshWorker::DoFInfo<dim> &dinfo2,
- typename MeshWorker::IntegrationInfo<dim> &info1,
- typename MeshWorker::IntegrationInfo<dim> &info2) const;
+ MeshWorker::DoFInfo<dim> &dinfo2,
+ typename MeshWorker::IntegrationInfo<dim> &info1,
+ typename MeshWorker::IntegrationInfo<dim> &info2) const;
};
void cell(MeshWorker::DoFInfo<dim> &dinfo, typename MeshWorker::IntegrationInfo<dim> &info) const;
void boundary(MeshWorker::DoFInfo<dim> &dinfo, typename MeshWorker::IntegrationInfo<dim> &info) const;
void face(MeshWorker::DoFInfo<dim> &dinfo1,
- MeshWorker::DoFInfo<dim> &dinfo2,
- typename MeshWorker::IntegrationInfo<dim> &info1,
- typename MeshWorker::IntegrationInfo<dim> &info2) const;
+ MeshWorker::DoFInfo<dim> &dinfo2,
+ typename MeshWorker::IntegrationInfo<dim> &info1,
+ typename MeshWorker::IntegrationInfo<dim> &info2) const;
};
void cell(MeshWorker::DoFInfo<dim> &dinfo, typename MeshWorker::IntegrationInfo<dim> &info) const;
void boundary(MeshWorker::DoFInfo<dim> &dinfo, typename MeshWorker::IntegrationInfo<dim> &info) const;
void face(MeshWorker::DoFInfo<dim> &dinfo1,
- MeshWorker::DoFInfo<dim> &dinfo2,
- typename MeshWorker::IntegrationInfo<dim> &info1,
- typename MeshWorker::IntegrationInfo<dim> &info2) const;
+ MeshWorker::DoFInfo<dim> &dinfo2,
+ typename MeshWorker::IntegrationInfo<dim> &info1,
+ typename MeshWorker::IntegrationInfo<dim> &info2) const;
};
// Here we have the integration on cells. There is currently no good
- // interfce in MeshWorker that would allow us to access values of regular
+ // interface in MeshWorker that would allow us to access values of regular
// functions in the quadrature points. Thus, we have to create the vectors
// for the exact function's values and gradients inside the cell
// integrator. After that, everything is as before and we just add up the
mg_matrix_dg_down.clear();
// It is important to update the sparsity patterns after <tt>clear()</tt>
// was called for the level matrices, since the matrices lock the sparsity
- // pattern through the Smartpointer ans Subscriptor mechanism.
+ // pattern through the Smartpointer and Subscriptor mechanism.
mg_sparsity.resize(0, n_levels-1);
mg_sparsity_dg_interface.resize(0, n_levels-1);
MeshWorker::Assembler::MGMatrixSimple<SparseMatrix<double> > assembler;
assembler.initialize(mg_matrix);
assembler.initialize_fluxes(mg_matrix_dg_up, mg_matrix_dg_down);
-
+
MatrixIntegrator<dim> integrator;
// Here is the other difference to the previous function: we run over all
// cells, not only the active ones. And we use <tt>mg_dof_handler</tt>,
MeshWorker::DoFInfo<dim> dof_info(dof_handler);
- // Since this assembler alows us to fill several vectors, the interface is
+ // Since this assembler allows us to fill several vectors, the interface is
// a little more complicated as above. The pointers to the vectors have to
// be stored in a NamedData object. While this seems to cause two extra
// lines of code here, it actually comes handy in more complex
const unsigned int n_gauss_points = dof_handler.get_fe().tensor_degree()+1;
info_box.initialize_gauss_quadrature(n_gauss_points, n_gauss_points+1, n_gauss_points);
- // but now we need to notify the info box of the finite element functio we
+ // but now we need to notify the info box of the finite element function we
// want to evaluate in the quadrature points. First, we create a NamedData
// object with this vector, which is the solution we just computed.
NamedData<Vector<double>* > solution_data;
// Then, we tell the Meshworker::VectorSelector for cells, that we need
// the second derivatives of this solution (to compute the
- // Laplacian). Therefore, the boolean arguments selecting function values
+ // Laplacian). Therefore, the Boolean arguments selecting function values
// and first derivatives a false, only the last one selecting second
// derivatives is true.
info_box.cell_selector.add("solution", false, false, true);
and 3d!). We would have to write the same function twice, once
working on <code>Triangulation2d</code> and once working with a
<code>Triangulation3d</code>. This is an unnecessary obstacle in
-programming and leads to a nuisance to keep the two function in synch
+programming and leads to a nuisance to keep the two function in sync
(at best) or difficult to find errors if the two versions get out of
sync (at worst; this would probably the more common case).
what is happening on the inside. The picture on the right is an attempt at
visualizing the interior as well, by showing surfaces where the solution has
constant values (as indicated by the legend at the top left). Isosurface
-pictures look best if one makes the individual surfaces slightly transparaent
+pictures look best if one makes the individual surfaces slightly transparent
so that it is possible to see through them and see what's behind.
<TABLE WIDTH="60%" ALIGN="center">
-/* Author: Wolfgang Bangerth, University of Heidelberg, 1999 */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 1999 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Wolfgang Bangerth, University of Heidelberg, 1999
+ */
-/* $Id$ */
-/* */
-/* Copyright (C) 1999-2012 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. */
// @sect3{Include files}
// formulas above right away.
//
// The last thing to note is that a <code>Point@<dim@></code> denotes a point
-// in dim-dimensionsal space, and its individual components (i.e. $x$, $y$,
+// in dim-dimensional space, and its individual components (i.e. $x$, $y$,
// ... coordinates) can be accessed using the () operator (in fact, the []
// operator will work just as well) with indices starting at zero as usual in
// C and C++.
// <code>data_out.write_gnuplot</code> call by
// <code>data_out.write_vtk</code>.
//
-// Since the program will run both 2d and 3d versions of the laplace solver,
+// Since the program will run both 2d and 3d versions of the Laplace solver,
// we use the dimension in the filename to generate distinct filenames for
// each run (in a better program, one would check whether <code>dim</code> can
// have other values than 2 or 3, but we neglect this here for the sake of
Error! The deal.II library found at ${DEAL_II_PATH} was not configured with
DEAL_II_WITH_PETSC = ON
DEAL_II_WITH_P4EST = ON
-which is required for this tutorial step."
+One or all of these are OFF in your installation but are required for this tutorial step."
)
ENDIF()
coefficients and output). In either case, the comments below will only be on
the things that set step-40 apart from step-6 and that aren't already covered
in the @ref distributed documentation module.
+
+
+@note This program will be able to compute on as many processors as you want
+to throw at it, and for as large a problem as you have the memory and patience
+to solve. However, there <i>is</i> a limit: the number of unknowns can not
+exceed the largest number that can be stored with an object of type
+types::global_dof_index. By default, this is a typedef for <code>unsigned
+int</code>, which on most machines today is a 32-bit integer, limiting you to
+some 4 billion (in reality, since this program uses PETSc, you will be limited
+to half that as PETSc uses signed integers). However, this can be changed
+during configuration to use 64-bit integers, see the ReadMe file. This will
+give problem sizes you are unlikely to exceed anytime soon.
this problem, the
limiting factor is that the program uses the BoomerAMG algebraic
multigrid method from the <a
-href="http://acts.nersc.gov/hypre/" target="_top">hypre package</a> as
+href="http://acts.nersc.gov/hypre/" target="_top">Hypre package</a> as
a preconditioner, which unfortunately uses signed 32-bit integers to
index the elements of a %distributed matrix. This limits the size of
problems to $2^31-1=2,147,483,647$ degrees of freedom. From the graphs
-/* Author: Wolfgang Bangerth, Texas A&M University, 2009, 2010 */
-/* Timo Heister, University of Goettingen, 2009, 2010 */
-
-/* $Id$ */
-/* */
-/* Copyright (C) 2009-2012 by Timo Heister and 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. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2009 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Wolfgang Bangerth, Texas A&M University, 2009, 2010
+ * Timo Heister, University of Goettingen, 2009, 2010
+ */
// @sect3{Include files}
// already be familiar friends:
#include <deal.II/base/quadrature_lib.h>
#include <deal.II/base/function.h>
+#include <deal.II/base/timer.h>
+
+#include <deal.II/lac/generic_linear_algebra.h>
+
+#define USE_PETSC_LA
+
+namespace LA
+{
+#ifdef USE_PETSC_LA
+ using namespace dealii::LinearAlgebraPETSc;
+#else
+ using namespace dealii::LinearAlgebraTrilinos;
+#endif
+}
+
#include <deal.II/lac/vector.h>
#include <deal.II/lac/full_matrix.h>
#include <deal.II/lac/solver_cg.h>
void refine_grid ();
void output_results (const unsigned int cycle) const;
- MPI_Comm mpi_communicator;
+ MPI_Comm mpi_communicator;
- parallel::distributed::Triangulation<dim> triangulation;
+ parallel::distributed::Triangulation<dim> triangulation;
- DoFHandler<dim> dof_handler;
- FE_Q<dim> fe;
+ DoFHandler<dim> dof_handler;
+ FE_Q<dim> fe;
- IndexSet locally_owned_dofs;
- IndexSet locally_relevant_dofs;
+ IndexSet locally_owned_dofs;
+ IndexSet locally_relevant_dofs;
- ConstraintMatrix constraints;
+ ConstraintMatrix constraints;
- PETScWrappers::MPI::SparseMatrix system_matrix;
- PETScWrappers::MPI::Vector locally_relevant_solution;
- PETScWrappers::MPI::Vector system_rhs;
+ LA::MPI::SparseMatrix system_matrix;
+ LA::MPI::Vector locally_relevant_solution;
+ LA::MPI::Vector system_rhs;
- ConditionalOStream pcout;
+ ConditionalOStream pcout;
+ TimerOutput computing_timer;
};
fe (2),
pcout (std::cout,
(Utilities::MPI::this_mpi_process(mpi_communicator)
- == 0))
+ == 0)),
+ computing_timer (pcout,
+ TimerOutput::summary,
+ TimerOutput::wall_times)
{}
template <int dim>
void LaplaceProblem<dim>::setup_system ()
{
+ TimerOutput::Scope t(computing_timer, "setup");
+
dof_handler.distribute_dofs (fe);
- // The next two lines extract some informatino we will need later on,
+ // The next two lines extract some information we will need later on,
// namely two index sets that provide information about which degrees of
// freedom are owned by the current processor (this information will be
// used to initialize solution and right hand side vectors, and the system
// locally owned cells (of course the linear solvers will read from it,
// but they do not care about the geometric location of degrees of
// freedom).
- locally_relevant_solution.reinit (mpi_communicator,
- locally_owned_dofs,
- locally_relevant_dofs);
- system_rhs.reinit (mpi_communicator,
- dof_handler.n_dofs(),
- dof_handler.n_locally_owned_dofs());
+ locally_relevant_solution.reinit (locally_owned_dofs,
+ locally_relevant_dofs, mpi_communicator);
+ system_rhs.reinit (locally_owned_dofs, mpi_communicator);
+
system_rhs = 0;
// The next step is to compute hanging node and boundary value
// entries that will exist in that part of the finite element matrix that
// it will own. The final step is to initialize the matrix with the
// sparsity pattern.
- CompressedSimpleSparsityPattern csp (dof_handler.n_dofs(),
- dof_handler.n_dofs(),
- locally_relevant_dofs);
- DoFTools::make_sparsity_pattern (dof_handler,
- csp,
+ CompressedSimpleSparsityPattern csp (locally_relevant_dofs);
+
+ DoFTools::make_sparsity_pattern (dof_handler, csp,
constraints, false);
SparsityTools::distribute_sparsity_pattern (csp,
dof_handler.n_locally_owned_dofs_per_processor(),
mpi_communicator,
locally_relevant_dofs);
- system_matrix.reinit (mpi_communicator,
+
+ system_matrix.reinit (locally_owned_dofs,
+ locally_owned_dofs,
csp,
- dof_handler.n_locally_owned_dofs_per_processor(),
- dof_handler.n_locally_owned_dofs_per_processor(),
- Utilities::MPI::this_mpi_process(mpi_communicator));
+ mpi_communicator);
}
template <int dim>
void LaplaceProblem<dim>::assemble_system ()
{
+ TimerOutput::Scope t(computing_timer, "assembly");
+
const QGauss<dim> quadrature_formula(3);
FEValues<dim> fe_values (fe, quadrature_formula,
template <int dim>
void LaplaceProblem<dim>::solve ()
{
- PETScWrappers::MPI::Vector
- completely_distributed_solution (mpi_communicator,
- dof_handler.n_dofs(),
- dof_handler.n_locally_owned_dofs());
+ TimerOutput::Scope t(computing_timer, "solve");
+ LA::MPI::Vector
+ completely_distributed_solution (locally_owned_dofs, mpi_communicator);
SolverControl solver_control (dof_handler.n_dofs(), 1e-12);
- PETScWrappers::SolverCG solver(solver_control, mpi_communicator);
+ LA::SolverCG solver(solver_control, mpi_communicator);
+ LA::MPI::PreconditionAMG preconditioner;
+
+ LA::MPI::PreconditionAMG::AdditionalData data;
- // Ask for a symmetric preconditioner by setting the first parameter in
- // AdditionalData to true.
- PETScWrappers::PreconditionBoomerAMG
- preconditioner(system_matrix,
- PETScWrappers::PreconditionBoomerAMG::AdditionalData(true));
+#ifdef USE_PETSC_LA
+ data.symmetric_operator = true;
+#else
+ //trilinos defaults are good
+#endif
+ preconditioner.initialize(system_matrix, data);
solver.solve (system_matrix, completely_distributed_solution, system_rhs,
preconditioner);
template <int dim>
void LaplaceProblem<dim>::refine_grid ()
{
+ TimerOutput::Scope t(computing_timer, "refine");
+
Vector<float> estimated_error_per_cell (triangulation.n_active_cells());
KellyErrorEstimator<dim>::estimate (dof_handler,
QGauss<dim-1>(3),
// that stores, for each cell, the subdomain the cell belongs to. This is
// slightly tricky, because of course not every processor knows about every
// cell. The vector we attach therefore has an entry for every cell that the
- // current processor has in its mesh (locally owned onces, ghost cells, and
+ // current processor has in its mesh (locally owned ones, ghost cells, and
// artificial cells), but the DataOut class will ignore all entries that
// correspond to cells that are not owned by the current processor. As a
// consequence, it doesn't actually matter what values we write into these
solve ();
if (Utilities::MPI::n_mpi_processes(mpi_communicator) <= 32)
- output_results (cycle);
+ {
+ TimerOutput::Scope t(computing_timer, "output");
+ output_results (cycle);
+ }
pcout << std::endl;
+ computing_timer.print_summary ();
+ computing_timer.reset ();
}
+
}
}
// The final function, <code>main()</code>, again has the same structure as in
// all other programs, in particular step-6. Like in the other programs that
-// use PETSc, we have to inialize and finalize PETSc, which is done using the
+// use PETSc, we have to initialize and finalize PETSc, which is done using the
// helper object MPI_InitFinalize.
//
// Note how we enclose the use the use of the LaplaceProblem class in a pair
// of braces. This makes sure that all member variables of the object are
-// destroyed by the time we destroy the mpi_intialization object. Not doing
+// destroyed by the time we destroy the mpi_initialization object. Not doing
// this will lead to strange and hard to debug errors when
// <code>PetscFinalize</code> first deletes all PETSc vectors that are still
// around, and the destructor of the LaplaceProblem class then tries to delete
MESSAGE(FATAL_ERROR "
Error! The deal.II library found at ${DEAL_II_PATH} was not configured with
DEAL_II_WITH_TRILINOS = ON
-which is required for this tutorial step."
+One or all of these are OFF in your installation but are required for this tutorial step."
)
ENDIF()
stair step obstacle against which gravity pushes the membrane.
This problem is typically called the "obstacle problem" (see also <a
-href="http://en.wikipedia.org/wiki/Obstacle_problem">this wikipedia article</a>), and it results in a
+href="http://en.wikipedia.org/wiki/Obstacle_problem">this Wikipedia article</a>), and it results in a
variational inequality, rather than a variational equation when put into the
weak form. We will below derive it from the classical formulation, but before we
go on to discuss the mathematics let us show how the solution of the problem we
@f{equation*}
E(u)\leq E(v)\quad \forall v\in G,
@f}
-with the convex set of admissble displacements:
+with the convex set of admissible displacements:
@f{equation*}
G:=\lbrace v\in V: v\geq g \text{ a.e. in } \Omega\rbrace,\quad V:=H^1_0(\Omega).
@f}
On the other hand, if $u=g$ then $G$ only allows test functions $v$ so that in fact
$v-u\ge 0$. This means that we can't test the equation with both $v-u$ and
$-(v-u)$ as above, and so we can no longer conclude that the two sides are in
-fact equal. Thus, this mimicks the way we have discussed the complementarity
+fact equal. Thus, this mimics the way we have discussed the complementarity
condition above.
large enough; for example there is no convergence for $c = 1$ using the
current program if we use 7 global refinements.)
-After some headscratching one can then convince oneself that the inequalities
+After some head-scratching one can then convince oneself that the inequalities
above can equivalently be rewritten as
@f{equation*}
C([BU]_i,\Lambda_i) = 0, \qquad \forall i\in{\cal S}.
-/* Authors: Joerg Frohne, Texas A&M University and */
-/* University of Siegen, 2011, 2012 */
-/* Wolfgang Bangerth, Texas A&M University, 2012 */
-
-/* $Id$ */
-/* */
-/* Copyright (C) 2011-2012 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. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2011 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Authors: Joerg Frohne, Texas A&M University and
+ * University of Siegen, 2011, 2012
+ * Wolfgang Bangerth, Texas A&M University, 2012
+ */
+
// @sect3{Include files}
// function given above and in the introduction.
//
// If we decide that the DoF should be part of the active set, we
- // add its index to the active set, introduce a nonhomogeneous
+ // add its index to the active set, introduce an inhomogeneous
// equality constraint in the ConstraintMatrix object, and reset the
// solution value to the height of the obstacle. Finally, the
// residual of the non-contact part of the system serves as an
// @sect4{ObstacleProblem::output_results}
// We use the vtk-format for the output. The file contains the displacement
- // and a numerical represenation of the active set. The function looks
+ // and a numerical representation of the active set. The function looks
// standard but note that we can add an IndexSet object to the DataOut
// object in exactly the same way as a regular solution vector: it is simply
// interpreted as a function that is either zero (when a degree of freedom
# You can specify additional files here!
)
-# A custom command line to run the program
-SET(TARGET_RUN mpirun -np 2 ${TARGET})
-
# Define the output that should be cleaned:
SET(CLEAN_UP_FILES *.vtu *.pvtu *.visit)
DEAL_II_WITH_MPI = ON
DEAL_II_WITH_P4EST = ON
DEAL_II_WITH_TRILINOS = ON
-which is required for this tutorial step."
+One or all of these are OFF in your installation but are required for this tutorial step."
)
ENDIF()
+++ /dev/null
-\documentclass{article}
-
-\usepackage{amsmath}
-\usepackage{amssymb}
-
-\title{Documentation of step-42, An obstacle problem for elasto-plastic material behavior in three dimensions}
-\author{Joerg Frohne}
-\date{Juni, 2012}
-
-\begin{document}
-
-\section{Introduction}
-
-This example is an extension of step-41, considering a contact problem with an
-elasto-plastic material behavior with isotropic hardening in three dimensions.
-That means that we have to take care of an additional nonlinearity: the
-material behavior. Since we consider a three dimensional problem here, a
-separate difference to step-41 is that the contact area is at the boundary of
-the deformable body now, rather than in the interior. Finally, compared to
-step-41, we also have to deal with
-hanging nodes because of the adaptive mesh in both the handling of the linear
-system as well as of the inequality constraints; in the latter case, we will
-have to deal with prioritizing whether the constraints from the hanging nodes
-or from the inequalities are more important.
-
-Since you can very easily reach a few million degrees of freedom in three
-dimensions, even with adaptive mesh refinement, we decided to use Trilinos and
-p4est to run our code in parallel, building on the framework of step-40 for
-the parallelization.\\
-
-\begin{huge}
-{distributed}
-\end{huge}
-
-
-\section{Classical formulation}
-
-The classical formulation of the problem possesses the following form:
-\begin{align*}
- \varepsilon(u) &= A\sigma + \lambda & &\quad\text{in } \Omega,\\
- \lambda(\tau - \sigma) &\geq 0\quad\forall\tau\text{ with
- }\mathcal{F}(\tau)\leq 0 & &\quad\text{in } \Omega,\\
- -\textrm{\textrm{div}}\ \sigma &= f & &\quad\text{in } \Omega,\\
- u(\mathbf x) &= 0 & &\quad\text{on }\Gamma_D,\\
- \sigma_t(u) &= 0,\quad\sigma_n(u)\leq 0 & &\quad\text{on }\Gamma_C,\\
-\sigma_n(u)(u_n - g) &= 0,\quad u_n(\mathbf x) - g(\mathbf x) \leq 0 & &\quad\text{on } \Gamma_C
-\end{align*}
-with $u\in H^2(\Omega),\Omega\subset\mathbb{R}^3$. The vector valued
-function $u$ denotes the displacement in the deformable body. The first two lines describe the
-elasto-plastic material behavior. Therein the equation shows the
-strain of the deformation $\varepsilon (u)$ as the additive decomposition of the
-elastic part $A\sigma$ and the plastic part $\lambda$. $A$ is defined as the
-compliance tensor of fourth order which contains some material constants and
-$\sigma$ as the symmetric stress tensor of second order. So we have to consider
-the inequality in the second row in a pointwise sense where $\lambda(\tau -
-\sigma)$ is the inner product of two symmetric tensors of second order.
-Furthermore we have to distinguish two cases.\\
-The continuous and convex function $\mathcal{F}$ denotes the von Mises flow function
-$$\mathcal{F}(\tau) = \vert\tau^D\vert - \sigma_0¸\quad\text{with}\quad \tau^D
-= \tau - \dfrac{1}{3}tr(\tau)I,$$
-$\sigma_0$ as yield stress and $\vert .\vert$ as the frobenius norm. If there
-are no plastic deformations in a particular point - that is $\lambda=0$ - this yields $\vert\sigma^D\vert <
-\sigma_0$ and otherwise if $\lambda > 0$ it follows that $\vert\sigma^D\vert = \sigma_0$.
-That means if the stress is smaller than the yield stress there are only elastic
-deformations in that point.\\
-To consider it the other way around if the deviator stress $\sigma^D$ is in a
-norm bigger than the yield stress then $\sigma^D$ has to be projected back to the yield surface and there are plastic deformations which means $\lambda$
-would be positiv for that particular point. We refer that the stresses are
-computed by Hooke's law for isotorpic materials. You can find the description at the end of section 3. Else if the norm of the deviator stress tensor is smaller or equal the yield stress then $\lambda$ is zero and there are no plastic deformations in
-that point.\\
-There the index $D$ denotes the deviator part of for example the stress where
-$tr(.)$ is the trace of a tensor. The definition shows an additive decomposition
-of the stress $\sigma$ into a hydrostatic part (or volumetric part) $\dfrac{1}{3}tr(\tau)I$ and the deviator
-part $\sigma^D$. For metal the deviator stress composes the main indicator for
-plastic deformations.\\
-The third equation is called equilibrium condition with a force of volume
-density $f$ which we will neglect in our example.
-The boundary of $\Omega$ separates as follows $\Gamma=\Gamma_D\bigcup\Gamma_C$ and $\Gamma_D\bigcap\Gamma_C=\emptyset$.
-At the boundary $\Gamma_D$ we have zero Dirichlet conditions. $\Gamma_C$ denotes the potential contact boundary.\\
-The last two lines decribe the so-called Signorini contact conditions. If there is no contact the normal stress
-$$ \sigma_n = \sigma n\cdot n$$
-is zero with the outward normal $n$. If there is contact ($u_n = g$) the tangential stress $\sigma_t = \sigma\cdot n - \sigma_n n$
-vanishes, because we consider a frictionless situation and the normal stress is
-negative. The gap $g$ comes with the start configuration of the obstacle and the
-deformable body. We refer that you have to ensure that the obstacle does not hit
-the boundary of $\Gamma_C$
-
-\section{Derivation of the variational inequality}
-
-As a starting point to derive the equations above, let us imagine that we want
-to minimise an energy functional:
-$$E(\tau) := \dfrac{1}{2}\int\limits_{\Omega}\tau A \tau d\tau,\quad \tau\in \Pi W^{\textrm{div}}$$
-with
-$$W^{\textrm{div}}:=\lbrace \tau\in
-L^2(\Omega,\mathbb{R}^{\textrm{dim}\times\textrm{dim}}_{\textrm{sym}}):\textrm{div}(\tau)\in L^2(\Omega,\mathbb{R}^{\textrm{dim}})\rbrace$$ and
-$$\Pi \Sigma:=\lbrace \tau\in \Sigma, \mathcal{F}(\tau)\leq 0\rbrace$$
-as the set of admissible stresses which is defined
-by a continious, convex flow function $\mathcal{F}$.
-
-With the goal of deriving the dual formulation of the minimisation
-problem, we define a lagrange function:
-$$L(\tau,\varphi) := E(\tau) + (\varphi, \textrm{div}(\tau)),\quad \lbrace\tau,\varphi\rbrace\in\Pi W^{\textrm{div}}\times V^+$$
-with
-$$V^+ := \lbrace u\in V: u_n\leq g \text{ on } \Gamma_C \rbrace$$
-$$V:=\left[ H_0^1 \right]^{\textrm{dim}}:=\lbrace u\in \left[H^1(\Omega)\right]^{\textrm{dim}}: u
-= 0 \text{ on } \Gamma_D\rbrace$$
-By building the Fr\'echet derivatives of $L$ for both components we obtain the
-dual formulation for the stationary case which is known as \textbf{Hencky-Type-Model}:\\
-Find a pair $\lbrace\sigma,u\rbrace\in \Pi W\times V^+$ with
-$$\left(A\sigma,\tau - \sigma\right) + \left(u, \textrm{div}(\tau) - \textrm{div}(\sigma)\right) \geq 0,\quad \forall \tau\in \Pi W^{\textrm{div}}$$
-$$-\left(\textrm{div}(\sigma),\varphi - u\right) \geq 0,\quad \forall \varphi\in V^+.$$
-By integrating by parts and multiplying the first inequality by the elastic
-tensor $C=A^{-1}$ we achieve the primal-mixed version of our problem:\\
-Find a pair $\lbrace\sigma,u\rbrace\in \Pi W\times V^+$ with
-$$\left(\sigma,\tau - \sigma\right) - \left(C\varepsilon(u), \tau - \sigma\right) \geq 0,\quad \forall \tau\in \Pi W$$
-$$\left(\sigma,\varepsilon(\varphi) - \varepsilon(u)\right) \geq 0,\quad \forall \varphi\in V^+.$$
-Therein $\varepsilon$ denotes the linearised deformation tensor with $\varepsilon(u) := \dfrac{1}{2}\left(\nabla u + \nabla u^T\right)$ for small deformations.\\
-Most materials - especially metals - have the property that they show some hardening effects during the forming process.
-There are different constitutive laws to describe those material behaviors. The
-simplest one is called linear isotropic hardening described by the flow function
-$\mathcal{F}(\tau,\eta) = \vert\tau^D\vert - (\sigma_0 + \gamma^{\text{iso}}\eta)$ where
-$\eta$ is the norm of the plastic strain $\eta = \vert \varepsilon -
-A\sigma\vert$.
-It can be considered by establishing an additional term in our primal-mixed formulation:\\
-Find a pair $\lbrace(\sigma,\xi),u\rbrace\in \Pi (W\times L^2(\Omega,\mathbb{R}))\times V^+$ with
-$$\left(\sigma,\tau - \sigma\right) - \left(C\varepsilon(u), \tau - \sigma\right) + \gamma^{\text{iso}}\left( \xi, \eta - \xi\right) \geq 0,\quad \forall (\tau,\eta)\in \Pi (W,L^2(\Omega,\mathbb{R}))$$
-$$\left(\sigma,\varepsilon(\varphi) - \varepsilon(u)\right) \geq 0,\quad \forall \varphi\in V^+,$$
-with the hardening parameter $\gamma^{\text{iso}} > 0$.\\
-Now we want to derive a primal problem which only depends on the displacement $u$. For that purpose we
-set $\eta = \xi$ and eliminate the stress $\sigma$ by applying the projection
-theorem (see Grossmann, Roos: Numerical Treatment of Partial Differential
-Equations, Springer-Verlag Berlin Heidelberg, 2007 and Frohne: FEM-Simulation
-der Umformtechnik metallischer Oberflächen im Mikrokosmos, Ph.D. thesis,
-University of Siegen, Germany, 2011) on\\
-$$\left(\sigma - C\varepsilon(u), \tau - \sigma\right) \geq 0,\quad \forall \tau\in \Pi W,$$
-which yields with the second inequality:\\
-Find the displacement $u\in V^+$ with
-$$\left(P_{\Pi}(C\varepsilon(u)),\varepsilon(\varphi) - \varepsilon(u)\right) \geq 0,\quad \forall \varphi\in V^+,$$
-with the projection:
-$$P_{\Pi}(\tau):=\begin{cases}
- \tau, & \text{if }\vert\tau^D\vert \leq \sigma_0 + \gamma^{\text{iso}}\xi,\\
- \hat\alpha\dfrac{\tau^D}{\vert\tau^D\vert} + \dfrac{1}{3}tr(\tau), & \text{if }\vert\tau^D\vert > \sigma_0 + \gamma^{\text{iso}}\xi,
- \end{cases}$$
-with the radius
-$$\hat\alpha := \sigma_0 + \gamma^{\text{iso}}\xi .$$
-With the relation $\xi = \vert\varepsilon(u) - A\sigma\vert$ it is possible to eliminate $\xi$ inside the projection $P_{\Pi}$:\\
-$$P_{\Pi}(\tau):=\begin{cases}
- \tau, & \text{if }\vert\tau^D\vert \leq \sigma_0,\\
- \alpha\dfrac{\tau^D}{\vert\tau^D\vert} + \dfrac{1}{3}tr(\tau), & \text{if }\vert\tau^D\vert > \sigma_0,
- \end{cases}$$
-$$\alpha := \sigma_0 + \dfrac{\gamma^{\text{iso}}}{2\mu+\gamma^{\text{iso}}}\left(\vert\tau^D\vert - \sigma_0\right) ,$$
-with a further material parameter $\mu>0$ called shear modulus. We refer that
-this only possible for isotropic plasticity.\\
-To make things a bit easier from now on we denote
-$$\gamma := \dfrac{\gamma^{\text{iso}}}{2\mu +
-\gamma^{\text{iso}}}\in[0,1)\text{ with }\gamma^{\text{iso}}\in[0,\infty),$$
-$$\beta :=\dfrac{\sigma_0}{\vert\tau^D\vert}.$$ If $\gamma^{\text{iso}}$ tends to zero $\gamma$ tends also to zero. And if $\gamma^{\text{iso}}$ tends to
-infinity $\gamma$ tends to one. This allows us to reformulate our problem as
-follows $$P_{\Pi}(\tau):=\begin{cases}
- \tau, & \text{if }\vert\tau^D\vert \leq \sigma_0,\\
- \gamma\tau^D + (1-\gamma)\beta\tau^D
- + \dfrac{1}{3}tr(\tau), & \text{if }\vert\tau^D\vert >
- \sigma_0, \end{cases}.$$
-For further details see Suttmeier: On Plasticity with Hardening:
-An Adaptive Finite Element Discretisation, International Mathematical Forum, 5,
-2010, no. 52, 2591-2601.\\
-So what we do is to calculate the stresses
-by using Hooke's law for linear elastic, isotropic materials $$\sigma = C \varepsilon(u) = 2\mu \varepsilon^D(u) + \kappa tr(\varepsilon(u))I = \left[2\mu\left(\mathbb{I} -\dfrac{1}{3} I\otimes I\right) + \kappa I\otimes I\right]\varepsilon(u)$$
-with the material parameter $\kappa>0$ (bulk modulus). The variables $I$ and
-$\mathbb{I}$ denote the identity tensors of second and forth order. In that
-notation $2\mu \varepsilon^D(u)$ is the deviatoric part and $\kappa
-tr(\varepsilon(u))$ the volumetric part of the stress tensor.\\
-In the next step we test in a pointwise sense where the deviator part of the
-stress in a norm is bigger than the yield stress. If there are such points we
-project the deviator stress in those points back to the yield surface. Methods of this kind are called projections algorithm or radial-return-algorithm.\\
-Now we have a primal formulation of our elasto-plastic contact problem which only depends on the displacement $u$.
-It consists of a nonlinear variational inequality and has a unique solution as
-it satisfies the theorem of Lions and Stampaccia. A proof can be found in
-Rodrigues: Obstacle Problems in Mathematical Physics, North-Holland, Amsterdam,
-1987.\\
-To handle the nonlinearity of the constitutive law we use a Newton method and to deal with the contact we apply an
-active set method like in step-41. To be more concrete we combine both methods to an inexact semi smooth Newton
-method - inexact since we use an iterative solver for the linearised problems in each Newton step.
-
-\section{Linearization of the constitutive law for the Newton method}
-
-To apply Newton method we have to linearise the following semi-linearform
-$$a(\psi;\varphi) :=
-\left(P_{\Pi}(C\varepsilon(\psi)),\varepsilon(\varphi)\right).$$ Because we have
-to find the solution $u$ in the convex set $V^+$, we have to apply an SQP-method (SQP: sequential quadratic programming). That means we have
-to solve a minimisation problem for a known $u^i$ in every SQP-step of the form
-\begin{eqnarray*}
- & & a(u^{i};u^{i+1} - u^i) + \dfrac{1}{2}a'(u^i;u^{i+1} - u^i,u^{i+1} - u^i)\\
- &=& a(u^i;u^{i+1}) - a(u^i;u^i) +\\
- & & \dfrac{1}{2}\left( a'(u^i;u^{i+1},u^{i+1}) - 2a'(u^i;u^i,u^{i+1}) - a'(u^i;u^i,u^i)\right)\\
- &\rightarrow& \textrm{min},\quad u^{i+1}\in V^+.
-\end{eqnarray*}
-Neglecting the constant terms $ a(u^i;u^i)$ and $ a'(u^i;u^i,u^i)$ we obtain the
-following minimisation problem $$\dfrac{1}{2} a'(u^i;u^{i+1},u^{i+1}) -
-F(u^{i+1})\rightarrow \textrm{min},\quad u^{i+1}\in V^+$$ with $$F(\varphi) :=
-\left(a'(u^{i};u^{i},\varphi) - a(u^{i},\varphi) \right).$$
-In the case of our constitutive law the Fr\'echet derivative of the
-semi-linearform $a(.;.)$ at the point $u^i$ is
-
-$$a'(u^i;\psi,\varphi) =
-(I(x)\varepsilon(\psi),\varepsilon(\varphi)),\quad x\in\Omega,$$ $$
-I(x) := \begin{cases}
-C_{\mu} + C_{\kappa}, &
-\quad \vert \tau^D \vert \leq \sigma_0\\
-\gamma C_{\mu} + (1-\gamma)\beta\left(C_{\mu} -
-2\mu\dfrac{\tau^D\otimes\tau^D}{\vert\tau^D\vert^2}\right) + C_{\kappa}, &\quad
-\vert \tau^D \vert > \sigma_0
-\end{cases}
-$$
-with
-$$C_{\mu} := 2\mu\left(\mathbb{I} - \dfrac{1}{3} I\otimes
-I\right)\quad\text{(shear part of the stress strain tensor)},$$
-$$C_{\kappa} := \kappa I\otimes I\quad\text{(bulk part of the stress strain
-tensor)},$$
-$$\tau^D := C\varepsilon^D(u^i).$$
-Remark that $a(.;.)$ is not differentiable in the common sense but it is
-slantly differentiable like the function for the contact problem and again we refer to
-Hintermueller, Ito, Kunisch: The primal-dual active set strategy as a semismooth newton method, SIAM J. OPTIM., 2003, Vol. 13, No. 3, pp. 865-888.
-Again the first case is for elastic and the second for plastic deformation.
-
-\section{Formulation as a saddle point problem}
-
-Just as in step-41 we compose a saddle point problem out of the minimisation
-problem. Again we do so to gain a formulation that allows us to solve a linear
-system of equations finally.\\
-We introduce a Lagrange multiplier $\lambda$ and the convex cone $K\subset W'$,
-$W'$ dual space of the trace space $W:=\left[ H_0^{\frac{1}{2}}(\Gamma_C)
-\right]^{\textrm{dim}}$ of $V$ restricted to $\Gamma_C$, $$K:=\{\mu\in W':\mu_T = 0,\quad\langle\mu n,v\rangle_{\Gamma_C}\geq 0,\quad
-\forall v\in H_0^{\frac{1}{2}}(\Gamma_C), v \ge 0\text{ on }\Gamma_C \}$$
-of Lagrange multipliers, where $\langle\cdot,\cdot\rangle$
-denotes the duality pairing, i.e. a boundary integral, between $W'$ and $W$.
-Intuitively, $K$ is the cone of all "non-positive functions", except that $ K\subset
-\left( \left[ H_0^{\frac{1}{2}}(\Gamma_C) \right]^{\textrm{dim}} \right)' $ and
-so contains other objects besides regular functions as well. This yields:\\
-
-\noindent
-\textit{Find $u\in V$ and $\lambda\in K$ such that}
-\begin{align*}
- \hat{a}(u,v) + b(v,\lambda) &= f(v),\quad &&v\in V\\
- b(u,\mu - \lambda) &\leq \langle g,(\mu -
- \lambda)n\rangle_{\Gamma_C},\quad&&\mu\in K,
-\end{align*}
-\textit{with}
-\begin{align*}
- \hat{a}(u,v) &:= a'(u^i;u,v)\\
- b(u,\mu) &:= \langle un,\mu n\rangle_{\Gamma_C},\quad &&u\in V,\quad\mu\in W'.
-\end{align*}
-As in the section before $u^i$ denotes the linearization point for the
-semi-linearform $a(.;.)$. In contrast to step-41 we directly consider $\lambda$
-as the additional, positive force $\sigma(u)n$ that the obstacle
-exerts on the boundary $\Gamma_C$ of the body.\\
-
-\noindent
-The existence and uniqueness of the analytical solution $(u,\lambda)\in V\times
-K$ of this saddle point problem has been stated in Glowinski, Lions and Tr\'{e}moli\`{e}res: Numerical
-Analysis of Variational Inequalities, North-Holland, 1981.\\
-
-\noindent
-NOTE: In this example as well as in the further documentation we make the
-assumption that the normal vector $n$ equals to $(0,0,1)$. This comes up with
-the starting condition of our deformable body.
-
-\section{Active Set methods to solve the saddle point problem}
-
-The linearized problem is essentially like a pure elastic problem with contact like
-in step-41. The only difference consists in the fact that the contact area
-is at the boundary instead of in the domain. But this has no further consequence
-so that we refer to the documentation of step-41 with the only hint that
-$\mathcal{S}$ containts all the vertices at the contact boundary $\Gamma_C$ this
-time.
-
-\section{The primal-dual active set algorithm combined with the inexact semi smooth
-Newton method}
-
-Now we describe an algorithm that combines the damped semismooth Newton-method,
-which we use for the nonlinear constitutive law, with the semismooth Newton
-method for the contact. It sums up the results of the sections before and works as follows:
-\begin{itemize}
- \item[(0)] Initialize $\mathcal{A}_k$ and $\mathcal{F}_k$, such that
- $\mathcal{S} = \mathcal{A}_k \cup \mathcal{F}_k$ and $\mathcal{A}_k \cap
- \mathcal{F}_k = \emptyset$ and set $k = 1$. The start value $\hat U^0 :=
- P_{\mathcal{A}_k}(0)$ fullfills our obstacle condition.
- \item[(1)] Assemble the Newton matrix $A := a'(\hat
- U^{k-1};\varphi_p,\varphi_q)$ and the right-hand-side $F(\hat U^{k-1})$.
- \item[(2)] Find the primal-dual pair $(\bar U^k,\Lambda^k)$ that satisfies
- \begin{align*}
- A\bar U^k + B\Lambda^k & = F, &\\
- \left[B^T\bar U^k\right]_p & = G_p & \forall p\in\mathcal{A}_k,\\
- \Lambda^k_p & = 0 & \forall p\in\mathcal{F}_k.
- \end{align*}
- \item[(3)] Damping for $k>2$ by applying a line search and calculating a linear
- combination of $U^{k-1}$ and $\bar U^k$. Find an
- $\alpha_i:=2^{-i},(i=0,\ldots,10)$ so that $$U^k := \alpha_i\bar U^k +
- (1-\alpha_i)U^{k-1}$$ yields $$\vert
- F\left(U^{k}\right) \vert < \vert F\left(U^{k-1}\right) \vert.$$
- \item[(4)] Define the new active and inactive sets by
- $$\mathcal{A}_{k+1}:=\lbrace p\in\mathcal{S}:\Lambda^k_p +
- c\left(\left[B^TU^k\right]_p - G_p\right) > 0\rbrace,$$
- $$\mathcal{F}_{k+1}:=\lbrace p\in\mathcal{S}:\Lambda^k_p +
- c\left(\left[B^TU^k\right]_p - G_p\right) \leq 0\rbrace.$$
- Projection $U^k$ so that it holds the second equation in (2)
- $$\hat U^K := P_{\mathcal{A}_{k+1}}(U^k).$$
- \item[(5)] If $\mathcal{A}_{k+1} = \mathcal{A}_k$ and $\vert
- F\left(U^{k}\right) \vert < \delta$ then stop, else set $k=k+1$ and go to
- step (1).
-\end{itemize}
-\noindent
-The subscript $p$ denotes a vertex and the meaning of the
-decorated and none decorated $U$ is as follows: $\bar U$ denotes the solution of the linear system of equations in (2), $U$ is the
-damped solution and equals to $\bar U$ if the damping parameter $\alpha_0 =
-1$ and $\hat U := P_{\mathcal{A}}(U)$ is the projection of the active
-components in $\mathcal{A}$ to the gap
-$$P_{\mathcal{A}}(U):=\begin{cases}
-U_p, & \textrm{if}\quad p\notin\mathcal{A}\\
-g_{h,p}, & \textrm{if}\quad
-p\in\mathcal{A}.
-\end{cases}$$\\
-The matrix $B\in\mathbb{R}^{n\times m}$, $n>m$ describes the coupling of the
-bases for the displacements and lagrange multiplier (contact forces)
-and it is not quadratic in our situation since $\Lambda^k$ is only defined on
-$\Gamma_C$. Due to the ansatz functions $\psi_i$ (scalar valued) of the
-lagrange multiplier are fullfilling the following biorthogonal condition (see Hüeber, Wohlmuth: A primal–dual active
-set strategy for non-linear multibody contact problems, Comput. Methods Appl. Mech. Engrg.
-194, 2005, pp. 3147-3166)
-$$ \int\limits_{\Gamma_C}\psi_i(x)\varphi_j(x)dx =
-\delta_{ij}\int\limits_{\Gamma_C}\varphi_j(x)dx$$
-this yields
-$$B_{pq} = \begin{cases}
-\int\limits_{\Gamma_C}\varphi_p(x)dxI_3, & \text{if}\quad p=q,\quad
-p,q\in\mathcal{S}\\
-0I_3, & \text{if}\quad p\neq q,\quad p\textrm{ or }q\notin\mathcal{S}.
-\end{cases}$$
-Here $I_3$ denotes the threedimensional identity matrix.
-In our programm we use the structure of a quadratic sparse for
-$B\in\mathbb{R}^{n\times n}$ and for $\Lambda^k$ a vector with length $n$ where
-$\Lambda^k_p = 0$ for $p\notin \mathcal{S}$.
-The vector $G$ is defined by a suitable approximation $g_h$ of the gap $g$
-$$G_p = \begin{cases}
-g_{h,p}\int\limits_{\Gamma_C}\varphi_p(x)dx, & \text{if}\quad p\in\mathcal{S}\\
-0, & \text{if}\quad p\notin\mathcal{S}.
-\end{cases}$$\\
-Note that $G_p$ is a threedimensional vector and that again we applied the
-biorthogonal property of the lagrange multiplier ansatz functions to the
-integral $\int\limits_{\Gamma_C}g_h(x)\varphi_p(x)dx$ with $g_h(x)=\sum\limits_i
-g_{h,p}\varphi_p(x)$ (see the reference mentioned above).\\
-Compared to step-41, step (1) is added but it should be clear from the sections
-above that we only linearize the problem. In step (2) we have to solve a linear system of equations again. And now the solution has to fulfill two stopping
-criteria. $\mathcal{A}_{k+1} = \mathcal{A}_k$ makes sure that the contact zones
-are iterated out and the second ensures an accurate enough residual which means that the plastic zones are also iterated out.\\
-A similar method can also be found in Brunssen, Schmid, Schaefer, Wohlmuth: A
-fast and robust iterative solver for nonlinear contact problems using a
-primal-dual active set strategy and algebraic multigrid, Int. J. Numer.
-Meth. Engng, 2007, 69, pp. 524-543. But in advance we apply a line search to
-obtain a more robust method regarding the start value. Solving an elastic
-problem in the very first step ($k=1$) we get a reasonable start value but as
-you can see in the results damping is important if we choose for example a ball as
-obstacle.\\
-Damping our Newton method is more important for the nonlinearity cause by the
-constitutive law as for the contact. For this reason we start to damp our method
-for $k>2$ when we have two plastic iterations. Note that $U^1$ is a solution of
-an elastic problem and $U^2$ is the first plastic solution. A linear combination
-between these both results in stresses which are not in the convex set
-of the feasible stresses.
-
-\section{Adaptive mesh refinement}
-
-Since we run our program in 3d, there is a good reason to use adaptive
-mesh refined. To make life a bit easier we are choosing the
-KellyErrorEstimator that is already implemented in deal.II. We hand the
-solution vector to it which contains the displacement $u$. As we will see in the
-results it yields a quite reasonable adaptive mesh for the contact zone.
-
-\section{Implementation}
-
-This tutorial is essentailly a mixture of step-40 and step-41 but instead of
-PETSc we let the Trilinos library deal with parallelizing the linear algebra
-(like in step-32). Since we are trying to solve a similar problem like in
-step-41 we will use the same methods but now in parallel.
-
-Another difficulty is the handling of the different constraints from
-(the dirichlet conditons), the hanging nodes and the inequality condition that
-arises from the contact. For this purpose we create three objects of type
-ConstraintMatrix.
-
-Beside the ConstitutiveLaw class there is another new class called Input. This
-class allows us to read in an obstacle from a file. In our example the file
-'obstacle\_file.dat' containts data which describe an Chinese, Japanese or
-Korean symbol for force or power. (See www.orientaloutpost.com/: ``This word can be used for motivation - it
-can also mean power / motion / propulsion / force. It can be anything
-internal or external that keeps you going. This is the safest way to express
-motivation in Chinese. If your audience is Japanese, please see the other entry
-for motivation. This is a word in Japanese and Korean, but it means "motive
-power" or "kinetic energy" (without the motivation meaning that you are
-probably looking for)'').
-
-\section{Results}
-
-
-
-\end{document}
<br>
<i>This program was contributed by Jörg Frohne (University of Siegen,
-Germany) while on a long-term visit to Texas A&M University.
+Germany) while on a long-term visit to Texas A&M University, with significant
+contributions by Timo Heister and Wolfgang Bangerth.
<br>
+<br>
+The code described here provides the basis for the numerical experiments shown
+in the following paper:
+<br>
+ J. Frohne, T. Heister, W. Bangerth: <b>Efficient numerical methods for the large-scale, parallel
+ solution of elastoplastic contact problems</b>. Submitted, 2013.
+</em>
</i>
<a name="Intro"></a>
<h3>Introduction</h3>
-This example is an extension of step-41, considering a contact problem with an
+This example is an extension of step-41, considering a 3d contact problem with an
elasto-plastic material behavior with isotropic hardening in three dimensions.
-That means that we have to take care of an additional nonlinearity: the
-material behavior. Since we consider a three dimensional problem here, a
-separate difference to step-41 is that the contact area is at the boundary of
+In other words, it considers how a three-dimensional body deforms if one pushes
+into it a rigid obstacle (the contact problem) where deformation is governed
+by an elasto-plastic material law (a material that can only accommodate a certain
+maximal stress) that hardens as deformation accumulates. To show we we intend to
+do before going into too many details, let us just show a picture of what the
+solution will look like (the deformable body is a cube - only half of
+which is actually shown -, the obstacle corresponds
+to a Chinese character that is discussed below):
+
+<img src="http://www.dealii.org/images/steps/developer/step-42.CellConstitutionLi2.png" alt="">
+
+
+This problem description implies that we have to take care of an additional
+nonlinearity compared to step-41: the
+material behavior. Since we consider a three dimensional problem here, we also
+have to account for the fact that the contact area is at the boundary of
the deformable body now, rather than in the interior. Finally, compared to
-step-41, we also have to deal with hanging nodes because of the adaptive mesh
-in both the handling of the linear
-system as well as of the inequality constraints; in the latter case, we will
+step-41, we also have to deal with hanging nodes in both the handling of the linear
+system as well as of the inequality constraints as we would like to use an
+adaptive mesh; in the latter case, we will
have to deal with prioritizing whether the constraints from the hanging nodes
or from the inequalities are more important.
Since you can very easily reach a few million degrees of freedom in three
dimensions, even with adaptive mesh refinement, we decided to use Trilinos and
p4est to run our code in parallel, building on the framework of step-40 for
-the parallelization.
-
-@f{huge}
-{distributed}
-@f}
+the parallelization. Additional pointers for parallelization can be found in
+step-32.
<h3>Classical formulation</h3>
The classical formulation of the problem possesses the following form:
@f{align*}
- \varepsilon(u) &= A\sigma + \lambda & &\quad\text{in } \Omega,\\
- \lambda(\tau - \sigma) &\geq 0\quad\forall\tau\text{ with
- }\mathcal{F}(\tau)\leq 0 & &\quad\text{in } \Omega,\\
- -\textrm{\textrm{div}}\ \sigma &= f & &\quad\text{in } \Omega,\\
- u(\mathbf x) &= 0 & &\quad\text{on }\Gamma_D,\\
- \sigma_t(u) &= 0,\quad\sigma_n(u)\leq 0 & &\quad\text{on }\Gamma_C,\\
-\sigma_n(u)(u_n - g) &= 0,\quad u_n(\mathbf x) - g(\mathbf x) \leq 0 & &\quad\text{on } \Gamma_C
+ \varepsilon(\mathbf u) &= A\sigma + \varepsilon^p & &\quad\text{in } \Omega,\\
+ -\textrm{\textrm{div}}\ \sigma &= \mathbf f & &\quad\text{in } \Omega,\\
+ \varepsilon^p:(\tau - \sigma) &\geq 0\quad\forall\tau\text{ with
+ }\mathcal{F}(\tau)\leq 0 & &\quad\text{in } \Omega,\\
+ \mathbf u &= 0 & &\quad\text{on }\Gamma_D,\\
+ \sigma \cdot \mathbf n - [\mathbf n \cdot(\sigma \cdot \mathbf n)]\mathbf n &= 0,
+ \quad \mathbf n \cdot (\sigma \cdot
+ \mathbf n) \leq 0 & &\quad\text{on }\Gamma_C,\\
+ (\mathbf n \cdot (\sigma \cdot
+ \mathbf n))(\mathbf n \cdot \mathbf u - g) &= 0,\quad \mathbf n
+ \cdot \mathbf u - g \leq 0 & &\quad\text{on } \Gamma_C.
@f}
-with $u\in H^2(\Omega),\Omega\subset\mathbb{R}^3$. The vector valued
-function $u$ denotes the displacement in the deformable body. The first two lines describe the
-elasto-plastic material behavior. Therein the equation shows the
-strain of the deformation $\varepsilon (u)$ as the additive decomposition of the
-elastic part $A\sigma$ and the plastic part $\lambda$. $A$ is defined as the compliance tensor of fourth order which contains some material constants and $\sigma$ as the
-symmetric stress tensor of second order. So we have to consider
-the inequality in the second row in a pointwise sense where $\lambda(\tau -
-\sigma)$ is the inner product of two symmetric tensors of second order. Furthermore we have to
-distinguish two cases.
-
-The continuous and convex function $\mathcal{F}$ denotes the von Mises flow function
-@f{gather*}\mathcal{F}(\tau) = \vert\tau^D\vert - \sigma_0�\quad\text{with}\quad \tau^D
-= \tau - \dfrac{1}{3}tr(\tau)I,@f}
-$\sigma_0$ as yield stress and $\vert .\vert$ as the Frobenius norm. If there
-are no plastic deformations in a particular point - that is $\lambda=0$ - this yields $\vert\sigma^D\vert <
-\sigma_0$ and otherwise if $\lambda > 0$ it follows that $\vert\sigma^D\vert = \sigma_0$.
-That means if the stress is smaller than the yield stress there are only elastic
-deformations in that point.
-
-To consider it the other way around if the deviator stress $\sigma^D$ is in a
-norm bigger than the yield stress then $\sigma^D$ has to be projected back to the yield surface and there are plastic deformations which means $\lambda$
-would be positiv for that particular point. We refer that the stresses are
-computed by Hooke's law for isotorpic materials. You can find the description at the end of section 3. Else if the norm of the deviator stress tensor is smaller or equal the yield stress then $\lambda$ is zero and there are no plastic deformations in
-that point.
-
-There the index $D$ denotes the deviator part of for example the stress where
-$tr(.)$ is the trace of a tensor. The definition shows an additive decomposition
-of the stress $\sigma$ into a hydrostatic part (or volumetric part) $\dfrac{1}{3}tr(\tau)I$ and the deviator
-part $\sigma^D$. For metal the deviator stress composes the main indicator for
-plastic deformations.
-
-The third equation is called equilibrium condition with a force of volume
-density $f$ which we will neglect in our example.
-The boundary of $\Omega$ separates as follows $\Gamma=\Gamma_D\bigcup\Gamma_C$ and $\Gamma_D\bigcap\Gamma_C=\emptyset$.
-At the boundary $\Gamma_D$ we have zero Dirichlet conditions. $\Gamma_C$ denotes the potential contact boundary.
-
-The last two lines decribe the so-called Signorini contact conditions. If there is no contact the normal stress
-@f{gather*} \sigma_n = \sigma n\cdot n@f}
-is zero with the outward normal $n$. If there is contact ($u_n = g$) the tangential stress $\sigma_t = \sigma\cdot n - \sigma_n n$
-vanishes, because we consider a frictionless situation and the normal stress is
-negative. The gap $g$ comes with the start configuration of the obstacle and the
-deformable body.
-
-
-<h3>Derivation of the variational inequality</h3>
-
-As a starting point to derive the equations above, let us imagine that we want
-to minimise an energy functional:
-@f{gather*}E(\tau) := \dfrac{1}{2}\int\limits_{\Omega}\tau A \tau d\tau,\quad \tau\in \Pi W^{\textrm{div}}@f}
-with
-@f{gather*}W^{\textrm{div}}:=\lbrace \tau\in
-L^2(\Omega,\mathbb{R}^{\textrm{dim}\times\textrm{dim}}_{\textrm{sym}}):\textrm{div}(\tau)\in L^2(\Omega,\mathbb{R}^{\textrm{dim}})\rbrace@f} and
-@f{gather*}\Pi \Sigma:=\lbrace \tau\in \Sigma, \mathcal{F}(\tau)\leq 0\rbrace@f}
-as the set of admissible stresses which is defined
-by a continious, convex flow function $\mathcal{F}$.
-
-With the goal of deriving the dual formulation of the minimisation
-problem, we define a lagrange function:
-@f{gather*}L(\tau,\varphi) := E(\tau) + (\varphi, \textrm{div}(\tau)),\quad \lbrace\tau,\varphi\rbrace\in\Pi W^{\textrm{div}}\times V^+@f}
-with
-@f{gather*}V^+ := \lbrace u\in V: u_n\leq g \text{ on } \Gamma_C \rbrace@f}
-@f{gather*}V:=\left[ H_0^1 \right]^{\textrm{dim}}:=\lbrace u\in \left[H^1(\Omega)\right]^{\textrm{dim}}: u
-= 0 \text{ on } \Gamma_D\rbrace@f}
-By building the Fréchet derivatives of $L$ for both components we obtain the
-dual formulation for the stationary case which is known as <i>Hencky-Type-Model</i>:\\
-Find a pair $\lbrace\sigma,u\rbrace\in \Pi W\times V^+$ with
-@f{gather*}\left(A\sigma,\tau - \sigma\right) + \left(u, \textrm{div}(\tau) - \textrm{div}(\sigma)\right) \geq 0,\quad \forall \tau\in \Pi W^{\textrm{div}}@f}
-@f{gather*}-\left(\textrm{div}(\sigma),\varphi - u\right) \geq 0,\quad \forall \varphi\in V^+.@f}
-By integrating by parts and multiplying the first inequality by the elastic
-tensor $C=A^{-1}$ we achieve the primal-mixed version of our problem:
-Find a pair $\lbrace\sigma,u\rbrace\in \Pi W\times V^+$ with
-@f{gather*}\left(\sigma,\tau - \sigma\right) - \left(C\varepsilon(u), \tau - \sigma\right) \geq 0,\quad \forall \tau\in \Pi W@f}
-@f{gather*}\left(\sigma,\varepsilon(\varphi) - \varepsilon(u)\right) \geq 0,\quad \forall \varphi\in V^+.@f}
-Therein $\varepsilon$ denotes the linearised deformation tensor with $\varepsilon(u) := \dfrac{1}{2}\left(\nabla u + \nabla u^T\right)$ for small deformations.
-
-Most materials - especially metals - have the property that they show some hardening effects during the forming process.
+Here, the first of these equations defines the
+relationship between strain $\varepsilon(\mathbf u)=\frac{1}{2}\left(\nabla \mathbf u
+ + \nabla \mathbf u^T\right)$ and stress $\sigma$ via
+the fourth-order compliance tensor $A$; $\varepsilon^p$ provides the plastic
+component of the strain to ensure that the stress does not exceed the yield
+stress. We will only consider isotropic
+materials for which $A$ can be expressed in terms of the Lam\'e moduli
+$\lambda$ and $\mu$ or alternatively in terms of the bulk modulus
+$\kappa$ and $\mu$.
+The second equation is the force balance; we will here
+not consider any body forces and henceforth assume that $\mathbf f=0$. The
+complementarity condition in the third line implies that $\varepsilon^p=0$ if
+$\mathcal{F}(\sigma)< 0$ but that $\varepsilon^p$ may be a nonzero tensor if and
+only if $\mathcal{F}(\sigma) = 0$, and in particular that in this case
+$\varepsilon^p$ must point in the direction $\partial
+\mathcal{F}(\sigma)/\partial \sigma$. The inequality $\mathcal{F}(\sigma)\le 0$ is
+a statement of the fact that plastic materials can only support a finite amount
+of stress; in other words, they react with plastic deformations $\varepsilon^p$
+if external forces would result in a stress $\sigma$ for which $\mathcal{F}(\sigma)> 0$
+would result. A typical form for this <i>yield function</i> is
+$\mathcal{F}(\sigma)=|\sigma^D|-\sigma_{\text{yield}}$ where $\tau^D
+= \tau - \dfrac{1}{3}tr(\tau)I$ is the deviatoric part of a tensor
+and $|\cdot|$ denotes the Frobenius norm.
+
+Further equations describe a
+fixed, zero displacement on $\Gamma_D$ and
+that on the surface $\Gamma_C=\partial\Omega\backslash\Gamma_D$ where contact may appear, the normal
+force $\sigma_n=\mathbf n \cdot (\sigma(\mathbf u) \cdot
+ \mathbf n)$ exerted by the obstacle is inward (no "pull" by the obstacle on our
+body) and with zero tangential component $\mathbf \sigma_t= \sigma \cdot \mathbf n - \mathbf \sigma_n \mathbf n
+= \sigma \cdot \mathbf n - [\mathbf n \cdot(\sigma \cdot \mathbf n)]\mathbf n$.
+The last condition is again a complementarity condition that
+implies that on $\Gamma_C$, the normal
+force can only be nonzero if the body is in contact with the obstacle; the
+second part describes the impenetrability of the obstacle and the body.
+The last two equations are commonly referred to as the Signorini contact
+conditions.
+
+Most materials - especially metals - have the property that they show some hardening as a result of
+deformation. In other words, $\sigma_{\text{yield}}$ increases with deformation.
+In practice, it is not the elastic deformation that results in hardening,
+but the plastic component.
There are different constitutive laws to describe those material behaviors. The
simplest one is called linear isotropic hardening described by the flow function
-$\mathcal{F}(\tau,\eta) = \vert\tau^D\vert - (\sigma_0 + \gamma^{\text{iso}}\eta)$ where
-$\eta$ is the norm of the plastic strain $\eta = \vert \varepsilon -
-A\sigma\vert$.
-It can be considered by establishing an additional term in our primal-mixed formulation:
-Find a pair $\lbrace(\sigma,\xi),u\rbrace\in \Pi (W\times L^2(\Omega,\mathbb{R}))\times V^+$ with
-@f{gather*}\left(\sigma,\tau - \sigma\right) - \left(C\varepsilon(u), \tau - \sigma\right) + \gamma^{\text{iso}}\left( \xi, \eta - \xi\right) \geq 0,\quad \forall (\tau,\eta)\in \Pi (W,L^2(\Omega,\mathbb{R}))@f}
-@f{gather*}\left(\sigma,\varepsilon(\varphi) - \varepsilon(u)\right) \geq 0,\quad \forall \varphi\in V^+,@f}
-with the hardening parameter $\gamma^{\text{iso}} > 0$.
-
-Now we want to derive a primal problem which only depends on the displacement $u$. For that purpose we
-set $\eta = \xi$ and eliminate the stress $\sigma$ by applying the projection
-theorem (see Grossmann, Roos: Numerical Treatment of Partial Differential
-Equations, Springer-Verlag Berlin Heidelberg, 2007 and Frohne: FEM-Simulation
-der Umformtechnik metallischer Oberflächen im Mikrokosmos, Ph.D. thesis,
-University of Siegen, Germany, 2011) on
-@f{gather*}\left(\sigma - C\varepsilon(u), \tau - \sigma\right) \geq 0,\quad \forall \tau\in \Pi W,@f}
-which yields with the second inequality:\\
-Find the displacement $u\in V^+$ with
-@f{gather*}\left(P_{\Pi}(C\varepsilon(u)),\varepsilon(\varphi) - \varepsilon(u)\right) \geq 0,\quad \forall \varphi\in V^+,@f}
-with the projection:
-@f{gather*}P_{\Pi}(\tau):=\begin{cases}
- \tau, & \text{if }\vert\tau^D\vert \leq \sigma_0 + \gamma^{\text{iso}}\xi,\\
- \hat\alpha\dfrac{\tau^D}{\vert\tau^D\vert} + \dfrac{1}{3}tr(\tau), & \text{if }\vert\tau^D\vert > \sigma_0 + \gamma^{\text{iso}}\xi,
- \end{cases}@f}
-with the radius
-@f{gather*}\hat\alpha := \sigma_0 + \gamma^{\text{iso}}\xi .@f}
-With the relation $\xi = \vert\varepsilon(u) - A\sigma\vert$ it is possible to eliminate $\xi$ inside the projection $P_{\Pi}$:\\
-@f{gather*}P_{\Pi}(\tau):=\begin{cases}
- \tau, & \text{if }\vert\tau^D\vert \leq \sigma_0,\\
- \alpha\dfrac{\tau^D}{\vert\tau^D\vert} + \dfrac{1}{3}tr(\tau), & \text{if }\vert\tau^D\vert > \sigma_0,
- \end{cases}@f}
-@f{gather*}\alpha := \sigma_0 + \dfrac{\gamma^{\text{iso}}}{2\mu+\gamma^{\text{iso}}}\left(\vert\tau^D\vert - \sigma_0\right) ,@f}
-with a further material parameter $\mu>0$ called shear modulus. We refer that
-this only possible for isotropic plasticity.
-
-To make things a bit easier from now on we denote
-@f{gather*}\gamma := \dfrac{\gamma^{\text{iso}}}{2\mu +
-\gamma^{\text{iso}}}\in[0,1)\text{ with }\gamma^{\text{iso}}\in[0,\infty),@f}
-@f{gather*}\beta :=\dfrac{\sigma_0}{\vert\tau^D\vert}.@f}
-If $\gamma^{\text{iso}}$ tends to zero $\gamma$ tends also to zero. And if $\gamma^{\text{iso}}$ tends to
-infinity $\gamma$ tends to one. This allows us to reformulate our problem as
-follows
-@f{gather*}P_{\Pi}(\tau):=\begin{cases}
- \tau, & \text{if }\vert\tau^D\vert \leq \sigma_0,\\
- \gamma\tau^D + (1-\gamma)\beta\tau^D
- + \dfrac{1}{3}tr(\tau), & \text{if }\vert\tau^D\vert >
- \sigma_0, \end{cases}.@f}
-For further details e.g., see Suttmeier: On Plasticity with Hardening:
-An Adaptive Finite Element Discretisation, International Mathematical Forum, 5,
-2010, no. 52, 2591-2601.
-
-So what we do is to calculate the stresses by using Hooke's law for linear elastic, isotropic materials
-@f{gather*}\sigma = C \varepsilon(u) = 2\mu \varepsilon^D(u) + \kappa tr(\varepsilon(u))I = \left[2\mu\left(\mathbb{I} -\dfrac{1}{3} I\otimes I\right) + \kappa I\otimes I\right]\varepsilon(u)@f}
-with the material parameter $\kappa>0$ (bulk modulus). The variables $I$ and
-$\mathbb{I}$ denote the identity tensors of second and forth order. In that
-notation $2\mu \varepsilon^D(u)$ is the deviatoric part and $\kappa
-tr(\varepsilon(u))$ the volumetric part of the stress tensor.
-
-In the next step we test in a pointwise sense where the deviator part of the
-stress in a norm is bigger than the yield stress. If there are such points we
-project the deviator stress in those points back to the yield surface. Methods of this kind are called projections algorithm or radial-return-algorithm.
-
-Now we have a primal formulation of our elasto-plastic contact problem which only depends on the displacement $u$.
-It consists of a nonlinear variational inequality and has a unique solution as
-it satisfies the theorem of Lions and Stampaccia. A proof can be found in
-Rodrigues: Obstacle Problems in Mathematical Physics, North-Holland, Amsterdam,
-1987.
-
-To handle the nonlinearity of the constitutive law we use a Newton method and to deal with the contact we apply an
-active set method like in step-41. To be more concrete we combine both methods to an inexact semi smooth Newton
-method - inexact since we use an iterative solver for the linearised problems in each Newton step.
-
-
-<h3>Linearisation of the constitutive law for the Newton method</h3>
-
-For the Newton method we have to linearise the following semi-linearform
-@f{gather*}a(\psi;\varphi) := \left(P_{\Pi}(C\varepsilon(\psi)),\varepsilon(\varphi)\right).@f}
-Because we have to find the solution $u$ in the convex set $V^+$, we have to
-apply an SQP-method (SQP: sequential quadratic programming). That means we have
-to solve a minimisation problem for a known $u^i$ in every SQP-step of the form
-@f{eqnarray*}
- & & a(u^{i};u^{i+1} - u^i) + \dfrac{1}{2}a'(u^i;u^{i+1} - u^i,u^{i+1} - u^i)\\
- &=& a(u^i;u^{i+1}) - a(u^i;u^i) +\\
- & & \dfrac{1}{2}\left( a'(u^i;u^{i+1},u^{i+1}) - 2a'(u^i;u^i,u^{i+1}) - a'(u^i;u^i,u^i)\right)\\
- &\rightarrow& \textrm{min},\quad u^{i+1}\in V^+.
-@f}
-Neglecting the constant terms $ a(u^i;u^i)$ and $ a'(u^i;u^i,u^i)$ we obtain the
-following minimisation problem @f{gather*}\dfrac{1}{2} a'(u^i;u^{i+1},u^{i+1}) - F(u^i)\rightarrow \textrm{min},\quad u^{i+1}\in V^+@f} with
-@f{gather*}F(\varphi) := \left(a'(\varphi;\varphi,u^{i+1}) - a(\varphi;u^{i+1}) \right).@f}
-In the case of our constitutive law the Fréchet derivative of the
-semi-linearform $a(.;.)$ at the point $u^i$ is
-
-@f{gather*}a'(u^i;\psi,\varphi) =
-(I(x)\varepsilon(\psi),\varepsilon(\varphi)),\quad x\in\Omega,@f}
-@f{gather*}
-I(x) := \begin{cases}
-C_{\mu} + C_{\kappa}, &
-\quad \vert \tau^D \vert \leq \sigma_0\\
-\gamma C_{\mu} + (1-\gamma)\beta\left(C_{\mu} -
-2\mu\dfrac{\tau^D\otimes\tau^D}{\vert\tau^D\vert^2}\right) + C_{\kappa}, &\quad
-\vert \tau^D \vert > \sigma_0
-\end{cases}
+$\mathcal{F}(\sigma,\varepsilon^p) = \vert\sigma^D\vert - (\sigma_0 +
+\gamma^{\text{iso}}|\varepsilon^p|)$.
+
+
+<h3>Reformulation as a variational inequality</h3>
+
+It is generally rather awkward to deal with inequalities. Here, we have to deal with
+two: plasticity and the contact problem.
+As described in more detail in the paper mentioned at the top of this page, one
+can at least reformulate the plasticity in a way that makes it look like a
+nonlinearity that we can then treat with Newton's method. This is slightly
+tricky mathematically since the nonlinearity is not just some smooth
+function but instead has kinks where the stress reaches the yield stress;
+however, it can be shown for such <i>semismooth</i> functions that Newton's
+method still converges.
+
+Without going into details, we will also get rid of the stress as an independent
+variable and instead work exclusively with the displacements $\mathbf u$. Ultimately,
+the goal of this reformulation is that we will want to end up with a symmetric,
+positive definite problem - such as a linearized elasticity problem with spatially
+variable coefficients resulting from the plastic behavior - that needs to be solved
+in each Newton step. We want this because there are efficient and scalable methods
+for the solution of such linear systems, such as CG preconditioned with an
+algebraic multigrid. This is opposed to the saddle point problem akin to the mixed
+Laplace (see step-20) we would get were we to continue with the mixed formulation
+containing both displacements and stresses, and for which step-20 already gives a
+hint at how difficult it is to construct good solvers and preconditioners.
+
+With this said, let us simply state the problem we obtain after reformulation
+(again, details can be found in the paper): Find a displacement $\mathbf u \in
+V^+$ so that
+@f{align*}
+\left(P_{\Pi}(C\varepsilon(\mathbf u)),\varepsilon(\varphi) - \varepsilon(\mathbf u)\right) \geq 0,\quad \forall \varphi\in V^+.
@f}
-with
-@f{gather*}C_{\mu} := 2\mu\left(\mathbb{I} - \dfrac{1}{3} I\otimes
-I\right)\quad\text{(shear part of the stress strain tensor)},@f}
-@f{gather*}C_{\kappa} := \kappa I\otimes I\quad\text{(bulk part of the stress strain
-tensor)},@f}
-@f{gather*}\tau^D := C\varepsilon^D(u^i).@f}
-Remark that $a(.;.)$ is not differentiable in the common sense but it is
-slantly differentiable like the function for the contact problem and again we refer to
-Hintermueller, Ito, Kunisch: The primal-dual active set strategy as a semismooth newton method, SIAM J. OPTIM., 2003, Vol. 13, No. 3, pp. 865-888.
-Again the first case is for elastic and the second for plastic deformation.
-
-
-<h3>Formulation as a saddle point problem</h3>
-
-Just as in step-41 we compose a saddle point problem out of the minimisation
-problem. Again we do so to gain a formulation that allows us to solve a linear
-system of equations finally.
-
-We introduce a Lagrange multiplier $\lambda$ and the convex cone $K\subset W'$,
-$W'$ dual space of the trace space $W:=\left[ H_0^{\frac{1}{2}}(\Gamma_C)
-\right]^{\textrm{dim}}$ of $V$ restricted to $\Gamma_C$,
-@f{gather*}K:=\{\mu\in W':\mu_T = 0,\quad\langle\mu n,v\rangle_{\Gamma_C}\geq 0,\quad
-\forall v\in H_0^{\frac{1}{2}}(\Gamma_C), v \ge 0\text{ on }\Gamma_C \}@f}
-of Lagrange multipliers, where $\langle\cdot,\cdot\rangle$
-denotes the duality pairing, i.e. a boundary integral, between $W'$ and $W$.
-Intuitively, $K$ is the cone of all "non-positive functions", except that $ K\subset
-\left( \left[ H_0^{\frac{1}{2}}(\Gamma_C) \right]^{\textrm{dim}} \right)' $ and so contains other
-objects besides regular functions as well. This yields:
-
-Find $u\in V$ and $\lambda\in K$ such that
+where the projector $P_\Pi$ is defined as
@f{align*}
- \hat{a}(u,v) + b(v,\lambda) &= f(v),\quad &&v\in V\\
- b(u,\mu - \lambda) &\leq \langle g,(\mu -
- \lambda)n\rangle_{\Gamma_C},\quad&&\mu\in K,
+ P_{\Pi}(\tau):=\begin{cases}
+ \tau, & \text{if }\vert\tau^D\vert \leq \sigma_0,\\
+ \left[
+ \dfrac{\gamma^{\text{iso}}}{2\mu + \gamma^{\text{iso}}} +
+ \left(1-\dfrac{\gamma^{\text{iso}}}{2\mu + \gamma^{\text{iso}}}\right)\dfrac{\sigma_0}{\vert\tau^D\vert}
+ \right]\tau^D
+ + \dfrac{1}{3}\text{trace}(\tau) I, & \text{if }\vert\tau^D\vert >
+ \sigma_0,
+ \end{cases}
@f}
-with
+and the space $V^+$ is the space of all displacements that satisfy the contact
+condition:
@f{align*}
- \hat{a}(u,v) &:= a'(u^i;u,v)\\
- b(u,\mu) &:= \langle un,\mu n\rangle_{\Gamma_C},\quad &&u\in V,\quad\mu\in W'.
+ V
+ &=
+ \left\{ \mathbf u\in \left[H^1(\Omega)\right]^{d}:
+ \mathbf u = 0 \text{ on } \Gamma_D\right\},
+ \\
+ V^+
+ &=
+ \left\{ \mathbf u\in V: \mathbf n \cdot \mathbf u\leq g \text{ on } \Gamma_C \right\}.
@f}
-As in the section before $u^i$ denotes the linearization point for the
-semi-linearform $a(.;.)$. In contrast to step-41 we directly consider $\lambda$
-as the additional, positive force $\sigma(u)n$ that the obstacle
-exerts on the boundary $\Gamma_C$ of the body.
-The existence and uniqueness of the analytical solution $(u,\lambda)\in V\times
-K$ of this saddle point problem has been stated in Glowinski, Lions and Tr\'{e}moli\`{e}res: Numerical
-Analysis of Variational Inequalities, North-Holland, 1981.
+Given this formulation, we will apply two techniques:
+- Run a Newton method to iterate out the nonlinearity in the projector.
+- Run an active set method for the contact condition, in much the same
+ way as we did in step-41.
+
+A strict approach would keep the active set fixed while we iterate
+the Newton method to convergence (or maybe the other way around: find the
+final active set before moving on to the next Newton iteration).
+In practice, it turns out that it is sufficient to do only a single
+Newton step per active set iteration, and so we will iterate over them
+concurrently. We will also, every once in a while, refine the mesh.
-NOTE: In this example as well as in the further documentation we make the
-assumption that the normal vector $n$ equals to $(0,0,1)$. This comes up with
-the starting condition of our deformable body.
+
+<h3>A Newton method for the plastic nonlinearity</h3>
+
+As mentioned, we will treat the nonlinearity of the operator $P_\Pi$ by
+applying a Newton method, despite the fact that the operator is not differentiable
+in the strict sense. However, it satisfies the conditions of <i>slant</i>
+differentiability and this turns out to be enough for Newton's method to work.
+The resulting method then goes by the name <i>semi-smooth Newton method</i>,
+which sounds impressive but is, in reality, just a Newton method applied to
+a semi-smooth function with an appropriately chosen "derivative".
+
+In the current case, we will run our iteration by solving in each iteration $i$
+the following equation (still an inequality, but linearized):
+@f{align*}
+ \label{eq:linearization}
+ \left(I_{\Pi}\varepsilon(\tilde {\mathbf u}^{i}),
+ \varepsilon(\varphi) - \varepsilon(\tilde {\mathbf u}^{i})\right) \geq 0,
+ \quad \forall \varphi\in V^+,
+@f}
+where the rank-4 tensor $I_\Pi=I_\Pi(\varepsilon^D(\mathbf u^{i-1}))$ given by
+@f{align}
+ I_\Pi = \begin{cases}
+ C_{\mu} + C_{\kappa}, & \hspace{-8em}\hfill \text{if } \vert C\varepsilon^D(\mathbf u^{i-1}) \vert \leq \sigma_0,
+ \\
+ \frac{\gamma^{\text{iso}}}{2\mu + \gamma^{\text{iso}}} C_{\mu} + \frac{\left(1-\frac{\gamma^{\text{iso}}}{2\mu + \gamma^{\text{iso}}}\right)\sigma_0}{\vert C\varepsilon^D(\mathbf u^{i-1}) \vert}\left(C_{\mu} -
+ 2\mu\dfrac{C\varepsilon^D(\mathbf u^{i-1})\otimes C\varepsilon^D(\mathbf
+ u^{i-1})}{\vert C\varepsilon^D(\mathbf u^{i-1})\vert^2}\right) + C_{\kappa}, & \text{ else.}
+\end{cases}
+@f}
+This tensor is the (formal) linearization of $P_\Pi(C\cdot)$ around $\varepsilon^D(\mathbf u^{i-1})$.
+For the linear isotropic material we consider here,
+the bulk and shear components of the projector are given by
+@f{gather*}
+ C_{\kappa} = \kappa I\otimes I,
+ \qquad\qquad\qquad\qquad
+ C_{\mu} = 2\mu\left(\mathbb{I} - \dfrac{1}{3} I\otimes
+ I\right),
+@f}
+where $I$
+and $\mathbb{I}$ are the identity tensors of rank 2 and 4, respectively.
+
+Note that this problem corresponds to a linear elastic contact problem
+where $I_\Pi$ plays the role of the elasticity tensor $C=A^{-1}$. Indeed,
+if the material is not plastic at a point, then $I_\Pi=C$. However, at
+places where the material is plastic, $I_\Pi$ is a spatially varying
+function. In any case, the system we have to solve for the Newton iterate
+$\tilde {\mathbf u}^{i}$ gets us closer to the goal of rewriting our problem in
+a way that allows us to use well-known solvers and preconditioners for
+elliptic systems.
+
+As a final note about the Newton method let us mention that as is common with
+Newton methods we need to globalize it by controlling the step length. In
+other words, while the system above solves for $\tilde {\mathbf u}^{i}$, the final
+iterate will rather be
+@f{align*}
+ {\mathbf u}^{i} = {\mathbf u}^{i-1} + \alpha_i (\tilde {\mathbf u}^{i} - {\mathbf u}^{i-1})
+@f}
+where the difference in parentheses on the right takes the role of the
+traditional Newton direction, $\delta {\mathbf u}^{i}$. We will determine
+$\alpha^i$ using a standard line search.
<h3>Active Set methods to solve the saddle point problem</h3>
-The linearized problem is essentially like a pure elastic problem with contact like
+This linearized problem to be solved in each Newton step is essentially like
in step-41. The only difference consists in the fact that the contact area
is at the boundary instead of in the domain. But this has no further consequence
so that we refer to the documentation of step-41 with the only hint that
-$\mathcal{S}$ containts all the vertices at the contact boundary $\Gamma_C$ this
-time.
+$\mathcal{S}$ contains all the vertices at the contact boundary $\Gamma_C$ this
+time. As there, what we need to do is keep a subset of degrees of freedom fixed,
+leading to additional constraints that one can write as a saddle point problem.
+However, as discussed in the paper, by writing these constraints in an
+appropriate way that removes the coupling between degrees of freedom,
+we end up with a set of nodes that essentially just have Dirichlet values
+attached to them.
-<h3>The primal-dual active set algorithm combined with the inexact semi smooth
-Newton method</h3>
+<h3>Overall algorithm</h3>
-Now we describe an algorithm that combines the damped semismooth Newton-method,
+The algorithm outlined above combines the damped semismooth Newton-method,
which we use for the nonlinear constitutive law, with the semismooth Newton
-method for the contact. It sums up the results of the sections before and works as follows:
+method for the contact. It works as follows:
<ol>
- <li> Initialize $\mathcal{A}_k$ and $\mathcal{F}_k$, such that
- $\mathcal{S} = \mathcal{A}_k \cup \mathcal{F}_k$ and $\mathcal{A}_k \cap
- \mathcal{F}_k = \emptyset$ and set $k = 1$. The start value $\hat U^0 :=
- P_{\mathcal{A}_k}(0)$ fullfills our obstacle condition.
- <li> Assemble the Newton matrix $A := a'(\hat
- U^{k-1};\varphi_p,\varphi_q)$ and the right-hand-side $F(\hat U^{k-1})$.
- <li> Find the primal-dual pair $(\bar U^k,\Lambda^k)$ that satisfies
+ <li> Initialize the active and inactive sets $\mathcal{A}_i$ and $\mathcal{F}_i$
+ such that $\mathcal{S} = \mathcal{A}_i \cup \mathcal{F}_i$ and $\mathcal{A}_i \cap
+ \mathcal{F}_i = \emptyset$ and set $i = 1$. Here, $\mathcal{S}$ is the set of
+ all degrees of freedom located at the surface of the domain where contact
+ may happen.
+ The start value $\hat U^0 :=
+ P_{\mathcal{A}_k}(0)$ fulfills our obstacle condition, i.e., we project an
+ initial zero displacement onto the set of feasible displacements.
+
+ <li> Assemble the Newton matrix $A_{pq} := a'(
+ U^{i-1};\varphi_p,\varphi_q)$ and the right-hand-side $F(\hat U^{i-1})$.
+ These correspond to the linearized Newton step, ignoring for the moment
+ the contact inequality.
+
+ <li> Find the primal-dual pair $(\tilde U^i,\Lambda^i)$ that satisfies
@f{align*}
- A\bar U^k + B\Lambda^k & = F, &\\
- \left[B^T\bar U^k\right]_p & = G_p & \forall p\in\mathcal{A}_k,\\
- \Lambda^k_p & = 0 & \forall p\in\mathcal{F}_k.
+ A\tilde U^i + B\Lambda^i & = F, &\\
+ \left[B^T\tilde U^i\right]_p & = G_p & \forall p\in\mathcal{A}_i,\\
+ \Lambda^i_p & = 0 & \forall p\in\mathcal{F}_i.
@f}
- <li> Damping for $k>2$ by applying a line search and calculating a linear
- combination of $U^{k-1}$ and $\bar U^k$. Find an
- $\alpha_i:=2^{-i},(i=0,\ldots,10)$ so that
- @f{gather*}U^k := \alpha_i\bar U^k +
- (1-\alpha_i)U^{k-1}@f}
- yields
- @f{gather*}\vert F\left(U^{k}\right) \vert < \vert F\left(U^{k-1}\right) \vert.\f}
+ As in step-41, we can obtain the solution to this problem by eliminating
+ those degrees of freedom in ${\cal A}_i$ from the first equation and
+ obtain a linear system $\hat {\hat A}(U^{i-1}) \tilde U^i = \hat {\hat H}(U^{i-1})$.
+
+
+
+ <li> Damp the Newton iteration for $i>2$ by applying a line search and
+ calculating a linear combination of $U^{i-1}$ and $\tilde U^i$. This
+ requires finding an
+ $\alpha^i_l:=2^{-l},(l=0,\ldots,10)$ so that
+ @f{gather*}U^i := \alpha^i_l\bar U^i +
+ (1-\alpha^i_l)U^{i-1}@f}
+ satisfies
+ @f{gather*}
+ \vert F\left(U^{i}\right) \vert < \vert F\left(U^{i-1}\right) \vert.
+ \f}
+
<li> Define the new active and inactive sets by
- @f{gather*}\mathcal{A}_{k+1}:=\lbrace p\in\mathcal{S}:\Lambda^k_p +
- c\left(\left[B^TU^k\right]_p - G_p\right) > 0\rbrace,@f}
- @f{gather*}\mathcal{F}_{k+1}:=\lbrace p\in\mathcal{S}:\Lambda^k_p +
- c\left(\left[B^TU^k\right]_p - G_p\right) \leq 0\rbrace.@f}
- Projection $U^k$ so that it holds the second equation in (2)
- @f{gather*}\hat U^K := P_{\mathcal{A}_{k+1}}(U^k).@f}
- <li> If $\mathcal{A}_{k+1} = \mathcal{A}_k$ and $\vert
- F\left(U^{k}\right) \vert < \delta$ then stop, else set $k=k+1$ and go to
- step (1).
+ @f{gather*}\mathcal{A}_{i+1}:=\lbrace p\in\mathcal{S}:\Lambda^i_p +
+ c\left(\left[B^TU^i\right]_p - G_p\right) > 0\rbrace,@f}
+ @f{gather*}\mathcal{F}_{i+1}:=\lbrace p\in\mathcal{S}:\Lambda^i_p +
+ c\left(\left[B^TU^i\right]_p - G_p\right) \leq 0\rbrace.@f}
+
+ <li>Project $U^i$ so that it satisfies the contact inequality,
+ @f{gather*}\hat U^i := P_{\mathcal{A}_{i+1}}(U^i).@f}
+ Here,
+ $P_{\mathcal{A}}(U)$ is the projection of the active
+ components in $\mathcal{A}$ to the gap
+ @f{gather*}P_{\mathcal{A}}(U)_p:=\begin{cases}
+ U_p, & \textrm{if}\quad p\notin\mathcal{A}\\
+ g_{h,p}, & \textrm{if}\quad
+ p\in\mathcal{A},
+ \end{cases}@f}
+ where $g_{h,p}$ is the <i>gap</i> denoting the distance of the obstacle
+ from the undisplaced configuration of the body.
+
+ <li> If $\mathcal{A}_{i+1} = \mathcal{A}_k$ and $\vert
+ F\left(U^{i}\right) \vert < \delta$ then stop, else set $i=i+1$ and go to
+ step (1). This step ensures that we only stop iterations if both the correct
+ active set has been found and the plasticity has been iterated to sufficient
+ accuracy.
</ol>
-The subscript $p$ denotes a vertex and the meaning of the
-decorated and none decorated $U$ is as follows: $\bar U$ denotes the solution of the linear system of equations in (2), $U$ is the
-damped solution and equals to $\bar U$ if the damping parameter $\alpha_0 =
-1$ and $\hat U := P_{\mathcal{A}}(U)$ is the projection of the active
-components in $\mathcal{A}$ to the gap
-
-@f{gather*}P_{\mathcal{A}}(U):=\begin{cases}
-U_p, & \textrm{if}\quad p\notin\mathcal{A}\\
-g_{h,p}, & \textrm{if}\quad
-p\in\mathcal{A}.
-\end{cases}@f}\\
-The matrix $B\in\mathbb{R}^{n\times m}$, $n>m$ describes the coupling of the
-bases for the displacements and lagrange multiplier (contact forces)
+In step 3 of this algorithm,
+the matrix $B\in\mathbb{R}^{n\times m}$, $n>m$ describes the coupling of the
+bases for the displacements and Lagrange multiplier (contact forces)
and it is not quadratic in our situation since $\Lambda^k$ is only defined on
-$\Gamma_C$. Due to the ansatz functions $\psi_i$ (scalar valued) of the
-lagrange multiplier are fullfilling the following biorthogonal condition (see Hüeber, Wohlmuth: A primal–dual active
+$\Gamma_C$, i.e., the surface where contact may happen. As shown in the paper,
+we can choose $B$ to be a matrix that has only one entry per row,
+(see also Hüeber, Wohlmuth: A primal-dual active
set strategy for non-linear multibody contact problems, Comput. Methods Appl. Mech. Engrg.
-194, 2005, pp. 3147-3166)
-@f{gather} \int\limits_{\Gamma_C}\psi_i(x)\varphi_j(x)dx =
-\delta_{ij}\int\limits_{\Gamma_C}\varphi_j(x)dx@f}
-this yields
-@f{gather*}B_{pq} = \begin{cases}
-\int\limits_{\Gamma_C}\varphi_p(x)dxI_3, & \text{if}\quad p=q,\quad
-p,q\in\mathcal{S}\\
-0I_3, & \text{if}\quad p\neq q,\quad p\textrm{ or }q\notin\mathcal{S}.
-\end{cases}@f}
-Here $I_3$ denotes the threedimensional identity matrix.
-In our programm we use the structure of a quadratic sparse for
-$B\in\mathbb{R}^{n\times n}$ and for $\Lambda^k$ a vector with length $n$ where
-$\Lambda^k_p = 0$ for $p\notin \mathcal{S}$.
+194, 2005, pp. 3147-3166).
The vector $G$ is defined by a suitable approximation $g_h$ of the gap $g$
@f{gather*}G_p = \begin{cases}
-g_{h,p}\int\limits_{\Gamma_C}\varphi_p(x)dx, & \text{if}\quad p\in\mathcal{S}\\
+g_{h,p}, & \text{if}\quad p\in\mathcal{S}\\
0, & \text{if}\quad p\notin\mathcal{S}.
\end{cases}@f}
-Note that $G_p$ is a threedimensional vector and that again we applied the
-biorthogonal property of the lagrange multiplier ansatz functions to the
-integral $\int\limits_{\Gamma_C}g_h(x)\varphi_p(x)dx$ with $g_h(x)=\sum\limits_i
-g_{h,p}\varphi_p(x)$ (see the reference mentioned above).
-
-Compared to step-41, step (1) is added but it should be clear
-from the sections above that we only linearize the problem. In step (2) we have
-to solve a linear system of equations again. And now the solution has to fulfill two stopping
-criteria. $\mathcal{A}_{k+1} = \mathcal{A}_k$ makes sure that the contact zones
-are iterated out and the second ensures an accurate enough residual which means
-that the plastic zones are also iterated out.
-
-A similar method can also be found in Brunssen, Schmid, Schäfer,
-Wohlmuth: A fast and robust iterative solver for nonlinear contact problems
-using a primal-dual active set strategy and algebraic multigrid, Int. J. Numer.
-Meth. Engng, 2007, 69, pp. 524-543. But in advance we apply a line search to
-obtain a more robust method regarding the start value. Solving an elastic
-problem in the very first step ($k=1$) we get a reasonable start value but as
-you can see in the results damping is important if we choose for example a ball as
-obstacle.
-
-Damping our Newton method is more important for the nonlinearity cause by the
-constitutive law as for the contact. For this reason we start to damp our method
-for $k>2$ when we have two plastic iterations. Note that $U^1$ is a solution of
-an elastic problem and $U^2$ is the first plastic solution. A linear combination
-between these both results in stresses which are not in the convex set
-of the feasible stresses.
-
<h3>Adaptive mesh refinement</h3>
-Since we run our program in 3d, there is a good reason to use adaptive
-mesh refinement. To make things a bit easier we are choosing the
+Since we run our program in 3d, the computations the program performs are
+expensive. Consequently using adaptive mesh refinement is an important step towards
+staying within acceptable run-times. To make our lives easier we simply choose the
KellyErrorEstimator that is already implemented in deal.II. We hand the
solution vector to it which contains the displacement $u$. As we will see in the
results it yields a quite reasonable adaptive mesh for the contact zone as well
-as for plasticity!
+as for plasticity.
<h3>Implementation</h3>
(like in step-32). Since we are trying to solve a similar problem like in
step-41 we will use the same methods but now in parallel.
-Another difficulty is the handling of the different constraints from
-(the dirichlet conditons), the hanging nodes and the inequality condition that
+A difficulty is handling of the constraints from
+the Dirichlet conditions, hanging nodes and the inequality condition that
arises from the contact. For this purpose we create three objects of type
-ConstraintMatrix.
-
-Beside the ConstitutiveLaw class there is another new class called Input. This
-class allows us to read in an obstacle from a file. In our example the file
-'obstacle_file.dat' containts data which describe an Chinese, Japanese or
-Korean symbol for force or power. (See http://www.orientaloutpost.com/ :
-"This word can be used for motivation - it
-can also mean power/motion/propulsion/force. It can be anything
-internal or external that keeps you going. This is the safest way to express
-motivation in Chinese. If your audience is Japanese, please see the other entry
-for motivation. This is a word in Japanese and Korean, but it means "motive
-power" or "kinetic energy" (without the motivation meaning that you are
-probably looking for)".)
+ConstraintMatrix that describe the various constraints and that we will
+combine as appropriate in each iteration.
+
+Compared to step-41, the programs has a few new classes:
+
+<ul>
+<li> <code>ConstitutiveLaw</code> describes the plastic behavior of the
+ material
+
+<li> <code>SphereObstacle</code> describes a sphere that serves as the
+ obstacle that is pushed into the deformable, elastoplastic body.
+ Whether this or the next class is used to describe the obstacle is
+ determined from the input parameter file.
+
+<li> <code>ChineseObstacle</code> (and a helper class) is a class that
+ allows us to read in an obstacle from a file. In the example we
+ will show in the results section, this file will be
+ <code>'obstacle_file.dat'</code> and will correspond to data that shows the
+ Chinese, Japanese or
+ Korean symbol for force or power (see http://www.orientaloutpost.com/ :
+ "This word can be used for motivation - it
+ can also mean power/motion/propulsion/force. It can be anything
+ internal or external that keeps you going. This is the safest way to express
+ motivation in Chinese. If your audience is Japanese, please see the other entry
+ for motivation. This is a word in Japanese and Korean, but it means "motive
+ power" or "kinetic energy" (without the motivation meaning that you are
+ probably looking for)"). In essence, we will pretend that we have a stamp
+ (i.e., a mask that corresponds to a flat bottomed obstacle with no pieces
+ of intermediate height) that we press into the body. The symbol in question
+ looks as follows (see also the picture at
+ the top of this section on how the end result looks like):
+
+ <img src="http://www.dealii.org/images/steps/developer/step-42.character.png" alt="" width="25%">
+</ul>
+
For each adaptive refinement cycle the iterations end if the active set doesn't
change anymore and if the residual is accurate enough. In the tables
-at the end of each cycle you find informations about computing time and the
+at the end of each cycle you find information about computing time and the
number of calls of different parts of the program like Assembling or calculating
the residual. In the second cycle there are 12 calls for the residual function
and only 10 calls for Solving or Assembling what means that two damping steps were
Chinese symbol as obstacle it turns out that an elastic start solution for each
cycle results in fewer Newton iterations.
-In every refinement step you can observe that the acitve set - the contact points -
+In every refinement step you can observe that the active set - the contact points -
are iterated out at first. After that the Newton method has only to struggle with the
plasticity. For the finer meshes there is quadratic convergence not until the
last 4 or 5 Newton iterations.
<table align="center">
<tr>
<td>
- @image html step-42-CellConstitutionColorbar.png
+ <img src="http://www.dealii.org/images/steps/developer/step-42.CellConstitutionColorbar.png" alt="">
</td>
<td>
- @image html step-42-CellConstitutionBall2.png
+ <img src="http://www.dealii.org/images/steps/developer/step-42.CellConstitutionBall2.png" alt="">
</td>
<td valign="top">
</td>
<td>
- @image html step-42-CellConstitutionLi2.png
+ <img src="http://www.dealii.org/images/steps/developer/step-42.CellConstitutionLi2.png" alt="">
</td>
</tr>
</table>
The picture shows the adaptive refinement and as well how much a cell is
-plastified druing the contact with the ball. Remember that we consider the
+plastified during the contact with the ball. Remember that we consider the
norm of the deviator part of the stress in each quadrature point to
see if there is elastic or plastic behavior. In the middle of the top -
where the mesh is finest - you can see the hollow caused by the ball. The blue
<h1>Possibilities for extensions</h1>
Extend the program from a static to a quasi-static problem, perhaps by choosing a
-backward-euler-scheme for the time discretization (for theoretical results see Frohne: FEM-Simulation
+backward-Euler-scheme for the time discretization (for theoretical results see Frohne: FEM-Simulation
der Umformtechnik metallischer Oberflächen im Mikrokosmos, Ph.D. thesis,
University of Siegen, Germany, 2011).
change of some material parameters.
It might be of interest to implement more accurate, problem-adapted error
-estimators for contact as well as for the plasticity.
\ No newline at end of file
+estimators for contact as well as for the plasticity.
--- /dev/null
+# Listing of Parameters
+# ---------------------
+
+# polynomial degree of the FE_Q finite element space, typically 1 or 2
+set polynomial degree = 1
+
+# number of initial global refinements before the first computation
+set number of initial refinements = 3
+
+# number of adaptive cycles to run
+set number of cycles = 12
+
+# refinement strategy for each cycle:
+# global: one global refinement
+# percentage: fixed percentage gets refined using kelly
+# fix dofs: tries to achieve 2^initial_refinement*300 dofs after cycle 1 (only
+# use 2 cycles!). Changes the coarse mesh!
+set refinement strategy = percentage
+
+# obstacle file to read, leave empty to use a sphere or 'obstacle_file.pbm'
+set obstacle filename =
+
+# directory to put output files (graphical output and benchmark statistics,
+# leave empty to put into current directory
+set output directory = p1adaptive
--- /dev/null
+# Listing of Parameters
+# ---------------------
+
+# polynomial degree of the FE_Q finite element space, typically 1 or 2
+set polynomial degree = 1
+
+# number of initial global refinements before the first computation
+set number of initial refinements = 3
+
+# number of adaptive cycles to run
+set number of cycles = 12
+
+# refinement strategy for each cycle:
+# global: one global refinement
+# percentage: fixed percentage gets refined using kelly
+# fix dofs: tries to achieve 2^initial_refinement*300 dofs after cycle 1 (only
+# use 2 cycles!). Changes the coarse mesh!
+set refinement strategy = percentage
+
+# obstacle file to read, leave empty to use a sphere or 'obstacle_file.pbm'
+set obstacle filename = obstacle_file.pbm
+
+# directory to put output files (graphical output and benchmark statistics,
+# leave empty to put into current directory
+set output directory = p1adaptive
--- /dev/null
+# Listing of Parameters
+# ---------------------
+
+# polynomial degree of the FE_Q finite element space, typically 1 or 2
+set polynomial degree = 1
+
+# number of initial global refinements before the first computation
+set number of initial refinements = 3
+
+# number of adaptive cycles to run
+set number of cycles = 7
+
+# refinement strategy for each cycle:
+# global: one global refinement
+# percentage: fixed percentage gets refined using kelly
+# fix dofs: tries to achieve 2^initial_refinement*300 dofs after cycle 1 (only
+# use 2 cycles!). Changes the coarse mesh!
+set refinement strategy = global
+
+# obstacle file to read, leave empty to use a sphere or 'obstacle_file.pbm'
+set obstacle filename =
+
+# directory to put output files (graphical output and benchmark statistics,
+# leave empty to put into current directory
+set output directory = p1global
--- /dev/null
+# Listing of Parameters
+# ---------------------
+
+# polynomial degree of the FE_Q finite element space, typically 1 or 2
+set polynomial degree = 2
+
+# number of initial global refinements before the first computation
+set number of initial refinements = 2
+
+# number of adaptive cycles to run
+set number of cycles = 11
+
+# refinement strategy for each cycle:
+# global: one global refinement
+# percentage: fixed percentage gets refined using kelly
+# fix dofs: tries to achieve 2^initial_refinement*300 dofs after cycle 1 (only
+# use 2 cycles!). Changes the coarse mesh!
+set refinement strategy = percentage
+
+# obstacle file to read, leave empty to use a sphere or 'obstacle_file.pbm'
+set obstacle filename =
+
+# directory to put output files (graphical output and benchmark statistics,
+# leave empty to put into current directory
+set output directory = p2adaptive
--- /dev/null
+# Listing of Parameters
+# ---------------------
+
+# polynomial degree of the FE_Q finite element space, typically 1 or 2
+set polynomial degree = 2
+
+# number of initial global refinements before the first computation
+set number of initial refinements = 3
+
+# number of adaptive cycles to run
+set number of cycles = 6
+
+# refinement strategy for each cycle:
+# global: one global refinement
+# percentage: fixed percentage gets refined using kelly
+# fix dofs: tries to achieve 2^initial_refinement*300 dofs after cycle 1 (only
+# use 2 cycles!). Changes the coarse mesh!
+set refinement strategy = global
+
+# obstacle file to read, leave empty to use a sphere or 'obstacle_file.pbm'
+set obstacle filename =
+
+# directory to put output files (graphical output and benchmark statistics,
+# leave empty to put into current directory
+set output directory = p2global
-/* $Id$ */
-/* Author: Wolfgang Bangerth, University of Heidelberg, 1999 */
-
-/* $Id$ */
-/* */
-/* Copyright (C) 1999-2012 by the deal.II authors */
-/* */
-/* This file is subject to QPL and may not be distributed */
-/* without copyrightG and license information. Please refer */
-/* to the file deal.II/doc/license.html for the text and */
-/* further information on this license. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2012 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Authors: Joerg Frohne, Texas A&M University and
+ * University of Siegen, 2012, 2013
+ * Wolfgang Bangerth, Texas A&M University, 2012, 2013
+ * Timo Heister, Texas A&M University, 2013
+ */
// @sect3{Include files}
-
-// We are using the the same
-// include files as in step-41:
-
-#include <deal.II/grid/tria.h>
-#include <deal.II/dofs/dof_handler.h>
-#include <deal.II/grid/grid_generator.h>
-#include <deal.II/grid/tria_accessor.h>
-#include <deal.II/grid/tria_iterator.h>
-#include <deal.II/dofs/dof_accessor.h>
-#include <deal.II/dofs/dof_renumbering.h>
-#include <deal.II/fe/fe_q.h>
-#include <deal.II/fe/fe_system.h>
-#include <deal.II/dofs/dof_tools.h>
-#include <deal.II/fe/fe_values.h>
+// The set of include files is not much of a surprise any more at this time:
+#include <deal.II/base/conditional_ostream.h>
+#include <deal.II/base/parameter_handler.h>
+#include <deal.II/base/utilities.h>
+#include <deal.II/base/index_set.h>
#include <deal.II/base/quadrature_lib.h>
#include <deal.II/base/function.h>
-#include <deal.II/numerics/vector_tools.h>
-#include <deal.II/numerics/matrix_tools.h>
+#include <deal.II/base/timer.h>
+
#include <deal.II/lac/vector.h>
#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/sparsity_tools.h>
#include <deal.II/lac/sparse_matrix.h>
#include <deal.II/lac/block_sparsity_pattern.h>
-#include <deal.II/lac/solver_cg.h>
-#include <deal.II/lac/solver_gmres.h>
#include <deal.II/lac/solver_bicgstab.h>
#include <deal.II/lac/precondition.h>
#include <deal.II/lac/constraint_matrix.h>
-
#include <deal.II/lac/trilinos_sparse_matrix.h>
#include <deal.II/lac/trilinos_block_sparse_matrix.h>
#include <deal.II/lac/trilinos_vector.h>
#include <deal.II/lac/trilinos_precondition.h>
#include <deal.II/lac/trilinos_solver.h>
-#include <deal.II/base/conditional_ostream.h>
-#include <deal.II/base/utilities.h>
-#include <deal.II/base/index_set.h>
-#include <deal.II/lac/sparsity_tools.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/grid_tools.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/tria_boundary_lib.h>
+
#include <deal.II/distributed/tria.h>
#include <deal.II/distributed/grid_refinement.h>
+#include <deal.II/distributed/solution_transfer.h>
+
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/dofs/dof_accessor.h>
+#include <deal.II/dofs/dof_renumbering.h>
+#include <deal.II/dofs/dof_tools.h>
+#include <deal.II/fe/fe_q.h>
+#include <deal.II/fe/fe_system.h>
+#include <deal.II/fe/fe_values.h>
+
+#include <deal.II/numerics/vector_tools.h>
+#include <deal.II/numerics/matrix_tools.h>
#include <deal.II/numerics/data_out.h>
#include <deal.II/numerics/error_estimator.h>
-#include <deal.II/distributed/solution_transfer.h>
-#include <deal.II/base/timer.h>
+#include <deal.II/numerics/fe_field_function.h>
+
#include <fstream>
#include <iostream>
-#include <list>
-#include <time.h>
-
-#include <deal.II/base/logstream.h>
+// This final include file provides the <code>mkdir</code> function
+// that we will use to create a directory for output files, if necessary:
+#include <sys/stat.h>
namespace Step42
{
using namespace dealii;
- // @sect3{The <code>Input</code> class template}
+ // @sect3{The <code>ConstitutiveLaw</code> class template}
- // This class has the the only purpose
- // to read in data from a picture file
- // that has to be stored in pbm ascii
- // format. This data will be bilinear
- // interpolated and provides in this way
- // a function which describes an obstacle.
+ // This class provides an interface for a constitutive law, i.e., for the
+ // relationship between strain $\varepsilon(\mathbf u)$ and stress
+ // $\sigma$. In this example we are using an elastoplastic material behavior
+ // with linear, isotropic hardening. Such materials are characterized by
+ // Young's modulus $E$, Poisson's ratio $\nu$, the initial yield stress
+ // $\sigma_0$ and the isotropic hardening parameter $\gamma$. For $\gamma =
+ // 0$ we obtain perfect elastoplastic behavior.
//
- // The data which we read in by the
- // function read_obstacle () from the file
- // "obstacle_file.pbm" will be stored
- // in a double std::vector named
- // obstacle_data.
- // This vector composes the base
- // to calculate a piecewise bilinear
- // function as a polynomial interpolation.
- // This will be done by obstacle_function ().
- //
- // In the function run () of the class
- // PlasticityContactProblem we create
- // an object of the class Input which will
- // be used in the class Obstacle to
- // supply the obstacle function in
- // update_solution_and_constraints () of
- // the class PlasticityContactProblem.
-
+ // As explained in the paper that describes this program, the first Newton
+ // steps are solved with a completely elastic material model to avoid having
+ // to deal with both nonlinearities (plasticity and contact) at once. To this
+ // end, this class has a function <code>set_sigma_0()</code> that we use later
+ // on to simply set $\sigma_0$ to a very large value -- essentially
+ // guaranteeing that the actual stress will not exceed it, and thereby
+ // producing an elastic material. When we are ready to use a plastic model, we
+ // set $\sigma_0$ back to its proper value, using the same function. As a
+ // result of this approach, we need to leave <code>sigma_0</code> as the only
+ // non-const member variable of this class.
template <int dim>
- class Input
+ class ConstitutiveLaw
{
- public:
- Input (const char* _name) :
- name (_name),
- mpi_communicator (MPI_COMM_WORLD),
- pcout (std::cout,
- (Utilities::MPI::this_mpi_process(mpi_communicator) == 0)),
- obstacle_data (0),
- hx (0),
- hy (0),
- nx (0),
- ny (0)
- {read_obstacle (name);}
-
- double hv (int i, int j);
-
- double obstacle_function (double x,double y);
-
- void read_obstacle (const char* name);
-
- private:
- const char* name;
- MPI_Comm mpi_communicator;
- ConditionalOStream pcout;
- std::vector<double> obstacle_data;
- double hx, hy;
- int nx, ny;
- };
+ public:
+ ConstitutiveLaw (const double E,
+ const double nu,
+ const double sigma_0,
+ const double gamma);
- // This function is used in obstacle_function ()
- // to provide the proper value of the obstacle.
- template <int dim>
- double Input<dim>::hv (int i, int j)
- {
- assert(i>=0 && i<nx);
- assert(j>=0 && j<ny);
- return obstacle_data[nx*(ny-1-j)+i]; // i indiziert x-werte, j indiziert y-werte
- }
+ void
+ set_sigma_0 (double sigma_zero);
- // obstacle_function () calculates the bilinear interpolated
- // value in the point (x,y).
- template <int dim>
- double Input<dim>::obstacle_function (double x,double y)
- {
- int ix = (int)(x/hx);
- int iy = (int)(y/hy);
+ bool
+ get_stress_strain_tensor (const SymmetricTensor<2, dim> &strain_tensor,
+ SymmetricTensor<4, dim> &stress_strain_tensor) const;
- if (ix<0)
- ix = 0;
+ void
+ get_linearized_stress_strain_tensors (const SymmetricTensor<2, dim> &strain_tensor,
+ SymmetricTensor<4, dim> &stress_strain_tensor_linearized,
+ SymmetricTensor<4, dim> &stress_strain_tensor) const;
- if (iy<0)
- iy = 0;
+ private:
+ const double kappa;
+ const double mu;
+ double sigma_0;
+ const double gamma;
- if (ix>=nx-1)
- ix = nx-2;
+ const SymmetricTensor<4, dim> stress_strain_tensor_kappa;
+ const SymmetricTensor<4, dim> stress_strain_tensor_mu;
+ };
- if (iy>=ny-1)
- iy = ny-2;
+ // The constructor of the ConstitutiveLaw class sets the required material
+ // parameter for our deformable body. Material parameters for elastic
+ // isotropic media can be defined in a variety of ways, such as the pair $E,
+ // \nu$ (elastic modulus and Poisson's number), using the Lame parameters
+ // $\lambda,mu$ or several other commonly used conventions. Here, the
+ // constructor takes a description of material parameters in the form of
+ // $E,\nu$, but since this turns out to these are not the coefficients that
+ // appear in the equations of the plastic projector, we immediately convert
+ // them into the more suitable set $\kappa,\mu$ of bulk and shear moduli. In
+ // addition, the constructor takes $\sigma_0$ (the yield stress absent any
+ // plastic strain) and $\gamma$ (the hardening parameter) as arguments. In
+ // this constructor, we also compute the two principal components of the
+ // stress-strain relation and its linearization.
+ template <int dim>
+ ConstitutiveLaw<dim>::ConstitutiveLaw (double E,
+ double nu,
+ double sigma_0,
+ double gamma)
+ :
+ kappa (E / (3 * (1 - 2 * nu))),
+ mu (E / (2 * (1 + nu))),
+ sigma_0(sigma_0),
+ gamma(gamma),
+ stress_strain_tensor_kappa (kappa
+ * outer_product(unit_symmetric_tensor<dim>(),
+ unit_symmetric_tensor<dim>())),
+ stress_strain_tensor_mu (2 * mu
+ * (identity_tensor<dim>()
+ - outer_product(unit_symmetric_tensor<dim>(),
+ unit_symmetric_tensor<dim>()) / 3.0))
+ {}
- double val = 0.0;
- {
- FullMatrix<double> H(4,4);
- Vector<double> X(4);
- Vector<double> b(4);
-
- double xx = 0.0;
- double yy = 0.0;
-
- xx = ix*hx;
- yy = iy*hy;
- H(0,0) = xx;
- H(0,1) = yy;
- H(0,2) = xx*yy;
- H(0,3) = 1.0;
- b(0) = hv (ix, iy);
-
- xx = (ix + 1)*hx;
- yy = iy*hy;
- H(1,0) = xx;
- H(1,1) = yy;
- H(1,2) = xx*yy;
- H(1,3) = 1.0;
- b(1) = hv (ix + 1, iy);
-
- xx = (ix + 1)*hx;
- yy = (iy + 1)*hy;
- H(2,0) = xx;
- H(2,1) = yy;
- H(2,2) = xx*yy;
- H(2,3) = 1.0;
- b(2) = hv (ix + 1, iy + 1);
-
- xx = ix*hx;
- yy = (iy + 1)*hy;
- H(3,0) = xx;
- H(3,1) = yy;
- H(3,2) = xx*yy;
- H(3,3) = 1.0;
- b(3) = hv (ix, iy + 1);
-
- H.gauss_jordan ();
- H.vmult (X, b);
-
- val = X(0)*x + X(1)*y + X(2)*x*y + X(3);
- }
- return val;
+ template <int dim>
+ void
+ ConstitutiveLaw<dim>::set_sigma_0 (double sigma_zero)
+ {
+ sigma_0 = sigma_zero;
}
- // As mentioned above this function reads in the
- // obstacle datas and stores them in the std::vector
- // obstacle_data. It will be used only in run ().
+
+ // @sect4{ConstitutiveLaw::get_stress_strain_tensor}
+
+ // This is the principal component of the constitutive law. It projects the
+ // deviatoric part of the stresses in a quadrature point back to the yield
+ // stress (i.e., the original yield stress $\sigma_0$ plus the term that
+ // describes linear isotropic hardening). We need this function to calculate
+ // the nonlinear residual in PlasticityContactProblem::residual_nl_system. The
+ // computations follow the formulas laid out in the introduction.
+ //
+ // The function returns whether the quadrature point is plastic to allow for
+ // some statistics downstream on how many of the quadrature points are
+ // plastic and how many are elastic.
template <int dim>
- void Input<dim>::read_obstacle (const char* name)
+ bool
+ ConstitutiveLaw<dim>::
+ get_stress_strain_tensor (const SymmetricTensor<2, dim> &strain_tensor,
+ SymmetricTensor<4, dim> &stress_strain_tensor) const
{
- std::ifstream f(name);
+ Assert (dim == 3, ExcNotImplemented());
+
+ SymmetricTensor<2, dim> stress_tensor;
+ stress_tensor = (stress_strain_tensor_kappa + stress_strain_tensor_mu)
+ * strain_tensor;
- std::string temp;
- f >> temp >> nx >> ny;
- assert(nx>0 && ny>0);
+ const SymmetricTensor<2, dim> deviator_stress_tensor = deviator(stress_tensor);
+ const double deviator_stress_tensor_norm = deviator_stress_tensor.norm();
- for (int k=0; k<nx*ny; k++)
+ stress_strain_tensor = stress_strain_tensor_mu;
+ if (deviator_stress_tensor_norm > sigma_0)
{
- double val;
- f >> val;
- obstacle_data.push_back(val);
+ const double beta = sigma_0 / deviator_stress_tensor_norm;
+ stress_strain_tensor *= (gamma + (1 - gamma) * beta);
}
- hx = 1.0/(nx - 1);
- hy = 1.0/(ny - 1);
+ stress_strain_tensor += stress_strain_tensor_kappa;
- pcout << "Resolution of the scanned obstacle picture: " << nx << " x " << ny << std::endl;
+ return (deviator_stress_tensor_norm > sigma_0);
}
- // @sect3{The <code>ConstitutiveLaw</code> class template}
- // This class provides an interface
- // for a constitutive law. In this
- // example we are using an elasto
- // plastic material behavior with linear,
- // isotropic hardening.
- // For gamma = 0 we obtain perfect elasto
- // plasticity behavior.
+ // @sect4{ConstitutiveLaw::get_linearized_stress_strain_tensors}
+
+ // This function returns the linearized stress strain tensor, linearized
+ // around the solution $u^{i-1}$ of the previous Newton step $i-1$. The
+ // parameter <code>strain_tensor</code> (commonly denoted
+ // $\varepsilon(u^{i-1})$) must be passed as an argument, and serves as the
+ // linearization point. The function returns the derivative of the nonlinear
+ // constitutive law in the variable stress_strain_tensor, as well as the
+ // stress-strain tensor of the linearized problem in
+ // stress_strain_tensor_linearized. See
+ // PlasticityContactProblem::assemble_nl_system where this function is used.
template <int dim>
- class ConstitutiveLaw
+ void
+ ConstitutiveLaw<dim>::
+ get_linearized_stress_strain_tensors (const SymmetricTensor<2, dim> &strain_tensor,
+ SymmetricTensor<4, dim> &stress_strain_tensor_linearized,
+ SymmetricTensor<4, dim> &stress_strain_tensor) const
{
- public:
- ConstitutiveLaw (double _E,
- double _nu,
- double _sigma_0,
- double _gamma,
- MPI_Comm _mpi_communicator,
- ConditionalOStream _pcout);
-
- void plast_linear_hardening (SymmetricTensor<4,dim> &stress_strain_tensor,
- const SymmetricTensor<2,dim> &strain_tensor,
- unsigned int &elast_points,
- unsigned int &plast_points,
- double &yield);
- void linearized_plast_linear_hardening (SymmetricTensor<4,dim> &stress_strain_tensor_linearized,
- SymmetricTensor<4,dim> &stress_strain_tensor,
- const SymmetricTensor<2,dim> &strain_tensor);
- inline SymmetricTensor<2,dim> get_strain (const FEValues<dim> &fe_values,
- const unsigned int shape_func,
- const unsigned int q_point) const;
- void set_sigma_0 (double sigma_hlp) {sigma_0 = sigma_hlp;}
+ Assert (dim == 3, ExcNotImplemented());
- private:
- SymmetricTensor<4,dim> stress_strain_tensor_mu;
- SymmetricTensor<4,dim> stress_strain_tensor_kappa;
- double E;
- double nu;
- double sigma_0;
- double gamma;
- double mu;
- double kappa;
- MPI_Comm mpi_communicator;
- ConditionalOStream pcout;
- };
+ SymmetricTensor<2, dim> stress_tensor;
+ stress_tensor = (stress_strain_tensor_kappa + stress_strain_tensor_mu)
+ * strain_tensor;
- // The constructor of the ConstitutiveLaw class sets the
- // required material parameter for our deformable body:
- // E -> elastic modulus
- // nu -> Passion's number
- // sigma_0 -> yield stress
- // gamma -> hardening parameter.
- // Also it supplies the stress strain tensor of forth order
- // of the volumetric and deviator part. For further details
- // see the documentation above.
- template <int dim>
- ConstitutiveLaw<dim>::ConstitutiveLaw(double _E, double _nu, double _sigma_0, double _gamma, MPI_Comm _mpi_communicator, ConditionalOStream _pcout)
- :E (_E),
- nu (_nu),
- sigma_0 (_sigma_0),
- gamma (_gamma),
- mpi_communicator (_mpi_communicator),
- pcout (_pcout)
- {
- mu = E/(2*(1+nu));
- kappa = E/(3*(1-2*nu));
- stress_strain_tensor_kappa = kappa*outer_product(unit_symmetric_tensor<dim>(), unit_symmetric_tensor<dim>());
- stress_strain_tensor_mu = 2*mu*(identity_tensor<dim>() - outer_product(unit_symmetric_tensor<dim>(), unit_symmetric_tensor<dim>())/3.0);
- }
+ stress_strain_tensor = stress_strain_tensor_mu;
+ stress_strain_tensor_linearized = stress_strain_tensor_mu;
- // Calculates the strain for the shape functions.
- template <int dim>
- inline
- SymmetricTensor<2,dim> ConstitutiveLaw<dim>::get_strain (const FEValues<dim> &fe_values,
- const unsigned int shape_func,
- const unsigned int q_point) const
- {
- const FEValuesExtractors::Vector displacement (0);
- SymmetricTensor<2,dim> tmp;
+ SymmetricTensor<2, dim> deviator_stress_tensor = deviator(stress_tensor);
+ const double deviator_stress_tensor_norm = deviator_stress_tensor.norm();
- tmp = fe_values[displacement].symmetric_gradient (shape_func,q_point);
+ if (deviator_stress_tensor_norm > sigma_0)
+ {
+ const double beta = sigma_0 / deviator_stress_tensor_norm;
+ stress_strain_tensor *= (gamma + (1 - gamma) * beta);
+ stress_strain_tensor_linearized *= (gamma + (1 - gamma) * beta);
+ deviator_stress_tensor /= deviator_stress_tensor_norm;
+ stress_strain_tensor_linearized -= (1 - gamma) * beta * 2 * mu
+ * outer_product(deviator_stress_tensor,
+ deviator_stress_tensor);
+ }
- return tmp;
+ stress_strain_tensor += stress_strain_tensor_kappa;
+ stress_strain_tensor_linearized += stress_strain_tensor_kappa;
}
- // This is the implemented constitutive law. It projects the
- // deviator part of the stresses in a quadrature point back to
- // the yield stress plus the linear isotropic hardening.
- // Also we sum up the elastic and the plastic quadrature
- // points.
- template <int dim>
- void ConstitutiveLaw<dim>::plast_linear_hardening (SymmetricTensor<4,dim> &stress_strain_tensor,
- const SymmetricTensor<2,dim> &strain_tensor,
- unsigned int &elast_points,
- unsigned int &plast_points,
- double &yield)
+ // <h3>Equation data: boundary forces, boundary values, obstacles</h3>
+ //
+ // The following should be relatively standard. We need classes for
+ // the boundary forcing term (which we here choose to be zero)
+ // and boundary values on those part of the boundary that are not part
+ // of the contact surface (also chosen to be zero here).
+ namespace EquationData
{
- if (dim == 3)
- {
- SymmetricTensor<2,dim> stress_tensor;
- stress_tensor = (stress_strain_tensor_kappa + stress_strain_tensor_mu)*strain_tensor;
-
- SymmetricTensor<2,dim> deviator_stress_tensor = deviator(stress_tensor);
+ template <int dim>
+ class BoundaryForce : public Function<dim>
+ {
+ public:
+ BoundaryForce ();
- double deviator_stress_tensor_norm = deviator_stress_tensor.norm ();
+ virtual
+ double value (const Point<dim> &p,
+ const unsigned int component = 0) const;
- yield = 0;
- stress_strain_tensor = stress_strain_tensor_mu;
- double beta = 1.0;
- if (deviator_stress_tensor_norm > sigma_0)
- {
- beta = sigma_0/deviator_stress_tensor_norm;
- stress_strain_tensor *= (gamma + (1 - gamma)*beta);
- yield = 1;
- plast_points += 1;
- }
- else
- elast_points += 1;
+ virtual
+ void vector_value (const Point<dim> &p,
+ Vector<double> &values) const;
+ };
- stress_strain_tensor += stress_strain_tensor_kappa;
- }
- }
+ template <int dim>
+ BoundaryForce<dim>::BoundaryForce ()
+ :
+ Function<dim>(dim)
+ {}
- // This function returns the linearized stress strain tensor.
- // It contains the derivative of the nonlinear constitutive law.
- template <int dim>
- void ConstitutiveLaw<dim>::linearized_plast_linear_hardening (SymmetricTensor<4,dim> &stress_strain_tensor_linearized,
- SymmetricTensor<4,dim> &stress_strain_tensor,
- const SymmetricTensor<2,dim> &strain_tensor)
- {
- if (dim == 3)
- {
- SymmetricTensor<2,dim> stress_tensor;
- stress_tensor = (stress_strain_tensor_kappa + stress_strain_tensor_mu)*strain_tensor;
- SymmetricTensor<2,dim> deviator_stress_tensor = deviator(stress_tensor);
+ template <int dim>
+ double
+ BoundaryForce<dim>::value (const Point<dim> &,
+ const unsigned int) const
+ {
+ return 0.;
+ }
- double deviator_stress_tensor_norm = deviator_stress_tensor.norm ();
+ template <int dim>
+ void
+ BoundaryForce<dim>::vector_value (const Point<dim> &p,
+ Vector<double> &values) const
+ {
+ for (unsigned int c = 0; c < this->n_components; ++c)
+ values(c) = BoundaryForce<dim>::value(p, c);
+ }
- stress_strain_tensor = stress_strain_tensor_mu;
- stress_strain_tensor_linearized = stress_strain_tensor_mu;
- double beta = 1.0;
- if (deviator_stress_tensor_norm > sigma_0)
- {
- beta = sigma_0/deviator_stress_tensor_norm;
- stress_strain_tensor *= (gamma + (1 - gamma)*beta);
- stress_strain_tensor_linearized *= (gamma + (1 - gamma)*beta);
- deviator_stress_tensor /= deviator_stress_tensor_norm;
- stress_strain_tensor_linearized -= (1 - gamma)*beta*2*mu*outer_product(deviator_stress_tensor, deviator_stress_tensor);
- }
- stress_strain_tensor += stress_strain_tensor_kappa;
- stress_strain_tensor_linearized += stress_strain_tensor_kappa;
- }
- }
- // In this namespace we provide three functions:
- // one for the body force, one for the boundary displacement
- // and one for the Obstacle.
- namespace EquationData
- {
- // It possible to apply an additional body force
- // but in here it is set to zero.
template <int dim>
- class RightHandSide : public Function<dim>
+ class BoundaryValues : public Function<dim>
{
public:
- RightHandSide () : Function<dim>(dim) {}
+ BoundaryValues ();
- virtual double value (const Point<dim> &p,
- const unsigned int component = 0) const;
+ virtual double value (const Point<dim> &p,
+ const unsigned int component = 0) const;
- virtual void vector_value (const Point<dim> &p,
- Vector<double> &values) const;
+ virtual
+ void vector_value (const Point<dim> &p,
+ Vector<double> &values) const;
};
+
+ template <int dim>
+ BoundaryValues<dim>::BoundaryValues ()
+ :
+ Function<dim>(dim)
+ {}
+
+
+ template <int dim>
+ double
+ BoundaryValues<dim>::value (const Point<dim> &,
+ const unsigned int) const
+ {
+ return 0.;
+ }
+
template <int dim>
- double RightHandSide<dim>::value (const Point<dim> &p,
- const unsigned int component) const
+ void
+ BoundaryValues<dim>::vector_value (const Point<dim> &p,
+ Vector<double> &values) const
{
- double return_value = 0.0;
+ for (unsigned int c = 0; c < this->n_components; ++c)
+ values(c) = BoundaryValues<dim>::value(p, c);
+ }
+
+
+ // @sect4{The <code>SphereObstacle</code> class}
+
+ // The following class is the first of two obstacles that can be
+ // selected from the input file. It describes a sphere centered
+ // at position $x=y=0.5, z=z_{\text{surface}}+0.59$ and radius $r=0.6$,
+ // where $z_{\text{surface}}$ is the vertical position of the (flat)
+ // surface of the deformable body. The function's <code>value</code>
+ // returns the location of the obstacle for a given $x,y$ value if the
+ // point actually lies below the sphere, or a large positive value that
+ // can't possibly interfere with the deformation if it lies outside
+ // the "shadow" of the sphere.
+ template <int dim>
+ class SphereObstacle : public Function<dim>
+ {
+ public:
+ SphereObstacle (const double z_surface);
+
+ virtual
+ double value (const Point<dim> &p,
+ const unsigned int component = 0) const;
+
+ virtual
+ void vector_value (const Point<dim> &p,
+ Vector<double> &values) const;
+ private:
+ const double z_surface;
+ };
+
+
+ template <int dim>
+ SphereObstacle<dim>::SphereObstacle (const double z_surface)
+ :
+ Function<dim>(dim),
+ z_surface(z_surface)
+ {}
+
+
+ template <int dim>
+ double
+ SphereObstacle<dim>::value (
+ const Point<dim> &p, const unsigned int component) const
+ {
if (component == 0)
- return_value = 0.0;
- if (component == 1)
- return_value = 0.0;
- if (component == 2)
- return_value = 0.0;
+ return p(0);
+ else if (component == 1)
+ return p(1);
+ else if (component == 2)
+ {
+ if ((p(0) - 0.5) * (p(0) - 0.5) + (p(1) - 0.5) * (p(1) - 0.5)
+ < 0.36)
+ return (-std::sqrt(
+ 0.36 - (p(0) - 0.5) * (p(0) - 0.5)
+ - (p(1) - 0.5) * (p(1) - 0.5)) + z_surface + 0.59);
+ else
+ return 1000;
+ }
- return return_value;
+ Assert(false, ExcNotImplemented());
+ return 1e9; // an unreasonable value; ignored in debug mode because of the preceding Assert
}
+
template <int dim>
- void RightHandSide<dim>::vector_value (const Point<dim> &p,
- Vector<double> &values) const
+ void
+ SphereObstacle<dim>::vector_value (const Point<dim> &p,
+ Vector<double> &values) const
{
- for (unsigned int c=0; c<this->n_components; ++c)
- values(c) = RightHandSide<dim>::value (p, c);
+ for (unsigned int c = 0; c < this->n_components; ++c)
+ values(c) = SphereObstacle<dim>::value(p, c);
}
- // This function class is used to describe the prescribed displacements
- // at the boundary. But again we set this to zero.
+ // @sect4{The <code>BitmapFile</code> and <code>ChineseObstacle</code> classes}
+
+ // The following two classes describe the obstacle outlined in the introduction,
+ // i.e., the Chinese character. The first of the two, <code>BitmapFile</code>
+ // is responsible for reading in data from a picture file
+ // stored in pbm ascii format. This data will be bilinearly interpolated and
+ // provides in this way a function which describes an obstacle.
+ //
+ // The data which we read from the file will be stored in a double std::vector
+ // named obstacle_data. This vector composes the base to calculate a
+ // piecewise bilinear function as a polynomial interpolation. The data we will
+ // read from a file consists of zeros (white) and ones (black).
+ //
+ // The <code>hx,hy</code> variables denote the spacing between pixels in $x$
+ // and $y$ directions. <code>nx,ny</code> are the numbers of pixels in each of
+ // these directions. <code>get_value()</code> returns the value of the image
+ // at a given location, interpolated from the adjacent pixel values.
template <int dim>
- class BoundaryValues : public Function<dim>
+ class BitmapFile
{
public:
- BoundaryValues () : Function<dim>(dim) {};
+ BitmapFile(const std::string &name);
- virtual double value (const Point<dim> &p,
- const unsigned int component = 0) const;
+ double
+ get_value(const double x, const double y) const;
- virtual void vector_value (const Point<dim> &p,
- Vector<double> &values) const;
+ private:
+ std::vector<double> obstacle_data;
+ double hx, hy;
+ int nx, ny;
+
+ double
+ get_pixel_value(const int i, const int j) const;
};
+ // The constructor of this class reads in the data that describes
+ // the obstacle from the given file name.
template <int dim>
- double BoundaryValues<dim>::value (const Point<dim> &p,
- const unsigned int component) const
+ BitmapFile<dim>::BitmapFile(const std::string &name)
+ :
+ obstacle_data(0),
+ hx(0),
+ hy(0),
+ nx(0),
+ ny(0)
{
- double return_value = 0;
+ std::ifstream f(name.c_str());
- if (component == 0)
- return_value = 0.0;
- if (component == 1)
- return_value = 0.0;
- if (component == 2)
- return_value = 0.0;
+ std::string temp;
+ f >> temp >> nx >> ny;
+
+ AssertThrow(nx > 0 && ny > 0, ExcMessage("Invalid file format."));
+
+ for (int k = 0; k < nx * ny; k++)
+ {
+ double val;
+ f >> val;
+ obstacle_data.push_back(val);
+ }
- return return_value;
+ hx = 1.0 / (nx - 1);
+ hy = 1.0 / (ny - 1);
+
+ if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0)
+ std::cout << "Read obstacle from file <" << name << ">" << std::endl
+ << "Resolution of the scanned obstacle picture: " << nx
+ << " x " << ny << std::endl;
+ }
+
+ template <int dim>
+ double
+ BitmapFile<dim>::get_pixel_value(const int i, const int j) const
+ {
+ assert(i >= 0 && i < nx);
+ assert(j >= 0 && j < ny);
+ return obstacle_data[nx * (ny - 1 - j) + i];
}
template <int dim>
- void BoundaryValues<dim>::vector_value (const Point<dim> &p,
- Vector<double> &values) const
+ double
+ BitmapFile<dim>::get_value(const double x, const double y) const
{
- for (unsigned int c=0; c<this->n_components; ++c)
- values(c) = BoundaryValues<dim>::value (p, c);
+ const int ix = std::min(std::max((int) (x / hx), 0), nx - 2);
+ const int iy = std::min(std::max((int) (y / hy), 0), ny - 2);
+
+ FullMatrix<double> H(4, 4);
+ Vector<double> X(4);
+ Vector<double> b(4);
+
+ double xx, yy;
+
+ xx = ix * hx;
+ yy = iy * hy;
+ H(0, 0) = xx;
+ H(0, 1) = yy;
+ H(0, 2) = xx * yy;
+ H(0, 3) = 1.0;
+ b(0) = get_pixel_value(ix, iy);
+
+ xx = (ix + 1) * hx;
+ yy = iy * hy;
+ H(1, 0) = xx;
+ H(1, 1) = yy;
+ H(1, 2) = xx * yy;
+ H(1, 3) = 1.0;
+ b(1) = get_pixel_value(ix + 1, iy);
+
+ xx = (ix + 1) * hx;
+ yy = (iy + 1) * hy;
+ H(2, 0) = xx;
+ H(2, 1) = yy;
+ H(2, 2) = xx * yy;
+ H(2, 3) = 1.0;
+ b(2) = get_pixel_value(ix + 1, iy + 1);
+
+ xx = ix * hx;
+ yy = (iy + 1) * hy;
+ H(3, 0) = xx;
+ H(3, 1) = yy;
+ H(3, 2) = xx * yy;
+ H(3, 3) = 1.0;
+ b(3) = get_pixel_value(ix, iy + 1);
+
+ H.gauss_jordan();
+ H.vmult(X, b);
+
+ return (X(0) * x + X(1) * y + X(2) * x * y + X(3));
}
- // This function is obviously implemented to
- // define the obstacle that penetrates our deformable
- // body. You can choose between two ways to define
- // your obstacle: to read it from a file or to use
- // a function (here a ball).
+ // Finally, this is the class that actually uses the class above. It
+ // has a BitmapFile object as a member that describes the height of the
+ // obstacle. As mentioned above, the BitmapFile class will provide us
+ // with a mask, i.e., values that are either zero or one (and, if you
+ // ask for locations between pixels, values that are interpolated between
+ // zero and one). This class translates this to heights that are either
+ // 0.001 below the surface of the deformable body (if the BitmapFile
+ // class reports a one at this location) or 0.999 above the obstacle (if
+ // the BitmapFile class reports a zero). The following function should then
+ // be self-explanatory.
template <int dim>
- class Obstacle : public Function<dim>
+ class ChineseObstacle : public Function<dim>
{
public:
- Obstacle (std_cxx1x::shared_ptr<Input<dim> > const &_input, bool _use_read_obstacle) :
- Function<dim>(dim),
- input_obstacle_copy(_input),
- use_read_obstacle(_use_read_obstacle)
- {}
+ ChineseObstacle(const std::string &filename,
+ const double z_surface);
- virtual double value (const Point<dim> &p,
- const unsigned int component = 0) const;
+ virtual
+ double value (const Point<dim> &p,
+ const unsigned int component = 0) const;
- virtual void vector_value (const Point<dim> &p,
- Vector<double> &values) const;
+ virtual
+ void vector_value (const Point<dim> &p,
+ Vector<double> &values) const;
private:
- std_cxx1x::shared_ptr<Input<dim> > const &input_obstacle_copy;
- bool use_read_obstacle;
+ const BitmapFile<dim> input_obstacle;
+ double z_surface;
};
+
template <int dim>
- double Obstacle<dim>::value (const Point<dim> &p,
+ ChineseObstacle<dim>::ChineseObstacle(const std::string &filename,
+ const double z_surface)
+ :
+ Function<dim>(dim),
+ input_obstacle(filename),
+ z_surface(z_surface)
+ {}
+
+
+ template <int dim>
+ double
+ ChineseObstacle<dim>::value (const Point<dim> &p,
const unsigned int component) const
{
- double R = 0.03;
- double return_value = 100.0;
if (component == 0)
- return_value = p(0);
+ return p(0);
if (component == 1)
- return_value = p(1);
- if (component == 2)
+ return p(1);
+ else if (component==2)
{
- if (use_read_obstacle)
- return_value = 1.999 - input_obstacle_copy->obstacle_function (p(0), p(1));
- else
- return_value = -std::sqrt (0.36 - (p(0)-0.5)*(p(0)-0.5) - (p(1)-0.5)*(p(1)-0.5)) + 1.59;
+ if (p(0) >= 0.0 && p(0) <= 1.0 && p(1) >= 0.0 && p(1) <= 1.0)
+ return z_surface + 0.999 - input_obstacle.get_value(p(0), p(1));
}
- return return_value;
+
+ Assert (false, ExcNotImplemented());
+ return 1e9; // an unreasonable value; ignored in debug mode because of the preceding Assert
}
template <int dim>
- void Obstacle<dim>::vector_value (const Point<dim> &p,
- Vector<double> &values) const
+ void
+ ChineseObstacle<dim>::vector_value (const Point<dim> &p,
+ Vector<double> &values) const
{
- for (unsigned int c=0; c<this->n_components; ++c)
- values(c) = Obstacle<dim>::value (p, c);
+ for (unsigned int c = 0; c < this->n_components; ++c)
+ values(c) = ChineseObstacle<dim>::value(p, c);
}
}
// @sect3{The <code>PlasticityContactProblem</code> class template}
- // This class supplies all function
+ // This is the main class of this program and supplies all functions
// and variables needed to describe
// the nonlinear contact problem. It is
// close to step-41 but with some additional
- // features like: handling hanging nodes,
+ // features like handling hanging nodes,
// a Newton method, using Trilinos and p4est
// for parallel distributed computing.
// To deal with hanging nodes makes
// life a bit more complicated since
- // we need an other ConstraintMatrix now.
+ // we need another ConstraintMatrix now.
// We create a Newton method for the
// active set method for the contact
// situation and to handle the nonlinear
// operator for the constitutive law.
-
+ //
+ // The general layout of this class is very much like for most other tutorial programs.
+ // To make our life a bit easier, this class reads a set of input parameters from an input file. These
+ // parameters, using the ParameterHandler class, are declared in the <code>declare_parameters</code>
+ // function (which is static so that it can be called before we even create an object of the current
+ // type), and a ParameterHandler object that has been used to read an input file will then be passed
+ // to the constructor of this class.
+ //
+ // The remaining member functions are by and large as we have seen in several of the other tutorial
+ // programs, though with additions for the current nonlinear system. We will comment on their purpose
+ // as we get to them further below.
template <int dim>
class PlasticityContactProblem
{
public:
- PlasticityContactProblem (int _n_refinements_global);
+ PlasticityContactProblem (const ParameterHandler &prm);
+
void run ();
+ static void declare_parameters (ParameterHandler &prm);
+
private:
void make_grid ();
- void setup_system();
- void assemble_nl_system (TrilinosWrappers::MPI::Vector &u);
- void residual_nl_system (TrilinosWrappers::MPI::Vector &u);
+ void setup_system ();
+ void assemble_nl_system (const TrilinosWrappers::MPI::Vector &u);
+ void compute_nonlinear_residual (const TrilinosWrappers::MPI::Vector ¤t_solution);
void assemble_mass_matrix_diagonal (TrilinosWrappers::SparseMatrix &mass_matrix);
void update_solution_and_constraints ();
void dirichlet_constraints ();
void solve_newton ();
void refine_grid ();
void move_mesh (const TrilinosWrappers::MPI::Vector &_complete_displacement) const;
- void output_results (const std::string &title) const;
-
- unsigned int n_refinements_global;
- unsigned int cycle;
- bool use_read_obstacle;
-
- MPI_Comm mpi_communicator;
-
- parallel::distributed::Triangulation<dim> triangulation;
-
- FESystem<dim> fe;
- DoFHandler<dim> dof_handler;
-
- std_cxx1x::shared_ptr<parallel::distributed::SolutionTransfer<dim, TrilinosWrappers::MPI::Vector> > soltrans;
-
- IndexSet locally_owned_dofs;
- IndexSet locally_relevant_dofs;
+ void output_results (const std::string &filename_base);
+ void output_contact_force () const;
+
+ // As far as member variables are concerned, we start with ones that we use to
+ // indicate the MPI universe this program runs on, a stream we use to let
+ // exactly one processor produce output to the console (see step-17) and
+ // a variable that is used to time the various sections of the program:
+ MPI_Comm mpi_communicator;
+ ConditionalOStream pcout;
+ TimerOutput computing_timer;
+
+ // The next group describes the mesh and the finite element space.
+ // In particular, for this parallel program, the finite element
+ // space has associated with it variables that indicate which degrees
+ // of freedom live on the current processor (the index sets, see
+ // also step-40 and the @ref distributed documentation module) as
+ // well as a variety of constraints: those imposed by hanging nodes,
+ // by Dirichlet boundary conditions, and by the active set of
+ // contact nodes. Of the three ConstraintMatrix variables defined
+ // here, the first only contains hanging node constraints, the
+ // second also those associated with Dirichlet boundary conditions,
+ // and the third these plus the contact constraints.
+ //
+ // The variable <code>active_set</code> consists of those degrees
+ // of freedom constrained by the contact, and we use
+ // <code>fraction_of_plastic_q_points_per_cell</code> to keep
+ // track of the fraction of quadrature points on each cell where
+ // the stress equals the yield stress. The latter is only used to
+ // create graphical output showing the plastic zone, but not for
+ // any further computation; the variable is a member variable of
+ // this class since the information is computed as a by-product
+ // of computing the residual, but is used only much later. (Note
+ // that the vector is a vector of length equal to the number of
+ // active cells on the <i>local mesh</i>; it is never used to
+ // exchange information between processors and can therefore be
+ // a regular deal.II vector.)
+ const unsigned int n_initial_global_refinements;
+ parallel::distributed::Triangulation<dim> triangulation;
+
+ const unsigned int fe_degree;
+ FESystem<dim> fe;
+ DoFHandler<dim> dof_handler;
+
+ IndexSet locally_owned_dofs;
+ IndexSet locally_relevant_dofs;
+
+ ConstraintMatrix constraints_hanging_nodes;
+ ConstraintMatrix constraints_dirichlet_and_hanging_nodes;
+ ConstraintMatrix all_constraints;
+
+ IndexSet active_set;
+ Vector<float> fraction_of_plastic_q_points_per_cell;
+
+
+ // The next block of variables corresponds to the solution
+ // and the linear systems we need to form. In particular, this
+ // includes the Newton matrix and right hand side; the vector
+ // that corresponds to the residual (i.e., the Newton right hand
+ // side) but from which we have not eliminated the various
+ // constraints and that is used to determine which degrees of
+ // freedom need to be constrained in the next iteration; and
+ // a vector that corresponds to the diagonal of the $B$ matrix
+ // briefly mentioned in the introduction and discussed in the
+ // accompanying paper.
+ TrilinosWrappers::SparseMatrix system_matrix_newton;
+
+ TrilinosWrappers::MPI::Vector solution;
+ TrilinosWrappers::MPI::Vector system_rhs_newton;
+ TrilinosWrappers::MPI::Vector system_rhs_lambda;
+ TrilinosWrappers::MPI::Vector resid_vector;
+ TrilinosWrappers::MPI::Vector diag_mass_matrix_vector;
+
+ // The next block contains the variables that describe the material
+ // response:
+ const double e_modulus, nu, gamma, sigma_0;
+ ConstitutiveLaw<dim> constitutive_law;
+
+ // And then there is an assortment of other variables that are used
+ // to identify the mesh we are asked to build as selected by the
+ // parameter file, the obstacle that is being pushed into the
+ // deformable body, the mesh refinement strategy, whether to transfer
+ // the solution from one mesh to the next, and how many mesh
+ // refinement cycles to perform. As possible, we mark these kinds
+ // of variables as <code>const</code> to help the reader identify
+ // which ones may or may not be modified later on (the output directory
+ // being an exception -- it is never modified outside the constructor
+ // but it is awkward to initialize in the member-initializer-list
+ // following the colon in the constructor since there we have only
+ // one shot at setting it; the same is true for the mesh refinement
+ // criterion):
+ const std::string base_mesh;
+ const std_cxx1x::shared_ptr<const Function<dim> > obstacle;
+
+ struct RefinementStrategy
+ {
+ enum value
+ {
+ refine_global,
+ refine_percentage,
+ refine_fix_dofs
+ };
+ };
+ typename RefinementStrategy::value refinement_strategy;
- unsigned int number_iterations;
+ const bool transfer_solution;
+ std::string output_dir;
+ const unsigned int n_refinement_cycles;
+ unsigned int current_refinement_cycle;
+ };
- ConstraintMatrix constraints;
- ConstraintMatrix constraints_hanging_nodes;
- ConstraintMatrix constraints_dirichlet_hanging_nodes;
- TrilinosWrappers::SparseMatrix system_matrix_newton;
+ // @sect3{Implementation of the <code>PlasticityContactProblem</code> class}
- TrilinosWrappers::MPI::Vector solution;
- TrilinosWrappers::MPI::Vector system_rhs_newton;
- TrilinosWrappers::MPI::Vector resid_vector;
- TrilinosWrappers::MPI::Vector diag_mass_matrix_vector;
- Vector<float> cell_constitution;
- IndexSet active_set;
+ // @sect4{PlasticityContactProblem::declare_parameters}
- ConditionalOStream pcout;
+ // Let us start with the declaration of run-time parameters that can be
+ // selected in the input file. These values will be read back in the
+ // constructor of this class to initialize the member variables of this
+ // class:
+ template <int dim>
+ void
+ PlasticityContactProblem<dim>::declare_parameters (ParameterHandler &prm)
+ {
+ prm.declare_entry("polynomial degree", "1", Patterns::Integer(),
+ "Polynomial degree of the FE_Q finite element space, typically 1 or 2.");
+ prm.declare_entry("number of initial refinements", "2",
+ Patterns::Integer(),
+ "Number of initial global mesh refinement steps before "
+ "the first computation.");
+ prm.declare_entry("refinement strategy", "percentage",
+ Patterns::Selection("global|percentage|fix dofs"),
+ "Mesh refinement strategy:\n"
+ " global: one global refinement\n"
+ " percentage: fixed percentage gets refined using the Kelly estimator\n"
+ " fix dofs: tries to achieve 2^initial_refinement*300 dofs after "
+ "refinement cycle 1 (only use 2 cycles!). This requires the code to "
+ "make some changes to the coarse mesh as well.");
+ prm.declare_entry("number of cycles", "5", Patterns::Integer(),
+ "Number of adaptive mesh refinement cycles to run.");
+ prm.declare_entry("obstacle filename", "", Patterns::Anything(),
+ "Obstacle file to read, use 'obstacle_file.pbm' or leave empty to use a sphere.");
+ prm.declare_entry("output directory", "", Patterns::Anything(),
+ "Directory for output files (graphical output and benchmark "
+ "statistics). If empty, use the current directory.");
+ prm.declare_entry("transfer solution", "false", Patterns::Bool(),
+ "Whether the solution should be used as a starting guess "
+ "for the next finer mesh. If false, then the iteration starts at "
+ "zero on every mesh.");
+ prm.declare_entry("base mesh", "box",
+ Patterns::Selection("box|half sphere"),
+ "Select the shape of the domain: 'box' or 'half sphere'");
+ }
- TrilinosWrappers::PreconditionAMG::AdditionalData additional_data;
- TrilinosWrappers::PreconditionAMG preconditioner_u;
- std_cxx1x::shared_ptr<Input<dim> > input_obstacle;
- std_cxx1x::shared_ptr<ConstitutiveLaw<dim> > plast_lin_hard;
+ // @sect4{The <code>PlasticityContactProblem</code> constructor}
- double sigma_0; // Yield stress
- double gamma; // Parameter for the linear isotropic hardening
- double e_modul; // E-Modul
- double nu; // Poisson ratio
+ // Given the declarations of member variables as well as the
+ // declarations of run-time parameters that are read from the input
+ // file, there is nothing surprising in this constructor. In the body
+ // we initialize the mesh refinement strategy and the output directory,
+ // creating such a directory if necessary.
+ template <int dim>
+ PlasticityContactProblem<dim>::
+ PlasticityContactProblem (const ParameterHandler &prm)
+ :
+ mpi_communicator(MPI_COMM_WORLD),
+ pcout(std::cout,
+ (Utilities::MPI::this_mpi_process(mpi_communicator) == 0)),
+ computing_timer(MPI_COMM_WORLD, pcout, TimerOutput::never,
+ TimerOutput::wall_times),
+
+ n_initial_global_refinements (prm.get_integer("number of initial refinements")),
+ triangulation(mpi_communicator),
+ fe_degree (prm.get_integer("polynomial degree")),
+ fe(FE_Q<dim>(QGaussLobatto<1>(fe_degree+1)), dim),
+ dof_handler(triangulation),
+
+ e_modulus (200000),
+ nu (0.3),
+ gamma (0.01),
+ sigma_0(400.0),
+ constitutive_law (e_modulus,
+ nu,
+ sigma_0,
+ gamma),
+
+ base_mesh (prm.get("base mesh")),
+ obstacle (prm.get("obstacle filename") != ""
+ ?
+ static_cast<const Function<dim>*>
+ (new EquationData::ChineseObstacle<dim>(prm.get("obstacle filename"), (base_mesh == "box" ? 1.0 : 0.5)))
+ :
+ static_cast<const Function<dim>*>
+ (new EquationData::SphereObstacle<dim>(base_mesh == "box" ? 1.0 : 0.5))),
+
+ transfer_solution (prm.get_bool("transfer solution")),
+ n_refinement_cycles (prm.get_integer("number of cycles"))
+ {
+ std::string strat = prm.get("refinement strategy");
+ if (strat == "global")
+ refinement_strategy = RefinementStrategy::refine_global;
+ else if (strat == "percentage")
+ refinement_strategy = RefinementStrategy::refine_percentage;
+ else
+ AssertThrow (false, ExcNotImplemented());
+
+ output_dir = prm.get("output directory");
+ if (output_dir != "" && *(output_dir.rbegin()) != '/')
+ output_dir += "/";
+ mkdir(output_dir.c_str(), 0777);
+
+ pcout << " Using output directory '" << output_dir << "'" << std::endl;
+ pcout << " FE degree " << fe_degree << std::endl;
+ pcout << " transfer solution "
+ << (transfer_solution ? "true" : "false") << std::endl;
+ }
- TimerOutput computing_timer;
- };
- // @sect3{Implementation of the <code>PlasticityContactProblem</code> class}
- // Next for the implementation of the class
- // template that makes use of the functions
- // above. As before, we will write everything
+ // @sect4{PlasticityContactProblem::make_grid}
- template <int dim>
- PlasticityContactProblem<dim>::PlasticityContactProblem (int _n_refinements_global)
- :
- n_refinements_global (_n_refinements_global),
- mpi_communicator (MPI_COMM_WORLD),
- triangulation (mpi_communicator),
- fe (FE_Q<dim>(1), dim),
- dof_handler (triangulation),
- pcout (std::cout,
- (Utilities::MPI::this_mpi_process(mpi_communicator) == 0)),
- sigma_0 (400),
- gamma (0.01),
- e_modul (2.0e+5),
- nu (0.3),
- computing_timer (MPI_COMM_WORLD,
- pcout,
- TimerOutput::never,
- TimerOutput::wall_times)
+ // The next block deals with constructing the starting mesh.
+ // We will use the following helper function and the first
+ // block of the <code>make_grid()</code> to construct a
+ // mesh that corresponds to a half sphere. deal.II has a function
+ // that creates such a mesh, but it is in the wrong location
+ // and facing the wrong direction, so we need to shift and rotate
+ // it a bit before using it:
+ Point<3>
+ rotate_half_sphere (const Point<3> &in)
{
- plast_lin_hard.reset (new ConstitutiveLaw<dim> (e_modul, nu, sigma_0, gamma, mpi_communicator, pcout));
+ return Point<3>(in(2), in(1), -in(0));
}
template <int dim>
- void PlasticityContactProblem<dim>::make_grid ()
+ void
+ PlasticityContactProblem<dim>::make_grid ()
{
- std::vector<unsigned int> repet(3);
- repet[0] = 1;
- repet[1] = 1;
- repet[2] = 1;
+ if (base_mesh == "half sphere")
+ {
+ const Point<dim> center(0, 0, 0);
+ const double radius = 0.8;
+ GridGenerator::half_hyper_ball(triangulation, center, radius);
- Point<dim> p1 (0,0,0);
- Point<dim> p2 (1.0, 1.0, 1.0);
- GridGenerator::subdivided_hyper_rectangle (triangulation, repet, p1, p2);
+ GridTools::transform(&rotate_half_sphere, triangulation);
+ GridTools::shift(Point<dim>(0.5, 0.5, 0.5), triangulation);
- Triangulation<3>::active_cell_iterator
- cell = triangulation.begin_active(),
- endc = triangulation.end();
+ static HyperBallBoundary<dim> boundary_description(Point<dim>(0.5, 0.5, 0.5), radius);
+ triangulation.set_boundary(0, boundary_description);
+ }
+ // Alternatively, create a hypercube mesh. After creating it,
+ // assign boundary indicators as follows:
+ // @code
+ // _______
+ // / 1 /|
+ // /______ / |
+ // | | 8|
+ // | 8 | /
+ // |_______|/
+ // 6
+ // @endcode
+ // In other words, the boundary indicators of the sides of the cube are 8.
+ // The boundary indicator of the bottom is 6 and the top has indicator 1.
+ else
+ {
+ const Point<dim> p1(0, 0, 0);
+ const Point<dim> p2(1.0, 1.0, 1.0);
- /* boundary_indicators:
- _______
- / 9 /|
- /______ / |
- 8| | 8|
- | 8 | /
- |_______|/
- 6
- */
+ GridGenerator::hyper_rectangle(triangulation, p1, p2);
- for (; cell!=endc; ++cell)
- for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
- {
- if (cell->face (face)->center ()[2] == p2(2))
- cell->face (face)->set_boundary_indicator (9);
- if (cell->face (face)->center ()[0] == p1(0) ||
- cell->face (face)->center ()[0] == p2(0) ||
- cell->face (face)->center ()[1] == p1(1) ||
- cell->face (face)->center ()[1] == p2(1))
- cell->face (face)->set_boundary_indicator (8);
- if (cell->face (face)->center ()[2] == p1(2))
- cell->face (face)->set_boundary_indicator (6);
- }
+ /* boundary_indicators:
- triangulation.refine_global (n_refinements_global);
+ */
+ Triangulation<3>::active_cell_iterator
+ cell = triangulation.begin_active(),
+ endc = triangulation.end();
+ for (; cell != endc; ++cell)
+ for (unsigned int face = 0; face < GeometryInfo<dim>::faces_per_cell;
+ ++face)
+ {
+ if (cell->face(face)->center()[2] == p2(2))
+ cell->face(face)->set_boundary_indicator(1);
+ if (cell->face(face)->center()[0] == p1(0)
+ || cell->face(face)->center()[0] == p2(0)
+ || cell->face(face)->center()[1] == p1(1)
+ || cell->face(face)->center()[1] == p2(1))
+ cell->face(face)->set_boundary_indicator(8);
+ if (cell->face(face)->center()[2] == p1(2))
+ cell->face(face)->set_boundary_indicator(6);
+ }
+ }
+
+ triangulation.refine_global(n_initial_global_refinements);
}
- // In following function we setup the degrees of freedom before each refinement
- // cycle. Except that we are using Trilinos here instead of PETSc most of it
- // is similar to step-40.
- // We are using TimerOutput to control the scaling for the distributing the dofs
- // and setting of the sparsity pattern and the system matrix.
+
template <int dim>
- void PlasticityContactProblem<dim>::setup_system ()
+ void
+ PlasticityContactProblem<dim>::setup_system ()
{
+ // setup dofs
{
- computing_timer.enter_section("Setup: distribute DoFs");
- dof_handler.distribute_dofs (fe);
+ TimerOutput::Scope t(computing_timer, "Setup: distribute DoFs");
+ dof_handler.distribute_dofs(fe);
- locally_owned_dofs = dof_handler.locally_owned_dofs ();
+ locally_owned_dofs = dof_handler.locally_owned_dofs();
locally_relevant_dofs.clear();
- DoFTools::extract_locally_relevant_dofs (dof_handler,
- locally_relevant_dofs);
- computing_timer.exit_section("Setup: distribute DoFs");
+ DoFTools::extract_locally_relevant_dofs(dof_handler,
+ locally_relevant_dofs);
}
- // Setup of the hanging nodes and the Dirichlet constraints.
+ // setup hanging nodes and Dirichlet constraints
{
- constraints_hanging_nodes.clear ();
- constraints_hanging_nodes.reinit (locally_relevant_dofs);
- DoFTools::make_hanging_node_constraints (dof_handler,
- constraints_hanging_nodes);
- constraints_hanging_nodes.close ();
+ TimerOutput::Scope t(computing_timer, "Setup: constraints");
+ constraints_hanging_nodes.reinit(locally_relevant_dofs);
+ DoFTools::make_hanging_node_constraints(dof_handler,
+ constraints_hanging_nodes);
+ constraints_hanging_nodes.close();
pcout << " Number of active cells: "
- << triangulation.n_global_active_cells()
- << std::endl
- << " Number of degrees of freedom: "
- << dof_handler.n_dofs ()
+ << triangulation.n_global_active_cells() << std::endl
+ << " Number of degrees of freedom: " << dof_handler.n_dofs()
<< std::endl;
- dirichlet_constraints ();
+ dirichlet_constraints();
}
- // Initialization for matrices and vectors.
+ // Initialization for matrices and vectors
{
- solution.reinit (locally_relevant_dofs, mpi_communicator);
- system_rhs_newton.reinit (locally_owned_dofs, mpi_communicator);
- resid_vector.reinit (system_rhs_newton);
- diag_mass_matrix_vector.reinit (system_rhs_newton);
- cell_constitution.reinit (triangulation.n_active_cells ());
- active_set.clear ();
- active_set.set_size (locally_relevant_dofs.size ());
+ TimerOutput::Scope t(computing_timer, "Setup: vectors");
+ solution.reinit(locally_relevant_dofs, mpi_communicator);
+ system_rhs_newton.reinit(locally_owned_dofs, mpi_communicator);
+ system_rhs_lambda.reinit(system_rhs_newton);
+ resid_vector.reinit(system_rhs_newton);
+ diag_mass_matrix_vector.reinit(system_rhs_newton);
+ fraction_of_plastic_q_points_per_cell.reinit(triangulation.n_active_cells());
+ active_set.clear();
+ active_set.set_size(locally_relevant_dofs.size());
}
- // Here we setup sparsity pattern.
+ // setup sparsity pattern
{
- computing_timer.enter_section("Setup: matrix");
- TrilinosWrappers::SparsityPattern sp (locally_owned_dofs,
- mpi_communicator);
+ TimerOutput::Scope t(computing_timer, "Setup: matrix");
+ TrilinosWrappers::SparsityPattern sp(locally_owned_dofs,
+ mpi_communicator);
- DoFTools::make_sparsity_pattern (dof_handler, sp, constraints_dirichlet_hanging_nodes, false,
- Utilities::MPI::this_mpi_process(mpi_communicator));
+ DoFTools::make_sparsity_pattern(dof_handler, sp,
+ constraints_dirichlet_and_hanging_nodes, false,
+ Utilities::MPI::this_mpi_process(mpi_communicator));
sp.compress();
- system_matrix_newton.reinit (sp);
-
- // we are going to reuse the system
- // matrix for assembling the diagonal
- // of the mass matrix so that we do not
- // need to allocate two sparse matrices
- // at the same time:
- TrilinosWrappers::SparseMatrix & mass_matrix = system_matrix_newton;
- assemble_mass_matrix_diagonal (mass_matrix);
- const unsigned int
- start = (system_rhs_newton.local_range().first),
- end = (system_rhs_newton.local_range().second);
- for (unsigned int j=start; j<end; j++)
- diag_mass_matrix_vector (j) = mass_matrix.diag_element (j);
- number_iterations = 0;
-
- diag_mass_matrix_vector.compress (VectorOperation::insert);
-
- // remove the mass matrix entries from the matrix:
- mass_matrix = 0;
+ system_matrix_newton.reinit(sp);
+
+ // we are going to reuse the system
+ // matrix for assembling the diagonal
+ // of the mass matrix so that we do not
+ // need to allocate two sparse matrices
+ // at the same time:
+ TrilinosWrappers::SparseMatrix &mass_matrix = system_matrix_newton;
+ assemble_mass_matrix_diagonal(mass_matrix);
+ const unsigned int start = (system_rhs_newton.local_range().first),
+ end = (system_rhs_newton.local_range().second);
+ for (unsigned int j = start; j < end; j++)
+ diag_mass_matrix_vector(j) = mass_matrix.diag_element(j);
+
+ diag_mass_matrix_vector.compress(VectorOperation::insert);
- computing_timer.exit_section("Setup: matrix");
+ // remove the mass matrix entries from the matrix:
+ mass_matrix = 0;
}
}
template <int dim>
- void PlasticityContactProblem<dim>::assemble_nl_system (TrilinosWrappers::MPI::Vector &u)
+ void
+ PlasticityContactProblem<dim>::assemble_nl_system (const TrilinosWrappers::MPI::Vector &u)
{
- computing_timer.enter_section("Assembling");
+ TimerOutput::Scope t(computing_timer, "Assembling");
- QGauss<dim> quadrature_formula(2);
- QGauss<dim-1> face_quadrature_formula(2);
+ QGauss<dim> quadrature_formula(fe.degree + 1);
+ QGauss<dim - 1> face_quadrature_formula(fe.degree + 1);
- FEValues<dim> fe_values (fe, quadrature_formula,
- UpdateFlags(update_values |
- update_gradients |
- update_q_points |
- update_JxW_values));
+ FEValues<dim> fe_values(fe, quadrature_formula,
+ UpdateFlags(
+ update_values | update_gradients | update_q_points
+ | update_JxW_values));
- FEFaceValues<dim> fe_values_face (fe, face_quadrature_formula,
- update_values | update_quadrature_points |
- update_JxW_values);
+ FEFaceValues<dim> fe_values_face(fe, face_quadrature_formula,
+ update_values | update_quadrature_points | update_JxW_values);
- const unsigned int dofs_per_cell = fe.dofs_per_cell;
- const unsigned int n_q_points = quadrature_formula.size ();
- const unsigned int n_face_q_points = face_quadrature_formula.size();
+ const unsigned int dofs_per_cell = fe.dofs_per_cell;
+ const unsigned int n_q_points = quadrature_formula.size();
+ const unsigned int n_face_q_points = face_quadrature_formula.size();
- const EquationData::RightHandSide<dim> right_hand_side;
- std::vector<Vector<double> > right_hand_side_values (n_q_points,
- Vector<double>(dim));
- std::vector<Vector<double> > right_hand_side_values_face (n_face_q_points,
- Vector<double>(dim));
+ const EquationData::BoundaryForce<dim> boundary_force;
+ std::vector<Vector<double> > boundary_force_values(n_face_q_points,
+ Vector<double>(dim));
- FullMatrix<double> cell_matrix (dofs_per_cell, dofs_per_cell);
- Vector<double> cell_rhs (dofs_per_cell);
+ FullMatrix<double> cell_matrix(dofs_per_cell, dofs_per_cell);
+ Vector<double> cell_rhs(dofs_per_cell);
- std::vector<types::global_dof_index> local_dof_indices (dofs_per_cell);
+ std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
- typename DoFHandler<dim>::active_cell_iterator cell = dof_handler.begin_active(),
- endc = dof_handler.end();
+ typename DoFHandler<dim>::active_cell_iterator cell =
+ dof_handler.begin_active(), endc = dof_handler.end();
- const FEValuesExtractors::Vector displacement (0);
+ const FEValuesExtractors::Vector displacement(0);
const double kappa = 1.0;
- for (; cell!=endc; ++cell)
+ for (; cell != endc; ++cell)
if (cell->is_locally_owned())
{
- fe_values.reinit (cell);
+ fe_values.reinit(cell);
cell_matrix = 0;
cell_rhs = 0;
- right_hand_side.vector_value_list (fe_values.get_quadrature_points(),
- right_hand_side_values);
-
- std::vector<SymmetricTensor<2,dim> > strain_tensor (n_q_points);
- fe_values[displacement].get_function_symmetric_gradients (u, strain_tensor);
+ std::vector<SymmetricTensor<2, dim> > strain_tensor(n_q_points);
+ fe_values[displacement].get_function_symmetric_gradients(u,
+ strain_tensor);
- for (unsigned int q_point=0; q_point<n_q_points; ++q_point)
+ for (unsigned int q_point = 0; q_point < n_q_points; ++q_point)
{
- SymmetricTensor<4,dim> stress_strain_tensor_linearized;
- SymmetricTensor<4,dim> stress_strain_tensor;
- SymmetricTensor<2,dim> stress_tensor;
+ SymmetricTensor<4, dim> stress_strain_tensor_linearized;
+ SymmetricTensor<4, dim> stress_strain_tensor;
+ SymmetricTensor<2, dim> stress_tensor;
- plast_lin_hard->linearized_plast_linear_hardening (stress_strain_tensor_linearized,
- stress_strain_tensor,
- strain_tensor[q_point]);
+ constitutive_law.get_linearized_stress_strain_tensors(strain_tensor[q_point],
+ stress_strain_tensor_linearized,
+ stress_strain_tensor);
- for (unsigned int i=0; i<dofs_per_cell; ++i)
+ for (unsigned int i = 0; i < dofs_per_cell; ++i)
{
- stress_tensor = stress_strain_tensor_linearized * plast_lin_hard->get_strain(fe_values, i, q_point);
+ stress_tensor = stress_strain_tensor_linearized
+ * fe_values[displacement].symmetric_gradient(i, q_point);
- for (unsigned int j=0; j<dofs_per_cell; ++j)
- {
- cell_matrix(i,j) += (stress_tensor *
- plast_lin_hard->get_strain(fe_values, j, q_point) *
- fe_values.JxW (q_point));
- }
+ for (unsigned int j = 0; j < dofs_per_cell; ++j)
+ cell_matrix(i, j) += (stress_tensor
+ * fe_values[displacement].symmetric_gradient(j, q_point)
+ * fe_values.JxW(q_point));
// the linearized part a(v^i;v^i,v) of the rhs
- cell_rhs(i) += (stress_tensor *
- strain_tensor[q_point] *
- fe_values.JxW (q_point));
+ cell_rhs(i) += (stress_tensor * strain_tensor[q_point]
+ * fe_values.JxW(q_point));
// the residual part a(v^i;v) of the rhs
- cell_rhs(i) -= (strain_tensor[q_point] * stress_strain_tensor *
- plast_lin_hard->get_strain(fe_values, i, q_point) *
- fe_values.JxW (q_point));
+ cell_rhs(i) -= (strain_tensor[q_point]
+ * stress_strain_tensor
+ * fe_values[displacement].symmetric_gradient(i, q_point)
+ * fe_values.JxW(q_point));
// the residual part F(v) of the rhs
- Tensor<1,dim> rhs_values;
+ Tensor<1, dim> rhs_values;
rhs_values = 0;
- cell_rhs(i) += (fe_values[displacement].value (i, q_point) *
- rhs_values *
- fe_values.JxW (q_point));
+ cell_rhs(i) += (fe_values[displacement].value(i, q_point)
+ * rhs_values * fe_values.JxW(q_point));
}
}
- for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
+ for (unsigned int face = 0;
+ face < GeometryInfo<dim>::faces_per_cell; ++face)
{
- if (cell->face (face)->at_boundary()
- && cell->face (face)->boundary_indicator () == 9)
+ if (cell->face(face)->at_boundary()
+ && cell->face(face)->boundary_indicator() == 1)
{
- fe_values_face.reinit (cell, face);
+ fe_values_face.reinit(cell, face);
- right_hand_side.vector_value_list (fe_values_face.get_quadrature_points(),
- right_hand_side_values_face);
+ boundary_force.vector_value_list(fe_values_face.get_quadrature_points(),
+ boundary_force_values);
- for (unsigned int q_point=0; q_point<n_face_q_points; ++q_point)
+ for (unsigned int q_point = 0; q_point < n_face_q_points;
+ ++q_point)
{
- Tensor<1,dim> rhs_values;
- rhs_values = 0;
- for (unsigned int i=0; i<dofs_per_cell; ++i)
- cell_rhs(i) += (fe_values_face[displacement].value (i, q_point) *
- rhs_values *
- fe_values_face.JxW (q_point));
+ Tensor<1, dim> rhs_values;
+ rhs_values[2] = boundary_force_values[q_point][2];
+ for (unsigned int i = 0; i < dofs_per_cell; ++i)
+ cell_rhs(i) += (fe_values_face[displacement].value(i,
+ q_point) * rhs_values
+ * fe_values_face.JxW(q_point));
}
}
}
- cell->get_dof_indices (local_dof_indices);
- constraints.distribute_local_to_global (cell_matrix, cell_rhs,
- local_dof_indices,
- system_matrix_newton, system_rhs_newton, true);
- };
+ cell->get_dof_indices(local_dof_indices);
+ all_constraints.distribute_local_to_global(cell_matrix, cell_rhs,
+ local_dof_indices,
+ system_matrix_newton,
+ system_rhs_newton,
+ true);
- system_matrix_newton.compress (VectorOperation::add);
- system_rhs_newton.compress (VectorOperation::add);
+ }
- computing_timer.exit_section("Assembling");
+ system_matrix_newton.compress(VectorOperation::add);
+ system_rhs_newton.compress(VectorOperation::add);
}
+
+
template <int dim>
- void PlasticityContactProblem<dim>::residual_nl_system (TrilinosWrappers::MPI::Vector &u)
+ void
+ PlasticityContactProblem<dim>::compute_nonlinear_residual (const TrilinosWrappers::MPI::Vector ¤t_solution)
{
- QGauss<dim> quadrature_formula(2);
- QGauss<dim-1> face_quadrature_formula(2);
+ QGauss<dim> quadrature_formula(fe.degree + 1);
+ QGauss<dim-1> face_quadrature_formula(fe.degree + 1);
- FEValues<dim> fe_values (fe, quadrature_formula,
- UpdateFlags(update_values |
- update_gradients |
- update_q_points |
- update_JxW_values));
+ FEValues<dim> fe_values(fe, quadrature_formula,
+ update_values | update_gradients |
+ update_q_points | update_JxW_values);
- FEFaceValues<dim> fe_values_face (fe, face_quadrature_formula,
- update_values | update_quadrature_points |
- update_JxW_values);
+ FEFaceValues<dim> fe_values_face(fe, face_quadrature_formula,
+ update_values | update_quadrature_points |
+ update_JxW_values);
- const unsigned int dofs_per_cell = fe.dofs_per_cell;
- const unsigned int n_q_points = quadrature_formula.size ();
- const unsigned int n_face_q_points = face_quadrature_formula.size();
+ const unsigned int dofs_per_cell = fe.dofs_per_cell;
+ const unsigned int n_q_points = quadrature_formula.size();
+ const unsigned int n_face_q_points = face_quadrature_formula.size();
- const EquationData::RightHandSide<dim> right_hand_side;
- std::vector<Vector<double> > right_hand_side_values (n_q_points,
- Vector<double>(dim));
- std::vector<Vector<double> > right_hand_side_values_face (n_face_q_points,
- Vector<double>(dim));
+ const EquationData::BoundaryForce<dim> boundary_force;
+ std::vector<Vector<double> > boundary_force_values(n_face_q_points,
+ Vector<double>(dim));
- Vector<double> cell_rhs (dofs_per_cell);
+ Vector<double> cell_rhs(dofs_per_cell);
- std::vector<types::global_dof_index> local_dof_indices (dofs_per_cell);
+ std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
- const FEValuesExtractors::Vector displacement (0);
+ const FEValuesExtractors::Vector displacement(0);
- typename DoFHandler<dim>::active_cell_iterator cell = dof_handler.begin_active(),
- endc = dof_handler.end();
+ typename DoFHandler<dim>::active_cell_iterator cell =
+ dof_handler.begin_active(), endc = dof_handler.end();
unsigned int elast_points = 0;
unsigned int plast_points = 0;
- double yield = 0;
+ double yield = 0;
unsigned int cell_number = 0;
- cell_constitution = 0;
+ fraction_of_plastic_q_points_per_cell = 0;
- for (; cell!=endc; ++cell)
+ for (; cell != endc; ++cell, ++cell_number)
if (cell->is_locally_owned())
{
- fe_values.reinit (cell);
+ fe_values.reinit(cell);
cell_rhs = 0;
- right_hand_side.vector_value_list (fe_values.get_quadrature_points(),
- right_hand_side_values);
-
- std::vector<SymmetricTensor<2,dim> > strain_tensor (n_q_points);
- fe_values[displacement].get_function_symmetric_gradients (u, strain_tensor);
+ std::vector<SymmetricTensor<2, dim> > strain_tensor(n_q_points);
+ fe_values[displacement].get_function_symmetric_gradients(current_solution,
+ strain_tensor);
- for (unsigned int q_point=0; q_point<n_q_points; ++q_point)
+ for (unsigned int q_point = 0; q_point < n_q_points; ++q_point)
{
- SymmetricTensor<4,dim> stress_strain_tensor;
- SymmetricTensor<2,dim> stress_tensor;
-
- plast_lin_hard->plast_linear_hardening (stress_strain_tensor, strain_tensor[q_point],
- elast_points, plast_points, yield);
+ SymmetricTensor<4, dim> stress_strain_tensor;
+ const bool q_point_is_plastic
+ = constitutive_law.get_stress_strain_tensor(strain_tensor[q_point],
+ stress_strain_tensor);
+ if (q_point_is_plastic)
+ {
+ ++plast_points;
+ ++fraction_of_plastic_q_points_per_cell(cell_number);
+ }
+ else
+ ++elast_points;
- cell_constitution (cell_number) += yield;
- for (unsigned int i=0; i<dofs_per_cell; ++i)
+ for (unsigned int i = 0; i < dofs_per_cell; ++i)
{
- cell_rhs(i) -= (strain_tensor[q_point] * stress_strain_tensor * //(stress_tensor) *
- plast_lin_hard->get_strain(fe_values, i, q_point) *
- fe_values.JxW (q_point));
+ cell_rhs(i) -= (strain_tensor[q_point]
+ * stress_strain_tensor
+ * fe_values[displacement].symmetric_gradient(i, q_point)
+ * fe_values.JxW(q_point));
- Tensor<1,dim> rhs_values;
+ Tensor<1, dim> rhs_values;
rhs_values = 0;
- cell_rhs(i) += ((fe_values[displacement].value (i, q_point) *
- rhs_values) *
- fe_values.JxW (q_point));
- };
- };
+ cell_rhs(i) += (fe_values[displacement].value(i, q_point)
+ * rhs_values * fe_values.JxW(q_point));
+ }
+ }
- for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
+ for (unsigned int face = 0;
+ face < GeometryInfo<dim>::faces_per_cell; ++face)
{
- if (cell->face (face)->at_boundary()
- && cell->face (face)->boundary_indicator () == 9)
+ if (cell->face(face)->at_boundary()
+ && cell->face(face)->boundary_indicator() == 1)
{
- fe_values_face.reinit (cell, face);
+ fe_values_face.reinit(cell, face);
- right_hand_side.vector_value_list (fe_values_face.get_quadrature_points(),
- right_hand_side_values_face);
+ boundary_force.vector_value_list(fe_values_face.get_quadrature_points(),
+ boundary_force_values);
- for (unsigned int q_point=0; q_point<n_face_q_points; ++q_point)
+ for (unsigned int q_point = 0; q_point < n_face_q_points;
+ ++q_point)
{
- Tensor<1,dim> rhs_values;
- rhs_values = 0;
- for (unsigned int i=0; i<dofs_per_cell; ++i)
- cell_rhs(i) += (fe_values_face[displacement].value (i, q_point) *
- rhs_values *
- fe_values_face.JxW (q_point));
+ Tensor<1, dim> rhs_values;
+ rhs_values[2] = boundary_force_values[q_point][2];
+ for (unsigned int i = 0; i < dofs_per_cell; ++i)
+ cell_rhs(i) += (fe_values_face[displacement].value(i, q_point) * rhs_values
+ * fe_values_face.JxW(q_point));
}
}
}
- cell->get_dof_indices (local_dof_indices);
- constraints_dirichlet_hanging_nodes.distribute_local_to_global (cell_rhs,
+ cell->get_dof_indices(local_dof_indices);
+ constraints_dirichlet_and_hanging_nodes.distribute_local_to_global(cell_rhs,
local_dof_indices,
system_rhs_newton);
- cell_number += 1;
+ for (unsigned int i = 0; i < dofs_per_cell; i++)
+ system_rhs_lambda(local_dof_indices[i]) += cell_rhs(i);
}
- else
- {
- cell_constitution (cell_number) = 0;
- cell_number += 1;
- };
- cell_constitution /= n_q_points;
- cell_constitution.compress (VectorOperation::add);
- system_rhs_newton.compress (VectorOperation::add);
+ fraction_of_plastic_q_points_per_cell /= quadrature_formula.size();
+ system_rhs_newton.compress(VectorOperation::add);
+ system_rhs_lambda.compress(VectorOperation::add);
- unsigned int sum_elast_points = Utilities::MPI::sum(elast_points, mpi_communicator);
- unsigned int sum_plast_points = Utilities::MPI::sum(plast_points, mpi_communicator);
+ const unsigned int sum_elast_points = Utilities::MPI::sum(elast_points,
+ mpi_communicator);
+ const unsigned int sum_plast_points = Utilities::MPI::sum(plast_points,
+ mpi_communicator);
pcout << " Number of elastic quadrature points: " << sum_elast_points
- << " and plastic quadrature points: " << sum_plast_points << std::endl;
+ << " and plastic quadrature points: " << sum_plast_points
+ << std::endl;
}
+
+
template <int dim>
- void PlasticityContactProblem<dim>::assemble_mass_matrix_diagonal (TrilinosWrappers::SparseMatrix &mass_matrix)
+ void
+ PlasticityContactProblem<dim>::assemble_mass_matrix_diagonal (TrilinosWrappers::SparseMatrix &mass_matrix)
{
- QTrapez<dim-1> face_quadrature_formula;
+ QGaussLobatto<dim - 1> face_quadrature_formula(fe.degree + 1);
- FEFaceValues<dim> fe_values_face (fe, face_quadrature_formula,
- update_values |
- update_quadrature_points |
- update_JxW_values);
+ FEFaceValues<dim> fe_values_face(fe, face_quadrature_formula,
+ update_values | update_quadrature_points | update_JxW_values);
- const unsigned int dofs_per_cell = fe.dofs_per_cell;
- const unsigned int n_face_q_points = face_quadrature_formula.size();
+ const unsigned int dofs_per_cell = fe.dofs_per_cell;
+ const unsigned int n_face_q_points = face_quadrature_formula.size();
- FullMatrix<double> cell_matrix (dofs_per_cell, dofs_per_cell);
- Tensor<1,dim,double> ones (dim);
- for (unsigned i=0; i<dim; i++)
- ones[i] = 1.0;
+ FullMatrix<double> cell_matrix(dofs_per_cell, dofs_per_cell);
+ Tensor<1, dim, double> ones(dim);
+ for (unsigned i = 0; i < dim; i++)
+ ones[i] = 1.0;
- std::vector<types::global_dof_index> local_dof_indices (dofs_per_cell);
+ std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
- const FEValuesExtractors::Vector displacement (0);
+ const FEValuesExtractors::Vector displacement(0);
- typename DoFHandler<dim>::active_cell_iterator
- cell = dof_handler.begin_active(),
- endc = dof_handler.end();
+ typename DoFHandler<dim>::active_cell_iterator cell =
+ dof_handler.begin_active(), endc = dof_handler.end();
- for (; cell!=endc; ++cell)
+ for (; cell != endc; ++cell)
if (cell->is_locally_owned())
- for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
- if (cell->face (face)->at_boundary()
- && cell->face (face)->boundary_indicator () == 9)
+ for (unsigned int face = 0; face < GeometryInfo<dim>::faces_per_cell;
+ ++face)
+ if (cell->face(face)->at_boundary()
+ && cell->face(face)->boundary_indicator() == 1)
{
- fe_values_face.reinit (cell, face);
+ fe_values_face.reinit(cell, face);
cell_matrix = 0;
- for (unsigned int q_point=0; q_point<n_face_q_points; ++q_point)
- for (unsigned int i=0; i<dofs_per_cell; ++i)
- cell_matrix(i,i) += (fe_values_face[displacement].value (i, q_point) *
- ones *
- fe_values_face.JxW (q_point));
+ for (unsigned int q_point = 0; q_point < n_face_q_points;
+ ++q_point)
+ for (unsigned int i = 0; i < dofs_per_cell; ++i)
+ cell_matrix(i, i) += (fe_values_face[displacement].value(i,
+ q_point) * ones * fe_values_face.JxW(q_point));
- cell->get_dof_indices (local_dof_indices);
+ cell->get_dof_indices(local_dof_indices);
- constraints_dirichlet_hanging_nodes.distribute_local_to_global (cell_matrix,
- local_dof_indices,
- mass_matrix);
+ for (unsigned int i = 0; i < dofs_per_cell; i++)
+ mass_matrix.add(local_dof_indices[i], local_dof_indices[i],
+ cell_matrix(i, i));
}
-
- mass_matrix.compress (VectorOperation::add);
+ mass_matrix.compress(VectorOperation::add);
}
- // @sect4{PlasticityContactProblem::update_solution_and_constraints}
+// @sect4{PlasticityContactProblem::update_solution_and_constraints}
- // Projection and updating of the active set
- // for the dofs which penetrates the obstacle.
+// Projection and updating of the active set
+// for the dofs which penetrates the obstacle.
template <int dim>
- void PlasticityContactProblem<dim>::update_solution_and_constraints ()
+ void
+ PlasticityContactProblem<dim>::update_solution_and_constraints ()
{
- computing_timer.enter_section("Update solution and constraints");
-
- const EquationData::Obstacle<dim> obstacle (input_obstacle, use_read_obstacle);
- std::vector<bool> vertex_touched (dof_handler.n_dofs (), false);
+ std::vector<bool> vertex_touched(dof_handler.n_dofs(), false);
typename DoFHandler<dim>::active_cell_iterator
cell = dof_handler.begin_active(),
endc = dof_handler.end();
- TrilinosWrappers::MPI::Vector distributed_solution (system_rhs_newton);
+ TrilinosWrappers::MPI::Vector distributed_solution(system_rhs_newton);
distributed_solution = solution;
- TrilinosWrappers::MPI::Vector lambda (solution);
+ TrilinosWrappers::MPI::Vector lambda(solution);
lambda = resid_vector;
- TrilinosWrappers::MPI::Vector diag_mass_matrix_vector_relevant (solution);
+ TrilinosWrappers::MPI::Vector diag_mass_matrix_vector_relevant(solution);
diag_mass_matrix_vector_relevant = diag_mass_matrix_vector;
- constraints.reinit(locally_relevant_dofs);
- active_set.clear ();
- IndexSet active_set_locally_owned;
- active_set_locally_owned.set_size (locally_owned_dofs.size ());
- const double c = 100.0*e_modul;
-
- for (; cell!=endc; ++cell)
- if (cell->is_locally_owned())
- for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
- if (cell->face (face)->at_boundary()
- && cell->face (face)->boundary_indicator () == 9)
- for (unsigned int v=0; v<GeometryInfo<dim-1>::vertices_per_cell; ++v)
- {
- unsigned int index_z = cell->face (face)->vertex_dof_index (v,2);
-
- if (vertex_touched[cell->face (face)->vertex_index(v)] == false)
- vertex_touched[cell->face (face)->vertex_index(v)] = true;
- else
- continue;
-
- // the local row where
- Point<dim> point (cell->face (face)->vertex (v)[0],
- cell->face (face)->vertex (v)[1],
- cell->face (face)->vertex (v)[2]);
-
- double obstacle_value = obstacle.value (point, 2);
- double solution_index_z = solution (index_z);
- double gap = obstacle_value - point (2);
-
-
-// std::cout << "lambda = " << lambda (index_z)
-// << ", solution_index_z - gap = " << solution_index_z - gap
-// << ", diag_mass_matrix_vector_relevant = " << diag_mass_matrix_vector_relevant (index_z)
-// << std::endl;
-
- if (lambda (index_z) +
- c *
- diag_mass_matrix_vector_relevant (index_z) *
- (solution_index_z - gap)
- > 0 &&
- !(constraints_hanging_nodes.is_constrained(index_z)))
- {
- constraints.add_line (index_z);
- constraints.set_inhomogeneity (index_z, gap);
-
- distributed_solution (index_z) = gap;
+ all_constraints.reinit(locally_relevant_dofs);
+ active_set.clear();
+ IndexSet active_set_locally_owned;
+ active_set_locally_owned.set_size(locally_owned_dofs.size());
+ const double c = 100.0 * e_modulus;
+
+ Quadrature<dim - 1> face_quadrature(fe.get_unit_face_support_points());
+ FEFaceValues<dim> fe_values_face(fe, face_quadrature,
+ update_quadrature_points);
+
+ const unsigned int dofs_per_face = fe.dofs_per_face;
+ const unsigned int n_face_q_points = face_quadrature.size();
+
+ std::vector<types::global_dof_index> dof_indices(dofs_per_face);
+
+ // pcout<< "dofs_per_face = " << dofs_per_face
+ // << "n_face_q_points = " << n_face_q_points
+ // <<std::endl;
+ unsigned int counter_hanging_nodes = 0;
+ for (; cell != endc; ++cell)
+ if (!cell->is_artificial())
+ for (unsigned int face = 0; face < GeometryInfo<dim>::faces_per_cell;
+ ++face)
+ if (cell->face(face)->at_boundary()
+ && cell->face(face)->boundary_indicator() == 1)
+ {
+ fe_values_face.reinit(cell, face);
+ cell->face(face)->get_dof_indices(dof_indices);
- if (locally_relevant_dofs.is_element (index_z))
- active_set.add_index (index_z);
+ for (unsigned int q_point = 0; q_point < n_face_q_points;
+ ++q_point)
+ {
+ unsigned int component = fe.face_system_to_component_index(
+ q_point).first;
- if (locally_owned_dofs.is_element (index_z))
- active_set_locally_owned.add_index (index_z);
- }
- }
- distributed_solution.compress (VectorOperation::insert);
+ if (component == 2)
+ {
+ unsigned int index_z = dof_indices[q_point];
+
+ if (vertex_touched[index_z] == false)
+ vertex_touched[index_z] = true;
+ else
+ continue;
+
+ // the local row where
+ Point<dim> point(
+ fe_values_face.quadrature_point(q_point));
+
+ double obstacle_value = obstacle->value(point, 2);
+ double solution_index_z = solution(index_z);
+ double gap = obstacle_value - point(2);
+
+ if (lambda(index_z)
+ / diag_mass_matrix_vector_relevant(index_z)
+ + c * (solution_index_z - gap) > 0
+ && !(constraints_hanging_nodes.is_constrained(index_z)))
+ {
+ all_constraints.add_line(index_z);
+ all_constraints.set_inhomogeneity(index_z, gap);
+ distributed_solution(index_z) = gap;
+
+ if (locally_owned_dofs.is_element(index_z))
+ {
+ active_set_locally_owned.add_index(index_z);
+ if (locally_relevant_dofs.is_element(index_z))
+ active_set.add_index(index_z);
+ }
+
+ }
+ else if (lambda(index_z)
+ / diag_mass_matrix_vector_relevant(index_z)
+ + c * (solution_index_z - gap) > 0
+ && constraints_hanging_nodes.is_constrained(index_z))
+ {
+ if (locally_owned_dofs.is_element(index_z))
+ counter_hanging_nodes += 1;
+ }
+ }
+ }
+ }
+ distributed_solution.compress(VectorOperation::insert);
- unsigned int sum_contact_constraints = Utilities::MPI::sum(active_set_locally_owned.n_elements (),
- mpi_communicator);
- pcout << " Size of active set: " << sum_contact_constraints <<std::endl;
+ const unsigned int sum_contact_constraints
+ = Utilities::MPI::sum(active_set_locally_owned.n_elements(),
+ mpi_communicator);
+ pcout << " Size of active set: " << sum_contact_constraints
+ << std::endl;
+ const unsigned int sum_contact_hanging_nodes
+ = Utilities::MPI::sum(counter_hanging_nodes,
+ mpi_communicator);
+ pcout << " Number of hanging nodes in contact: "
+ << sum_contact_hanging_nodes << std::endl;
solution = distributed_solution;
- constraints.close ();
-
- constraints.merge (constraints_dirichlet_hanging_nodes);
-
- computing_timer.exit_section("Update solution and constraints");
+ all_constraints.close();
+ all_constraints.merge(constraints_dirichlet_and_hanging_nodes);
}
- // @sect4{PlasticityContactProblem::dirichlet_constraints}
+// @sect4{PlasticityContactProblem::dirichlet_constraints}
- // This function defines the new ConstraintMatrix
- // constraints_dirichlet_hanging_nodes. It contains
- // the dirichlet boundary values as well as the
- // hanging nodes constraints.
+// This function defines the new ConstraintMatrix
+// constraints_dirichlet_hanging_nodes. It contains
+// the Dirichlet boundary values as well as the
+// hanging nodes constraints.
template <int dim>
- void PlasticityContactProblem<dim>::dirichlet_constraints ()
+ void
+ PlasticityContactProblem<dim>::dirichlet_constraints ()
{
/* boundary_indicators:
- _______
- / 9 /|
- /______ / |
- 8| | 8|
- | 8 | /
- |_______|/
- 6
+ _______
+ / 1 /|
+ /______ / |
+ 8| | 8|
+ | 8 | /
+ |_______|/
+ 6
*/
- constraints_dirichlet_hanging_nodes.reinit (locally_relevant_dofs);
- constraints_dirichlet_hanging_nodes.merge (constraints_hanging_nodes);
+ constraints_dirichlet_and_hanging_nodes.reinit(locally_relevant_dofs);
+ constraints_dirichlet_and_hanging_nodes.merge(constraints_hanging_nodes);
// interpolate all components of the solution
- VectorTools::interpolate_boundary_values (dof_handler,
- 6,
- EquationData::BoundaryValues<dim>(),
- constraints_dirichlet_hanging_nodes,
- ComponentMask());
+ VectorTools::interpolate_boundary_values(dof_handler,
+ base_mesh == "box" ? 6 : 0, EquationData::BoundaryValues<dim>(),
+ constraints_dirichlet_and_hanging_nodes, ComponentMask());
// interpolate x- and y-components of the
// solution (this is a bit mask, so apply
// operator| )
- FEValuesExtractors::Scalar x_displacement(0);
- FEValuesExtractors::Scalar y_displacement(1);
- VectorTools::interpolate_boundary_values (dof_handler,
- 8,
- EquationData::BoundaryValues<dim>(),
- constraints_dirichlet_hanging_nodes,
- (fe.component_mask(x_displacement)
- |
- fe.component_mask(y_displacement)));
- constraints_dirichlet_hanging_nodes.close ();
+ const FEValuesExtractors::Scalar x_displacement(0);
+ const FEValuesExtractors::Scalar y_displacement(1);
+ VectorTools::interpolate_boundary_values(dof_handler, 8,
+ EquationData::BoundaryValues<dim>(),
+ constraints_dirichlet_and_hanging_nodes,
+ (fe.component_mask(x_displacement) | fe.component_mask(y_displacement)));
+ constraints_dirichlet_and_hanging_nodes.close();
}
- // @sect4{PlasticityContactProblem::solve}
+// @sect4{PlasticityContactProblem::solve}
- // In addition to step-41 we have
- // to deal with the hanging node
- // constraints. Again we also consider
- // the locally_owned_dofs only by
- // creating the vector distributed_solution.
- //
- // For the hanging nodes we have to apply
- // the set_zero function to system_rhs_newton.
- // This is necessary if a hanging node value x_0
- // has one neighbor which is in contact with
- // value x_0 and one neighbor which is not with
- // value x_1. This leads to an inhomogeneity
- // constraint with value x_1/2 = gap/2 in the
- // ConstraintMatrix.
- // So the corresponding entries in the
- // ride-hang-side are non-zero with a
- // meaningless value. These values have to
- // to set to zero.
-
- // The rest of the function is similar to
- // step-41 except that we use a FGMRES-solver
- // instead of CG. For a very small hardening
- // value gamma the linear system becomes
- // almost semi definite but still symmetric.
+// In addition to step-41 we have
+// to deal with the hanging node
+// constraints. Again we also consider
+// the locally_owned_dofs only by
+// creating the vector distributed_solution.
+//
+// For the hanging nodes we have to apply
+// the set_zero function to system_rhs_newton.
+// This is necessary if a hanging node value x_0
+// has one neighbor which is in contact with
+// value x_0 and one neighbor which is not with
+// value x_1. This leads to an inhomogeneity
+// constraint with value x_1/2 = gap/2 in the
+// ConstraintMatrix.
+// So the corresponding entries in the
+// ride-hang-side are non-zero with a
+// meaningless value. These values have to
+// to set to zero.
+
+// The rest of the function is similar to
+// step-41 except that we use a FGMRES-solver
+// instead of CG. For a very small hardening
+// value gamma the linear system becomes
+// almost semi definite but still symmetric.
template <int dim>
- void PlasticityContactProblem<dim>::solve ()
+ void
+ PlasticityContactProblem<dim>::solve ()
{
- computing_timer.enter_section ("Solve");
+ TimerOutput::Scope t(computing_timer, "Solve");
- TrilinosWrappers::MPI::Vector distributed_solution (system_rhs_newton);
+ TrilinosWrappers::MPI::Vector distributed_solution(system_rhs_newton);
distributed_solution = solution;
- constraints_hanging_nodes.set_zero (distributed_solution);
- constraints_hanging_nodes.set_zero (system_rhs_newton);
+ constraints_hanging_nodes.set_zero(distributed_solution);
+ constraints_hanging_nodes.set_zero(system_rhs_newton);
distributed_solution.compress(VectorOperation::insert);
system_rhs_newton.compress(VectorOperation::insert);
- computing_timer.enter_section("Solve: setup preconditioner");
-
- preconditioner_u.initialize (system_matrix_newton, additional_data);
-
- computing_timer.exit_section("Solve: setup preconditioner");
-
- computing_timer.enter_section("Solve: iterate");
-
- PrimitiveVectorMemory<TrilinosWrappers::MPI::Vector> mem;
- TrilinosWrappers::MPI::Vector tmp (system_rhs_newton);
- const double solver_tolerance = 1e-3 *
- system_matrix_newton.residual (tmp, distributed_solution, system_rhs_newton);
-
-// SolverControl solver_control (system_matrix_newton.m(), solver_tolerance);
-// SolverFGMRES<TrilinosWrappers::MPI::Vector>
-// solver(solver_control, mem,
-// SolverFGMRES<TrilinosWrappers::MPI::Vector>::
-// AdditionalData(30, true));
-//
-// solver.solve(system_matrix_newton, distributed_solution, system_rhs_newton, preconditioner_u);
-//
-// pcout << " Error: " << solver_control.initial_value()
-// << " -> " << solver_control.last_value()
-// << " in " << solver_control.last_step()
-// << " FGMRES iterations."
-// << std::endl;
-
- SolverControl solver_control (system_matrix_newton.m(), solver_tolerance);
- SolverBicgstab<TrilinosWrappers::MPI::Vector>
- solver(solver_control, mem,
- SolverBicgstab<TrilinosWrappers::MPI::Vector>::
- AdditionalData(false, 1.e-10));
-
- solver.solve(system_matrix_newton, distributed_solution, system_rhs_newton, preconditioner_u);
-
- pcout << " Error: " << solver_control.initial_value()
- << " -> " << solver_control.last_value()
- << " in " << solver_control.last_step()
- << " Bicgstab iterations."
- << std::endl;
-
- computing_timer.exit_section("Solve: iterate");
+ TrilinosWrappers::PreconditionAMG preconditioner;
+ {
+ TimerOutput::Scope t(computing_timer, "Solve: setup preconditioner");
+
+ std::vector < std::vector<bool> > constant_modes;
+ DoFTools::extract_constant_modes(dof_handler, ComponentMask(),
+ constant_modes);
+
+ TrilinosWrappers::PreconditionAMG::AdditionalData additional_data;
+ additional_data.constant_modes = constant_modes;
+ additional_data.elliptic = true;
+ additional_data.n_cycles = 1;
+ additional_data.w_cycle = false;
+ additional_data.output_details = false;
+ additional_data.smoother_sweeps = 2;
+ additional_data.aggregation_threshold = 1e-2;
+
+ preconditioner.initialize(system_matrix_newton, additional_data);
+ }
- number_iterations += solver_control.last_step();
+ {
+ TimerOutput::Scope t(computing_timer, "Solve: iterate");
+
+ PrimitiveVectorMemory<TrilinosWrappers::MPI::Vector> mem;
+ TrilinosWrappers::MPI::Vector tmp(system_rhs_newton);
+ // 1e-4 seems to be the fasted option altogether, but to get more
+ // reproducible parallel benchmark results, we use a small residual:
+ double relative_accuracy = 1e-8;
+ if (output_dir.compare("its/") == 0)
+ relative_accuracy = 1e-4;
+
+ const double solver_tolerance = relative_accuracy
+ * system_matrix_newton.residual(tmp, distributed_solution,
+ system_rhs_newton);
+
+ SolverControl solver_control(system_matrix_newton.m(),
+ solver_tolerance);
+ SolverBicgstab<TrilinosWrappers::MPI::Vector> solver(solver_control,
+ mem/*,
+ SolverFGMRES<TrilinosWrappers::MPI::Vector>::
+ AdditionalData(30, true)*/);
+ solver.solve(system_matrix_newton, distributed_solution,
+ system_rhs_newton, preconditioner);
+
+ pcout << " Error: " << solver_control.initial_value()
+ << " -> " << solver_control.last_value() << " in "
+ << solver_control.last_step() << " Bicgstab iterations."
+ << std::endl;
+ }
- constraints.distribute (distributed_solution);
+ all_constraints.distribute(distributed_solution);
solution = distributed_solution;
-
- computing_timer.exit_section("Solve");
}
- // @sect4{PlasticityContactProblem::solve_newton}
+// @sect4{PlasticityContactProblem::solve_newton}
- // In this function the damped Newton method is implemented.
- // That means two nested loops: the outer loop for the newton
- // iteration and the inner loop for the damping steps which
- // will be used only if necessary. To obtain a good and reasonable
- // starting value we solve an elastic problem in very first step (j=1).
+// In this function the damped Newton method is implemented.
+// That means two nested loops: the outer loop for the newton
+// iteration and the inner loop for the damping steps which
+// will be used only if necessary. To obtain a good and reasonable
+// starting value we solve an elastic problem in very first step (j=1).
template <int dim>
- void PlasticityContactProblem<dim>::solve_newton ()
+ void
+ PlasticityContactProblem<dim>::solve_newton ()
{
- double resid=0;
- double resid_old=100000;
- TrilinosWrappers::MPI::Vector old_solution (system_rhs_newton);
- TrilinosWrappers::MPI::Vector res (system_rhs_newton);
- TrilinosWrappers::MPI::Vector tmp_vector (system_rhs_newton);
+ TimerOutput::Scope t(computing_timer, "solve newton setup");
- std::vector<std::vector<bool> > constant_modes;
- DoFTools::extract_constant_modes (dof_handler,
- ComponentMask(),
- constant_modes);
+ double resid = 0;
+ double resid_old = 100000;
+ TrilinosWrappers::MPI::Vector old_solution(system_rhs_newton);
+ TrilinosWrappers::MPI::Vector res(system_rhs_newton);
+ TrilinosWrappers::MPI::Vector tmp_vector(system_rhs_newton);
double sigma_hlp = sigma_0;
- additional_data.constant_modes = constant_modes;
- additional_data.elliptic = true;
- additional_data.n_cycles = 1;
- additional_data.w_cycle = false;
- additional_data.output_details = false;
- additional_data.smoother_sweeps = 2;
- additional_data.aggregation_threshold = 1e-2;
+ IndexSet active_set_old(active_set);
+
+ t.stop(); // stop newton setup timer
- IndexSet active_set_old (active_set);
unsigned int j = 1;
unsigned int number_assemble_system = 0;
- for (; j<=100; j++)
+ for (; j <= 100; j++)
{
- if (j == 1 && cycle == 0)
- plast_lin_hard->set_sigma_0 (1e+10);
- else if (j == 2 || cycle > 0)
- plast_lin_hard->set_sigma_0 (sigma_hlp);
+ if (transfer_solution)
+ {
+ if (transfer_solution && j == 1 && current_refinement_cycle == 0)
+ constitutive_law.set_sigma_0(1e+10);
+ else if (transfer_solution && (j == 2 || current_refinement_cycle > 0))
+ constitutive_law.set_sigma_0(sigma_hlp);
+ }
+ else
+ {
+ if (j == 1)
+ constitutive_law.set_sigma_0(1e+10);
+ else
+ constitutive_law.set_sigma_0(sigma_hlp);
+ }
- pcout << " " <<std::endl;
+ pcout << " " << std::endl;
pcout << " Newton iteration " << j << std::endl;
pcout << " Updating active set..." << std::endl;
- update_solution_and_constraints ();
+ {
+ TimerOutput::Scope t(computing_timer, "update active set");
+ update_solution_and_constraints();
+ }
pcout << " Assembling system... " << std::endl;
system_matrix_newton = 0;
system_rhs_newton = 0;
- assemble_nl_system (solution); //compute Newton-Matrix
+ assemble_nl_system(solution); //compute Newton-Matrix
number_assemble_system += 1;
pcout << " Solving system... " << std::endl;
- solve ();
+ solve();
- TrilinosWrappers::MPI::Vector distributed_solution (system_rhs_newton);
+ TrilinosWrappers::MPI::Vector distributed_solution(system_rhs_newton);
distributed_solution = solution;
-
// We handle a highly nonlinear problem so we have to damp
// the Newtons method. We refer that we iterate the new solution
// in each Newton step and not only the solution update.
bool damped = false;
tmp_vector = old_solution;
double a = 0;
- for (unsigned int i=0; (i<10)&&(!damped); i++)
+ for (unsigned int i = 0; (i < 5) && (!damped); i++)
{
- a=std::pow(0.5, static_cast<double>(i));
+ a = std::pow(0.5, static_cast<double>(i));
old_solution = tmp_vector;
- old_solution.sadd(1-a,a, distributed_solution);
- old_solution.compress (VectorOperation::add);
+ old_solution.sadd(1 - a, a, distributed_solution);
+ old_solution.compress(VectorOperation::add);
- computing_timer.enter_section("Residual and lambda");
+ TimerOutput::Scope t(computing_timer, "Residual and lambda");
system_rhs_newton = 0;
+ system_rhs_lambda = 0;
solution = old_solution;
- residual_nl_system (solution);
+ compute_nonlinear_residual(solution);
res = system_rhs_newton;
- const unsigned int
- start_res = (res.local_range().first),
- end_res = (res.local_range().second);
- for (unsigned int n=start_res; n<end_res; ++n)
- if (constraints.is_inhomogeneously_constrained (n))
+ const unsigned int start_res = (res.local_range().first),
+ end_res = (res.local_range().second);
+ for (unsigned int n = start_res; n < end_res; ++n)
+ if (all_constraints.is_inhomogeneously_constrained(n))
res(n) = 0;
res.compress(VectorOperation::insert);
- resid = res.l2_norm ();
+ resid = res.l2_norm();
- if (resid<resid_old)
- damped=true;
+ if (resid < resid_old)
+ damped = true;
- computing_timer.exit_section("Residual and lambda");
-
- pcout << " Residual of the non-contact part of the system: " << resid
- << std::endl
- << " with a damping parameter alpha = " << a
- << std::endl;
+ pcout << " Residual of the non-contact part of the system: "
+ << resid << std::endl
+ << " with a damping parameter alpha = " << a
+ << std::endl;
// The previous iteration of step 0 is the solution of an elastic problem.
// So a linear combination of a plastic and an elastic solution makes no sense
// since the elastic solution is not in the convex set of the plastic solution.
- if (j == 2)
+ if (!transfer_solution && j == 2)
+ break;
+ if (transfer_solution && j == 2 && current_refinement_cycle == 0)
break;
}
- resid_old=resid;
+ resid_old = resid;
- resid_vector = system_rhs_newton;
- resid_vector.compress (VectorOperation::insert);
+ resid_vector = system_rhs_lambda;
- int is_my_set_changed = (active_set == active_set_old)?0:1;
- int num_changed = Utilities::MPI::sum(is_my_set_changed, MPI_COMM_WORLD);
- if (num_changed==0 && resid < 1e-8)
- break;
+ if (Utilities::MPI::sum((active_set == active_set_old) ? 0 : 1,
+ mpi_communicator) == 0)
+ {
+ pcout << " Active set did not change!" << std::endl;
+ if (output_dir.compare("its/") != 0 && resid < 1e-7)
+ break;
+ else if (output_dir.compare("its/") == 0 && resid < 1e-10)
+ break;
+ }
active_set_old = active_set;
}
- pcout << "" << std::endl
- << " Number of assembled systems = " << number_assemble_system
- << std::endl
- << " Number of Solver-Iterations = " << number_iterations << std::endl;
+ pcout << "" << std::endl << " Number of assembled systems = "
+ << number_assemble_system << std::endl;
}
-
+// @sect3{The <code>refine_grid</code> function}
template <int dim>
- void PlasticityContactProblem<dim>::refine_grid ()
+ void
+ PlasticityContactProblem<dim>::refine_grid ()
{
- Vector<float> estimated_error_per_cell (triangulation.n_active_cells());
- KellyErrorEstimator<dim>::estimate (dof_handler,
- QGauss<dim-1>(3),
- typename FunctionMap<dim>::type(),
- solution,
- estimated_error_per_cell);
- parallel::distributed::GridRefinement::
- refine_and_coarsen_fixed_number (triangulation,
- estimated_error_per_cell,
- 0.3, 0.03);
+ if (refinement_strategy == RefinementStrategy::refine_global)
+ {
+ for (typename Triangulation<dim>::active_cell_iterator
+ cell = triangulation.begin_active();
+ cell != triangulation.end(); ++cell)
+ if (cell->is_locally_owned())
+ cell->set_refine_flag ();
+ }
+ else
+ {
+ Vector<float> estimated_error_per_cell(triangulation.n_active_cells());
+ KellyErrorEstimator<dim>::estimate(dof_handler,
+ QGauss<dim - 1>(fe.degree + 2),
+ typename FunctionMap<dim>::type(),
+ solution,
+ estimated_error_per_cell);
+
+ parallel::distributed::GridRefinement::refine_and_coarsen_fixed_number(
+ triangulation, estimated_error_per_cell, 0.3, 0.03);
+ }
triangulation.prepare_coarsening_and_refinement();
- soltrans->prepare_for_coarsening_and_refinement(solution);
- triangulation.execute_coarsening_and_refinement ();
- }
+ parallel::distributed::SolutionTransfer<dim,
+ TrilinosWrappers::MPI::Vector> solution_transfer(dof_handler);
+ if (transfer_solution)
+ solution_transfer.prepare_for_coarsening_and_refinement(solution);
+ triangulation.execute_coarsening_and_refinement();
+ setup_system();
+
+ if (transfer_solution)
+ {
+ TrilinosWrappers::MPI::Vector distributed_solution(system_rhs_newton);
+ distributed_solution = solution;
+ solution_transfer.interpolate(distributed_solution);
+ solution = distributed_solution;
+ compute_nonlinear_residual(solution);
+ resid_vector = system_rhs_lambda;
+ }
+ }
+
+// @sect3{The <code>move_mesh</code> function}
template <int dim>
- void PlasticityContactProblem<dim>::move_mesh (const TrilinosWrappers::MPI::Vector &_complete_displacement) const
+ void
+ PlasticityContactProblem<dim>::move_mesh (
+ const TrilinosWrappers::MPI::Vector &_complete_displacement) const
{
- std::vector<bool> vertex_touched (triangulation.n_vertices(),
- false);
+ std::vector<bool> vertex_touched(triangulation.n_vertices(), false);
- for (typename DoFHandler<dim>::active_cell_iterator
- cell = dof_handler.begin_active ();
- cell != dof_handler.end(); ++cell)
+ for (typename DoFHandler<dim>::active_cell_iterator cell =
+ dof_handler.begin_active(); cell != dof_handler.end(); ++cell)
if (cell->is_locally_owned())
- for (unsigned int v=0; v<GeometryInfo<dim>::vertices_per_cell; ++v)
+ for (unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_cell;
+ ++v)
{
if (vertex_touched[cell->vertex_index(v)] == false)
{
vertex_touched[cell->vertex_index(v)] = true;
Point<dim> vertex_displacement;
- for (unsigned int d=0; d<dim; ++d)
+ for (unsigned int d = 0; d < dim; ++d)
{
- if (_complete_displacement(cell->vertex_dof_index(v,d)) != 0)
- vertex_displacement[d]
- = _complete_displacement(cell->vertex_dof_index(v,d));
+ if (_complete_displacement(cell->vertex_dof_index(v, d))
+ != 0)
+ vertex_displacement[d] = _complete_displacement(
+ cell->vertex_dof_index(v, d));
}
cell->vertex(v) += vertex_displacement;
}
}
-
+// @sect4{PlasticityContactProblem::output_results}
template <int dim>
- void PlasticityContactProblem<dim>::output_results (const std::string &title) const
+ void
+ PlasticityContactProblem<dim>::output_results (const std::string &filename_base)
{
- move_mesh (solution);
-
- TrilinosWrappers::MPI::Vector lambda (solution);
- lambda = resid_vector;
+ TimerOutput::Scope t(computing_timer, "Graphical output");
+
+ pcout << " Writing graphical output... " << std::flush;
+
+ move_mesh(solution);
+
+ // Calculation of the contact forces
+ TrilinosWrappers::MPI::Vector lambda(solution);
+ TrilinosWrappers::MPI::Vector distributed_lambda(system_rhs_newton);
+ const unsigned int start_res = (resid_vector.local_range().first),
+ end_res = (resid_vector.local_range().second);
+ for (unsigned int n = start_res; n < end_res; ++n)
+ if (all_constraints.is_inhomogeneously_constrained(n))
+ distributed_lambda(n) = resid_vector(n) / diag_mass_matrix_vector(n);
+ distributed_lambda.compress(VectorOperation::insert);
+ constraints_hanging_nodes.distribute(distributed_lambda);
+ lambda = distributed_lambda;
+ TrilinosWrappers::MPI::Vector resid_vector_relevant(solution);
+ TrilinosWrappers::MPI::Vector distributed_resid_vector(resid_vector);
+ constraints_hanging_nodes.distribute(distributed_resid_vector);
+ resid_vector_relevant = distributed_resid_vector;
DataOut<dim> data_out;
- data_out.attach_dof_handler (dof_handler);
-
- const std::vector<DataComponentInterpretation::DataComponentInterpretation>
- data_component_interpretation
- (dim, DataComponentInterpretation::component_is_part_of_vector);
- data_out.add_data_vector (solution, std::vector<std::string>(dim, "Displacement"),
- DataOut<dim>::type_dof_data,
- data_component_interpretation);
- data_out.add_data_vector (lambda, std::vector<std::string>(dim, "Residual"),
- DataOut<dim>::type_dof_data,
- data_component_interpretation);
- data_out.add_data_vector (active_set, std::vector<std::string>(dim, "ActiveSet"),
- DataOut<dim>::type_dof_data,
- data_component_interpretation);
-
- Vector<float> subdomain (triangulation.n_active_cells());
- for (unsigned int i=0; i<subdomain.size(); ++i)
+ data_out.attach_dof_handler(dof_handler);
+
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> data_component_interpretation(
+ dim, DataComponentInterpretation::component_is_part_of_vector);
+ data_out.add_data_vector(solution,
+ std::vector < std::string > (dim, "Displacement"),
+ DataOut<dim>::type_dof_data, data_component_interpretation);
+ data_out.add_data_vector(lambda,
+ std::vector < std::string > (dim, "ContactForce"),
+ DataOut<dim>::type_dof_data, data_component_interpretation);
+ data_out.add_data_vector(active_set,
+ std::vector < std::string > (dim, "ActiveSet"),
+ DataOut<dim>::type_dof_data, data_component_interpretation);
+ data_out.add_data_vector(resid_vector_relevant,
+ std::vector < std::string > (dim, "Residual"),
+ DataOut<dim>::type_dof_data, data_component_interpretation);
+
+ Vector<float> subdomain(triangulation.n_active_cells());
+ for (unsigned int i = 0; i < subdomain.size(); ++i)
subdomain(i) = triangulation.locally_owned_subdomain();
- data_out.add_data_vector (subdomain, "subdomain");
+ data_out.add_data_vector(subdomain, "subdomain");
- data_out.add_data_vector (cell_constitution, "CellConstitution");
+ data_out.add_data_vector(fraction_of_plastic_q_points_per_cell, "FractionOfPlasticQPoints");
- data_out.build_patches ();
+ data_out.build_patches();
- const std::string filename = (title + "-" +
- Utilities::int_to_string
- (triangulation.locally_owned_subdomain(), 4));
+ const std::string filename =
+ (output_dir + filename_base + "-"
+ + Utilities::int_to_string(triangulation.locally_owned_subdomain(), 4));
- std::ofstream output_vtu ((filename + ".vtu").c_str ());
- data_out.write_vtu (output_vtu);
+ std::ofstream output_vtu((filename + ".vtu").c_str());
+ data_out.write_vtu(output_vtu);
+ pcout << output_dir + filename_base << ".pvtu" << std::endl;
if (Utilities::MPI::this_mpi_process(mpi_communicator) == 0)
{
- std::vector<std::string> filenames;
- for (unsigned int i=0;
- i<Utilities::MPI::n_mpi_processes(mpi_communicator);
- ++i)
- filenames.push_back (title + "-" +
- Utilities::int_to_string (i, 4) +
- ".vtu");
-
- std::ofstream master_output ((filename + ".pvtu").c_str());
- data_out.write_pvtu_record (master_output, filenames);
+ std::vector < std::string > filenames;
+ for (unsigned int i = 0;
+ i < Utilities::MPI::n_mpi_processes(mpi_communicator); ++i)
+ filenames.push_back(
+ filename_base + "-" + Utilities::int_to_string(i, 4) + ".vtu");
+
+ std::ofstream master_output((output_dir + filename_base + ".pvtu").c_str());
+ data_out.write_pvtu_record(master_output, filenames);
}
- TrilinosWrappers::MPI::Vector tmp (solution);
+ TrilinosWrappers::MPI::Vector tmp(solution);
tmp *= -1;
- move_mesh (tmp);
+ move_mesh(tmp);
}
-
-
+// @sect4{PlasticityContactProblem::output_contact_force}
+
+// This function provides the contact force by calculating
+// an integral over the contact pressure in z-directions
+// over the contact area. For this purpose we set the contact
+// pressure lambda to 0 for all inactive dofs. For all
+// active dofs we lambda contains the quotient of the nonlinear
+// residual (resid_vector) and corresponding diagonal entry
+// of the mass matrix (diag_mass_matrix_vector). Because it is
+// not unlikely that hanging nodes shows up in the contact area
+// it is important to apply contraints_hanging_nodes.distribute
+// to the distributed_lambda vector.
+// To calculate the contact pressure in a certain point in the
+// contact area, we apply the Functions::FEFieldFunction.
+// In parallel this is a little tricky because we have to find the
+// process with the right cell which contains this point. If
+// a processor does not own the cell with the point we have to
+// catch these cases.
template <int dim>
- void PlasticityContactProblem<dim>::run ()
+ void
+ PlasticityContactProblem<dim>::output_contact_force () const
{
- use_read_obstacle = false;
- if (use_read_obstacle)
- {
- pcout << "Read the obstacle from a file." << std::endl;
- input_obstacle.reset (new Input<dim>("obstacle_file.pbm"));
- pcout << "Obstacle is available now." << std::endl;
- }
-
- const unsigned int n_cycles = 6;
- for (cycle=0; cycle<n_cycles; ++cycle)
+ Functions::FEFieldFunction<dim, DoFHandler<dim>,
+ TrilinosWrappers::MPI::Vector> solution_function(dof_handler,
+ solution);
+ std::cout.precision(10);
+
+ Vector<double> solution_p1(dim);
+ std::vector<Tensor<1, dim> > solution_gradient_p1(dim);
+
+ // Here we calculate the contact pressure as a vector lambda.
+ // If a dof is element of the active set lambda contains the
+ // nonlinear residual this dof divided by the according entry
+ // of the mass matrix. In all other dofs lambda will be set to
+ // zero.
+ TrilinosWrappers::MPI::Vector lambda(solution);
+ TrilinosWrappers::MPI::Vector distributed_lambda(system_rhs_newton);
+ const unsigned int start_res = (resid_vector.local_range().first),
+ end_res = (resid_vector.local_range().second);
+ for (unsigned int n = start_res; n < end_res; ++n)
+ if (all_constraints.is_inhomogeneously_constrained(n))
+ distributed_lambda(n) = resid_vector(n) / diag_mass_matrix_vector(n);
+ else
+ distributed_lambda(n) = 0;
+ distributed_lambda.compress(VectorOperation::insert);
+ constraints_hanging_nodes.distribute(distributed_lambda);
+ lambda = distributed_lambda;
+ Functions::FEFieldFunction<dim, DoFHandler<dim>,
+ TrilinosWrappers::MPI::Vector> lambda_function(dof_handler, lambda);
+
+ // Here we try to find the MPI-process which owns the cell
+ // with the point_of_interest. If it is the wrong MPI-process
+ // we catch this case and set point_found to false.
+ const Point<dim> point_of_interest(0.49, 0.5001, 1.0);
+ Vector<double> contact_pressure_in_point(dim);
+ bool point_found = true;
+
+ MPI_Barrier(MPI_COMM_WORLD);
+ try
{
- computing_timer.enter_section("Setup");
+ lambda_function.vector_value(point_of_interest,
+ contact_pressure_in_point);
+ }
+ catch (const typename Functions::FEFieldFunction<dim, DoFHandler<dim>,
+ TrilinosWrappers::MPI::Vector>::ExcPointNotAvailableHere &)
+ {
+ point_found = false;
+ }
- pcout << std::endl;
- pcout << "Cycle " << cycle << ':' << std::endl;
+ if (point_found == true)
+ {
+ std::cout << "PoI contact pressure: " << contact_pressure_in_point(2)
+ << std::endl;
+ }
- if (cycle == 0)
- {
- make_grid();
- }
- else
- {
- computing_timer.enter_section("Setup: refine mesh");
- soltrans.reset (new parallel::distributed::SolutionTransfer<dim,TrilinosWrappers::MPI::Vector>(dof_handler));
- refine_grid ();
- computing_timer.exit_section("Setup: refine mesh");
- }
+ // To obtain the contact force we have to compute an integral of the contact pressure
+ // in z-direction over the whole contact area. To be accurate enough we use the
+ // Gaussian quadrature rule with fe.degree + 1.
+ double contact_force = 0.0;
+ {
+ QGauss<dim - 1> face_quadrature_formula(fe.degree + 1);
- setup_system ();
+ FEFaceValues<dim> fe_values_face(fe, face_quadrature_formula,
+ update_values | update_quadrature_points | update_JxW_values);
- if (cycle > 0)
- {
- TrilinosWrappers::MPI::Vector distributed_solution (system_rhs_newton);
- distributed_solution = solution;
- soltrans->interpolate(distributed_solution);
- solution = distributed_solution;
- }
+ const unsigned int n_face_q_points = face_quadrature_formula.size();
+
+ const FEValuesExtractors::Vector displacement(0);
+
+ typename DoFHandler<dim>::active_cell_iterator cell =
+ dof_handler.begin_active(), endc = dof_handler.end();
+ for (; cell != endc; ++cell)
+ if (cell->is_locally_owned())
+ for (unsigned int face = 0;
+ face < GeometryInfo<dim>::faces_per_cell; ++face)
+ if (cell->face(face)->at_boundary()
+ && cell->face(face)->boundary_indicator() == 1)
+ {
+ fe_values_face.reinit(cell, face);
+
+ std::vector<Tensor<1, dim> > lambda_values(n_face_q_points);
+ fe_values_face[displacement].get_function_values(lambda,
+ lambda_values);
- computing_timer.exit_section("Setup");
+ for (unsigned int q_point = 0; q_point < n_face_q_points;
+ ++q_point)
+ {
+ contact_force += lambda_values[q_point][2]
+ * fe_values_face.JxW(q_point);
+ }
+ }
+ contact_force = Utilities::MPI::sum(contact_force, MPI_COMM_WORLD);
+ pcout << "Contact force = " << contact_force << std::endl;
+ }
+ MPI_Barrier(MPI_COMM_WORLD);
+ }
+
+
+ // @sect4{PlasticityContactProblem::run}
+
+ // As in all other tutorial programs, the <code>run()</code> function contains
+ // the overall logic. There is not very much to it here: in essence, it
+ // performs the loops over all mesh refinement cycles, and within each, hands
+ // things over to the Newton solver in <code>solve_newton()</code> on the
+ // current mesh and calls the function that creates graphical output for
+ // the so-computed solution. It then outputs some statistics concerning both
+ // run times and memory consumption that has been collected over the course of
+ // computations on this mesh.
+ template <int dim>
+ void
+ PlasticityContactProblem<dim>::run ()
+ {
+ computing_timer.reset();
+ for (current_refinement_cycle = 0;
+ current_refinement_cycle < n_refinement_cycles;
+ ++current_refinement_cycle)
+ {
+ {
+ TimerOutput::Scope t(computing_timer, "Setup");
- solve_newton ();
+ pcout << std::endl;
+ pcout << "Cycle " << current_refinement_cycle << ':' << std::endl;
- pcout << " Writing graphical output..." << std::endl;
- computing_timer.enter_section("Graphical output");
+ if (current_refinement_cycle == 0)
+ {
+ make_grid();
+ setup_system();
+ }
+ else
+ {
+ TimerOutput::Scope t(computing_timer, "Setup: refine mesh");
+ refine_grid();
+ }
+ }
- std::ostringstream filename_solution;
- filename_solution << "solution-";
- filename_solution << cycle;
- output_results (filename_solution.str ());
+ solve_newton();
- computing_timer.exit_section("Graphical output");
+ output_results((std::string("solution-") +
+ Utilities::int_to_string(current_refinement_cycle, 2)).c_str());
computing_timer.print_summary();
computing_timer.reset();
+
+ Utilities::System::MemoryStats stats;
+ Utilities::System::get_memory_stats(stats);
+ pcout << "Peak virtual memory used, resident in kB: " << stats.VmSize << " "
+ << stats.VmRSS << std::endl;
+
+ if (base_mesh == "box")
+ output_contact_force();
}
}
}
// @sect3{The <code>main</code> function}
+// There really isn't much to the <code>main()</code> function. It looks
+// like they always do:
int main (int argc, char *argv[])
{
using namespace dealii;
using namespace Step42;
- deallog.depth_console (0);
-
- Utilities::MPI::MPI_InitFinalize mpi_initialization (argc, argv);
- {
- int _n_refinements_global = 3;
-
- if (argc == 2)
- _n_refinements_global = atoi(argv[1]);
+ try
+ {
+ deallog.depth_console(0);
+ ParameterHandler prm;
+ PlasticityContactProblem<3>::declare_parameters(prm);
+ if (argc != 2)
+ {
+ std::cerr << "*** Call this program as <./step-42 input.prm>" << std::endl;
+ return 1;
+ }
- PlasticityContactProblem<3> laplace_problem_3d (_n_refinements_global);
- laplace_problem_3d.run ();
- }
+ prm.read_input(argv[1]);
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv);
+ {
+ PlasticityContactProblem<3> problem(prm);
+ problem.run();
+ }
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ }
return 0;
}
MESSAGE(FATAL_ERROR "
Error! The deal.II library found at ${DEAL_II_PATH} was not configured with
DEAL_II_WITH_TRILINOS = ON
-which is required for this tutorial step."
+One or all of these are OFF in your installation but are required for this tutorial step."
)
ENDIF()
media. Computers & Fluids, 39:1585-1596, 2010
- Chih-Che Chueh, Ned Djilali, Wolfgang Bangerth. An h-adaptive operator
splitting method for two-phase flow in 3D heterogeneous porous
- media. Submitted.
+ media. SIAM Journal on Scientific Computing, 35:B149-B175, 2013.
The implementation discussed here uses and extends
parts of the step-21 and step-31 tutorial programs.
CC Chueh, N Djilali and W Bangerth.
<br> An h-adaptive operator splitting method for two-phase flow in 3D
heterogeneous porous media.
-<br> <i>Submitted</i>, 2012.
+<br> SIAM Journal on Scientific Computing, vol. 35 (2013), pp. B149-B175
<li>
M. Kronbichler, T. Heister, and W. Bangerth
<br> High Accuracy Mantle Convection Simulation through Modern Numerical
Methods.
-<br> <i>Submitted to Geophysics Journal International</i>, 2011.
+<br> Geophysics Journal International, vol. 191 (2012), pp. 12-29
<li>
F Brezzi and M Fortin.
<li>
JL Guermond and R Pasquetti.
-<br> Entropy-based nonlinear viscosity for fourier approximations of
+<br> Entropy-based nonlinear viscosity for Fourier approximations of
conservation laws.
<br> <i>Comptes Rendus Mathematique</i>, 346(13-14):801-806, 2008.
-/* Author: Chih-Che Chueh, University of Victoria, 2010 */
-/* Wolfgang Bangerth, Texas A&M University, 2010 */
-
-/* $Id$ */
-/* */
-/* Copyright (C) 2010-2012 by Chih-Che Chueh and 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. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2010 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Authors: Chih-Che Chueh, University of Victoria, 2010
+ * Wolfgang Bangerth, Texas A&M University, 2010
+ */
// @sect3{Include files}
// Unlike step-31, this step uses one more ConstraintMatrix object called
// darcy_preconditioner_constraints. This constraint object is used only for
// assembling the matrix for the Darcy preconditioner and includes hanging
- // node constrants as well as Dirichlet boundary value constraints for the
+ // node constraints as well as Dirichlet boundary value constraints for the
// pressure variable. We need this because we are building a Laplace matrix
// for the pressure as an approximation of the Schur complement) which is
// only positive definite if boundary conditions are applied.
// the run() function, the central one in this program.
//
// At the beginning of the function, we ask whether to solve the
- // pressure-velocity part by evaluating the posteriori criterion (see the
+ // pressure-velocity part by evaluating the a posteriori criterion (see the
// following function). If necessary, we will solve the pressure-velocity
// part using the GMRES solver with the Schur complement block
// preconditioner as is described in the introduction.
//
// With the exception of the startup code that loops back to the beginning
// of the function through the <code>goto start_time_iteration</code> label,
- // everything should be relatively straightforward. In any case, it mimicks
+ // everything should be relatively straightforward. In any case, it mimics
// the corresponding function in step-31.
template <int dim>
void TwoPhaseFlowProblem<dim>::run ()
Classical single-field approaches (see e.g. step-18) can not correctly describe the response of quasi-incompressible materials.
The response is overly stiff; a phenomenon known as locking.
Locking problems can be circumvented using a variety of alternative strategies.
-One such straegy is the three-field formulation.
+One such strategy is the three-field formulation.
It is used here to model the three-dimensional, fully-nonlinear (geometrical and material) response of an isotropic continuum body.
The material response is approximated as hyperelastic.
Additionally, the three-field formulation employed is valid for quasi-incompressible as well as compressible materials.
@f}
There are no derivatives of the pressure and dilatation (primary) variables present in the formulation.
-Thus the discontinuous finite element interpolation of the pressure ana dilatation yields a block
+Thus the discontinuous finite element interpolation of the pressure and dilatation yields a block
diagonal matrix for
$\mathbf{\mathsf{K}}_{\widetilde{p}\widetilde{J}}$,
$\mathbf{\mathsf{K}}_{\widetilde{J}\widetilde{p}}$ and
discussed and demonstrated in Step-18 and others.
With over 93% of the time being spent in the linear solver, it is obvious that it may be necessary
to invest in a better solver for large three-dimensional problems.
-The SSOR preconditioner is not multi-threaded but is effective for this class of solid problems.
+The SSOR preconditioner is not multithreaded but is effective for this class of solid problems.
It may be beneficial to investigate the use of another solver such as those available through the Trilinos library.
-/* Authors: Jean-Paul Pelteret, University of Cape Town, */
-/* Andrew McBride, University of Erlangen-Nuremberg, 2010 */
-/* */
-/* Copyright (C) 2010-2012 by the deal.II authors */
-/* & Jean-Paul Pelteret and Andrew McBride */
-/* */
-/* 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. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2010 - 2013 by the deal.II authors and
+ * & Jean-Paul Pelteret and Andrew McBride
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+/*
+ * Authors: Jean-Paul Pelteret, University of Cape Town,
+ * Andrew McBride, University of Erlangen-Nuremberg, 2010
+ */
+
// We start by including all the necessary deal.II header files and some C++
// related ones. They have been discussed in detail in previous tutorial
}
protected:
- // Define constitutive model paramaters $\kappa$ (bulk modulus) and the
+ // Define constitutive model parameters $\kappa$ (bulk modulus) and the
// neo-Hookean model parameter $c_1$:
const double kappa;
const double c_1;
// \textrm{Grad}\ \mathbf{u}$: Since $I$ has data type SymmetricTensor,
// just writing <code>I + Grad_u_n</code> would convert the second
// argument to a symmetric tensor, perform the sum, and then cast the
- // result to a Tensor (i.e., the type of a possibly non-symmetric
+ // result to a Tensor (i.e., the type of a possibly nonsymmetric
// tensor). However, since <code>Grad_u_n</code> is nonsymmetric in
// general, the conversion to SymmetricTensor will fail. We can avoid this
// back and forth by converting $I$ to Tensor first, and then performing
- // the addition as between non-symmetric tensors:
+ // the addition as between nonsymmetric tensors:
void update_values (const Tensor<2, dim> &Grad_u_n,
const double p_tilde,
const double J_tilde)
determine_component_extractors();
// Several functions to assemble the system and right hand side matrices
- // using multi-threading. Each of them comes as a wrapper function, one
+ // using multithreading. Each of them comes as a wrapper function, one
// that is executed to do the work in the WorkStream model on one cell,
// and one that copies the work done on this one cell into the global
// object that represents it:
std::vector<PointHistory<dim> > quadrature_point_history;
// A description of the finite-element system including the displacement
- // polynomial degree, the degree-of-freedom handler, number of dof's per
+ // polynomial degree, the degree-of-freedom handler, number of DoFs per
// cell and the extractor objects used to retrieve information from the
// solution vectors:
const unsigned int degree;
block_component[J_component] = J_dof; // Dilatation
// The DOF handler is then initialised and we renumber the grid in an
- // efficient manner. We also record the number of DOF's per block.
+ // efficient manner. We also record the number of DOFs per block.
dof_handler_ref.distribute_dofs(fe);
DoFRenumbering::Cuthill_McKee(dof_handler_ref);
DoFRenumbering::component_wise(dof_handler_ref, block_component);
// @sect4{Solid::update_qph_incremental}
// As the update of QP information occurs frequently and involves a number of
-// expensive operations, we define a multi-threaded approach to distributing
+// expensive operations, we define a multithreaded approach to distributing
// the task across a number of CPU cores.
//
// To start this, we first we need to obtain the total solution as it stands
// @sect4{Solid::solve_linear_system}
// Solving the entire block system is a bit problematic as there are no
// contributions to the $\mathsf{\mathbf{k}}_{ \widetilde{J} \widetilde{J}}$
-// block, rendering it non-invertible.
+// block, rendering it noninvertible.
// Since the pressure and dilatation variables DOFs are discontinuous, we can
// condense them out to form a smaller displacement-only system which
// we will then solve and subsequently post-process to retrieve the
using namespace dealii;
using namespace Step44;
- Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv);
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, dealii::numbers::invalid_unsigned_int);
try
{
-/* Author: Markus Buerg, University of Karlsruhe, 2010 */
-
-/* $Id$ */
-/* */
-/* Copyright (C) 2010-2012 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. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2010 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Markus Buerg, University of Karlsruhe, 2010
+ */
// @sect3{Include files}
MESSAGE(FATAL_ERROR "
Error! The deal.II library found at ${DEAL_II_PATH} was not configured with
DEAL_II_WITH_UMFPACK = ON
-which is required for this tutorial step."
+One or all of these are OFF in your installation but are required for this tutorial step."
)
ENDIF()
- Implementing the bilinear form, and in particular dealing with the
interface term, both in the matrix and the sparsity pattern.
- Implementing Dirichlet boundary conditions on the external and
- internal parts of the boundaryies
+ internal parts of the boundaries
$\partial\Omega_f,\partial\Omega_s$.
-/* Author: Wolfgang Bangerth, Texas A&M University, 2011 */
-
-/* $Id$ */
-/* */
-/* Copyright (C) 2011-2012 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. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2011 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Wolfgang Bangerth, Texas A&M University, 2011
+ */
// @sect3{Include files}
// The following classes do as their names suggest. The boundary values for
// the velocity are $\mathbf u=(0, \sin(\pi x))^T$ in 2d and $\mathbf u=(0,
// 0, \sin(\pi x)\sin(\pi y))^T$ in 3d, respectively. The remaining boundary
- // conditions for this problem are all homogenous and have been discussed in
+ // conditions for this problem are all homogeneous and have been discussed in
// the introduction. The right hand side forcing term is zero for both the
// fluid and the solid.
template <int dim>
// this end, we first have to set the active FE indices with the function
// immediately above, then distribute degrees of freedom, and then determine
// constraints on the linear system. The latter includes hanging node
- // constraints as usual, but also the inhomogenous boundary values at the
+ // constraints as usual, but also the inhomogeneous boundary values at the
// top fluid boundary, and zero boundary values along the perimeter of the
// solid subdomain.
template <int dim>
-/* Author: Wolfgang Bangerth, University of Heidelberg, 2000 */
-
-/* $Id$ */
-/* */
-/* Copyright (C) 2011-2012 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. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2011 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Wolfgang Bangerth, University of Heidelberg, 2000
+ */
#include <deal.II/base/quadrature_lib.h>
// To integrate the enriched elements we have to find the geometrical
// decomposition of the original element in subelements. The subelements are
// used to integrate the elements on both sides of the discontinuity. The
-// disontinuity line is approximated by a piece-wise linear interpolation
+// discontinuity line is approximated by a piece-wise linear interpolation
// between the intersection of the discontinuity with the edges of the
// elements. The vector level_set_values has the values of the level set
// function at the vertices of the elements. From these values can be found by
// the sign of the level set function at the 4 nodes of the elements can
// be positive + or negative - depending on the sign of the level set
- // function we have the folloing three classes of decomposition type 1:
+ // function we have the following three classes of decomposition type 1:
// ++++, ---- type 2: -+++, +-++, ++-+, +++-, +---, -+--, --+-, ---+ type
// 3: +--+, ++--, +-+-, -++-, --++, -+-+
indices of the DoFs that it is constrained to. Then, we have another
variable <code>constraint_indicator</code> at hand that holds, for
each cell, the local indices of DoFs that are constrained as well as
-the identifer of the type of constraint. Actually, you will not see
+the identifier of the type of constraint. Actually, you will not see
these data structures in the example program since the class
<code>FEEvaluationGL</code> takes care of the constraints without user
interaction.
<h3>Parallel run in 3D</h3>
-To demonstrate how the example scales for a parallel run and to demsonstrate
+To demonstrate how the example scales for a parallel run and to demonstrate
that hanging node constraints can be handled in an efficient way, we run the
example in 3D with $\mathcal{Q}_4$ elements. First, we run it on a notebook
with 2 cores (Sandy Bridge CPU) at 2.7 GHz.
@endcode
We observe a considerable speedup over the notebook (16 cores versus 2 cores;
-nonethess, one notebook core is considerably faster than one core of the
+nonetheless, one notebook core is considerably faster than one core of the
cluster because of a newer processor architecture). If we run the same program
on 4 nodes with 8 threads on each node, we get:
@code
-/* $Id$ */
-/* Author: Katharina Kormann, Martin Kronbichler, Uppsala University, 2011-2012 */
-
-/* $Id$ */
-/* */
-/* Copyright (C) 2011-2013 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. */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2011 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Katharina Kormann, Martin Kronbichler, Uppsala University, 2011-2012
+ */
// The necessary files from the deal.II library.
// dimensions of extent $[-15,15]$. We refine the mesh more in the center of
// the domain since the solution is concentrated there. We first refine all
// cells whose center is within a radius of 11, and then refine once more
- // for a radius 6. This is simple ad-hoc refinement could be done better by
+ // for a radius 6. This simple ad hoc refinement could be done better by
// adapting the mesh to the solution using error estimators during the time
// stepping as done in other example programs, and using
// parallel::distributed::SolutionTransfer to transfer the solution to the
"solution-" + Utilities::int_to_string (timestep_number, 3);
std::ofstream output ((filename +
- "." + Utilities::int_to_string (Utilities::MPI::
- this_mpi_process(MPI_COMM_WORLD),4) + ".vtu").c_str());
+ "." + Utilities::int_to_string (Utilities::MPI::
+ this_mpi_process(MPI_COMM_WORLD),4) + ".vtu").c_str());
data_out.write_vtu (output);
if (Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0)
<h3>Modifying a Mesh</h3>
-After aquiring one (or several) meshes in the ways described above, there are
+After acquiring one (or several) meshes in the ways described above, there are
many ways to manipulate them before using them in a finite element
computation.
<h1>Results</h1>
The program produces a series of <code>.eps</code> files of the
-Triangulations. The methods are discussed above.
+triangulations. The methods are discussed above.
<h3>Next steps: Curved boundaries</h3>
-/* $Id$
+/* ---------------------------------------------------------------------
+ * $Id$
*
* Copyright (C) 2013 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.
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Timo Heister, Texas A&M University, 2013
*/
// format that can easily be visualized in the same way as was done in step-1.
template<int dim>
void mesh_info(const Triangulation<dim> &tria,
- const std::string &filename)
+ const std::string &filename)
{
std::cout << "Mesh info:" << std::endl
<< " dimension: " << dim << std::endl
GridOut grid_out;
grid_out.write_eps (tria, out);
std::cout << " written to " << filename
- << std::endl
- << std::endl;
+ << std::endl
+ << std::endl;
}
// @sect3{Main routines}
repetitions[1]=2;
GridGenerator::subdivided_hyper_rectangle (tria2, repetitions,
Point<2>(1.0,-1.0),
- Point<2>(4.0,1.0));
+ Point<2>(4.0,1.0));
Triangulation<2> triangulation;
GridGenerator::merge_triangulations (tria1, tria2, triangulation);
Point<2> grid_5_transform (const Point<2> &in)
{
return Point<2>(in(0),
- in(1) + std::sin(in(0)/5.0*3.14159));
+ in(1) + std::sin(in(0)/5.0*3.14159));
}
repetitions[1] = 2;
GridGenerator::subdivided_hyper_rectangle (tria, repetitions,
Point<2>(0.0,0.0),
- Point<2>(10.0,1.0));
+ Point<2>(10.0,1.0));
GridTools::transform(&grid_5_transform, tria);
mesh_info(tria, "grid-5.eps");
// vertices.
struct Grid6Func
{
- double trans(const double y) const
- {
- return std::tanh(2*y)/tanh(2);
- }
+ double trans(const double y) const
+ {
+ return std::tanh(2*y)/tanh(2);
+ }
- Point<2> operator() (const Point<2> & in) const
- {
- return Point<2> (in(0),
- trans(in(1)));
- }
+ Point<2> operator() (const Point<2> &in) const
+ {
+ return Point<2> (in(0),
+ trans(in(1)));
+ }
};
repetitions[0] = repetitions[1] = 40;
GridGenerator::subdivided_hyper_rectangle (tria, repetitions,
Point<2>(0.0,0.0),
- Point<2>(1.0,1.0));
+ Point<2>(1.0,1.0));
GridTools::transform(Grid6Func(), tria);
mesh_info(tria, "grid-6.eps");
repetitions[0] = repetitions[1] = 16;
GridGenerator::subdivided_hyper_rectangle (tria, repetitions,
Point<2>(0.0,0.0),
- Point<2>(1.0,1.0));
+ Point<2>(1.0,1.0));
GridTools::distort_random (0.3, tria, true);
mesh_info(tria, "grid-7.eps");
-/* Author: Wolfgang Bangerth, University of Heidelberg, 1999 */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 1999 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Wolfgang Bangerth, University of Heidelberg, 1999
+ */
-/* $Id$ */
-/* */
-/* Copyright (C) 1999-2004, 2006-2008, 2010-2012 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. */
// @sect3{Include files}
// The second to last thing in this program is the definition of the
// <code>run()</code> function. In contrast to the previous programs, we will
-// compute on a sequence of meshes that after each iteration is globall
+// compute on a sequence of meshes that after each iteration is globally
// refined. The function therefore consists of a loop over 6 cycles. In each
// cycle, we first print the cycle number, and then have to decide what to do
// with the mesh. If this is not the first cycle, we simply refine the
# You can specify additional files here!
)
-# A custom command line to run the program
-SET(TARGET_RUN mpirun -np 2 ${TARGET})
-
# Define the output that should be cleaned:
SET(CLEAN_UP_FILES *.vtu *.pvtu *.visit)
DEAL_II_WITH_MPI = ON
DEAL_II_WITH_P4EST = ON
DEAL_II_WITH_TRILINOS = ON
-which is required for this tutorial step."
+One or all of these are OFF in your installation but are required for this tutorial step."
)
ENDIF()
-/* Author: Guido Kanschat, University of Heidelberg, 2003 */
-/* Baerbel Janssen, University of Heidelberg, 2010 */
-/* Wolfgang Bangerth, Texas A&M University, 2010 */
-
-/* $Id$ */
-/* */
-/* Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 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. */
-
-// parallel geometric multi-grid. work in progress!
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2003 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Guido Kanschat, University of Heidelberg, 2003
+ * Baerbel Janssen, University of Heidelberg, 2010
+ * Wolfgang Bangerth, Texas A&M University, 2010
+ */
+
+
+// parallel geometric multigrid. work in progress!
// As discussed in the introduction, most of
// this program is copied almost verbatim
#include <deal.II/lac/trilinos_precondition.h>
// These, now, are the include necessary for
-// the multi-level methods. The first two
+// the multilevel methods. The first two
// declare classes that allow us to enumerate
// degrees of freedom not only on the finest
// mesh level, but also on intermediate
deallog << "Number of degrees of freedom: "
<< mg_dof_handler.n_dofs();
- for (unsigned int l=0; l<triangulation.n_levels(); ++l)
+ for (unsigned int l=0; l<triangulation.n_global_levels(); ++l)
deallog << " " << 'L' << l << ": "
<< mg_dof_handler.n_dofs(l);
deallog << std::endl;
DoFTools::extract_locally_relevant_dofs (mg_dof_handler,
- locally_relevant_set);
+ locally_relevant_set);
//solution.reinit (mg_dof_handler.n_dofs());
// Now for the things that concern the
// multigrid data structures. First, we
- // resize the multi-level objects to hold
+ // resize the multilevel objects to hold
// matrices and sparsity patterns for every
// level. The coarse level is zero (this is
// mandatory right now but may change in a
MGTools::make_sparsity_pattern(mg_dof_handler, csp, level);
mg_matrices[level].reinit(mg_dof_handler.locally_owned_mg_dofs(level),
- mg_dof_handler.locally_owned_mg_dofs(level),
- csp,
- MPI_COMM_WORLD, true);
+ mg_dof_handler.locally_owned_mg_dofs(level),
+ csp,
+ MPI_COMM_WORLD, true);
mg_interface_matrices[level].reinit(mg_dof_handler.locally_owned_mg_dofs(level),
- mg_dof_handler.locally_owned_mg_dofs(level),
- csp,
- MPI_COMM_WORLD, true);
+ mg_dof_handler.locally_owned_mg_dofs(level),
+ csp,
+ MPI_COMM_WORLD, true);
}
}
// @sect4{LaplaceProblem::assemble_system}
// The following function assembles the
- // linear system on the finesh level of the
+ // linear system on the finest level of the
// mesh. It is almost exactly the same as in
// step-6, with the exception that we don't
// eliminate hanging nodes and boundary
FullMatrix<double> cell_matrix (dofs_per_cell, dofs_per_cell);
Vector<double> cell_rhs (dofs_per_cell);
- std::vector<unsigned int> local_dof_indices (dofs_per_cell);
+ std::vector<types::global_dof_index> local_dof_indices (dofs_per_cell);
const Coefficient<dim> coefficient;
std::vector<double> coefficient_values (n_q_points);
// over all existing cells instead of just
// the active ones, and the results must be
// entered into the correct matrix. Note also
- // that since we only do multi-level
+ // that since we only do multilevel
// preconditioning, no right-hand side needs
// to be assembled here.
//
FullMatrix<double> cell_matrix (dofs_per_cell, dofs_per_cell);
- std::vector<unsigned int> local_dof_indices (dofs_per_cell);
+ std::vector<types::global_dof_index> local_dof_indices (dofs_per_cell);
const Coefficient<dim> coefficient;
std::vector<double> coefficient_values (n_q_points);
- // Next a few things that are specific to
- // building the multigrid data structures
- // (since we only need them in the current
- // function, rather than also elsewhere, we
- // build them here instead of the
- // <code>setup_system</code>
- // function). Some of the following may be
- // a bit obscure if you're not familiar
- // with the algorithm actually implemented
- // in deal.II to support multilevel
- // algorithms on adaptive meshes; if some
- // of the things below seem strange, take a
- // look at the @ref mg_paper.
+ // Next a few things that are specific to building the multigrid
+ // data structures (since we only need them in the current
+ // function, rather than also elsewhere, we build them here
+ // instead of the <code>setup_system</code> function). Some of the
+ // following may be a bit obscure if you're not familiar with the
+ // algorithm actually implemented in deal.II to support multilevel
+ // algorithms on adaptive meshes; if some of the things below seem
+ // strange, take a look at the @ref mg_paper.
//
- // Our first job is to identify those
- // degrees of freedom on each level that
- // are located on interfaces between
- // adaptively refined levels, and those
- // that lie on the interface but also on
- // the exterior boundary of the domain. As
- // in many other parts of the library, we
- // do this by using boolean masks,
- // i.e. vectors of booleans each element of
- // which indicates whether the
- // corresponding degree of freedom index is
- // an interface DoF or not. The <code>MGConstraints</code>
- // already computed the information for us
- // when we called initialize in <code>setup_system()</code>.
+ // Our first job is to identify those degrees of freedom on each
+ // level that are located on interfaces between adaptively refined
+ // levels, and those that lie on the interface but also on the
+ // exterior boundary of the domain. As in many other parts of the
+ // library, we do this by using Boolean masks, i.e. vectors of
+ // Booleans each element of which indicates whether the
+ // corresponding degree of freedom index is an interface DoF or
+ // not. The <code>MGConstraints</code> already computed the
+ // information for us when we called initialize in
+ // <code>setup_system()</code>.
std::vector<std::vector<bool> > interface_dofs
= mg_constrained_dofs.get_refinement_edge_indices ();
std::vector<std::vector<bool> > boundary_interface_dofs
= mg_constrained_dofs.get_refinement_edge_boundary_indices ();
- // The indices just identified will later
- // be used to decide where the assembled value
- // has to be added into on each level.
- // On the other hand,
- // we also have to impose zero boundary
- // conditions on the external boundary of
- // each level. But this the <code>MGConstraints</code>
- // knows it. So we simply ask for them by calling
- // <code>get_boundary_indices ()</code>.
- // The third step is to construct
- // constraints on all those degrees of
- // freedom: their value should be zero
- // after each application of the level
- // operators. To this end, we construct
- // ConstraintMatrix objects for each level,
- // and add to each of these constraints for
- // each degree of freedom. Due to the way
- // the ConstraintMatrix stores its data,
- // the function to add a constraint on a
- // single degree of freedom and force it to
- // be zero is called
- // Constraintmatrix::add_line(); doing so
- // for several degrees of freedom at once
- // can be done using
+ // The indices just identified will later be used to decide where
+ // the assembled value has to be added into on each level. On the
+ // other hand, we also have to impose zero boundary conditions on
+ // the external boundary of each level. But this the
+ // <code>MGConstraints</code> knows it. So we simply ask for them
+ // by calling <code>get_boundary_indices ()</code>. The third
+ // step is to construct constraints on all those degrees of
+ // freedom: their value should be zero after each application of
+ // the level operators. To this end, we construct ConstraintMatrix
+ // objects for each level, and add to each of these constraints
+ // for each degree of freedom. Due to the way the ConstraintMatrix
+ // stores its data, the function to add a constraint on a single
+ // degree of freedom and force it to be zero is called
+ // Constraintmatrix::add_line(); doing so for several degrees of
+ // freedom at once can be done using
// Constraintmatrix::add_lines():
- std::vector<ConstraintMatrix> boundary_constraints (triangulation.n_levels());
- std::vector<ConstraintMatrix> boundary_interface_constraints (triangulation.n_levels());
- for (unsigned int level=0; level<triangulation.n_levels(); ++level)
+ std::vector<ConstraintMatrix> boundary_constraints (triangulation.n_global_levels());
+ std::vector<ConstraintMatrix> boundary_interface_constraints (triangulation.n_global_levels());
+ for (unsigned int level=0; level<triangulation.n_global_levels(); ++level)
{
boundary_constraints[level].add_lines (interface_dofs[level]);
boundary_constraints[level].add_lines (mg_constrained_dofs.get_boundary_indices()[level]);
boundary_interface_constraints[level].close ();
}
- // Now that we're done with most of our
- // preliminaries, let's start the
- // integration loop. It looks mostly like
- // the loop in
- // <code>assemble_system</code>, with two
- // exceptions: (i) we don't need a right
- // hand side, and more significantly (ii) we
- // don't just loop over all active cells,
- // but in fact all cells, active or
- // not. Consequently, the correct iterator
- // to use is MGDoFHandler::cell_iterator
- // rather than
- // MGDoFHandler::active_cell_iterator. Let's
- // go about it:
+ // Now that we're done with most of our preliminaries, let's start
+ // the integration loop. It looks mostly like the loop in
+ // <code>assemble_system</code>, with two exceptions: (i) we don't
+ // need a right hand side, and more significantly (ii) we don't
+ // just loop over all active cells, but in fact all cells, active
+ // or not. Consequently, the correct iterator to use is
+ // MGDoFHandler::cell_iterator rather than
+ // MGDoFHandler::active_cell_iterator. Let's go about it:
typename DoFHandler<dim>::cell_iterator cell = mg_dof_handler.begin(),
endc = mg_dof_handler.end();
fe_values.shape_grad(j,q_point) *
fe_values.JxW(q_point));
- // The rest of the assembly is again
- // slightly different. This starts with
- // a gotcha that is easily forgotten:
- // The indices of global degrees of
- // freedom we want here are the ones
- // for current level, not for the
- // global matrix. We therefore need the
- // function
- // MGDoFAccessorLLget_mg_dof_indices,
- // not MGDoFAccessor::get_dof_indices
- // as used in the assembly of the
- // global system:
+ // The rest of the assembly is again slightly
+ // different. This starts with a gotcha that is easily
+ // forgotten: The indices of global degrees of freedom we
+ // want here are the ones for current level, not for the
+ // global matrix. We therefore need the function
+ // MGDoFAccessorLLget_mg_dof_indices, not
+ // MGDoFAccessor::get_dof_indices as used in the assembly of
+ // the global system:
cell->get_mg_dof_indices (local_dof_indices);
- // Next, we need to copy local
- // contributions into the level
- // objects. We can do this in the same
- // way as in the global assembly, using
- // a constraint object that takes care
- // of constrained degrees (which here
- // are only boundary nodes, as the
- // individual levels have no hanging
- // node constraints). Note that the
- // <code>boundary_constraints</code>
- // object makes sure that the level
- // matrices contains no contributions
- // from degrees of freedom at the
- // interface between cells of different
+ // Next, we need to copy local contributions into the level
+ // objects. We can do this in the same way as in the global
+ // assembly, using a constraint object that takes care of
+ // constrained degrees (which here are only boundary nodes,
+ // as the individual levels have no hanging node
+ // constraints). Note that the
+ // <code>boundary_constraints</code> object makes sure that
+ // the level matrices contains no contributions from degrees
+ // of freedom at the interface between cells of different
// refinement level.
boundary_constraints[cell->level()]
.distribute_local_to_global (cell_matrix,
local_dof_indices,
mg_matrices[cell->level()]);
- // The next step is again slightly more
- // obscure (but explained in the @ref
- // mg_paper): We need the remainder of
- // the operator that we just copied
- // into the <code>mg_matrices</code>
- // object, namely the part on the
- // interface between cells at the
- // current level and cells one level
- // coarser. This matrix exists in two
- // directions: for interior DoFs (index
- // $i$) of the current level to those
- // sitting on the interface (index
- // $j$), and the other way around. Of
- // course, since we have a symmetric
- // operator, one of these matrices is
- // the transpose of the other.
+ // The next step is again slightly more obscure (but
+ // explained in the @ref mg_paper): We need the remainder of
+ // the operator that we just copied into the
+ // <code>mg_matrices</code> object, namely the part on the
+ // interface between cells at the current level and cells
+ // one level coarser. This matrix exists in two directions:
+ // for interior DoFs (index $i$) of the current level to
+ // those sitting on the interface (index $j$), and the other
+ // way around. Of course, since we have a symmetric
+ // operator, one of these matrices is the transpose of the
+ // other.
//
- // The way we assemble these matrices
- // is as follows: since the are formed
- // from parts of the local
- // contributions, we first delete all
- // those parts of the local
- // contributions that we are not
- // interested in, namely all those
- // elements of the local matrix for
- // which not $i$ is an interface DoF
- // and $j$ is not. The result is one of
- // the two matrices that we are
- // interested in, and we then copy it
- // into the
- // <code>mg_interface_matrices</code>
- // object. The
- // <code>boundary_interface_constraints</code>
- // object at the same time makes sure
- // that we delete contributions from
- // all degrees of freedom that are not
- // only on the interface but also on
- // the external boundary of the domain.
+ // The way we assemble these matrices is as follows: since
+ // the are formed from parts of the local contributions, we
+ // first delete all those parts of the local contributions
+ // that we are not interested in, namely all those elements
+ // of the local matrix for which not $i$ is an interface DoF
+ // and $j$ is not. The result is one of the two matrices
+ // that we are interested in, and we then copy it into the
+ // <code>mg_interface_matrices</code> object. The
+ // <code>boundary_interface_constraints</code> object at the
+ // same time makes sure that we delete contributions from
+ // all degrees of freedom that are not only on the interface
+ // but also on the external boundary of the domain.
//
- // The last part to remember is how to
- // get the other matrix. Since it is
- // only the transpose, we will later
- // (in the <code>solve()</code>
- // function) be able to just pass the
- // transpose matrix where necessary.
+ // The last part to remember is how to get the other
+ // matrix. Since it is only the transpose, we will later (in
+ // the <code>solve()</code> function) be able to just pass
+ // the transpose matrix where necessary.
for (unsigned int i=0; i<dofs_per_cell; ++i)
for (unsigned int j=0; j<dofs_per_cell; ++j)
if ( !(interface_dofs[cell->level()][local_dof_indices[i]]==true &&
mg_interface_matrices[cell->level()]);
}
- for (unsigned int i=0;i<triangulation.n_global_levels();++i)
+ for (unsigned int i=0; i<triangulation.n_global_levels(); ++i)
{
mg_matrices[i].compress(VectorOperation::add);
mg_interface_matrices[i].compress(VectorOperation::add);
// @sect4{LaplaceProblem::solve}
- // This is the other function that is
- // significantly different in support of the
- // multigrid solver (or, in fact, the
- // preconditioner for which we use the
- // multigrid method).
+ // This is the other function that is significantly different in
+ // support of the multigrid solver (or, in fact, the preconditioner
+ // for which we use the multigrid method).
//
- // Let us start out by setting up two of the
- // components of multilevel methods: transfer
- // operators between levels, and a solver on
- // the coarsest level. In finite element
- // methods, the transfer operators are
- // derived from the finite element function
- // spaces involved and can often be computed
- // in a generic way independent of the
- // problem under consideration. In that case,
- // we can use the MGTransferPrebuilt class
- // that, given the constraints on the global
- // level and an MGDoFHandler object computes
- // the matrices corresponding to these
- // transfer operators.
+ // Let us start out by setting up two of the components of
+ // multilevel methods: transfer operators between levels, and a
+ // solver on the coarsest level. In finite element methods, the
+ // transfer operators are derived from the finite element function
+ // spaces involved and can often be computed in a generic way
+ // independent of the problem under consideration. In that case, we
+ // can use the MGTransferPrebuilt class that, given the constraints
+ // on the global level and an MGDoFHandler object computes the
+ // matrices corresponding to these transfer operators.
//
- // The second part of the following lines
- // deals with the coarse grid solver. Since
- // our coarse grid is very coarse indeed, we
- // decide for a direct solver (a Householder
- // decomposition of the coarsest level
- // matrix), even if its implementation is not
- // particularly sophisticated. If our coarse
- // mesh had many more cells than the five we
- // have here, something better suited would
- // obviously be necessary here.
+ // The second part of the following lines deals with the coarse grid
+ // solver. Since our coarse grid is very coarse indeed, we decide
+ // for a direct solver (a Householder decomposition of the coarsest
+ // level matrix), even if its implementation is not particularly
+ // sophisticated. If our coarse mesh had many more cells than the
+ // five we have here, something better suited would obviously be
+ // necessary here.
template <int dim>
void LaplaceProblem<dim>::solve ()
{
- // Create the object that deals with the transfer
- // between different refinement levels. We need to
- // pass it the hanging node constraints.
+ // Create the object that deals with the transfer between
+ // different refinement levels. We need to pass it the hanging
+ // node constraints.
MGTransferPrebuilt<vector_t> mg_transfer(hanging_node_constraints, mg_constrained_dofs);
- // Now the prolongation matrix has to be built.
- // This matrix needs to take the boundary values on
- // each level into account and needs to know about
- // the indices at the refinement egdes. The
- // <code>MGConstraints</code> knows about that so
- // pass it as an argument.
+ // Now the prolongation matrix has to be built. This matrix needs
+ // to take the boundary values on each level into account and
+ // needs to know about the indices at the refinement edges. The
+ // <code>MGConstraints</code> knows about that so pass it as an
+ // argument.
mg_transfer.build_matrices(mg_dof_handler);
- matrix_t & coarse_matrix = mg_matrices[0];
+ matrix_t &coarse_matrix = mg_matrices[0];
//coarse_matrix.copy_from (mg_matrices[0]);
//MGCoarseGridHouseholder<double,vector_t> coarse_grid_solver;
//coarse_grid_solver.initialize (coarse_matrix);
coarse_matrix,
id);
- // The next component of a multilevel
- // solver or preconditioner is that we need
- // a smoother on each level. A common
- // choice for this is to use the
- // application of a relaxation method (such
- // as the SOR, Jacobi or Richardson method). The
- // MGSmootherPrecondition class provides
- // support for this kind of
- // smoother. Here, we opt for the
- // application of a single SOR
- // iteration. To this end, we define an
- // appropriate <code>typedef</code> and
- // then setup a smoother object.
+ // The next component of a multilevel solver or preconditioner is
+ // that we need a smoother on each level. A common choice for this
+ // is to use the application of a relaxation method (such as the
+ // SOR, Jacobi or Richardson method). The MGSmootherPrecondition
+ // class provides support for this kind of smoother. Here, we opt
+ // for the application of a single SOR iteration. To this end, we
+ // define an appropriate <code>typedef</code> and then setup a
+ // smoother object.
//
- // The last step is to initialize the
- // smoother object with our level matrices
- // and to set some smoothing parameters.
- // The <code>initialize()</code> function
- // can optionally take additional arguments
- // that will be passed to the smoother
- // object on each level. In the current
- // case for the SOR smoother, this could,
- // for example, include a relaxation
- // parameter. However, we here leave these
- // at their default values. The call to
- // <code>set_steps()</code> indicates that
- // we will use two pre- and two
- // post-smoothing steps on each level; to
- // use a variable number of smoother steps
- // on different levels, more options can be
- // set in the constructor call to the
- // <code>mg_smoother</code> object.
+ // The last step is to initialize the smoother object with our
+ // level matrices and to set some smoothing parameters. The
+ // <code>initialize()</code> function can optionally take
+ // additional arguments that will be passed to the smoother object
+ // on each level. In the current case for the SOR smoother, this
+ // could, for example, include a relaxation parameter. However, we
+ // here leave these at their default values. The call to
+ // <code>set_steps()</code> indicates that we will use two pre-
+ // and two post-smoothing steps on each level; to use a variable
+ // number of smoother steps on different levels, more options can
+ // be set in the constructor call to the <code>mg_smoother</code>
+ // object.
//
// The last step results from the fact that
// we use the SOR method as a smoother -
// With all this together, we can finally
// get about solving the linear system in
// the usual way:
- SolverControl solver_control (500, 1e-12, false);
+ SolverControl solver_control (500, 1e-8*system_rhs.l2_norm(), false);
SolverCG<vector_t> cg (solver_control);
solution = 0;
if (false)
{
- // code to optionally compare to Trilinos ML
- TrilinosWrappers::PreconditionAMG prec;
-
- TrilinosWrappers::PreconditionAMG::AdditionalData Amg_data;
- // Amg_data.constant_modes = constant_modes;
- Amg_data.elliptic = true;
- Amg_data.higher_order_elements = true;
- Amg_data.smoother_sweeps = 2;
- Amg_data.aggregation_threshold = 0.02;
- // Amg_data.symmetric = true;
-
- prec.initialize (system_matrix,
- Amg_data);
- cg.solve (system_matrix, solution, system_rhs,
- prec);
+ // code to optionally compare to Trilinos ML
+ TrilinosWrappers::PreconditionAMG prec;
+
+ TrilinosWrappers::PreconditionAMG::AdditionalData Amg_data;
+ // Amg_data.constant_modes = constant_modes;
+ Amg_data.elliptic = true;
+ Amg_data.higher_order_elements = true;
+ Amg_data.smoother_sweeps = 2;
+ Amg_data.aggregation_threshold = 0.02;
+ // Amg_data.symmetric = true;
+
+ prec.initialize (system_matrix,
+ Amg_data);
+ cg.solve (system_matrix, solution, system_rhs,
+ prec);
}
else
{
- cg.solve (system_matrix, solution, system_rhs,
- preconditioner);
+ cg.solve (system_matrix, solution, system_rhs,
+ preconditioner);
}
-
+
constraints.distribute (solution);
}
TrilinosWrappers::MPI::Vector temp_solution;
temp_solution.reinit(locally_relevant_set, MPI_COMM_WORLD);
temp_solution = solution;
-
+
KellyErrorEstimator<dim>::estimate (static_cast<DoFHandler<dim>&>(mg_dof_handler),
QGauss<dim-1>(3),
typename FunctionMap<dim>::type(),
temp_solution,
estimated_error_per_cell);
- GridRefinement::refine_and_coarsen_fixed_number (triangulation,
- estimated_error_per_cell,
- 0.3, 0.03);
+ parallel::distributed::GridRefinement::
+ refine_and_coarsen_fixed_fraction (triangulation,
+ estimated_error_per_cell,
+ 0.3, 0.03);
triangulation.execute_coarsening_and_refinement ();
}
triangulation.refine_global (3);
}
else
- refine_grid ();
+ refine_grid ();
deallog << " Number of active cells: "
<< triangulation.n_global_active_cells()
deallog << " Number of degrees of freedom: "
<< mg_dof_handler.n_dofs()
<< " (by level: ";
- for (unsigned int level=0; level<triangulation.n_levels(); ++level)
+ for (unsigned int level=0; level<triangulation.n_global_levels(); ++level)
deallog << mg_dof_handler.n_dofs(level)
- << (level == triangulation.n_levels()-1
+ << (level == triangulation.n_global_levels()-1
? ")" : ", ");
deallog << std::endl;
--- /dev/null
+##
+# CMake script for the step-7 tutorial program:
+##
+
+# Set the name of the project and target:
+SET(TARGET "step-51")
+
+# Declare all source files the target consists of:
+SET(TARGET_SRC
+ ${TARGET}.cc
+ # You can specify additional files here!
+ )
+
+# Usually, you will not need to modify anything beyond this point...
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
+
+FIND_PACKAGE(deal.II 8.0 QUIET
+ HINTS ${deal.II_DIR} ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR}
+ )
+IF(NOT ${deal.II_FOUND})
+ MESSAGE(FATAL_ERROR "\n"
+ "*** Could not locate deal.II. ***\n\n"
+ "You may want to either pass a flag -DDEAL_II_DIR=/path/to/deal.II to cmake\n"
+ "or set an environment variable \"DEAL_II_DIR\" that contains this path."
+ )
+ENDIF()
+
+DEAL_II_INITIALIZE_CACHED_VARIABLES()
+PROJECT(${TARGET})
+DEAL_II_INVOKE_AUTOPILOT()
--- /dev/null
+step-7 step-32 step-44
--- /dev/null
+<br>
+
+<i>
+This program was contributed by Martin Kronbichler and Scott Miller.
+</i>
+
+<a name="Intro"></a>
+<h1>Introduction</h1>
+
+This tutorial program presents the implementation of a hybridizable
+discontinuous Galkerin method for the convection-diffusion equation.
+
+<h3> Hybridizable discontinuous Galerkin methods</h3>
+
+One common argument against the use of discontinuous Galerkin elements
+is the large number of globally coupled degrees of freedom that one
+must solve in an implicit system. This is because, unlike continuous finite
+elements, in typical discontinuous elements there is one degree of freedom at
+each vertex <i>for each of the adjacent elements</i>, rather than just one,
+and similarly for edges and faces. As an example of how fast the number of
+unknowns grows,
+consider the <code>FE_DGP_Monomial</code> basis: each
+scalar solution component is represented by polynomials of degree $p$
+with $(1/dim!)*\prod_{i=1}^{dim}(p+i)$ degrees of freedom per
+element. Typically, all degrees of freedom in an element are coupled
+to all of the degrees of freedom in the adjacent elements. The resulting
+discrete equations yield very large linear systems very quickly, especially
+for systems of equations in 2 or 3 dimensions.
+
+<h4> Reducing the size of the linear system </h4>
+To alleviate the computational cost of solving such large linear systems,
+the hybridizable discontinuous Galerkin (HDG) methodology was introduced
+by Cockburn and co-workers
+(see the references in the recent HDG overview article by
+ N.C. Nguyen and J. Peraire:
+ <i>Hybridizable discontinuous Galerkin methods for partial differential
+ equations in continuum mechanics</i>, Journal of Computational Physics,
+ 2012, 231:18, 5955-5988.
+ <a href="http://dx.doi.org/10.1016/j.jcp.2012.02.033">[DOI]</a>).
+The HDG method achieves
+this goal by formulating the mathematical problem using Dirichlet-to-Neumann
+mappings. The partial differential equations are first written as a first
+order system, and each field is then discretized via a DG method. At this
+point the single-valued "trace" values on the skeleton of the
+mesh, i.e. element faces, are taken to be independent unknown quantities.
+The Dirichlet-to-Neumann map concept then permits the following solution procedure:
+<ol>
+ <li> Use local element interior data to enforce a Neumann condition on the
+skeleton of the triangulation. The global problem is then to solve for the
+trace values, which are the only globally coupled unknowns.
+ <li> Use the known skeleton values as Dirichlet data for solving local
+element-level solutions. This is known as the
+'local solver', and is an <i>embarrassingly parallel</i> element-by-element
+solution process.
+</ol>
+
+The above procedure also has a linear algebra interpretation and is referred to
+as static condensation. Let us write the complete linear system associated to
+the HDG problem as a block system with the discrete DG variables <i>U</i> as
+first block and the skeleton variables $\Lambda$ as the second block:
+@f{eqnarray*}
+\begin{pmatrix} A & B \\ C & D \end{pmatrix}
+\begin{pmatrix} U \\ \Lambda \end{pmatrix}
+=
+\begin{pmatrix} F \\ G \end{pmatrix}.
+@f}
+Our aim is now to eliminate the <i>U</i> block with a Schur complement
+approach similar to step-20, which results in the following two steps:
+@f{eqnarray*}
+(D - C A^{-1} B) \Lambda &=& G - C A^{-1} F, \\
+A U &=& F - B \Lambda.
+@f}
+The point is that the presence of $A^{-1}$ is not a problem because $A$ is a
+block diagonal matrix where each block corresponds to one cell and is
+therefore easy enough to invert.
+The coupling to other cells is introduced by the matrices
+<i>B</i> and <i>C</i> over the skeleton variable. The block-diagonality of
+<i>A</i> and the structure in <i>B</i> and <i>C</i> allow us to invert the
+matrix <i>A</i> element by element (the local solution of the Dirichlet
+problem) and subtract $CA^{-1}B$ from $D$. The steps in the Dirichlet-to-Neumann map concept hence correspond to
+<ol>
+ <li> constructing the Schur complement matrix $D-C A^{-1} B$ and right hand side $G - C A^{-1} F$ <i>locally on each cell</i>
+ and inserting the contribution into the global trace matrix in the usual way,
+ <li> solving the Schur complement system for $\Lambda$, and
+ <li> solving for <i>U</i> using the second equation, given $\Lambda$.
+</ol>
+
+
+<h4> Solution quality and rates of convergence</h4>
+Another criticism of traditional DG methods is that the approximate fluxes
+converge suboptimally. The local HDG solutions can be shown to converge
+as $\mathcal{O}(h^{p+1})$, i.e., at optimal order. Additionally, a
+super-convergence property can be used to post-process a new approximate
+solution that converges at the rate $\mathcal{O}(h^{p+2})$.
+
+
+
+<h3> HDG applied to the convection-diffusion problem </h3>
+
+The HDG formulation used for this example is taken from
+<br>
+<b>
+ N.C. Nguyen, J. Peraire, B. Cockburn:
+ <i>An implicit high-order hybridizable discontinuous Galerkin method
+ for linear convection–diffusion equations</i>,
+ Journal of Computational Physics, 2009, 228:9, 3232-3254.
+ <a href="http://dx.doi.org/10.1016/j.jcp.2009.01.030">[DOI]</a>
+</b>
+
+We consider the convection-diffusion equation over the domain $\Omega$
+with Dirichlet boundary $\partial \Omega_D$ and Neumann boundary
+$\partial \Omega_N$:
+@f{eqnarray*}
+ \nabla \cdot (\mathbf{c} u) - \nabla \cdot (\kappa \nabla u) &=& f,
+ \quad \text{ in } \Omega, \\
+ u &=& g_D, \quad \text{ on } \partial \Omega_D, \\
+ (\mathbf{c} u - \kappa \nabla u)\cdot \mathbf{n} &=& g_N,
+ \quad \text{ on } \partial \Omega_N.
+@f}
+
+Introduce the auxiliary variable $\mathbf{q}=-\kappa \nabla u$ and rewrite
+the above equation as the first order system:
+@f{eqnarray*}
+ \mathbf{q} + \kappa \nabla u &=& 0, \quad \text{ in } \Omega, \\
+ \nabla \cdot (\mathbf{c} u + \mathbf{q}) &=& f, \quad \text{ in } \Omega, \\
+ u &=& g_D, \quad \text{ on } \partial \Omega_D, \\
+ (\mathbf{q} + \mathbf{c}u)\cdot\mathbf{n} &=& g_N,
+ \quad \text{ on } \partial \Omega_N.
+@f}
+
+We multiply these equations by the weight functions $\mathbf{v}, w$
+and integrate by parts over every element $K$ to obtain:
+@f{eqnarray*}
+ (\mathbf{v}, \kappa^{-1} \mathbf{q})_K - (\nabla\cdot\mathbf{v}, u)_K
+ + \left<\mathbf{v}\cdot\mathbf{n}, \hat{u}\right>_{\partial K} &=& 0, \\
+ - (\nabla w, \mathbf{c} u + \mathbf{q})_K
+ + \left<(w, \widehat{\mathbf{c} u}+\hat{\mathbf{q}})\cdot\mathbf{n}\right>_{\partial K}
+ &=& (w,f)_K.
+@f}
+
+The terms decorated with a hat denote the numerical traces (also commonly referred
+to as numerical fluxes). They are approximations
+to the interior values on the boundary of the element. To ensure conservation,
+these terms must be single-valued on any given element edge $\partial K$ even
+though, with discontinuous shape functions, there may of course be multiple
+values coming from the cells adjacent to an interface.
+We eliminate the numerical trace $\hat{\mathbf{q}}$ by using traces of the form:
+@f{eqnarray*}
+ \widehat{\mathbf{c} u}+\hat{\mathbf{q}} = \mathbf{c}\hat{u} + \mathbf{q}
+ + \tau(u - \hat{u})\mathbf{n} \quad \text{ on } \partial K.
+@f}
+
+The variable $\hat {u}$ is introduced as an additional independent variable
+and is the one for which we finally set up a globally coupled linear
+system. As mentioned above, it is defined on the element faces and
+discontinuous from one face to another.
+Values for $u$ and $\mathbf{q}$ appearing in the numerical trace function
+are taken to be the cell's interior solution restricted
+to the boundary $\partial K$.
+
+The local stabilization parameter $\tau$ has effects on stability and accuracy
+of HDG solutions; see the literature for a further discussion. A stabilization
+parameter of unity is reported to be the choice which gives best results. A
+stabilization parameter $\tau$ that tends to infinity prohibits jumps in the
+solution over the element boundaries, making the HDG solution approach the
+approximation with continuous finite elements. In the program below, we choose
+the stabilization parameter as
+@f{eqnarray*}
+ \tau = \frac{\kappa}{\ell} + |\mathbf{c} \cdot \mathbf{n}|
+@f}
+where we set the diffusion $\kappa=1$ and the diffusion length scale to
+$\ell = \frac{1}{5}$.
+
+The trace/skeleton variables in HDG methods are single-valued on element
+faces. As such, they must strongly represent the Dirichlet data on
+$\partial\Omega_D$. This means that
+@f{equation*}
+ \hat{u}|_{\partial \Omega_D} = g_D,
+@f}
+where the equal sign actually means an $L_2$ projection of the boundary
+function $g$ onto the space of the face variables (e.g. linear functions on
+the faces). This constraint is then applied to the skeleton variable $\hat{u}$
+using inhomogeneous constraints by the method
+VectorTools::project_boundary_values.
+
+Summing the elemental
+contributions across all elements in the triangulation, enforcing the normal
+component of the numerical flux, and integrating by parts
+on the equation weighted by $w$, we arrive at the final form of the problem:
+Find $(\mathbf{q}_h, u_h, \hat{u}_h) \in
+\mathcal{V}_h^p \times \mathcal{W}_h^p \times \mathcal{M}_h^p$ such that
+@f{eqnarray*}
+ (\mathbf{v}, \kappa^{-1} \mathbf{q}_h)_{\mathcal{T}}
+ - ( \nabla\cdot\mathbf{v}, u_h)_{\mathcal{T}}
+ + \left<\mathbf{v}\cdot\mathbf{n}, \hat{u}_h\right>_{\partial\mathcal{T}}
+ &=& 0,
+ \quad \forall \mathbf{v} \in \mathcal{V}_h^p,
+\\
+ - (\nabla w, \mathbf{c} u_h)_{\mathcal{T}}
+ + (w, \nabla \cdot \mathbf{q}_h)_{\mathcal{T}}
+ + (w, (\mathbf{c}\cdot\mathbf{n}) \hat{u}_H)_{\mathcal{T}}
+ + \left<w, \tau (u_h - \hat{u}_h)\right>_{\partial \mathcal{T}}
+ &=&
+ (w, f)_{\mathcal{T}},
+ \quad \forall w \in \mathcal{W}_h^p,
+\\
+ \left< \mu, \hat{u}_h\mathbf{c} \cdot \mathbf{n}
+ + \mathbf{q}_h\cdot \mathbf{n}
+ + \tau (u_h - \hat{u}_h)\right>_{\partial \mathcal{T}}
+ &=&
+ \left<\mu, g_N\right>_{\partial\Omega_N},
+ \quad \forall \mu \in \mathcal{M}_h^p.
+@f}
+
+The unknowns $(\mathbf{q}_h, u_h)$ are referred to as local variables; they are
+represented as standard DG variables. The unknown $\hat{u}_h$ is the skeleton
+variable which has support on the codimension-1 surfaces (faces) of the mesh.
+
+We use the notation $(\cdot, \cdot)_{\mathcal{T}} = \sum_K (\cdot, \cdot)_K$
+to denote the sum of integrals over all cells and $\left<\cdot,
+\cdot\right>_{\partial \mathcal{T}} = \sum_K \left<\cdot,
+\cdot\right>_{\partial K}$ to denote integration over all faces of all cells,
+i.e., interior faces are visited twice. When combining the contribution from
+both elements sharing a face, the above equation yields terms familiar for DG
+with jumps of the solution over the cell boundaries.
+
+In the equation above, the space $\mathcal {W}_h^{p}$ for the scalar variable
+<i>u<sub>h</sub></i> is defined as the space of functions that are tensor
+product polynomials of degree <i>p</i> on each cell and discontinuous over the
+element boundaries $\mathcal Q_{-p}$, i.e., the space described by
+<code>FE_DGQ<dim>(p)</code>. The space for the gradient or flux variable
+<b>q</b><i><sub>h</sub></i> is a vector element space where each component is
+a locally polynomial and discontinuous $\mathcal Q_{-p}$. In the code below,
+we collect these two local parts together in one FESystem where the first @p
+dim components denote the gradient part and the last scalar component
+corresponds to the scalar variable. For the skeleton component $\hat{u}_h$, we
+define a space that consists of discontinuous tensor product polynomials that
+live on the element faces, which in deal.II is implemented by the class
+FE_FaceQ. This space is otherwise similar to FE_DGQ, i.e., the solution
+function is not continuous between two neighboring faces, see also the results
+section below for an illustration.
+
+In the weak form given above, we can note the following coupling patterns:
+<ol>
+ <li> The matrix $A$ consists of local-local coupling terms. These arise when the
+ local weighting functions $(\mathbf{v}, w)$ multiply the local solution terms
+ $(\mathbf{q}_h, u_h)$.
+ <li> The matrix $B$ represents the local-face coupling. These are the terms
+ with weighting functions $(\mathbf{v}, w)$ multiplying the skeleton variable
+ $\hat{u}_h$.
+ <li> The matrix $C$ represents the face-local coupling, which involves the
+ weighting function $\mu$ multiplying the local solutions $(\mathbf{q}_h, u_h)$.
+ <li> The matrix $D$ is the face-face coupling;
+ terms involve both $\mu$ and $\hat{u}_h$.
+</ol>
+
+<h4> Post-processing and super-convergence </h4>
+
+One special feature of the HDG methods is that they typically allow for
+constructing an enriched solution that gains accuracy. This post-processing
+takes the HDG solution in an element-by-element fashion and combines it such
+that one can get $\mathcal O(h^{p+2})$ order of accuracy when using
+polynomials of degree <i>p</i>. For this to happen, there are two necessary
+ingredients:
+<ol>
+ <li> The computed solution gradient $\mathbf{q}_h$ converges at optimal rate,
+ i.e., $\mathcal{O}(h^{p+1})$.
+ <li> The average of the scalar part of the solution, <i>u<sub>h</sub></i>,
+ on each cell <i>K</i> super-converges at rate $\mathcal{O}(h^{p+2})$.
+</ol>
+
+We now introduce a new variable $u_h^* \in \mathcal{V}_h^{p+1}$, which we find
+by the expression $|\kappa \nabla u_h^* + \mathbf{q}_h|^2$ over the cell
+<i>K</i> under the constraint $\left(1, u_h^*\right)_K &=& \left(1,
+u_h\right)_K$. This translates to the following system of equations:
+@f{eqnarray*}
+\left(1, u_h^*\right)_K &=& \left(1, u_h\right)_K\\
+\left(\nabla w_h^*, \kappa \nabla u_h^*\right)_K &=&
+-\left(\nabla w_h^*, \mathbf{q}_h\right)_K
+\quad \text{for all } w_h^* \in \mathcal Q^{p+1}.
+@f}
+
+Since we test by the whole set of basis functions in the space of tensor
+product polynomials of degree <i>p</i>+1 in the second set of equations, this
+is an overdetermined system with one more equation than unknowns. We fix this
+in the code below by omitting one of these equations (since the rows in the
+Laplacian are linearly dependent when representing a constant function). As we
+will see below, this form of the post-processing gives the desired
+super-convergence result with rate $\mathcal {O}(h^{p+2})$. It should be
+noted that there is some freedom in constructing $u_h^*$ and this minimization
+approach to extract the information from the gradient is not the only one. In
+particular, the post-processed solution defined here does not satisfy the
+convection-diffusion equation in any sense. As an alternative, the paper by
+Nguyen, Peraire and Cockburn cited above suggests another somewhat more
+involved formula for convection-diffusion that can also post-process the flux
+variable into an $H(\Omega,\mathrm{div})$-conforming variant and better
+represents the local convection-diffusion operator when the diffusion is
+small. We leave the implementation of a more sophisticated post-processing as
+a possible extension to the interested reader.
+
+Note that for vector-valued problems, the post-processing works similarly. One
+simply sets the constraint for the mean value of each vector component
+separately and uses the gradient as the main source of information.
+
+<h3> Problem specific data </h3>
+
+For this tutorial program, we consider almost the same test case as in
+step-7. The computational domain is $\Omega := [-1,1]^d$ and the exact
+solution corresponds to the one in step-7, except for a scaling. We use the
+following source centers <i>x<sub>i</sub></i> for the exponentials
+<ul>
+ <li> 1D: $\{x_i\}^1 = \{ -\frac{1}{3}, 0, \frac{1}{3} \}$,
+ <li> 2D: $\{\mathbf{x}_i\}^2 = \{ (-\frac{1}{2},\frac{1}{2}),
+ (-\frac{1}{2},-\frac{1}{2}),
+ (\frac{1}{2},-\frac{1}{2})
+ \}$,
+ <li> 3D: $\{\mathbf{x}_i\}^3 = \{ (-\frac{1}{2},\frac{1}{2}, \frac{1}{4}),
+ (-\frac{3}{5},-\frac{1}{2}, -\frac{1}{8}),
+ (\frac{1}{2},-\frac{1}{2}, \frac{1}{2})
+ \}$.
+</ul>
+
+With the exact solution given, we then choose the forcing on the right hand
+side and the Neumann boundary condition such that we obtain this solution
+(manufactured solution technique). In this example, we choose the diffusion
+equal to one and the convection as
+\f[
+\mathbf{c} = \begin{cases}
+1, & \textrm{dim}=1 \\
+(y, -x), & \textrm{dim}=2 \\
+(y, -x, 1), & \textrm{dim}=3
+\end{cases}
+\f]
+Note that the convection is divergence-free, $\nabla \cdot c = 0$.
+
+<h3> Implementation </h3>
+
+Besides implementing the above equations, the implementation below provides the following features:
+<ul>
+ <li> WorkStream to parallelize local solvers. Workstream is already used in
+ step-32, step-44.
+ <li> Reconstruct the local DG solution from the trace.
+ <li> Post-processing the solution for superconvergence.
+ <li> DataOutFaces for direct output of the global skeleton solution.
+</ul>
--- /dev/null
+techniques
--- /dev/null
+<h1>Results</h1>
+
+<h3>Program output</h3>
+
+We first have a look at the output generated by the program when run in 2D. In
+the four images below, we show the solution for polynomial degree <i>p</i>=1
+and cycles 2, 3, 4, and 8 of the program. In the plots, we overlay the data
+generated from the internal data (DG part) with the skeleton part ($\hat{u}$)
+into the same plot. We had to generate two different data sets because cells
+and faces represent different geometric entities, the combination of which (in
+the same file) is not supported in the VTK output of deal.II.
+
+The images show the distinctive features of HDG: The cell solution (colored
+surfaces) is discontinuous between the cells. The solution on the skeleton
+variable sits on the faces and ties together the local parts. The skeleton
+solution is not continuous on the vertices where the faces meet, even though
+its values are quite close along lines in the same coordinate direction. The
+skeleton solution can be interpreted as a rubber spring between the two sides
+that balances the jumps in the solution (or rather, the flux $\kappa \nabla u
++ \mathbf{c} u$). As the mesh is refined, the jumps between the cells get
+small (we represent a smooth solution), and the skeleton solution approaches
+the interior parts. For cycle 8, there is no visible difference in the two
+variables. We also see how boundary conditions are implemented weakly and that
+the interior variables do not exactly satisfy boundary conditions. On the
+lower and left boundaries, we set Neumann boundary conditions, whereas we set
+Dirichlet conditions on the right and top boundaries.
+
+<table align="center" border="1" cellspacing="3" cellpadding="3">
+ <tr>
+ <td>
+ <img src="http://www.dealii.org/images/steps/developer/step-51.sol_2.png" alt="">
+ </td>
+ <td>
+ <img src="http://www.dealii.org/images/steps/developer/step-51.sol_3.png" alt="">
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <img src="http://www.dealii.org/images/steps/developer/step-51.sol_4.png" alt="">
+ </td>
+ <td>
+ <img src="http://www.dealii.org/images/steps/developer/step-51.sol_8.png" alt="">
+ </td>
+ </tr>
+</table>
+
+Next, we have a look at the post-processed solution, again at cycles 2, 3, 4,
+and 8. This is a discontinuous solution that is locally described by second
+order polynomials. While the solution does not look very good on the mesh of
+cycle two, it looks much better for cycles three and four. As shown by the
+convergence table below, we find that is also converges more quickly to the
+analytical solution.
+
+<table align="center" border="1" cellspacing="3" cellpadding="3">
+ <tr>
+ <td>
+ <img src="http://www.dealii.org/images/steps/developer/step-51.post_2.png" alt="">
+ </td>
+ <td>
+ <img src="http://www.dealii.org/images/steps/developer/step-51.post_3.png" alt="">
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <img src="http://www.dealii.org/images/steps/developer/step-51.post_4.png" alt="">
+ </td>
+ <td>
+ <img src="http://www.dealii.org/images/steps/developer/step-51.post_8.png" alt="">
+ </td>
+ </tr>
+</table>
+
+Finally, we look at the solution for <i>p</i>=3 at cycle 2. Despite the coarse
+mesh with only 64 cells, the post-processed solution is similar in quality
+to the linear solution (not post-processed) at cycle 8 with 4,096
+cells. This clearly shows the superiority of high order methods for smooth
+solutions.
+
+<table align="center" border="1" cellspacing="3" cellpadding="3">
+ <tr>
+ <td>
+ <img src="http://www.dealii.org/images/steps/developer/step-51.sol_q3_2.png" alt="">
+ </td>
+ <td>
+ <img src="http://www.dealii.org/images/steps/developer/step-51.post_q3_2.png" alt="">
+ </td>
+ </tr>
+</table>
+
+<h4>Convergence tables</h4>
+
+When the program is run, it also outputs information about the respective
+steps and convergence tables with errors in the various components in the
+end. In 2D, the convergence tables look the following:
+
+@code
+Q1 elements, adaptive refinement:
+cells dofs val L2 grad L2 val L2-post
+ 16 80 1.804e+01 2.207e+01 1.798e+01
+ 31 170 9.874e+00 1.322e+01 9.798e+00
+ 61 314 7.452e-01 3.793e+00 4.891e-01
+ 121 634 3.240e-01 1.511e+00 2.616e-01
+ 238 1198 8.585e-02 8.212e-01 1.808e-02
+ 454 2290 4.802e-02 5.178e-01 2.195e-02
+ 898 4378 2.561e-02 2.947e-01 4.318e-03
+ 1720 7864 1.306e-02 1.664e-01 2.978e-03
+ 3271 14638 7.025e-03 9.815e-02 1.075e-03
+ 6217 27214 4.119e-03 6.407e-02 9.975e-04
+
+Q1 elements, global refinement:
+cells dofs val L2 grad L2 val L2-post
+ 16 80 1.804e+01 - 2.207e+01 - 1.798e+01 -
+ 36 168 6.125e+00 2.66 9.472e+00 2.09 6.084e+00 2.67
+ 64 288 9.785e-01 6.38 4.260e+00 2.78 7.102e-01 7.47
+ 144 624 2.730e-01 3.15 1.866e+00 2.04 6.115e-02 6.05
+ 256 1088 1.493e-01 2.10 1.046e+00 2.01 2.880e-02 2.62
+ 576 2400 6.965e-02 1.88 4.846e-01 1.90 9.204e-03 2.81
+ 1024 4224 4.018e-02 1.91 2.784e-01 1.93 4.027e-03 2.87
+ 2304 9408 1.831e-02 1.94 1.264e-01 1.95 1.236e-03 2.91
+ 4096 16640 1.043e-02 1.96 7.185e-02 1.96 5.306e-04 2.94
+ 9216 37248 4.690e-03 1.97 3.228e-02 1.97 1.599e-04 2.96
+
+Q3 elements, global refinement:
+cells dofs val L2 grad L2 val L2-post
+ 16 160 3.613e-01 - 1.891e+00 - 3.020e-01 -
+ 36 336 6.411e-02 4.26 5.081e-01 3.24 3.238e-02 5.51
+ 64 576 3.480e-02 2.12 2.533e-01 2.42 5.277e-03 6.31
+ 144 1248 8.297e-03 3.54 5.924e-02 3.58 6.330e-04 5.23
+ 256 2176 2.254e-03 4.53 1.636e-02 4.47 1.403e-04 5.24
+ 576 4800 4.558e-04 3.94 3.277e-03 3.96 1.844e-05 5.01
+ 1024 8448 1.471e-04 3.93 1.052e-03 3.95 4.378e-06 5.00
+ 2304 18816 2.956e-05 3.96 2.104e-04 3.97 5.750e-07 5.01
+ 4096 33280 9.428e-06 3.97 6.697e-05 3.98 1.362e-07 5.01
+ 9216 74496 1.876e-06 3.98 1.330e-05 3.99 1.788e-08 5.01
+@endcode
+
+
+One can see the error reduction upon grid refinement, and for the cases where
+global refinement was performed, also the convergence rates. The quadratic
+convergence rates of Q1 elements in the $L_2$ norm for both the scalar
+variable and the gradient variable is apparent, as is the cubic rate for the
+postprocessed scalar variable in the $L_2$ norm. Note that is is a distinctive
+feature of an HDG solution. In typical continuous finite elements, the
+gradient of the solution of order <i>p</i> converges at rate <i>p</i> only, as
+opposed to <i>p</i>+1 for the actual solution. Even though superconvergence
+results for finite elements are also available (e.g. superconvergent patch
+recovery first introduced by Zienkiewicz and Zhu), these are typically limited
+to structured meshes and other special cases. For Q3 HDG variables, the scalar
+variable and gradient converge at fourth order and the postprocessed scalar
+variable at fifth order.
+
+The same convergence rates are observed in 3d.
+@code
+Q1 elements, adaptive refinement:
+cells dofs val L2 grad L2 val L2-post
+ 8 144 7.122e+00 1.941e+01 6.102e+00
+ 29 500 3.309e+00 1.023e+01 2.145e+00
+ 113 1792 2.204e+00 1.023e+01 1.912e+00
+ 379 5732 6.085e-01 5.008e+00 2.233e-01
+ 1317 19412 1.543e-01 1.464e+00 4.196e-02
+ 4579 64768 5.058e-02 5.611e-01 9.521e-03
+ 14596 199552 2.129e-02 3.122e-01 4.569e-03
+ 46180 611400 1.033e-02 1.622e-01 1.684e-03
+144859 1864212 5.007e-03 8.371e-02 7.364e-04
+451060 5684508 2.518e-03 4.562e-02 3.070e-04
+
+Q1 elements, global refinement:
+cells dofs val L2 grad L2 val L2-post
+ 8 144 7.122e+00 - 1.941e+01 - 6.102e+00 -
+ 27 432 5.491e+00 0.64 2.184e+01 -0.29 4.448e+00 0.78
+ 64 960 3.646e+00 1.42 1.299e+01 1.81 3.306e+00 1.03
+ 216 3024 1.595e+00 2.04 8.550e+00 1.03 1.441e+00 2.05
+ 512 6912 6.922e-01 2.90 5.306e+00 1.66 2.511e-01 6.07
+ 1728 22464 2.915e-01 2.13 2.490e+00 1.87 8.588e-02 2.65
+ 4096 52224 1.684e-01 1.91 1.453e+00 1.87 4.055e-02 2.61
+ 13824 172800 7.972e-02 1.84 6.861e-01 1.85 1.335e-02 2.74
+ 32768 405504 4.637e-02 1.88 3.984e-01 1.89 5.932e-03 2.82
+110592 1354752 2.133e-02 1.92 1.830e-01 1.92 1.851e-03 2.87
+
+Q3 elements, global refinement:
+cells dofs val L2 grad L2 val L2-post
+ 8 576 5.670e+00 - 1.868e+01 - 5.462e+00 -
+ 27 1728 1.048e+00 4.16 6.988e+00 2.42 8.011e-01 4.73
+ 64 3840 2.831e-01 4.55 2.710e+00 3.29 1.363e-01 6.16
+ 216 12096 7.883e-02 3.15 7.721e-01 3.10 2.158e-02 4.55
+ 512 27648 3.642e-02 2.68 3.305e-01 2.95 5.231e-03 4.93
+ 1728 89856 8.546e-03 3.58 7.581e-02 3.63 7.640e-04 4.74
+ 4096 208896 2.598e-03 4.14 2.313e-02 4.13 1.783e-04 5.06
+ 13824 691200 5.314e-04 3.91 4.697e-03 3.93 2.355e-05 4.99
+ 32768 1622016 1.723e-04 3.91 1.517e-03 3.93 5.602e-06 4.99
+110592 5419008 3.482e-05 3.94 3.055e-04 3.95 7.374e-07 5.00
+@endcode
+
+<h3>Comparison with continuous finite elements</h3>
+
+<h4>Results for 2D</h4>
+
+The convergence tables verify the expected convergence rates stated in the
+introduction. Now, we want to show a quick comparison of the computational
+efficiency of the HDG method compared to a usual finite element (continuous
+Galkerin) method on the problem of this tutorial. Of course, stability aspects
+of the HDG method compared to continuous finite elements for
+transport-dominated problems are also important in practice, which is an
+aspect not seen on a problem with smooth analytic solution. In the picture
+below, we compare the $L_2$ error as a function of the number of degrees of
+freedom (left) and of the computing time spent in the linear solver (right)
+for two space dimensions of continuous finite elements (CG) and the hybridized
+discontinuous Galerkin method presented in this tutorial. As opposed to the
+tutorial where we only use unpreconditioned BiCGStab, the times shown in the
+figures below use the Trilinos algebraic multigrid preconditioner in
+TrilinosWrappers::PreconditionAMG. For the HDG part, a wrapper around
+ChunkSparseMatrix for the trace variable has been used in order to utilize the
+block structure in the matrix on the finest level.
+
+<table align="center" border="1" cellspacing="3" cellpadding="3">
+ <tr>
+ <td>
+ <img src="http://www.dealii.org/images/steps/developer/step-51.2d_plain.png" width="400" alt="">
+ </td>
+ <td>
+ <img src="http://www.dealii.org/images/steps/developer/step-51.2dt_plain.png" width="400" alt="">
+ </td>
+ </tr>
+</table>
+
+The results in the graphs show that the HDG method is slower than continuous
+finite elements at <i>p</i>=1, about equally fast for cubic elements and
+faster for sixth order elements. However, we have seen above that the HDG
+method actually produces solutions which are more accurate than what is
+represented in the original variables. Therefore, in the next two plots below
+we instead display the error of the post-processed solution for HDG (denoted
+by $p=1^*$ for example). We now see a clear advantage of HDG for the same
+amount of work for both <i>p</i>=3 and <i>p</i>=6, and about the same quality
+for <i>p</i>=1.
+
+<table align="center" border="1" cellspacing="3" cellpadding="3">
+ <tr>
+ <td>
+ <img src="http://www.dealii.org/images/steps/developer/step-51.2d_post.png" width="400" alt="">
+ </td>
+ <td>
+ <img src="http://www.dealii.org/images/steps/developer/step-51.2dt_post.png" width="400" alt="">
+ </td>
+ </tr>
+</table>
+
+Since the HDG method actually produces results converging as
+<i>h</i><sup><i>p</i>+2</sup>, we should compare it to a continuous Galerkin
+solution with the same asymptotic convergence behavior, i.e., FE_Q with degree
+<i>p</i>+1. If we do this, we get the convergence curves below. We see that
+CG with second order polynomials is again clearly better than HDG with
+linears. However, the advantage of HDG for higher orders remains.
+
+<table align="center" border="1" cellspacing="3" cellpadding="3">
+ <tr>
+ <td>
+ <img src="http://www.dealii.org/images/steps/developer/step-51.2d_postb.png" width="400" alt="">
+ </td>
+ <td>
+ <img src="http://www.dealii.org/images/steps/developer/step-51.2dt_postb.png" width="400" alt="">
+ </td>
+ </tr>
+</table>
+
+The results are in line with properties of DG methods in general: Best
+performance is typically not achieved for linear elements, but rather at
+somewhat higher order, usually around <i>p</i>=3. This is because of a
+volume-to-surface effect for discontinuous solutions with too much of the
+solution living on the surfaces and hence duplicating work when the elements
+are linear. Put in other words, DG methods are often most efficient when used
+at relatively high order, despite their focus on discontinuous (and hence,
+seemingly low accurate) representation of solutions.
+
+<h4>Resuls for 3D</h4>
+
+We now show the same figures in 3D: The first row shows the number of degrees
+of freedom and computing time versus the $L_2$ error in the scalar variable
+<i>u</i> for CG and HDG at order <i>p</i>, the second row shows the
+post-processed HDG solution instead of the original one, and the third row
+compares the post-processed HDG solution with CG at order <i>p</i>+1. In 3D,
+the volume-to-surface effect makes the cost of HDG somewhat higher and the CG
+solution is clearly better than HDG for linears by any metric. For cubics, HDG
+and CG are of similar quality, whereas HDG is again more efficient for sixth
+order polynomials. One can alternatively also use the combination of FE_DGP
+and FE_FaceP instead of (FE_DGQ, FE_FaceQ), which do not use tensor product
+polynomials of degree <i>p</i> but Legendre polynomials of <i>complete</i>
+degree <i>p</i>. There are fewer degrees of freedom on the skeleton variable
+for FE_FaceP for a given mesh size, but the solution quality (error vs. number
+of DoFs) is very similar to the results for FE_FaceQ.
+
+<table align="center" border="1" cellspacing="3" cellpadding="3">
+ <tr>
+ <td>
+ <img src="http://www.dealii.org/images/steps/developer/step-51.3d_plain.png" width="400" alt="">
+ </td>
+ <td>
+ <img src="http://www.dealii.org/images/steps/developer/step-51.3dt_plain.png" width="400" alt="">
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <img src="http://www.dealii.org/images/steps/developer/step-51.3d_post.png" width="400" alt="">
+ </td>
+ <td>
+ <img src="http://www.dealii.org/images/steps/developer/step-51.3dt_post.png" width="400" alt="">
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <img src="http://www.dealii.org/images/steps/developer/step-51.3d_postb.png" width="400" alt="">
+ </td>
+ <td>
+ <img src="http://www.dealii.org/images/steps/developer/step-51.3dt_postb.png" width="400" alt="">
+ </td>
+ </tr>
+</table>
+
+One final note on the efficiency comparison: We tried to use general-purpose
+sparse matrix structures and similar solvers (optimal AMG preconditioners for
+both without particular tuning of the AMG parameters on any of them) to give a
+fair picture of the cost versus accuracy of two methods, on a toy example. It
+should be noted however that GMG for continuous finite elements is about a
+factor four to five faster for <i>p</i>=3 and <i>p</i>=6. The authors of this
+tutorial have not seen similarly advanced solvers for the HDG linear
+systems. Also, there are other implementation aspects for CG available such as
+fast matrix-free approaches as shown in step-37 that make higher order
+continuous elements more competitive. Again, it is not clear to the authors of
+the tutorial whether similar improvements could be made for HDG.
+
+<h3>Possibilities for improvements</h3>
+
+As already mentioned in the introduction, one possibility is to implement
+another post-processing technique as discussed in the literature.
+
+A second item that is not done optimally relates to the performance of this
+program, which is of course an issue in practical applications (weighing in
+also the better solution quality of (H)DG methods for transport-dominated
+problems). Let us look at
+the computing time of the tutorial program and the share of the individual
+components:
+
+<table align="center" border="1">
+ <tr>
+ <th> </th>
+ <th> </th>
+ <th>Setup</th>
+ <th>Assemble</th>
+ <th>Solve</th>
+ <th>Trace reconstruct</th>
+ <th>Post-processing</th>
+ <th>Output</th>
+ </tr>
+ <tr>
+ <th> </th>
+ <th>Total time</th>
+ <th colspan="6">Relative share</th>
+ </tr>
+ <tr>
+ <td align="left">2D, Q1, cycle 9, 37,248 dofs</td>
+ <td align="center">5.34s</td>
+ <td align="center">0.7%</td>
+ <td align="center">1.2%</td>
+ <td align="center">89.5%</td>
+ <td align="center">0.9%</td>
+ <td align="center">2.3%</td>
+ <td align="center">5.4%</td>
+ </tr>
+ <tr>
+ <td align="left">2D, Q3, cycle 9, 74,496 dofs</td>
+ <td align="center">22.2s</td>
+ <td align="center">0.4%</td>
+ <td align="center">4.3%</td>
+ <td align="center">84.1%</td>
+ <td align="center">4.1%</td>
+ <td align="center">3.5%</td>
+ <td align="center">3.6%</td>
+ </tr>
+ <tr>
+ <td align="left">3D, Q1, cycle 7, 172,800 dofs</td>
+ <td align="center">9.06s</td>
+ <td align="center">3.1%</td>
+ <td align="center">8.9%</td>
+ <td align="center">42.7%</td>
+ <td align="center">7.0%</td>
+ <td align="center">20.6%</td>
+ <td align="center">17.7%</td>
+ </tr>
+ <tr>
+ <td align="left">3D, Q3, cycle 7, 691,200 dofs</td>
+ <td align="center">516s</td>
+ <td align="center">0.6%</td>
+ <td align="center">34.5%</td>
+ <td align="center">13.4%</td>
+ <td align="center">32.8%</td>
+ <td align="center">17.1%</td>
+ <td align="center">1.5%</td>
+ </tr>
+</table>
+
+As can be seen from the table, the solver and assembly calls dominate the
+runtime of the program. This also gives a clear indication of where an
+improvement makes most sense.
+
+<ol>
+ <li> Better linear solvers: We use a BiCGStab iterative solver without
+ preconditioner, where the number of iteration increases with increasing
+ problem size (the number of iterations for Q1 elements and global
+ refinements start at 35 for the small sizes but increase up to 701 for the
+ largest size). To do better, one could for example use an algebraic
+ multigrid preconditioner from Trilinos. For diffusion-dominated problems as
+ the problem at hand with finer meshes, such a solver can be designed that
+ uses the matrix-vector products from the more efficient ChunkSparseMatrix on
+ the finest level, as long as we are not working in parallel with MPI. For
+ MPI-parallelized computation, a standard TrilinosWrappers::SparseMatrix can
+ be used.
+
+ <li> Speed up assembly by pre-assembling parts that do not change from one
+ cell to another (those that do neither contain variable coefficients nor
+ mapping-dependent terms).
+</ol>
--- /dev/null
+Convection-diffusion equation. Hybridizable discontinuous Galerkin methods. Face elements.
--- /dev/null
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2013 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Martin Kronbichler, Technische Universität München,
+ * Scott T. Miller, The Pennsylvania State University, 2013
+ */
+
+// @sect3{Include files}
+//
+// Most of the deal.II include files have already been covered in previous
+// examples and are not commented on.
+#include <deal.II/base/quadrature_lib.h>
+#include <deal.II/base/function.h>
+#include <deal.II/base/tensor_function.h>
+#include <deal.II/base/exceptions.h>
+#include <deal.II/base/logstream.h>
+#include <deal.II/base/work_stream.h>
+#include <deal.II/base/convergence_table.h>
+#include <deal.II/lac/vector.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/compressed_simple_sparsity_pattern.h>
+#include <deal.II/lac/solver_bicgstab.h>
+#include <deal.II/lac/precondition.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/grid_refinement.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/tria_boundary_lib.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/dofs/dof_accessor.h>
+#include <deal.II/dofs/dof_renumbering.h>
+#include <deal.II/dofs/dof_tools.h>
+#include <deal.II/fe/fe_dgq.h>
+#include <deal.II/fe/fe_system.h>
+#include <deal.II/fe/fe_values.h>
+#include <deal.II/numerics/vector_tools.h>
+#include <deal.II/numerics/error_estimator.h>
+#include <deal.II/numerics/matrix_tools.h>
+#include <deal.II/numerics/data_out.h>
+
+// However, we do have a few new includes for the example.
+// The first one defines finite element spaces on the faces
+// of the triangulation, which we refer to as the 'skeleton'.
+// These finite elements do not have any support on the element
+// interior, and they represent polynomials that have a single
+// value on each codimension-1 surface, but admit discontinuities
+// on codimension-2 surfaces.
+#include <deal.II/fe/fe_face.h>
+
+// The second new file we include defines a new type of sparse matrix. The
+// regular <code>SparseMatrix</code> type stores indices to all non-zero
+// entries. The <code>ChunkSparseMatrix</code> takes advantage of the coupled
+// nature of DG solutions. It stores an index to a matrix sub-block of a
+// specified size. In the HDG context, this sub-block-size is actually the
+// number of degrees of freedom per face defined by the skeleton solution
+// field. This reduces the memory consumption of the matrix by up to one third
+// and results in similar speedups when using the matrix in solvers.
+#include <deal.II/lac/chunk_sparse_matrix.h>
+
+// The final new include for this example deals with data output. Since
+// we have a finite element field defined on the skeleton of the mesh,
+// we would like to visualize what that solution actually is.
+// DataOutFaces does exactly this; the interface is the almost the same
+// as the familiar DataOut, but the output only has codimension-1 data for
+// the simulation.
+#include <deal.II/numerics/data_out_faces.h>
+
+
+// We start by putting the class into its own namespace.
+namespace Step51
+{
+
+ using namespace dealii;
+
+// @sect3{Equation data}
+//
+// The structure of the analytic solution is the same as in step-7. There are
+// two exceptions. Firstly, we also create a solution for the 3d case, and
+// secondly, we scale the solution so its norm is of order unity for all
+// values of the solution width.
+ template <int dim>
+ class SolutionBase
+ {
+ protected:
+ static const unsigned int n_source_centers = 3;
+ static const Point<dim> source_centers[n_source_centers];
+ static const double width;
+ };
+
+
+ template <>
+ const Point<1>
+ SolutionBase<1>::source_centers[SolutionBase<1>::n_source_centers]
+ = { Point<1>(-1.0 / 3.0),
+ Point<1>(0.0),
+ Point<1>(+1.0 / 3.0)
+ };
+
+
+ template <>
+ const Point<2>
+ SolutionBase<2>::source_centers[SolutionBase<2>::n_source_centers]
+ = { Point<2>(-0.5, +0.5),
+ Point<2>(-0.5, -0.5),
+ Point<2>(+0.5, -0.5)
+ };
+
+ template <>
+ const Point<3>
+ SolutionBase<3>::source_centers[SolutionBase<3>::n_source_centers]
+ = { Point<3>(-0.5, +0.5, 0.25),
+ Point<3>(-0.6, -0.5, -0.125),
+ Point<3>(+0.5, -0.5, 0.5)
+ };
+
+ template <int dim>
+ const double SolutionBase<dim>::width = 1./5.;
+
+
+ template <int dim>
+ class Solution : public Function<dim>,
+ protected SolutionBase<dim>
+ {
+ public:
+ Solution () : Function<dim>() {}
+
+ virtual double value (const Point<dim> &p,
+ const unsigned int component = 0) const;
+
+ virtual Tensor<1,dim> gradient (const Point<dim> &p,
+ const unsigned int component = 0) const;
+ };
+
+
+
+ template <int dim>
+ double Solution<dim>::value (const Point<dim> &p,
+ const unsigned int) const
+ {
+ double return_value = 0;
+ for (unsigned int i=0; i<this->n_source_centers; ++i)
+ {
+ const Point<dim> x_minus_xi = p - this->source_centers[i];
+ return_value += std::exp(-x_minus_xi.square() /
+ (this->width * this->width));
+ }
+
+ return return_value /
+ Utilities::fixed_power<dim>(std::sqrt(2. * numbers::PI) * this->width);
+ }
+
+
+
+ template <int dim>
+ Tensor<1,dim> Solution<dim>::gradient (const Point<dim> &p,
+ const unsigned int) const
+ {
+ Tensor<1,dim> return_value;
+
+ for (unsigned int i=0; i<this->n_source_centers; ++i)
+ {
+ const Point<dim> x_minus_xi = p - this->source_centers[i];
+
+ return_value += (-2 / (this->width * this->width) *
+ std::exp(-x_minus_xi.square() /
+ (this->width * this->width)) *
+ x_minus_xi);
+ }
+
+ return return_value / Utilities::fixed_power<dim>(std::sqrt(2 * numbers::PI) *
+ this->width);
+ }
+
+
+
+// This class implements a function where the scalar solution and its negative
+// gradient are collected together. This function is used when computing the
+// error of the HDG approximation and its implementation is to simply call
+// value and gradient function of the Solution class.
+ template <int dim>
+ class SolutionAndGradient : public Function<dim>,
+ protected SolutionBase<dim>
+ {
+ public:
+ SolutionAndGradient () : Function<dim>(dim) {}
+
+ virtual void vector_value (const Point<dim> &p,
+ Vector<double> &v) const;
+ };
+
+ template <int dim>
+ void SolutionAndGradient<dim>::vector_value (const Point<dim> &p,
+ Vector<double> &v) const
+ {
+ AssertDimension(v.size(), dim+1);
+ Solution<dim> solution;
+ Tensor<1,dim> grad = solution.gradient(p);
+ for (unsigned int d=0; d<dim; ++d)
+ v[d] = -grad[d];
+ v[dim] = solution.value(p);
+ }
+
+
+
+// Next comes the implementation of the convection velocity. As described in
+// the introduction, we choose a velocity field that is $(y, -x)$ in 2D and
+// $(y, -x, 1)$ in 3D. This gives a divergence-free velocity field.
+ template <int dim>
+ class ConvectionVelocity : public TensorFunction<1,dim>
+ {
+ public:
+ ConvectionVelocity() : TensorFunction<1,dim>() {}
+
+ virtual Tensor<1,dim> value (const Point<dim> &p) const;
+ };
+
+
+
+ template <int dim>
+ Tensor<1,dim>
+ ConvectionVelocity<dim>::value(const Point<dim> &p) const
+ {
+ Tensor<1,dim> convection;
+ switch (dim)
+ {
+ case 1:
+ convection[0] = 1;
+ break;
+ case 2:
+ convection[0] = p[1];
+ convection[1] = -p[0];
+ break;
+ case 3:
+ convection[0] = p[1];
+ convection[1] = -p[0];
+ convection[2] = 1;
+ break;
+ default:
+ Assert(false, ExcNotImplemented());
+ }
+ return convection;
+ }
+
+
+
+// The last function we implement is the right hand side for the manufactured
+// solution. It is very similar to step-7, with the exception that we now have
+// a convection term instead of the reaction term. Since the velocity field is
+// incompressible, i.e. $\nabla \cdot \mathbf{c} = 0$, this term simply reads
+// $\mathbf{c} \nabla \ve u$.
+ template <int dim>
+ class RightHandSide : public Function<dim>,
+ protected SolutionBase<dim>
+ {
+ public:
+ RightHandSide () : Function<dim>() {}
+
+ virtual double value (const Point<dim> &p,
+ const unsigned int component = 0) const;
+
+ private:
+ const ConvectionVelocity<dim> convection_velocity;
+ };
+
+
+ template <int dim>
+ double RightHandSide<dim>::value (const Point<dim> &p,
+ const unsigned int) const
+ {
+ Tensor<1,dim> convection = convection_velocity.value(p);
+ double return_value = 0;
+ for (unsigned int i=0; i<this->n_source_centers; ++i)
+ {
+ const Point<dim> x_minus_xi = p - this->source_centers[i];
+
+ return_value +=
+ ((2*dim - 2*convection*x_minus_xi - 4*x_minus_xi.square()/
+ (this->width * this->width)) /
+ (this->width * this->width) *
+ std::exp(-x_minus_xi.square() /
+ (this->width * this->width)));
+ }
+
+ return return_value / Utilities::fixed_power<dim>(std::sqrt(2 * numbers::PI)
+ * this->width);
+ }
+
+// @sect3{The HDG solver class}
+
+// The HDG solution procedure follows closely that of step-7. The major
+// difference is the use of three different sets of <code>DoFHandler</code> and FE
+// objects, along with the <code>ChunkSparseMatrix</code> and the
+// corresponding solutions vectors. We also use WorkStream to enable a
+// multithreaded local solution process which exploits the embarrassingly
+// parallel nature of the local solver. For WorkStream, we define the local
+// operations on a cell and a copy function into the global matrix and
+// vector. We do this both for the assembly (which is run twice, once when we
+// generate the system matrix and once when we compute the element-interior
+// solutions from the skeleton values) and for the postprocessing where
+// we extract a solution that converges at higher order.
+ template <int dim>
+ class HDG
+ {
+ public:
+ enum RefinementMode
+ {
+ global_refinement, adaptive_refinement
+ };
+
+ HDG (const unsigned int degree,
+ const RefinementMode refinement_mode);
+ void run ();
+
+ private:
+
+ void setup_system ();
+ void assemble_system (const bool reconstruct_trace = false);
+ void solve ();
+ void postprocess ();
+ void refine_grid (const unsigned int cylce);
+ void output_results (const unsigned int cycle);
+
+ // Data for the assembly and solution of the primal variables.
+ struct PerTaskData;
+ struct ScratchData;
+
+ // Post-processing the solution to obtain $u^*$ is an element-by-element
+ // procedure; as such, we do not need to assemble any global data and do
+ // not declare any 'task data' for WorkStream to use.
+ struct PostProcessScratchData;
+
+ // The following three functions are used by WorkStream to do the actual
+ // work of the program.
+ void assemble_system_one_cell (const typename DoFHandler<dim>::active_cell_iterator &cell,
+ ScratchData &scratch,
+ PerTaskData &task_data);
+
+ void copy_local_to_global(const PerTaskData &data);
+
+ void postprocess_one_cell (const typename DoFHandler<dim>::active_cell_iterator &cell,
+ PostProcessScratchData &scratch,
+ unsigned int &empty_data);
+
+
+ Triangulation<dim> triangulation;
+
+ // The 'local' solutions are interior to each element. These
+ // represent the primal solution field $u$ as well as the auxiliary
+ // field $\mathbf{q}$.
+ FESystem<dim> fe_local;
+ DoFHandler<dim> dof_handler_local;
+ Vector<double> solution_local;
+
+ // The new finite element type and corresponding <code>DoFHandler</code> are
+ // used for the global skeleton solution that couples the element-level local
+ // solutions.
+ FE_FaceQ<dim> fe;
+ DoFHandler<dim> dof_handler;
+ Vector<double> solution;
+ Vector<double> system_rhs;
+
+ // As stated in the introduction, HDG solutions can be post-processed to
+ // attain superconvergence rates of $\mathcal{O}(h^{p+2})$. The
+ // post-processed solution is a discontinuous finite element solution
+ // representing the primal variable on the interior of each cell. We define
+ // a FE type of degree $p+1$ to represent this post-processed solution,
+ // which we only use for output after constructing it.
+ FE_DGQ<dim> fe_u_post;
+ DoFHandler<dim> dof_handler_u_post;
+ Vector<double> solution_u_post;
+
+ // The degrees of freedom corresponding to the skeleton strongly enforce
+ // Dirichlet boundary conditions, just as in a continuous Galerkin finite
+ // element method. We can enforce the boundary conditions in an analogous
+ // manner through the use of <code>ConstrainMatrix</code> constructs. In
+ // addition, hanging nodes are handled in the same way as for
+ // continuous finite elements: For the face elements which
+ // only define degrees of freedom on the face, this process sets the
+ // solution on the refined to be the one from the coarse side.
+ ConstraintMatrix constraints;
+
+ // The usage of the ChunkSparseMatrix class is similar to the usual sparse
+ // matrices: You need a sparsity pattern of type ChunkSparsityPattern and
+ // the actual matrix object. When creating the sparsity pattern, we just
+ // have to additionally pass the size of local blocks.
+ ChunkSparsityPattern sparsity_pattern;
+ ChunkSparseMatrix<double> system_matrix;
+
+ // Same as step-7:
+ const RefinementMode refinement_mode;
+ ConvergenceTable convergence_table;
+ };
+
+ // @sect3{The HDG class implementation}
+
+ // @sect4{Constructor}
+ // The constructor is similar to those in other examples,
+ // with the exception of handling multiple <code>DoFHandler</code> and
+ // <code>FiniteElement</code> objects. Note that we create a system of finite
+ // elements for the local DG part, including the gradient/flux part and the
+ // scalar part.
+ template <int dim>
+ HDG<dim>::HDG (const unsigned int degree,
+ const RefinementMode refinement_mode) :
+ fe_local (FE_DGQ<dim>(degree), dim,
+ FE_DGQ<dim>(degree), 1),
+ dof_handler_local (triangulation),
+ fe (degree),
+ dof_handler (triangulation),
+ fe_u_post (degree+1),
+ dof_handler_u_post (triangulation),
+ refinement_mode (refinement_mode)
+ {}
+
+
+
+ // @sect4{HDG::setup_system}
+ // The system for an HDG solution is setup in an analogous manner to most
+ // of the other tutorial programs. We are careful to distribute dofs with
+ // all of our <code>DoFHandler</code> objects. The @p solution and @p system_matrix
+ // objects go with the global skeleton solution.
+ template <int dim>
+ void
+ HDG<dim>::setup_system ()
+ {
+ dof_handler_local.distribute_dofs(fe_local);
+ dof_handler.distribute_dofs(fe);
+ dof_handler_u_post.distribute_dofs(fe_u_post);
+
+ std::cout << " Number of degrees of freedom: "
+ << dof_handler.n_dofs()
+ << std::endl;
+
+ solution.reinit (dof_handler.n_dofs());
+ system_rhs.reinit (dof_handler.n_dofs());
+
+ solution_local.reinit (dof_handler_local.n_dofs());
+ solution_u_post.reinit (dof_handler_u_post.n_dofs());
+
+ constraints.clear ();
+ DoFTools::make_hanging_node_constraints (dof_handler, constraints);
+ typename FunctionMap<dim>::type boundary_functions;
+ Solution<dim> solution_function;
+ boundary_functions[0] = &solution_function;
+ VectorTools::project_boundary_values (dof_handler,
+ boundary_functions,
+ QGauss<dim-1>(fe.degree+1),
+ constraints);
+ constraints.close ();
+
+ // When creating the chunk sparsity pattern, we first create the usual
+ // compressed sparsity pattern and then set the chunk size, which is equal
+ // to the number of dofs on a face, when copying this into the final
+ // sparsity pattern.
+ {
+ CompressedSimpleSparsityPattern csp (dof_handler.n_dofs());
+ DoFTools::make_sparsity_pattern (dof_handler, csp,
+ constraints, false);
+ sparsity_pattern.copy_from(csp, fe.dofs_per_face);
+ }
+ system_matrix.reinit (sparsity_pattern);
+ }
+
+
+
+ // @sect4{HDG::PerTaskData}
+ // Next comes the definition of the local data structures for the parallel
+ // assembly. The first structure @p PerTaskData contains the local vector
+ // and matrix that are written into the global matrix, whereas the
+ // ScratchData contains all data that we need for the local assembly. There
+ // is one variable worth noting here, namely the boolean variable @p
+ // trace_reconstruct. As mentioned in the introdution, we solve the HDG
+ // system in two steps. First, we create a linear system for the skeleton
+ // system where we condense the local part into it via the Schur complement
+ // $D-CA^{-1}B$. Then, we solve for the local part using the skeleton
+ // solution. For these two steps, we need the same matrices on the elements
+ // twice, which we want to compute by two assembly steps. Since most of the
+ // code is similar, we do this with the same function but only switch
+ // between the two based on a flag that we set when starting the
+ // assembly. Since we need to pass this information on to the local worker
+ // routines, we store it once in the task data.
+ template <int dim>
+ struct HDG<dim>::PerTaskData
+ {
+ FullMatrix<double> cell_matrix;
+ Vector<double> cell_vector;
+ std::vector<types::global_dof_index> dof_indices;
+
+ bool trace_reconstruct;
+
+ PerTaskData(const unsigned int n_dofs, const bool trace_reconstruct)
+ : cell_matrix(n_dofs, n_dofs),
+ cell_vector(n_dofs),
+ dof_indices(n_dofs),
+ trace_reconstruct(trace_reconstruct)
+ {}
+ };
+
+
+
+ // @sect4{HDG::ScratchData}
+ // @p ScratchData contains persistent data for each
+ // thread within <code>WorkStream</code>. The <code>FEValues</code>, matrix,
+ // and vector objects should be familiar by now. There are two objects that
+ // need to be discussed: @p std::vector<std::vector<unsigned int> >
+ // fe_local_support_on_face and @p std::vector<std::vector<unsigned int> >
+ // fe_support_on_face. These are used to indicate whether or not the finite
+ // elements chosen have support (non-zero values) on a given face of the
+ // reference cell for the local part associated to @p fe_local and the
+ // skeleton part @p fe. We extract this information in the
+ // constructor and store it once for all cells that we work on. Had we not
+ // stored this information, we would be forced to assemble a large number of
+ // zero terms on each cell, which would significantly slow the program.
+ template <int dim>
+ struct HDG<dim>::ScratchData
+ {
+ FEValues<dim> fe_values_local;
+ FEFaceValues<dim> fe_face_values_local;
+ FEFaceValues<dim> fe_face_values;
+
+ FullMatrix<double> ll_matrix;
+ FullMatrix<double> lf_matrix;
+ FullMatrix<double> fl_matrix;
+ FullMatrix<double> tmp_matrix;
+ Vector<double> l_rhs;
+ Vector<double> tmp_rhs;
+
+ std::vector<Tensor<1,dim> > q_phi;
+ std::vector<double> q_phi_div;
+ std::vector<double> u_phi;
+ std::vector<Tensor<1,dim> > u_phi_grad;
+ std::vector<double> tr_phi;
+ std::vector<double> trace_values;
+
+ std::vector<std::vector<unsigned int> > fe_local_support_on_face;
+ std::vector<std::vector<unsigned int> > fe_support_on_face;
+
+ ConvectionVelocity<dim> convection_velocity;
+ RightHandSide<dim> right_hand_side;
+ const Solution<dim> exact_solution;
+
+ ScratchData(const FiniteElement<dim> &fe,
+ const FiniteElement<dim> &fe_local,
+ const QGauss<dim> &quadrature_formula,
+ const QGauss<dim-1> &face_quadrature_formula,
+ const UpdateFlags local_flags,
+ const UpdateFlags local_face_flags,
+ const UpdateFlags flags)
+ :
+ fe_values_local (fe_local, quadrature_formula, local_flags),
+ fe_face_values_local (fe_local, face_quadrature_formula, local_face_flags),
+ fe_face_values (fe, face_quadrature_formula, flags),
+ ll_matrix (fe_local.dofs_per_cell, fe_local.dofs_per_cell),
+ lf_matrix (fe_local.dofs_per_cell, fe.dofs_per_cell),
+ fl_matrix (fe.dofs_per_cell, fe_local.dofs_per_cell),
+ tmp_matrix (fe.dofs_per_cell, fe_local.dofs_per_cell),
+ l_rhs (fe_local.dofs_per_cell),
+ tmp_rhs (fe_local.dofs_per_cell),
+ q_phi (fe_local.dofs_per_cell),
+ q_phi_div (fe_local.dofs_per_cell),
+ u_phi (fe_local.dofs_per_cell),
+ u_phi_grad (fe_local.dofs_per_cell),
+ tr_phi (fe.dofs_per_cell),
+ trace_values(face_quadrature_formula.size()),
+ fe_local_support_on_face(GeometryInfo<dim>::faces_per_cell),
+ fe_support_on_face(GeometryInfo<dim>::faces_per_cell)
+ {
+ for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
+ for (unsigned int i=0; i<fe_local.dofs_per_cell; ++i)
+ {
+ if (fe_local.has_support_on_face(i,face))
+ fe_local_support_on_face[face].push_back(i);
+ }
+
+ for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
+ for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
+ {
+ if (fe.has_support_on_face(i,face))
+ fe_support_on_face[face].push_back(i);
+ }
+ }
+
+ ScratchData(const ScratchData &sd)
+ :
+ fe_values_local (sd.fe_values_local.get_fe(),
+ sd.fe_values_local.get_quadrature(),
+ sd.fe_values_local.get_update_flags()),
+ fe_face_values_local (sd.fe_face_values_local.get_fe(),
+ sd.fe_face_values_local.get_quadrature(),
+ sd.fe_face_values_local.get_update_flags()),
+ fe_face_values (sd.fe_face_values.get_fe(),
+ sd.fe_face_values.get_quadrature(),
+ sd.fe_face_values.get_update_flags()),
+ ll_matrix (sd.ll_matrix),
+ lf_matrix (sd.lf_matrix),
+ fl_matrix (sd.fl_matrix),
+ tmp_matrix (sd.tmp_matrix),
+ l_rhs (sd.l_rhs),
+ tmp_rhs (sd.tmp_rhs),
+ q_phi (sd.q_phi),
+ q_phi_div (sd.q_phi_div),
+ u_phi (sd.u_phi),
+ u_phi_grad (sd.u_phi_grad),
+ tr_phi (sd.tr_phi),
+ trace_values(sd.trace_values),
+ fe_local_support_on_face(sd.fe_local_support_on_face),
+ fe_support_on_face(sd.fe_support_on_face)
+ {}
+ };
+
+
+
+ // @sect4{HDG::PostProcessScratchData}
+ // @p PostProcessScratchData contains the data used by <code>WorkStream</code>
+ // when post-processing the local solution $u^*$. It is similar, but much
+ // simpler, than @p ScratchData.
+ template <int dim>
+ struct HDG<dim>::PostProcessScratchData
+ {
+ FEValues<dim> fe_values_local;
+ FEValues<dim> fe_values;
+
+ std::vector<double> u_values;
+ std::vector<Tensor<1,dim> > u_gradients;
+ FullMatrix<double> cell_matrix;
+
+ Vector<double> cell_rhs;
+ Vector<double> cell_sol;
+
+ PostProcessScratchData(const FiniteElement<dim> &fe,
+ const FiniteElement<dim> &fe_local,
+ const QGauss<dim> &quadrature_formula,
+ const UpdateFlags local_flags,
+ const UpdateFlags flags)
+ :
+ fe_values_local (fe_local, quadrature_formula, local_flags),
+ fe_values (fe, quadrature_formula, flags),
+ u_values (quadrature_formula.size()),
+ u_gradients (quadrature_formula.size()),
+ cell_matrix (fe.dofs_per_cell, fe.dofs_per_cell),
+ cell_rhs (fe.dofs_per_cell),
+ cell_sol (fe.dofs_per_cell)
+ {}
+
+ PostProcessScratchData(const PostProcessScratchData &sd)
+ :
+ fe_values_local (sd.fe_values_local.get_fe(),
+ sd.fe_values_local.get_quadrature(),
+ sd.fe_values_local.get_update_flags()),
+ fe_values (sd.fe_values.get_fe(),
+ sd.fe_values.get_quadrature(),
+ sd.fe_values.get_update_flags()),
+ u_values (sd.u_values),
+ u_gradients (sd.u_gradients),
+ cell_matrix (sd.cell_matrix),
+ cell_rhs (sd.cell_rhs),
+ cell_sol (sd.cell_sol)
+ {}
+ };
+
+
+
+ // @sect4{HDG::assemble_system}
+ // The @p assemble_system function is similar to <code>Step-32</code>, where
+ // the quadrature formula and the update flags are set up, and then
+ // <code>WorkStream</code> is used to do the work in a multi-threaded
+ // manner. The @p trace_reconstruct input parameter is used to decide
+ // whether we are solving for the global skeleton solution (false) or the
+ // local solution (true).
+ template <int dim>
+ void
+ HDG<dim>::assemble_system (const bool trace_reconstruct)
+ {
+ const QGauss<dim> quadrature_formula(fe.degree+1);
+ const QGauss<dim-1> face_quadrature_formula(fe.degree+1);
+
+ const UpdateFlags local_flags (update_values | update_gradients |
+ update_JxW_values | update_quadrature_points);
+
+ const UpdateFlags local_face_flags (update_values);
+
+ const UpdateFlags flags ( update_values | update_normal_vectors |
+ update_quadrature_points |
+ update_JxW_values);
+
+ PerTaskData task_data (fe.dofs_per_cell,
+ trace_reconstruct);
+ ScratchData scratch (fe, fe_local,
+ quadrature_formula,
+ face_quadrature_formula,
+ local_flags,
+ local_face_flags,
+ flags);
+
+ WorkStream::run(dof_handler.begin_active(),
+ dof_handler.end(),
+ *this,
+ &HDG<dim>::assemble_system_one_cell,
+ &HDG<dim>::copy_local_to_global,
+ scratch,
+ task_data);
+ }
+
+
+
+ // @sect4{HDG::assemble_system_one_cell}
+ // The real work of the HDG program is done by @p assemble_system_one_cell.
+ // Assembling the local matrices $A, B, C$ is done here, along with the
+ // local contributions of the global matrix $D$.
+ template <int dim>
+ void
+ HDG<dim>::assemble_system_one_cell (const typename DoFHandler<dim>::active_cell_iterator &cell,
+ ScratchData &scratch,
+ PerTaskData &task_data)
+ {
+ // Construct iterator for dof_handler_local for FEValues reinit function.
+ typename DoFHandler<dim>::active_cell_iterator
+ loc_cell (&triangulation,
+ cell->level(),
+ cell->index(),
+ &dof_handler_local);
+
+ const unsigned int n_q_points = scratch.fe_values_local.get_quadrature().size();
+ const unsigned int n_face_q_points = scratch.fe_face_values_local.get_quadrature().size();
+
+ const unsigned int loc_dofs_per_cell = scratch.fe_values_local.get_fe().dofs_per_cell;
+
+ const FEValuesExtractors::Vector fluxes (0);
+ const FEValuesExtractors::Scalar scalar (dim);
+
+ scratch.ll_matrix = 0;
+ scratch.l_rhs = 0;
+ if (!task_data.trace_reconstruct)
+ {
+ scratch.lf_matrix = 0;
+ scratch.fl_matrix = 0;
+ task_data.cell_matrix = 0;
+ task_data.cell_vector = 0;
+ }
+ scratch.fe_values_local.reinit (loc_cell);
+
+ // We first compute the cell-interior contribution to @p ll_matrix matrix
+ // (referred to as matrix $A$ in the introduction) corresponding to
+ // local-local coupling, as well as the local right-hand-side vector. We
+ // store the values at each quadrature point for the basis functions, the
+ // right-hand-side value, and the convection velocity, in order to have
+ // quick access to these fields.
+ for (unsigned int q=0; q<n_q_points; ++q)
+ {
+ const double rhs_value
+ = scratch.right_hand_side.value(scratch.fe_values_local.quadrature_point(q));
+ const Tensor<1,dim> convection
+ = scratch.convection_velocity.value(scratch.fe_values_local.quadrature_point(q));
+ const double JxW = scratch.fe_values_local.JxW(q);
+ for (unsigned int k=0; k<loc_dofs_per_cell; ++k)
+ {
+ scratch.q_phi[k] = scratch.fe_values_local[fluxes].value(k,q);
+ scratch.q_phi_div[k] = scratch.fe_values_local[fluxes].divergence(k,q);
+ scratch.u_phi[k] = scratch.fe_values_local[scalar].value(k,q);
+ scratch.u_phi_grad[k] = scratch.fe_values_local[scalar].gradient(k,q);
+ }
+ for (unsigned int i=0; i<loc_dofs_per_cell; ++i)
+ {
+ for (unsigned int j=0; j<loc_dofs_per_cell; ++j)
+ scratch.ll_matrix(i,j) += (
+ scratch.q_phi[i] * scratch.q_phi[j]
+ -
+ scratch.q_phi_div[i] * scratch.u_phi[j]
+ +
+ scratch.u_phi[i] * scratch.q_phi_div[j]
+ -
+ (scratch.u_phi_grad[i] * convection) * scratch.u_phi[j]
+ ) * JxW;
+ scratch.l_rhs(i) += scratch.u_phi[i] * rhs_value * JxW;
+ }
+ }
+
+ // Face terms are assembled on all faces of all elements. This is in
+ // contrast to more traditional DG methods, where each face is only visited
+ // once in the assembly procedure.
+ for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
+ {
+ scratch.fe_face_values_local.reinit(loc_cell, face);
+ scratch.fe_face_values.reinit(cell, face);
+
+ // The already obtained $\hat{u}$ values are needed when solving for the
+ // local variables.
+ if (task_data.trace_reconstruct)
+ scratch.fe_face_values.get_function_values (solution, scratch.trace_values);
+
+ for (unsigned int q=0; q<n_face_q_points; ++q)
+ {
+ const double JxW = scratch.fe_face_values.JxW(q);
+ const Point<dim> quadrature_point =
+ scratch.fe_face_values.quadrature_point(q);
+ const Point<dim> normal = scratch.fe_face_values.normal_vector(q);
+ const Tensor<1,dim> convection
+ = scratch.convection_velocity.value(quadrature_point);
+
+ // Here we compute the stabilization parameter discussed in the
+ // introduction: since the diffusion is one and the diffusion
+ // length scale is set to 1/5, it simply results in a contribution
+ // of 5 for the diffusion part and the magnitude of convection
+ // through the element boundary in a centered scheme for the
+ // convection part.
+ const double tau_stab = (5. +
+ std::abs(convection * normal));
+
+ // We store the non-zero flux and scalar values, making use of the
+ // support_on_face information we created in @p ScratchData.
+ for (unsigned int k=0; k<scratch.fe_local_support_on_face[face].size(); ++k)
+ {
+ const unsigned int kk=scratch.fe_local_support_on_face[face][k];
+ scratch.q_phi[k] = scratch.fe_face_values_local[fluxes].value(kk,q);
+ scratch.u_phi[k] = scratch.fe_face_values_local[scalar].value(kk,q);
+ }
+
+ // When @p trace_reconstruct=false, we are preparing to assemble the
+ // system for the skeleton variable $\hat{u}$. If this is the case,
+ // we must assemble all local matrices associated with the problem:
+ // local-local, local-face, face-local, and face-face. The
+ // face-face matrix is stored as @p TaskData::cell_matrix, so that
+ // it can be assembled into the global system by @p
+ // copy_local_to_global.
+ if (!task_data.trace_reconstruct)
+ {
+ for (unsigned int k=0; k<scratch.fe_support_on_face[face].size(); ++k)
+ scratch.tr_phi[k] =
+ scratch.fe_face_values.shape_value(scratch.fe_support_on_face[face][k],q);
+ for (unsigned int i=0; i<scratch.fe_local_support_on_face[face].size(); ++i)
+ for (unsigned int j=0; j<scratch.fe_support_on_face[face].size(); ++j)
+ {
+ const unsigned int ii=scratch.fe_local_support_on_face[face][i];
+ const unsigned int jj=scratch.fe_support_on_face[face][j];
+ scratch.lf_matrix(ii,jj) += (
+ (scratch.q_phi[i] * normal
+ +
+ (convection * normal -
+ tau_stab) * scratch.u_phi[i])
+ * scratch.tr_phi[j]
+ ) * JxW;
+
+ // Note the sign of the face-local matrix. We negate the
+ // sign during assembly here so that we can use the
+ // FullMatrix::mmult with addition when computing the
+ // Schur complement.
+ scratch.fl_matrix(jj,ii) -= (
+ (scratch.q_phi[i] * normal
+ +
+ tau_stab * scratch.u_phi[i])
+ * scratch.tr_phi[j]
+ ) * JxW;
+ }
+
+ for (unsigned int i=0; i<scratch.fe_support_on_face[face].size(); ++i)
+ for (unsigned int j=0; j<scratch.fe_support_on_face[face].size(); ++j)
+ {
+ const unsigned int ii=scratch.fe_support_on_face[face][i];
+ const unsigned int jj=scratch.fe_support_on_face[face][j];
+ task_data.cell_matrix(ii,jj) += (
+ (convection * normal - tau_stab) *
+ scratch.tr_phi[i] * scratch.tr_phi[j]
+ ) * JxW;
+ }
+
+ if (cell->face(face)->at_boundary()
+ &&
+ (cell->face(face)->boundary_indicator() == 1))
+ {
+ const double neumann_value =
+ - scratch.exact_solution.gradient (quadrature_point) * normal
+ + convection * normal * scratch.exact_solution.value(quadrature_point);
+ for (unsigned int i=0; i<scratch.fe_support_on_face[face].size(); ++i)
+ {
+ const unsigned int ii=scratch.fe_support_on_face[face][i];
+ task_data.cell_vector(ii) += scratch.tr_phi[i] * neumann_value * JxW;
+ }
+ }
+ }
+
+ // This last term adds the contribution of the term $\left<w,\tau
+ // u_h\right>_{\partial \mathcal T}$ to the local matrix. As opposed
+ // to the face matrices above, we need it in both assembly stages.
+ for (unsigned int i=0; i<scratch.fe_local_support_on_face[face].size(); ++i)
+ for (unsigned int j=0; j<scratch.fe_local_support_on_face[face].size(); ++j)
+ {
+ const unsigned int ii=scratch.fe_local_support_on_face[face][i];
+ const unsigned int jj=scratch.fe_local_support_on_face[face][j];
+ scratch.ll_matrix(ii,jj) += tau_stab * scratch.u_phi[i] * scratch.u_phi[j] * JxW;
+ }
+
+ // When @p trace_reconstruct=true, we are solving for the local
+ // solutions on an element by element basis. The local
+ // right-hand-side is calculated by replacing the basis functions @p
+ // tr_phi in the @p lf_matrix computation by the computed values @p
+ // trace_values. Of course, the sign of the matrix is now minus
+ // since we have moved everything to the other side of the equation.
+ if (task_data.trace_reconstruct)
+ for (unsigned int i=0; i<scratch.fe_local_support_on_face[face].size(); ++i)
+ {
+ const unsigned int ii=scratch.fe_local_support_on_face[face][i];
+ scratch.l_rhs(ii) -= (scratch.q_phi[i] * normal
+ +
+ scratch.u_phi[i] * (convection * normal - tau_stab)
+ ) * scratch.trace_values[q] * JxW;
+ }
+ }
+ }
+
+ // Once assembly of all of the local contributions is complete, we must either:
+ // (1) assemble the global system, or (2) compute the local solution values and
+ // save them.
+ // In either case, the first step is to invert the local-local matrix.
+ scratch.ll_matrix.gauss_jordan();
+
+ // For (1), we compute the Schur complement and add it to the @p
+ // cell_matrix, matrix $D$ in the introduction.
+ if (task_data.trace_reconstruct == false)
+ {
+ scratch.fl_matrix.mmult(scratch.tmp_matrix, scratch.ll_matrix);
+ scratch.tmp_matrix.vmult_add(task_data.cell_vector, scratch.l_rhs);
+ scratch.tmp_matrix.mmult(task_data.cell_matrix, scratch.lf_matrix, true);
+ cell->get_dof_indices(task_data.dof_indices);
+ }
+ // For (2), we are simply solving (ll_matrix).(solution_local) = (l_rhs).
+ // Hence, we multiply @p l_rhs by our already inverted local-local matrix
+ // and store the result using the <code>set_dof_values</code> function.
+ else
+ {
+ scratch.ll_matrix.vmult(scratch.tmp_rhs, scratch.l_rhs);
+ loc_cell->set_dof_values(scratch.tmp_rhs, solution_local);
+ }
+ }
+
+
+
+ // @sect4{HDG::copy_local_to_global}
+ // If we are in the first step of the solution, i.e. @p trace_reconstruct=false,
+ // then we assemble the local matrices into the global system.
+ template <int dim>
+ void HDG<dim>::copy_local_to_global(const PerTaskData &data)
+ {
+ if (data.trace_reconstruct == false)
+ constraints.distribute_local_to_global (data.cell_matrix,
+ data.cell_vector,
+ data.dof_indices,
+ system_matrix, system_rhs);
+ }
+
+
+
+ // @sect4{HDG::solve}
+ // The skeleton solution is solved for by using a BiCGStab solver with
+ // identity preconditioner.
+ template <int dim>
+ void HDG<dim>::solve ()
+ {
+ SolverControl solver_control (system_matrix.m()*10,
+ 1e-11*system_rhs.l2_norm());
+ SolverBicgstab<> solver (solver_control, false);
+ solver.solve (system_matrix, solution, system_rhs,
+ PreconditionIdentity());
+
+ std::cout << " Number of BiCGStab iterations: " << solver_control.last_step()
+ << std::endl;
+
+ system_matrix.clear();
+ sparsity_pattern.reinit(0,0,0,1);
+
+ constraints.distribute(solution);
+
+ // Once we have solved for the skeleton solution,
+ // we can solve for the local solutions in an element-by-element
+ // fashion. We do this by re-using the same @p assemble_system function
+ // but switching @p trace_reconstruct to true.
+ assemble_system(true);
+ }
+
+
+
+ // @sect4{HDG::postprocess}
+
+ // The postprocess method serves two purposes. First, we want to construct a
+ // post-processed scalar variables in the element space of degree $p+1$ that
+ // we hope will converge at order $p+2$. This is again an element-by-element
+ // process and only involves the scalar solution as well as the gradient on
+ // the local cell. To do this, we introduce the already defined scratch data
+ // together with some update flags and run the work stream to do this in
+ // parallel.
+ //
+ // Secondly, we want to compute discretization errors just as we did in
+ // step-7. The overall procedure is similar with calls to
+ // VectorTools::integrate_difference. The difference is in how we compute
+ // the errors for the scalar variable and the gradient variable. In step-7,
+ // we did this by computing @p L2_norm or @p H1_seminorm
+ // contributions. Here, we have a DoFHandler with these two contributions
+ // computed and sorted by their vector component, <code>[0, dim)</code> for the
+ // gradient and @p dim for the scalar. To compute their value, we hence use
+ // a ComponentSelectFunction with either of them, together with the @p
+ // SolutionAndGradient class introduced above that contains the analytic
+ // parts of either of them. Eventually, we also compute the L2-error of the
+ // post-processed solution and add the results into the convergence table.
+ template <int dim>
+ void
+ HDG<dim>::postprocess()
+ {
+ {
+ const QGauss<dim> quadrature_formula(fe_u_post.degree+1);
+ const UpdateFlags local_flags (update_values);
+ const UpdateFlags flags ( update_values | update_gradients |
+ update_JxW_values);
+
+ PostProcessScratchData scratch (fe_u_post, fe_local,
+ quadrature_formula,
+ local_flags,
+ flags);
+
+ WorkStream::run(dof_handler_u_post.begin_active(),
+ dof_handler_u_post.end(),
+ std_cxx1x::bind (&HDG<dim>::postprocess_one_cell,
+ std_cxx1x::ref(*this),
+ std_cxx1x::_1, std_cxx1x::_2, std_cxx1x::_3),
+ std_cxx1x::function<void(const unsigned int &)>(),
+ scratch,
+ 0U);
+ }
+
+ Vector<float> difference_per_cell (triangulation.n_active_cells());
+
+ ComponentSelectFunction<dim> value_select (dim, dim+1);
+ VectorTools::integrate_difference (dof_handler_local,
+ solution_local,
+ SolutionAndGradient<dim>(),
+ difference_per_cell,
+ QGauss<dim>(fe.degree+2),
+ VectorTools::L2_norm,
+ &value_select);
+ const double L2_error = difference_per_cell.l2_norm();
+
+ ComponentSelectFunction<dim> gradient_select (std::pair<unsigned int,unsigned int>(0, dim),
+ dim+1);
+ VectorTools::integrate_difference (dof_handler_local,
+ solution_local,
+ SolutionAndGradient<dim>(),
+ difference_per_cell,
+ QGauss<dim>(fe.degree+2),
+ VectorTools::L2_norm,
+ &gradient_select);
+ const double grad_error = difference_per_cell.l2_norm();
+
+ VectorTools::integrate_difference (dof_handler_u_post,
+ solution_u_post,
+ Solution<dim>(),
+ difference_per_cell,
+ QGauss<dim>(fe.degree+3),
+ VectorTools::L2_norm);
+ const double post_error = difference_per_cell.l2_norm();
+
+ convergence_table.add_value("cells", triangulation.n_active_cells());
+ convergence_table.add_value("dofs", dof_handler.n_dofs());
+ convergence_table.add_value("val L2", L2_error);
+ convergence_table.add_value("grad L2", grad_error);
+ convergence_table.add_value("val L2-post", post_error);
+ }
+
+
+
+ // @sect4{HDG::postprocess_one_cell}
+ //
+ // This is the actual work done for the postprocessing. According to the
+ // discussion in the introduction, we need to set up a system that projects
+ // the gradient part of the DG solution onto the gradient of the
+ // post-processed variable. Moreover, we need to set the average of the new
+ // post-processed variable to equal the average of the scalar DG solution
+ // on the cell.
+ //
+ // More technically speaking, the projection of the gradient is a system
+ // that would potentially fills our @p dofs_per_cell times @p dofs_per_cell
+ // matrix but is singular (the sum of all rows would be zero because the
+ // constant function has zero gradient). Therefore, we take one row away and
+ // use it for imposing the average of the scalar value. We pick the first
+ // row for the scalar part, even though we could pick any row for $\mathcal
+ // Q_{-p}$ elements. However, had we used FE_DGP elements instead, the first
+ // row would correspond to the constant part already and deleting e.g. the
+ // last row would give us a singular system. This way, our program can also
+ // be used for those elements.
+ template <int dim>
+ void
+ HDG<dim>::postprocess_one_cell (const typename DoFHandler<dim>::active_cell_iterator &cell,
+ PostProcessScratchData &scratch,
+ unsigned int &)
+ {
+ typename DoFHandler<dim>::active_cell_iterator
+ loc_cell (&triangulation,
+ cell->level(),
+ cell->index(),
+ &dof_handler_local);
+
+ scratch.fe_values_local.reinit (loc_cell);
+ scratch.fe_values.reinit(cell);
+
+ FEValuesExtractors::Vector fluxes(0);
+ FEValuesExtractors::Scalar scalar(dim);
+
+ const unsigned int n_q_points = scratch.fe_values.get_quadrature().size();
+ const unsigned int dofs_per_cell = scratch.fe_values.dofs_per_cell;
+
+ scratch.fe_values_local[scalar].get_function_values(solution_local, scratch.u_values);
+ scratch.fe_values_local[fluxes].get_function_values(solution_local, scratch.u_gradients);
+
+ double sum = 0;
+ for (unsigned int i=1; i<dofs_per_cell; ++i)
+ {
+ for (unsigned int j=0; j<dofs_per_cell; ++j)
+ {
+ sum = 0;
+ for (unsigned int q=0; q<n_q_points; ++q)
+ sum += (scratch.fe_values.shape_grad(i,q) *
+ scratch.fe_values.shape_grad(j,q)
+ ) * scratch.fe_values.JxW(q);
+ scratch.cell_matrix(i,j) = sum;
+ }
+
+ sum = 0;
+ for (unsigned int q=0; q<n_q_points; ++q)
+ sum -= (scratch.fe_values.shape_grad(i,q) * scratch.u_gradients[q]
+ ) * scratch.fe_values.JxW(q);
+ scratch.cell_rhs(i) = sum;
+ }
+ for (unsigned int j=0; j<dofs_per_cell; ++j)
+ {
+ sum = 0;
+ for (unsigned int q=0; q<n_q_points; ++q)
+ sum += scratch.fe_values.shape_value(j,q) * scratch.fe_values.JxW(q);
+ scratch.cell_matrix(0,j) = sum;
+ }
+ {
+ sum = 0;
+ for (unsigned int q=0; q<n_q_points; ++q)
+ sum += scratch.u_values[q] * scratch.fe_values.JxW(q);
+ scratch.cell_rhs(0) = sum;
+ }
+
+ // Having assembled all terms, we can again go on and solve the linear
+ // system. We invert the matrix and then multiply the inverse by the
+ // right hand side. An alternative (and more numerically stable) method would have
+ // been to only factorize the matrix and apply the factorization.
+ scratch.cell_matrix.gauss_jordan();
+ scratch.cell_matrix.vmult(scratch.cell_sol, scratch.cell_rhs);
+ cell->distribute_local_to_global(scratch.cell_sol, solution_u_post);
+ }
+
+
+
+ // @sect4{HDG::output_results}
+ // We have 3 sets of results that we would like to output: the local solution,
+ // the post-processed local solution, and the skeleton solution. The former 2
+ // both 'live' on element volumes, wheras the latter lives on codimention-1 surfaces
+ // of the triangulation. Our @p output_results function writes all local solutions
+ // to the same vtk file, even though they correspond to different <code>DoFHandler</code>
+ // objects. The graphical output for the skeleton variable is done through
+ // use of the <code>DataOutFaces</code> class.
+ template <int dim>
+ void HDG<dim>::output_results (const unsigned int cycle)
+ {
+ std::string filename;
+ switch (refinement_mode)
+ {
+ case global_refinement:
+ filename = "solution-global";
+ break;
+ case adaptive_refinement:
+ filename = "solution-adaptive";
+ break;
+ default:
+ Assert (false, ExcNotImplemented());
+ }
+
+ std::string face_out(filename);
+ face_out += "-face";
+
+ filename += "-q" + Utilities::int_to_string(fe.degree,1);
+ filename += "-" + Utilities::int_to_string(cycle,2);
+ filename += ".vtk";
+ std::ofstream output (filename.c_str());
+
+ DataOut<dim> data_out;
+
+ // We first define the names and types of the local solution,
+ // and add the data to @p data_out.
+ std::vector<std::string> names (dim, "gradient");
+ names.push_back ("solution");
+ std::vector<DataComponentInterpretation::DataComponentInterpretation>
+ component_interpretation
+ (dim+1, DataComponentInterpretation::component_is_part_of_vector);
+ component_interpretation[dim]
+ = DataComponentInterpretation::component_is_scalar;
+ data_out.add_data_vector (dof_handler_local, solution_local,
+ names, component_interpretation);
+
+ // The second data item we add is the post-processed solution.
+ // In this case, it is a single scalar variable belonging to
+ // a different DoFHandler.
+ std::vector<std::string> post_name(1,"u_post");
+ std::vector<DataComponentInterpretation::DataComponentInterpretation>
+ post_comp_type(1, DataComponentInterpretation::component_is_scalar);
+ data_out.add_data_vector (dof_handler_u_post, solution_u_post,
+ post_name, post_comp_type);
+
+ data_out.build_patches (fe.degree);
+ data_out.write_vtk (output);
+
+ face_out += "-q" + Utilities::int_to_string(fe.degree,1);
+ face_out += "-" + Utilities::int_to_string(cycle,2);
+ face_out += ".vtk";
+ std::ofstream face_output (face_out.c_str());
+
+// The <code>DataOutFaces</code> class works analagously to the <code>DataOut</code>
+// class when we have a <code>DoFHandler</code> that defines the solution on
+// the skeleton of the triangulation. We treat it as such here, and the code is
+// similar to that above.
+ DataOutFaces<dim> data_out_face(false);
+ std::vector<std::string> face_name(1,"u_hat");
+ std::vector<DataComponentInterpretation::DataComponentInterpretation>
+ face_component_type(1, DataComponentInterpretation::component_is_scalar);
+
+ data_out_face.add_data_vector (dof_handler,
+ solution,
+ face_name,
+ face_component_type);
+
+ data_out_face.build_patches (fe.degree);
+ data_out_face.write_vtk (face_output);
+ }
+
+// @sect4{HDG::refine_grid}
+
+// We implement two different refinement cases for HDG, just as in
+// <code>Step-7</code>: adaptive_refinement and global_refinement. The
+// global_refinement option recreates the entire triangulation every
+// time. This is because we want to use a finer sequence of meshes than what
+// we would get with one refinement step, namely 2, 3, 4, 6, 8, 12, 16, ...
+// elements per direction.
+
+// The adaptive_refinement mode uses the <code>KellyErrorEstimator</code> to
+// give a decent indication of the non-regular regions in the scalar local
+// solutions.
+ template <int dim>
+ void HDG<dim>::refine_grid (const unsigned int cycle)
+ {
+ if (cycle == 0)
+ {
+ GridGenerator::subdivided_hyper_cube (triangulation, 2, -1, 1);
+ triangulation.refine_global(3-dim);
+ }
+ else
+ switch (refinement_mode)
+ {
+ case global_refinement:
+ {
+ triangulation.clear();
+ GridGenerator::subdivided_hyper_cube (triangulation, 2+(cycle%2), -1, 1);
+ triangulation.refine_global(3-dim+cycle/2);
+ break;
+ }
+
+ case adaptive_refinement:
+ {
+ Vector<float> estimated_error_per_cell (triangulation.n_active_cells());
+
+ FEValuesExtractors::Scalar scalar(dim);
+ typename FunctionMap<dim>::type neumann_boundary;
+ KellyErrorEstimator<dim>::estimate (dof_handler_local,
+ QGauss<dim-1>(3),
+ neumann_boundary,
+ solution_local,
+ estimated_error_per_cell,
+ fe_local.component_mask(scalar));
+
+ GridRefinement::refine_and_coarsen_fixed_number (triangulation,
+ estimated_error_per_cell,
+ 0.3, 0.);
+
+ triangulation.execute_coarsening_and_refinement ();
+
+ break;
+ }
+
+ default:
+ {
+ Assert (false, ExcNotImplemented());
+ }
+ }
+
+ // Just as in step-7, we set the boundary indicator of two of the faces to 1
+ // where we want to specify Neumann boundary conditions instead of Dirichlet
+ // conditions. Since we re-create the triangulation every time for global
+ // refinement, the flags are set in every refinement step, not just at the
+ // beginning.
+ typename Triangulation<dim>::cell_iterator
+ cell = triangulation.begin (),
+ endc = triangulation.end();
+ for (; cell!=endc; ++cell)
+ for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
+ if (cell->face(face)->at_boundary())
+ if ((std::fabs(cell->face(face)->center()(0) - (-1)) < 1e-12)
+ ||
+ (std::fabs(cell->face(face)->center()(1) - (-1)) < 1e-12))
+ cell->face(face)->set_boundary_indicator (1);
+ }
+
+ // @sect4{HDG::run}
+ // The functionality here is basically the same as <code>Step-7</code>.
+ // We loop over 10 cycles, refining the grid on each one. At the end,
+ // convergence tables are created.
+ template <int dim>
+ void HDG<dim>::run ()
+ {
+ for (unsigned int cycle=0; cycle<10; ++cycle)
+ {
+ std::cout << "Cycle " << cycle << ':' << std::endl;
+
+ refine_grid (cycle);
+ setup_system ();
+ assemble_system (false);
+ solve ();
+ postprocess();
+ output_results (cycle);
+ }
+
+
+
+ convergence_table.set_precision("val L2", 3);
+ convergence_table.set_scientific("val L2", true);
+ convergence_table.set_precision("grad L2", 3);
+ convergence_table.set_scientific("grad L2", true);
+ convergence_table.set_precision("val L2-post", 3);
+ convergence_table.set_scientific("val L2-post", true);
+
+ // There is one minor change for the convergence table compared to step-7:
+ // Since we did not refine our mesh by a factor two in each cycle (but
+ // rather used the sequence 2, 3, 4, 6, 8, 12, ...), we need to tell the
+ // convergence rate evaluation about this. We do this by setting the
+ // number of cells as a reference column and additionally specifying the
+ // dimension of the problem, which gives the necessary information for the
+ // relation between number of cells and mesh size.
+ if (refinement_mode == global_refinement)
+ {
+ convergence_table
+ .evaluate_convergence_rates("val L2", "cells", ConvergenceTable::reduction_rate_log2, dim);
+ convergence_table
+ .evaluate_convergence_rates("grad L2", "cells", ConvergenceTable::reduction_rate_log2, dim);
+ convergence_table
+ .evaluate_convergence_rates("val L2-post", "cells", ConvergenceTable::reduction_rate_log2, dim);
+ }
+ convergence_table.write_text(std::cout);
+ }
+
+} // end of namespace Step51
+
+
+
+int main (int argc, char **argv)
+{
+ const unsigned int dim = 2;
+
+ try
+ {
+ using namespace dealii;
+
+ deallog.depth_console (0);
+
+ // Now for the three calls to the main class in complete analogy to
+ // step-7.
+ {
+ std::cout << "Solving with Q1 elements, adaptive refinement" << std::endl
+ << "=============================================" << std::endl
+ << std::endl;
+
+ Step51::HDG<dim> hdg_problem (1, Step51::HDG<dim>::adaptive_refinement);
+ hdg_problem.run ();
+
+ std::cout << std::endl;
+ }
+
+ {
+ std::cout << "Solving with Q1 elements, global refinement" << std::endl
+ << "===========================================" << std::endl
+ << std::endl;
+
+ Step51::HDG<dim> hdg_problem (1, Step51::HDG<dim>::global_refinement);
+ hdg_problem.run ();
+
+ std::cout << std::endl;
+ }
+
+ {
+ std::cout << "Solving with Q3 elements, global refinement" << std::endl
+ << "===========================================" << std::endl
+ << std::endl;
+
+ Step51::HDG<dim> hdg_problem (3, Step51::HDG<dim>::global_refinement);
+ hdg_problem.run ();
+
+ std::cout << std::endl;
+ }
+
+ }
+ catch (std::exception &exc)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ }
+
+ return 0;
+}
-/* Author: Wolfgang Bangerth, University of Heidelberg, 2000 */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2000 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Wolfgang Bangerth, University of Heidelberg, 2000
+ */
-/* $Id$ */
-/* */
-/* Copyright (C) 2000-2004, 2006-2008, 2010-2012 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. */
// @sect3{Include files}
#include <deal.II/grid/grid_refinement.h>
// Finally, we need a simple way to actually compute the refinement indicators
-// based on some error estimat. While in general, adaptivity is very
+// based on some error estimate. While in general, adaptivity is very
// problem-specific, the error indicator in the following file often yields
// quite nicely adapted grids for a wide class of problems.
#include <deal.II/numerics/error_estimator.h>
// After setting up all the degrees of freedoms, here are now the
// differences compared to step-5, all of which are related to constraints
- // associated with the hanging nodes. In the class desclaration, we have
+ // associated with the hanging nodes. In the class declaration, we have
// already allocated space for an object <code>constraints</code> that will
// hold a list of these constraints (they form a matrix, which is reflected
// in the name of the class, but that is immaterial for the moment). Now we
// approximately the same string as would be generated if the exception was
// thrown using the <code>Assert</code> macro. You have seen the output of
// such an exception in the previous example, and you then know that it
- // contains the file and line number of where the exception occured, and
+ // contains the file and line number of where the exception occurred, and
// some other information. This is also what the following statements would
// print.
//
-/* Author: Wolfgang Bangerth and Ralf Hartmann, University of Heidelberg, 2000 */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2000 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Wolfgang Bangerth and Ralf Hartmann, University of Heidelberg, 2000
+ */
-/* $Id$ */
-/* */
-/* Copyright (C) 2000-2004, 2006-2009, 2011-2012 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. */
// @sect3{Include files}
// share the same connotation that points have and are only objects in a
// more abstract space than the one spanned by the coordinate
// directions. (In fact, gradients live in `reciprocal' space, since the
- // dimension of their components is not that of a length, but one over
+ // dimension of their components is not that of a length, but of one over
// length).
template <int dim>
Tensor<1,dim> Solution<dim>::gradient (const Point<dim> &p,
//
// For this, we will use the following convention: Faces belonging to Gamma1
// will have the boundary indicator <code>0</code> (which is the default, so
- // we don't have to set it explicitely), and faces belonging to Gamma2 will
+ // we don't have to set it explicitly), and faces belonging to Gamma2 will
// use <code>1</code> as boundary indicator. To set these values, we loop
// over all cells, then over all faces of a given cell, check whether it is
// part of the boundary that we want to denote by Gamma2, and if so set its
that can be obtained by assuming that the body has infinite extent in
$z$-direction and that the solution function does not depend on the $z$
coordinate. On the other hand, there are equations for two-dimensional models
-of elasticity; see for example the wikipedia article on <a
+of elasticity; see for example the Wikipedia article on <a
href="http://en.wikipedia.org/wiki/Infinitesimal_strain_theory#Special_cases">plane
strain</a>, <a
href="http://en.wikipedia.org/wiki/Antiplane_shear">antiplane shear</a> and <a
-/* Author: Wolfgang Bangerth, University of Heidelberg, 2000 */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2000 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Wolfgang Bangerth, University of Heidelberg, 2000
+ */
-/* $Id$ */
-/* */
-/* Copyright (C) 2000-2004, 2006-2008, 2010-2012 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. */
// @sect3{Include files}
// @sect4{ElasticProblem::setup_system}
- // Setting up the system of equations is identitical to the function used in
+ // Setting up the system of equations is identical to the function used in
// the step-6 example. The <code>DoFHandler</code> class and all other
// classes used here are fully aware that the finite element we want to use
// is vector-valued, and take care of the vector-valuedness of the finite
-/* Author: Wolfgang Bangerth, University of Heidelberg, 2000 */
+/* ---------------------------------------------------------------------
+ * $Id$
+ *
+ * Copyright (C) 2000 - 2013 by the deal.II authors
+ *
+ * This file is part of the deal.II library.
+ *
+ * The deal.II library is free software; you can use it, redistribute
+ * it, and/or modify it under the terms of the GNU Lesser General
+ * Public License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * The full text of the license can be found in the file LICENSE at
+ * the top level of the deal.II distribution.
+ *
+ * ---------------------------------------------------------------------
+
+ *
+ * Author: Wolfgang Bangerth, University of Heidelberg, 2000
+ */
-/* $Id$ */
-/* */
-/* Copyright (C) 2000-2004, 2006-2008, 2010-2013 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. */
// Just as in previous examples, we have to include several files of which the
// meaning has already been discussed:
#include <deal.II/fe/fe_q.h>
#include <deal.II/grid/grid_out.h>
-// The following two files provide classes and information for multi-threaded
+// The following two files provide classes and information for multithreaded
// programs. In the first one, the classes and functions are declared which we
// need to start new threads and to wait for threads to return (i.e. the
// <code>Thread</code> class and the <code>new_thread</code> functions). The
// @sect3{Equation data declaration}
// Next we declare a class that describes the advection field. This, of
- // course, is a vector field with as many compents as there are space
+ // course, is a vector field with as many components as there are space
// dimensions. One could now use a class derived from the
// <code>Function</code> base class, as we have done for boundary values and
// coefficients in previous examples, but there is another possibility in
// rather than the common vectors of doubles, as the additional accuracy is
// not necessary for estimated values.
//
- // In addition to these two functions, the class declares to exceptions
+ // In addition to these two functions, the class declares two exceptions
// which are raised when a cell has no neighbors in each of the space
// directions (in which case the matrix described in the introduction would
// be singular and can't be inverted), while the other one is used in the
// information, we could use the value of the global variable
// <code>multithread_info.n_cpus</code>, which is determined at start-up
// time of your program automatically. (Note that if the library was not
- // configured for multi-threading, then the number of CPUs is set to one.)
+ // configured for multithreading, then the number of CPUs is set to one.)
// However, sometimes there might be reasons to use another value. For
// example, you might want to use less processors than there are in your
- // system in order not to use too many computational ressources. On the
+ // system in order not to use too many computational resources. On the
// other hand, if there are several jobs running on a computer and you
// want to get a higher percentage of CPU time, it might be worth to start
// more threads than there are CPUs, as most operating systems assign
- // roughly the same CPU ressources to all threads presently running. For
+ // roughly the same CPU resources to all threads presently running. For
// this reason, the <code>MultithreadInfo</code> class contains a
// read-write variable <code>n_default_threads</code> which is set to
// <code>n_cpus</code> by default, but can be set to another value. This
// can be omitted. (However, you still need to write the angle brackets,
// even if they are empty.)
//
- // If you did not configure for multi-threading, then the
+ // If you did not configure for multithreading, then the
// <code>new_thread</code> function that is supposed to start a new thread
// in parallel only executes the function which should be run in parallel,
// waits for it to return (i.e. the function is executed sequentially),
// the same size. Each thread will then assemble the local contributions
// of the cells within its chunk and transfer these contributions to the
// global matrix. As splitting a range of cells is a rather common task
- // when using multi-threading, there is a function in the
+ // when using multithreading, there is a function in the
// <code>Threads</code> namespace that does exactly this. In fact, it does
// this not only for a range of cell iterators, but for iterators in
// general, so you could use it for <code>std::vector::iterator</code> or
// differ (<code>begin_active</code> returns an
// <code>active_iterator</code>, while <code>end</code> returns a
// <code>raw_iterator</code>), and in this case the C++ language requires
- // us to specify the template type explicitely. For brevity, we first
+ // us to specify the template type explicitly. For brevity, we first
// typedef this data type to an alias.
typedef typename DoFHandler<dim>::active_cell_iterator active_cell_iterator;
std::vector<std::pair<active_cell_iterator,active_cell_iterator> >
n_threads);
// Finally, for each of the chunks of iterators we have computed, start
- // one thread (or if not in multi-thread mode: execute assembly on these
+ // one thread (or if not in multithread mode: execute assembly on these
// chunks sequentially). This is done using the following sequence of
// function calls:
for (unsigned int thread=0; thread<n_threads; ++thread)
thread_ranges[thread].first,
thread_ranges[thread].second);
// The reasons and internal workings of these functions can be found in
- // the report on the subject of multi-threading, which is available online
+ // the report on the subject of multithreading, which is available online
// as well. Suffice it to say that we create a new thread that calls the
// <code>assemble_system_interval</code> function on the present object
// (the <code>this</code> pointer), with the arguments following in the
// When all the threads are running, the only thing we have to do is wait
// for them to finish. This is necessary of course, as we can't proceed
// with our tasks before the matrix and right hand side are
- // assemblesd. Waiting for all the threads to finish can be done using the
- // <code>joint_all</code> function in the <code>ThreadGroup</code>
+ // assembled. Waiting for all the threads to finish can be done using the
+ // <code>join_all</code> function in the <code>ThreadGroup</code>
// container, which just calls <code>join</code> on each of the thread
// objects it stores.
//
- // Again, if the library was not configured to use multi-threading, then
+ // Again, if the library was not configured to use multithreading, then
// no threads can run in parallel and the function returns immediately.
threads.join_all ();
- // After the matrix has been assembled in parallel, we stil have to
+ // After the matrix has been assembled in parallel, we still have to
// eliminate hanging node constraints. This is something that can't be
// done on each of the threads separately, so we have to do it now.
hanging_node_constraints.condense (system_matrix);
//
// On the other hand, we would now like to write the local
// contributions to the global system of equations into the global
- // objects. This needs some kind of synchronisation, as if we would
+ // objects. This needs some kind of synchronization, as if we would
// not take care of the fact that multiple threads write into the
// matrix at the same time, we might be surprised that one threads
// reads data from the matrix that another thread is presently
// i.e. other threads can now enter into the protected section by
// acquiring the lock. Two final notes are in place here, however:
//
- // 1. If the library was not configured for multi-threading, then
+ // 1. If the library was not configured for multithreading, then
// there can't be parallel threads and there is no need to
// synchronize. Thus, the <code>lock</code> and <code>release</code>
// functions are no-ops, i.e. they return without doing anything.
// can determine an approximation of the gradient for the present
// cell, then we need to have passed over vectors <code>y</code> which
// span the whole space, otherwise we would not have all components of
- // the gradient. This is indicated by the invertability of the matrix.
+ // the gradient. This is indicated by the invertibility of the matrix.
//
// If the matrix should not be invertible, this means that the present
// cell had an insufficient number of active neighbors. In contrast to
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Configure config.h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__newton_h
#define __deal2__newton_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2007, 2008, 2009, 2010, 2012 by Guido Kanschat
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/algorithms/newton.h>
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__operator_h
#define __deal2__operator_h
DEAL_II_NAMESPACE_OPEN
+/**
+ * Namespace containing numerical algorithms in a unified form.
+ *
+ * All algorithmic classes in this namespace are derived from either
+ * Operator or OutputOperator, depending on whether they return a
+ * value or not. See the documentation of those classes for more
+ * detailed information on how to use them.
+ *
+ * @author Guido Kanschat
+ * @date 2012, 2013
+ */
namespace Algorithms
{
/**
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2007, 2008, 2009, 2010, 2012 by Guido Kanschat
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/algorithms/operator.h>
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__theta_timestepping_h
#define __deal2__theta_timestepping_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2007, 2008, 2009, 2010, 2012 by Guido Kanschat
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/algorithms/theta_timestepping.h>
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2012 by Guido Kanschat
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__time_step_control_h
#define __deal2__time_step_control_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2012 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__auto_derivative_function_h
#define __deal2__auto_derivative_function_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__conditional_ostream_h
#define __deal2__conditional_ostream_h
-//---------------------------- config.h.in ---------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2012, 2013 by the deal.II authors
+// Copyright (C) 2012 - 2013 by the deal.II authors
//
-// TODO: Header
+// This file is part of the deal.II library.
//
-// Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
//
-//---------------------------- config.h.in ---------------------------
+// ---------------------------------------------------------------------
#ifndef __deal2__config_h
#define __deal2__config_h
* Configured in check_2_compiler_bugs: *
****************************************/
-/* Defined if we have to work around a bug where the compiler doesn't accept
- * an explicit destructor call. See the aclocal.m4 file in the top-level
- * directory for a description of this bug.
- */
-#cmakedefine DEAL_II_EXPLICIT_DESTRUCTOR_BUG
-
/* Defined if we have to work around a bug with some compilers that will not
* allow us to specify a fully specialized class of a template as a friend.
* See the aclocal.m4 file in the top-level directory for a description of
#cmakedefine DEAL_II_WITH_P4EST
#ifdef DEAL_II_WITH_P4EST
# define DEAL_II_USE_P4EST
+
+# define DEAL_II_P4EST_VERSION_MAJOR @P4EST_VERSION_MAJOR@
+# define DEAL_II_P4EST_VERSION_MINOR @P4EST_VERSION_MINOR@
+# define DEAL_II_P4EST_VERSION_SUBMINOR @P4EST_VERSION_SUBMINOR@
+# define DEAL_II_P4EST_VERSION_PATCH @P4EST_VERSION_PATCH@
+
+# define DEAL_II_P4EST_VERSION_GTE(major,minor,subminor,patch) \
+ ((DEAL_II_P4EST_VERSION_MAJOR * 1000000 + \
+ DEAL_II_P4EST_VERSION_MINOR * 10000 + \
+ DEAL_II_P4EST_VERSION_SUBMINOR * 100 + \
+ DEAL_II_P4EST_VERSION_PATCH) \
+ >= \
+ (major)*1000000 + (minor)*10000 + (subminor)*100 + (patch))
+#else
+ // p4est up to 0.3.4.1 didn't define P4EST_VERSION_*. since
+ // we didn't supports anything before 0.3.4, we assume 0.3.4
+ // This means that we can't use the new features in 0.3.4.1
+# define DEAL_II_P4EST_VERSION_GTE(major,minor,subminor,patch) \
+ ((0 * 1000000 + \
+ 3 * 10000 + \
+ 4 * 100 + \
+ 0) \
+ >= \
+ (major)*1000000 + (minor)*10000 + (subminor)*100 + (patch))
+
#endif
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__convergence_table_h
#define __deal2__convergence_table_h
* omitted (see previous function) and execpt of the columns that are
* previously evaluated rate columns. This function allows to evaluate the
* convergence rate for almost all columns of a table without calling
- * evaluate_convergence_rates() for each column seperately.
+ * evaluate_convergence_rates() for each column separately.
*
* Example:
* Columns like <tt>n cells</tt> or <tt>n dofs</tt> columns may be wanted to
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__data_out_base_h
#define __deal2__data_out_base_h
class ParameterHandler;
class XDMFEntry;
+class DataOutFilter;
/**
* This is a base class for output of data on meshes of very general
{
public:
/**
- * Data structure describing a patch of
- * data in <tt>dim</tt> space
+ * Data structure describing a patch of data in <tt>dim</tt> space
* dimensions.
*
* A patch consists of the following data:
* <ul>
* <li>the corner #vertices,
- * <li> the number
- * #n_subdivisions of the number
- * of cells the Patch has in each
- * space direction,
- * <li> the #data attached to
- * each vertex, in the usual
+ * <li> the number #n_subdivisions of the number of cells the Patch
+ * has in each space direction,
+ * <li> the #data attached to each vertex, in the usual
* lexicographic ordering,
* <li> Information on #neighbors.
* </ul>
*
- * See the general
- * documentation of the
- * <tt>DataOutBase</tt> class for more
- * information on its contents and
- * purposes. In the case of two
- * dimensions, the next picture ist an
- * example of <tt>n_subdivision</tt> = 4
- * because the number of (sub)cells
- * within each patch is equal to
- * <tt>2^dim</tt>.
+ * See the general documentation of the DataOutBase class for more
+ * information on its contents and purposes. In the case of two
+ * dimensions, the next picture ist an example of
+ * <tt>n_subdivision</tt> = 4 because the number of (sub)cells
+ * within each patch is equal to <tt>2<sup>dim</sup></tt>.
*
* @ingroup output
*
struct Patch
{
/**
- * Make the <tt>spacedim</tt> template
- * parameter available.
+ * Make the <tt>spacedim</tt> template parameter available.
*/
static const unsigned int space_dim=spacedim;
/**
- * Corner points of a patch.
- * Inner points are computed by
- * a multilinear transform of
- * the unit cell to the cell
- * specified by these corner
- * points. The order of points
- * is the same as for cells
- * in the triangulation.
+ * Corner points of a patch. Inner points are computed by a
+ * multilinear transform of the unit cell to the cell specified by
+ * these corner points. The order of points is the same as for
+ * cells in the triangulation.
*/
Point<spacedim> vertices[GeometryInfo<dim>::vertices_per_cell];
/**
- * Numbers of neighbors of a patch.
- * OpenDX format requires
- * neighbor information for
- * advanced output. Here the
- * neighborship relationship
- * of patches is
- * stored. During output,
- * this must be transformed
- * into neighborship of
- * sub-grid cells.
+ * Numbers of neighbors of a patch. OpenDX format requires
+ * neighbor information for advanced output. Here the neighborship
+ * relationship of patches is stored. During output, this must be
+ * transformed into neighborship of sub-grid cells.
*/
unsigned int neighbors[dim > 0
?
1];
/**
- * Number of this
- * patch. Since we are not
- * sure patches are handled
- * in the same order, always,
- * we better store this.
+ * Number of this patch. Since we are not sure patches are handled
+ * in the same order, always, we better store this.
*/
unsigned int patch_index;
/**
- * Number of subdivisions with
- * which this patch is to be
- * written. <tt>1</tt> means no
- * subdivision, <tt>2</tt> means
- * bisection, <tt>3</tt> trisection,
- * etc.
+ * Number of subdivisions with which this patch is to be
+ * written. <tt>1</tt> means no subdivision, <tt>2</tt> means
+ * bisection, <tt>3</tt> trisection, etc.
*/
unsigned int n_subdivisions;
/**
- * Data vectors. The format is
- * as follows:
- * <tt>data(i,.)</tt> denotes the data
- * belonging to the <tt>i</tt>th data
- * vector. <tt>data.n()</tt>
- * therefore equals the number
- * of output points; this
- * number is <tt>(subdivisions+1)^{dim</tt>}.
- * <tt>data.m()</tt> equals the number of
- * data vectors.
+ * Data vectors. The format is as follows: <tt>data(i,.)</tt>
+ * denotes the data belonging to the <tt>i</tt>th data
+ * vector. <tt>data.n()</tt> therefore equals the number of output
+ * points; this number is <tt>(subdivisions+1)^{dim</tt>}.
+ * <tt>data.m()</tt> equals the number of data vectors.
*
- * Within each column,
- * <tt>data(.,j)</tt> are the
- * data values at the output
- * point <tt>j</tt>, where
- * <tt>j</tt> denotes the
- * usual lexicographic
- * ordering in deal.II. This
- * is also the order of
- * points as provided by the
- * <tt>QIterated</tt> class
- * when used with the
- * <tt>QTrapez</tt> class as
- * subquadrature.
+ * Within each column, <tt>data(.,j)</tt> are the data values at
+ * the output point <tt>j</tt>, where <tt>j</tt> denotes the usual
+ * lexicographic ordering in deal.II. This is also the order of
+ * points as provided by the <tt>QIterated</tt> class when used
+ * with the <tt>QTrapez</tt> class as subquadrature.
*
- * Since the number of data vectors
- * is usually the same for all
- * patches to be printed,
- * <tt>data.size()</tt> should yield
- * the same value for all patches
- * provided. The exception are
- * patches for which
- * points_are_available are set,
- * where the actual coordinates of
- * the point are appended to the
- * 'data' field, see the
- * documentation of the
- * points_are_available flag.
+ * Since the number of data vectors is usually the same for all
+ * patches to be printed, <tt>data.size()</tt> should yield the
+ * same value for all patches provided. The exception are patches
+ * for which points_are_available are set, where the actual
+ * coordinates of the point are appended to the 'data' field, see
+ * the documentation of the points_are_available flag.
*/
Table<2,float> data;
/**
- * Bool flag indicating, whether the
- * coordinates of the inner patch
- * points are appended to the @p data
- * table (@ true) or not (@ false),
- * where the second is the standard and
- * can be found for all cells in the
- * interior of a domain.
+ * Bool flag indicating, whether the coordinates of the inner
+ * patch points are appended to the @p data table (@p true) or not
+ * (@p false), where the second is the standard and can be found
+ * for all cells in the interior of a domain.
*
- * On the boundary of a domain, patch
- * points are evaluated using a
- * Mapping and therefore have to be
- * stored inside the patch, as the
- * Mapping and the corresponding
- * boundary information are no longer
- * available later on when we
- * actually write the patch out to an
- * output stream.
+ * On the boundary of a domain, patch points are evaluated using a
+ * Mapping and therefore have to be stored inside the patch, as
+ * the Mapping and the corresponding boundary information are no
+ * longer available later on when we actually write the patch out
+ * to an output stream.
*/
bool points_are_available;
/**
- * Default constructor. Sets
- * <tt>n_subdivisions</tt> to one.
+ * Default constructor. Sets #n_subdivisions to one.
*/
Patch ();
/**
- * Compare the present patch
- * for equality with another
- * one. This is used in a few
- * of the automated tests in
- * our testsuite.
+ * Compare the present patch for equality with another one. This
+ * is used in a few of the automated tests in our testsuite.
*/
bool operator == (const Patch &patch) const;
/**
- * Determine an estimate for
- * the memory consumption (in
- * bytes) of this
- * object. Since sometimes
- * the size of objects can
- * not be determined exactly
- * (for example: what is the
- * memory consumption of an
- * STL <tt>std::map</tt> type with a
- * certain number of
- * elements?), this is only
- * an estimate. however often
- * quite close to the true
- * value.
+ * Determine an estimate for the memory consumption (in bytes) of
+ * this object. Since sometimes the size of objects can not be
+ * determined exactly (for example: what is the memory consumption
+ * of an STL <tt>std::map</tt> type with a certain number of
+ * elements?), this is only an estimate. however often quite close
+ * to the true value.
*/
std::size_t memory_consumption () const;
/**
- * Value to be used if this
- * patch has no neighbor on
- * one side.
+ * Value to be used if this patch has no neighbor on one side.
*/
static const unsigned int no_neighbor = numbers::invalid_unsigned_int;
/** @addtogroup Exceptions
};
/**
- * Flags controlling the details of
- * output in OpenDX format.
+ * Flags controlling the details of output in OpenDX format.
*
* @ingroup output
*/
struct DXFlags
{
/**
- * Write neighbor
- * information. This
- * information is necessary
- * for instance, if OpenDX is
- * supposed to compute
- * integral curves
- * (streamlines). If it is
- * not present, streamlines
- * end at cell boundaries.
+ * Write neighbor information. This information is necessary for
+ * instance, if OpenDX is supposed to compute integral curves
+ * (streamlines). If it is not present, streamlines end at cell
+ * boundaries.
*/
bool write_neighbors;
/**
- * Write integer values of
- * the Triangulation in
- * binary format.
+ * Write integer values of the Triangulation in binary format.
*/
bool int_binary;
/**
- * Write coordinate vectors in
- * binary format.
+ * Write coordinate vectors in binary format.
*/
bool coordinates_binary;
/**
- * Write data vectors in
- * binary format.
+ * Write data vectors in binary format.
*/
bool data_binary;
/**
- * Write binary coordinate
- * vectors as double (64 bit)
- * numbers instead of float (32 bit).
+ * Write binary coordinate vectors as double (64 bit) numbers
+ * instead of float (32 bit).
*/
bool data_double;
const bool data_binary = false);
/**
- * Declare all flags with name
- * and type as offered by this
- * class, for use in input files.
+ * Declare all flags with name and type as offered by this class,
+ * for use in input files.
*/
static void declare_parameters (ParameterHandler &prm);
/**
- * Read the parameters declared in
- * <tt>declare_parameters</tt> and set the
- * flags for this output format
- * accordingly.
+ * Read the parameters declared in declare_parameters() and set
+ * the flags for this output format accordingly.
*
- * The flags thus obtained overwrite
- * all previous contents of this object.
+ * The flags thus obtained overwrite all previous contents of this
+ * object.
*/
void parse_parameters (const ParameterHandler &prm);
/**
- * Determine an estimate for
- * the memory consumption (in
- * bytes) of this
- * object.
+ * Determine an estimate for the memory consumption (in bytes) of
+ * this object.
*/
std::size_t memory_consumption () const;
};
/**
- * Flags controlling the details
- * of output in UCD format for
- * AVS.
+ * Flags controlling the details of output in UCD format for AVS.
*
* @ingroup output
*/
struct UcdFlags
{
/**
- * Write a comment at the
- * beginning of the file
- * stating the date of
- * creation and some other
- * data. While this is
- * supported by the UCD
- * format and
- * AVS, some other
- * programs get confused by
- * this, so the default is to
- * not write a
- * preamble. However, a
- * preamble can be written
- * using this flag.
+ * Write a comment at the beginning of the file stating the date
+ * of creation and some other data. While this is supported by
+ * the UCD format and AVS, some other programs get confused by
+ * this, so the default is to not write a preamble. However, a
+ * preamble can be written using this flag.
*
* Default: <code>false</code>.
*/
UcdFlags (const bool write_preamble = false);
/**
- * Declare all flags with name
- * and type as offered by this
- * class, for use in input files.
+ * Declare all flags with name and type as offered by this class,
+ * for use in input files.
*/
static void declare_parameters (ParameterHandler &prm);
/**
- * Read the parameters declared in
- * <tt>declare_parameters</tt> and set the
- * flags for this output format
- * accordingly.
+ * Read the parameters declared in declare_parameters() and
+ * set the flags for this output format accordingly.
*
- * The flags thus obtained overwrite
- * all previous contents of this object.
+ * The flags thus obtained overwrite all previous contents of this
+ * object.
*/
void parse_parameters (const ParameterHandler &prm);
/**
- * Determine an estimate for
- * the memory consumption (in
- * bytes) of this
- * object. Since sometimes
- * the size of objects can
- * not be determined exactly
- * (for example: what is the
- * memory consumption of an
- * STL <tt>std::map</tt> type with a
- * certain number of
- * elements?), this is only
- * an estimate. however often
- * quite close to the true
- * value.
+ * Determine an estimate for the memory consumption (in bytes) of
+ * this object. Since sometimes the size of objects can not be
+ * determined exactly (for example: what is the memory consumption
+ * of an STL <tt>std::map</tt> type with a certain number of
+ * elements?), this is only an estimate. however often quite close
+ * to the true value.
*/
std::size_t memory_consumption () const;
};
/**
- * Flags controlling the details of
- * output in Gnuplot format. At
+ * Flags controlling the details of output in Gnuplot format. At
* present no flags are implemented.
*
* @ingroup output
{
private:
/**
- * Dummy entry to suppress compiler
- * warnings when copying an empty
- * structure. Remove this member
- * when adding the first flag to
- * this structure (and remove the
- * <tt>private</tt> as well).
+ * Dummy entry to suppress compiler warnings when copying an empty
+ * structure. Remove this member when adding the first flag to
+ * this structure (and remove the <tt>private</tt> as well).
*/
int dummy;
GnuplotFlags ();
/**
- * Declare all flags with name
- * and type as offered by this
- * class, for use in input files.
+ * Declare all flags with name and type as offered by this class,
+ * for use in input files.
*/
static void declare_parameters (ParameterHandler &prm);
/**
- * Read the parameters declared in
- * <tt>declare_parameters</tt> and set the
- * flags for this output format
- * accordingly.
+ * Read the parameters declared in declare_parameters() and set
+ * the flags for this output format accordingly.
*
- * The flags thus obtained overwrite
- * all previous contents of this object.
+ * The flags thus obtained overwrite all previous contents of this
+ * object.
*/
void parse_parameters (const ParameterHandler &prm) const;
/**
- * Determine an estimate for
- * the memory consumption (in
- * bytes) of this
- * object. Since sometimes
- * the size of objects can
- * not be determined exactly
- * (for example: what is the
- * memory consumption of an
- * STL <tt>std::map</tt> type with a
- * certain number of
- * elements?), this is only
- * an estimate. however often
- * quite close to the true
- * value.
+ * Determine an estimate for the memory consumption (in bytes) of
+ * this object. Since sometimes the size of objects can not be
+ * determined exactly (for example: what is the memory consumption
+ * of an STL <tt>std::map</tt> type with a certain number of
+ * elements?), this is only an estimate. however often quite close
+ * to the true value.
*/
std::size_t memory_consumption () const;
};
/**
- * Flags controlling the details
- * of output in Povray
- * format. Several flags are
- * implemented, see their
- * respective documentation.
+ * Flags controlling the details of output in Povray format. Several
+ * flags are implemented, see their respective documentation.
*
* @ingroup output
*/
struct PovrayFlags
{
/**
- * Normal vector interpolation,
- * if set to true
+ * Normal vector interpolation, if set to true
*
* default = false
*/
bool smooth;
/**
- * Use bicubic patches (b-splines)
- * instead of triangles.
+ * Use bicubic patches (b-splines) instead of triangles.
*
* default = false
*/
bool bicubic_patch;
/**
- * include external "data.inc"
- * with camera, light and
- * texture definition for the
- * scene.
+ * include external "data.inc" with camera, light and texture
+ * definition for the scene.
*
* default = false
*/
const bool external_data = false);
/**
- * Declare all flags with name
- * and type as offered by this
- * class, for use in input files.
+ * Declare all flags with name and type as offered by this class,
+ * for use in input files.
*/
static void declare_parameters (ParameterHandler &prm);
/**
- * Read the parameters declared in
- * <tt>declare_parameters</tt> and set the
- * flags for this output format
- * accordingly.
+ * Read the parameters declared in declare_parameters() and
+ * set the flags for this output format accordingly.
*
- * The flags thus obtained overwrite
- * all previous contents of this object.
+ * The flags thus obtained overwrite all previous contents of this
+ * object.
*/
void parse_parameters (const ParameterHandler &prm);
/**
- * Determine an estimate for
- * the memory consumption (in
- * bytes) of this
- * object. Since sometimes
- * the size of objects can
- * not be determined exactly
- * (for example: what is the
- * memory consumption of an
- * STL <tt>std::map</tt> type with a
- * certain number of
- * elements?), this is only
- * an estimate. however often
- * quite close to the true
- * value.
+ * Determine an estimate for the memory consumption (in bytes) of
+ * this object. Since sometimes the size of objects can not be
+ * determined exactly (for example: what is the memory consumption
+ * of an STL <tt>std::map</tt> type with a certain number of
+ * elements?), this is only an estimate. however often quite close
+ * to the true value.
*/
std::size_t memory_consumption () const;
};
/**
- * Flags controlling the details of
- * output in encapsulated postscript
- * format.
+ * Flags controlling the details of output in encapsulated
+ * postscript format.
*
* @ingroup output
*/
struct EpsFlags
{
/**
- * This denotes the number of the
- * data vector which shall be used
- * for generating the height
- * information. By default, the
- * first data vector is taken,
- * i.e. <tt>height_vector==0</tt>, if
- * there is any data vector. If there
- * is no data vector, no height
+ * This denotes the number of the data vector which shall be used
+ * for generating the height information. By default, the first
+ * data vector is taken, i.e. <tt>height_vector==0</tt>, if there
+ * is any data vector. If there is no data vector, no height
* information is generated.
*/
unsigned int height_vector;
/**
- * Number of the vector which is
- * to be taken to colorize cells.
- * The same applies as for
- * <tt>height_vector</tt>.
+ * Number of the vector which is to be taken to colorize cells.
+ * The same applies as for #height_vector.
*/
unsigned int color_vector;
/**
- * Enum denoting the possibilities
- * whether the scaling should be done
- * such that the given <tt>size</tt> equals
- * the width or the height of
- * the resulting picture.
+ * Enum denoting the possibilities whether the scaling should be
+ * done such that the given <tt>size</tt> equals the width or the
+ * height of the resulting picture.
*/
enum SizeType
{
SizeType size_type;
/**
- * Width or height of the output
- * as given in postscript units
- * This usually is given by the
- * strange unit 1/72 inch. Whether
- * this is height or width is
- * specified by the flag
- * <tt>size_type</tt>.
+ * Width or height of the output as given in postscript units This
+ * usually is given by the strange unit 1/72 inch. Whether this is
+ * height or width is specified by the flag <tt>size_type</tt>.
*
- * Default is 300, which represents
- * a size of roughly 10 cm.
+ * Default is 300, which represents a size of roughly 10 cm.
*/
unsigned int size;
/**
- * Width of a line in postscript
- * units. Default is 0.5.
+ * Width of a line in postscript units. Default is 0.5.
*/
double line_width;
/**
- * Angle of the line origin-viewer
- * against the z-axis in degrees.
+ * Angle of the line origin-viewer against the z-axis in degrees.
*
- * Default is the Gnuplot-default
- * of 60.
+ * Default is the Gnuplot-default of 60.
*/
double azimut_angle;
/**
- * Angle by which the viewers
- * position projected onto the
- * x-y-plane is rotated around
- * the z-axis, in positive sense
- * when viewed from above. The
- * unit are degrees, and zero
- * equals a position above or below
- * the negative y-axis.
+ * Angle by which the viewers position projected onto the
+ * x-y-plane is rotated around the z-axis, in positive sense when
+ * viewed from above. The unit are degrees, and zero equals a
+ * position above or below the negative y-axis.
*
- * Default is the
- * Gnuplot-default of 30.
- * An example of a
- * Gnuplot-default of 0 is
- * the following:
+ * Default is the Gnuplot-default of 30. An example of a
+ * Gnuplot-default of 0 is the following:
*
* @verbatim
*
double turn_angle;
/**
- * Factor by which the z-axis is to
- * be stretched as compared to the
- * x- and y-axes. This is to compensate
- * for the different sizes that
- * coordinate and solution values may
- * have and to prevent that the plot
- * looks to much out-of-place (no
- * elevation at all if solution values
- * are much smaller than coordinate
- * values, or the common "extremely
- * mountainous area" in the opposite
- * case.
+ * Factor by which the z-axis is to be stretched as compared to
+ * the x- and y-axes. This is to compensate for the different
+ * sizes that coordinate and solution values may have and to
+ * prevent that the plot looks to much out-of-place (no elevation
+ * at all if solution values are much smaller than coordinate
+ * values, or the common "extremely mountainous area" in the
+ * opposite case.
*
* Default is <tt>1.0</tt>.
*/
double z_scaling;
/**
- * Flag the determines whether the
- * lines bounding the cells (or the
- * parts of each patch) are to be
- * plotted.
+ * Flag the determines whether the lines bounding the cells (or
+ * the parts of each patch) are to be plotted.
*
* Default: <tt>true</tt>.
*/
bool draw_mesh;
/**
- * Flag whether to fill the regions
- * between the lines bounding the cells
- * or not. If not, no hidden line removal
- * is performed, which in this crude
- * implementation is done through
- * writing the cells in a back-to-front
- * order, thereby hiding the cells in
- * the background by cells in the
- * foreground.
+ * Flag whether to fill the regions between the lines bounding the
+ * cells or not. If not, no hidden line removal is performed,
+ * which in this crude implementation is done through writing the
+ * cells in a back-to-front order, thereby hiding the cells in the
+ * background by cells in the foreground.
*
- * If this flag is <tt>false</tt> and <tt>draw_mesh</tt>
- * is <tt>false</tt> as well, nothing will be
- * printed.
+ * If this flag is <tt>false</tt> and #draw_mesh is <tt>false</tt>
+ * as well, nothing will be printed.
*
- * If this flag is <tt>true</tt>, then the cells
- * will be drawn either colored by one
- * of the data sets (if <tt>shade_cells</tt> is
- * <tt>true</tt>), or pure white (if
- * <tt>shade_cells</tt> is false or if there are
- * no data sets).
+ * If this flag is <tt>true</tt>, then the cells will be drawn
+ * either colored by one of the data sets (if #shade_cells is
+ * <tt>true</tt>), or pure white (if #shade_cells is false or if
+ * there are no data sets).
*
* Default is <tt>true</tt>.
*/
bool draw_cells;
/**
- * Flag to determine whether the cells
- * shall be colorized by the data
- * set denoted by <tt>color_vector</tt>, or
- * simply be painted in white. This
- * flag only makes sense if
- * <tt>draw_cells==true</tt>. Colorization is
- * done through the <tt>color_function</tt>.
+ * Flag to determine whether the cells shall be colorized by the
+ * data set denoted by #color_vector, or simply be painted in
+ * white. This flag only makes sense if
+ * <tt>#draw_cells==true</tt>. Colorization is done through
+ * #color_function.
*
* Default is <tt>true</tt>.
*/
bool shade_cells;
/**
- * Structure keeping the three color
- * values in the RGB system.
+ * Structure keeping the three color values in the RGB system.
*/
struct RgbValues
{
float blue;
/**
- * Return <tt>true</tt> if the
- * color represented by
- * the three color values
- * is a grey scale,
- * i.e. all components
- * are equal.
+ * Return <tt>true</tt> if the color represented by the three
+ * color values is a grey scale, i.e. all components are equal.
*/
bool is_grey () const;
};
/**
- * Definition of a function pointer
- * type taking a value and returning
- * a triple of color values in RGB
- * values.
+ * Definition of a function pointer type taking a value and
+ * returning a triple of color values in RGB values.
*
- * Besides the actual value by which
- * the color is to be computed, min
- * and max values of the data to
- * be colorized are given as well.
+ * Besides the actual value by which the color is to be computed,
+ * min and max values of the data to be colorized are given as
+ * well.
*/
typedef RgbValues (*ColorFunction) (const double value,
const double min_value,
const double max_value);
/**
- * This is a pointer to the function
- * which is used to colorize the cells.
- * By default, it points to the
- * static function <tt>default_color_function</tt>
- * which is a member of this class.
+ * This is a pointer to the function which is used to colorize the
+ * cells. By default, it points to the static function
+ * default_color_function() which is a member of this class.
*/
ColorFunction color_function;
/**
- * Default colorization function. This
- * one does what one usually wants:
- * It shifts colors from black (lowest
- * value) through blue, green and red
- * to white (highest value). For the
- * exact defition of the color scale
- * refer to the implementation.
+ * Default colorization function. This one does what one usually
+ * wants: It shifts colors from black (lowest value) through blue,
+ * green and red to white (highest value). For the exact defition
+ * of the color scale refer to the implementation.
*
- * This function was originally written
- * by Stefan Nauber.
+ * This function was originally written by Stefan Nauber.
*/
static RgbValues
default_color_function (const double value,
const double max_value);
/**
- * This is an alternative color
- * function producing a grey scale
- * between black (lowest values)
- * and white (highest values). You
- * may use it by setting the
- * <tt>color_function</tt> variable to the
+ * This is an alternative color function producing a grey scale
+ * between black (lowest values) and white (highest values). You
+ * may use it by setting the #color_function variable to the
* address of this function.
*/
static RgbValues
const double max_value);
/**
- * This is one more
- * alternative color function
- * producing a grey scale
- * between white (lowest
- * values) and black (highest
- * values), i.e. the scale is
- * reversed to the previous
- * one. You may use it by
- * setting the
- * <tt>color_function</tt>
- * variable to the address of
- * this function.
+ * This is one more alternative color function producing a grey
+ * scale between white (lowest values) and black (highest values),
+ * i.e. the scale is reversed to the previous one. You may use it
+ * by setting the #color_function variable to the address of this
+ * function.
*/
static RgbValues
reverse_grey_scale_color_function (const double value,
const ColorFunction color_function= &default_color_function);
/**
- * Declare all flags with name
- * and type as offered by this
- * class, for use in input files.
+ * Declare all flags with name and type as offered by this class,
+ * for use in input files.
*
- * For coloring, only the color
- * functions declared in this
- * class are offered.
+ * For coloring, only the color functions declared in this class
+ * are offered.
*/
static void declare_parameters (ParameterHandler &prm);
/**
- * Read the parameters declared in
- * <tt>declare_parameters</tt> and set the
- * flags for this output format
- * accordingly.
+ * Read the parameters declared in declare_parameters() and set
+ * the flags for this output format accordingly.
*
- * The flags thus obtained overwrite
- * all previous contents of this object.
+ * The flags thus obtained overwrite all previous contents of this
+ * object.
*/
void parse_parameters (const ParameterHandler &prm);
/**
- * Determine an estimate for
- * the memory consumption (in
- * bytes) of this
- * object. Since sometimes
- * the size of objects can
- * not be determined exactly
- * (for example: what is the
- * memory consumption of an
- * STL <tt>std::map</tt> type with a
- * certain number of
- * elements?), this is only
- * an estimate. however often
- * quite close to the true
- * value.
+ * Determine an estimate for the memory consumption (in bytes) of
+ * this object. Since sometimes the size of objects can not be
+ * determined exactly (for example: what is the memory consumption
+ * of an STL <tt>std::map</tt> type with a certain number of
+ * elements?), this is only an estimate. however often quite close
+ * to the true value.
*/
std::size_t memory_consumption () const;
};
/**
- * Flags controlling the details
- * of output in GMV
- * format. At present no flags
- * are implemented.
+ * Flags controlling the details of output in GMV format. At present
+ * no flags are implemented.
*
* @ingroup output
*/
{
private:
/**
- * Dummy entry to suppress compiler
- * warnings when copying an empty
- * structure. Remove this member
- * when adding the first flag to
- * this structure (and remove the
- * <tt>private</tt> as well).
+ * Dummy entry to suppress compiler warnings when copying an empty
+ * structure. Remove this member when adding the first flag to
+ * this structure (and remove the <tt>private</tt> as well).
*/
int dummy;
GmvFlags ();
/**
- * Declare all flags with name
- * and type as offered by this
- * class, for use in input files.
+ * Declare all flags with name and type as offered by this class,
+ * for use in input files.
*/
static void declare_parameters (ParameterHandler &prm);
/**
- * Read the parameters declared in
- * <tt>declare_parameters</tt> and set the
- * flags for this output format
- * accordingly.
+ * Read the parameters declared in declare_parameters() and set
+ * the flags for this output format accordingly.
*
- * The flags thus obtained overwrite
- * all previous contents of this object.
+ * The flags thus obtained overwrite all previous contents of this
+ * object.
*/
void parse_parameters (const ParameterHandler &prm) const;
/**
- * Determine an estimate for
- * the memory consumption (in
- * bytes) of this
- * object. Since sometimes
- * the size of objects can
- * not be determined exactly
- * (for example: what is the
- * memory consumption of an
- * STL <tt>std::map</tt> type with a
- * certain number of
- * elements?), this is only
- * an estimate. however often
- * quite close to the true
- * value.
+ * Determine an estimate for the memory consumption (in bytes) of
+ * this object. Since sometimes the size of objects can not be
+ * determined exactly (for example: what is the memory consumption
+ * of an STL <tt>std::map</tt> type with a certain number of
+ * elements?), this is only an estimate. however often quite close
+ * to the true value.
*/
std::size_t memory_consumption () const;
};
/**
- * Flags controlling the details
- * of output in
- * Tecplot format.
+ * Flags controlling the details of output in Tecplot format.
*
* @ingroup output
*/
public:
/**
- * This variable is needed to hold the
- * output file name when using the
- * Tecplot API to write binary files.
- * If the user doesn't set the file
- * name with this variable only
- * ASCII Tecplot output will be
- * produced.
+ * This variable is needed to hold the output file name when using
+ * the Tecplot API to write binary files. If the user doesn't set
+ * the file name with this variable only ASCII Tecplot output will
+ * be produced.
*/
const char *tecplot_binary_file_name;
/**
- * Tecplot allows to assign
- * names to zones. This
- * variable stores this name.
+ * Tecplot allows to assign names to zones. This variable stores
+ * this name.
*/
const char *zone_name;
const char *zone_name = NULL);
/**
- * Declare all flags with name
- * and type as offered by this
- * class, for use in input files.
+ * Declare all flags with name and type as offered by this class,
+ * for use in input files.
*/
static void declare_parameters (ParameterHandler &prm);
/**
- * Read the parameters declared in
- * <tt>declare_parameters</tt> and set the
- * flags for this output format
- * accordingly.
+ * Read the parameters declared in declare_parameters() and set
+ * the flags for this output format accordingly.
*
- * The flags thus obtained overwrite
- * all previous contents of this object.
+ * The flags thus obtained overwrite all previous contents of this
+ * object.
*/
void parse_parameters (const ParameterHandler &prm) const;
/**
- * Determine an estimate for
- * the memory consumption (in
- * bytes) of this
- * object. Since sometimes
- * the size of objects can
- * not be determined exactly
- * (for example: what is the
- * memory consumption of an
- * STL <tt>std::map</tt> type with a
- * certain number of
- * elements?), this is only
- * an estimate. however often
- * quite close to the true
- * value.
+ * Determine an estimate for the memory consumption (in bytes) of
+ * this object. Since sometimes the size of objects can not be
+ * determined exactly (for example: what is the memory consumption
+ * of an STL <tt>std::map</tt> type with a certain number of
+ * elements?), this is only an estimate. however often quite close
+ * to the true value.
*/
std::size_t memory_consumption () const;
};
/**
- * Flags controlling the details
- * of output in VTK
- * format.
+ * Flags controlling the details of output in VTK format.
*
* @ingroup output
*/
{
public:
/**
- * The time of the time step if this file is part of a
- * time dependent simulation.
+ * The time of the time step if this file is part of a time
+ * dependent simulation.
*
- * The value of this variable is written into the output file according
- * to the instructions provided in
+ * The value of this variable is written into the output file
+ * according to the instructions provided in
* http://www.visitusers.org/index.php?title=Time_and_Cycle_in_VTK_files
- * unless it is at its default value of std::numeric_limits<double>::min().
+ * unless it is at its default value of
+ * std::numeric_limits<double>::min().
*/
double time;
/**
- * The number of the time step if this file is part of a
- * time dependent simulation, or the cycle within a nonlinear or other
+ * The number of the time step if this file is part of a time
+ * dependent simulation, or the cycle within a nonlinear or other
* iteration.
*
- * The value of this variable is written into the output file according
- * to the instructions provided in
+ * The value of this variable is written into the output file
+ * according to the instructions provided in
* http://www.visitusers.org/index.php?title=Time_and_Cycle_in_VTK_files
- * unless it is at its default value of std::numeric_limits<unsigned int>::min().
+ * unless it is at its default value of
+ * std::numeric_limits<unsigned int>::min().
*/
unsigned int cycle;
+ /**
+ * Flag to determine whether the current date and time shall be
+ * printed as a comment in the file's second line.
+ *
+ * Default is <tt>true</tt>.
+ */
+ bool print_date_and_time;
+
/**
* Default constructor.
*/
- VtkFlags (const double time = std::numeric_limits<double>::min(),
- const unsigned int cycle = std::numeric_limits<unsigned int>::min());
+ VtkFlags (const double time = std::numeric_limits<double>::min(),
+ const unsigned int cycle = std::numeric_limits<unsigned int>::min(),
+ const bool print_date_and_time = true);
/**
- * Declare the flags with name
- * and type as offered by this
- * class, for use in input files.
+ * Declare the flags with name and type as offered by this class,
+ * for use in input files.
*
* Unlike the flags in many of the other classes similar to this one, we do
* not actually declare parameters for the #cycle and #time member variables
static void declare_parameters (ParameterHandler &prm);
/**
- * Read the parameters declared in
- * <tt>declare_parameters</tt> and set the
- * flags for this output format
- * accordingly.
+ * Read the parameters declared in declare_parameters() and
+ * set the flags for this output format accordingly.
*
- * The flags thus obtained overwrite
- * all previous contents of this object.
+ * The flags thus obtained overwrite all previous contents of this
+ * object.
*/
void parse_parameters (const ParameterHandler &prm) const;
/**
- * Determine an estimate for
- * the memory consumption (in
- * bytes) of this
- * object. Since sometimes
- * the size of objects can
- * not be determined exactly
- * (for example: what is the
- * memory consumption of an
- * STL <tt>std::map</tt> type with a
- * certain number of
- * elements?), this is only
- * an estimate. however often
- * quite close to the true
- * value.
+ * Determine an estimate for the memory consumption (in bytes) of
+ * this object. Since sometimes the size of objects can not be
+ * determined exactly (for example: what is the memory consumption
+ * of an STL <tt>std::map</tt> type with a certain number of
+ * elements?), this is only an estimate. however often quite close
+ * to the true value.
*/
std::size_t memory_consumption () const;
};
*/
struct SvgFlags
{
- public:
- /**
- * This denotes the number of the
- * data vector which shall be used
- * for generating the height
- * information. By default, the
- * first data vector is taken,
- * i.e. <tt>height_vector==0</tt>, if
- * there is any data vector. If there
- * is no data vector, no height
- * information is generated.
- */
- unsigned int height_vector;
+ public:
+ /**
+ * Height of the image in SVG
+ * units. Default value is 4000.
+ */
+ unsigned int height;
- /*
- * Angles for the perspective view
- */
- int azimuth_angle, polar_angle;
-
- unsigned int line_thickness;
+ /**
+ * Width of the image in SVG
+ units. If left zero, the width is computed from the height.
+ */
+ unsigned int width;
- /*
- * Draw a margin of 5% around the plotted area
- */
- bool margin;
+ /**
+ * This denotes the number of the data vector which shall be used
+ * for generating the height information. By default, the first
+ * data vector is taken, i.e. <tt>#height_vector==0</tt>, if there
+ * is any data vector. If there is no data vector, no height
+ * information is generated.
+ */
+ unsigned int height_vector;
- /*
- * Draw a colorbar encoding the cell coloring
- */
- bool draw_colorbar;
+ /**
+ * Angles for the perspective view
+ */
+ int azimuth_angle, polar_angle;
- /*
- * Constructor.
- */
- SvgFlags(const unsigned int height_vector = 0,
- const int azimuth_angle = 37,
- const int polar_angle = 45,
- const unsigned int line_thickness = 1,
- const bool margin = true,
- const bool draw_colorbar = true);
+ unsigned int line_thickness;
- /**
- * Determine an estimate for
- * the memory consumption (in
- * bytes) of this
- * object. Since sometimes
- * the size of objects can
- * not be determined exactly
- * (for example: what is the
- * memory consumption of an
- * STL <tt>std::map</tt> type with a
- * certain number of
- * elements?), this is only
- * an estimate. however often
- * quite close to the true
- * value.
- */
- std::size_t memory_consumption () const;
-
- private:
+ /**
+ * Draw a margin of 5% around the plotted area
+ */
+ bool margin;
+
+ /**
+ * Draw a colorbar encoding the cell coloring
+ */
+ bool draw_colorbar;
+
+ /**
+ * Constructor.
+ */
+ SvgFlags(const unsigned int height_vector = 0,
+ const int azimuth_angle = 37,
+ const int polar_angle = 45,
+ const unsigned int line_thickness = 1,
+ const bool margin = true,
+ const bool draw_colorbar = true);
+
+ /**
+ * Determine an estimate for the memory consumption (in bytes) of
+ * this object. Since sometimes the size of objects can not be
+ * determined exactly (for example: what is the memory consumption
+ * of an STL <tt>std::map</tt> type with a certain number of
+ * elements?), this is only an estimate. however often quite close
+ * to the true value.
+ */
+ std::size_t memory_consumption () const;
+
+ private:
};
/**
- * Flags controlling the details
- * of output in deal.II
- * intermediate format. At
- * present no flags are
- * implemented.
+ * Flags controlling the details of output in deal.II intermediate
+ * format. At present no flags are implemented.
*
* @ingroup output
*/
struct Deal_II_IntermediateFlags
{
/**
- * An indicator of the
- * currect file format
- * version used to write
- * intermediate format. We do
- * not attempt to be backward
- * compatible, so this number
- * is used only to verify
- * that the format we are
- * writing is what the
- * current readers and
- * writers understand.
+ * An indicator of the currect file format version used to write
+ * intermediate format. We do not attempt to be backward
+ * compatible, so this number is used only to verify that the
+ * format we are writing is what the current readers and writers
+ * understand.
*/
static const unsigned int format_version = 3;
private:
/**
- * Dummy entry to suppress compiler
- * warnings when copying an empty
- * structure. Remove this member
- * when adding the first flag to
- * this structure (and remove the
- * <tt>private</tt> as well).
+ * Dummy entry to suppress compiler warnings when copying an empty
+ * structure. Remove this member when adding the first flag to
+ * this structure (and remove the <tt>private</tt> as well).
*/
int dummy;
*/
Deal_II_IntermediateFlags ();
+ /**
+ * Declare all flags with name and type as offered by this class,
+ * for use in input files.
+ */
+ static void declare_parameters (ParameterHandler &prm);
+
+ /**
+ * Read the parameters declared in declare_parameters() and
+ * set the flags for this output format accordingly.
+ *
+ * The flags thus obtained overwrite
+ * all previous contents of this object.
+ */
+ void parse_parameters (const ParameterHandler &prm) const;
+
+ /**
+ * Determine an estimate for the memory consumption (in bytes) of
+ * this object. Since sometimes the size of objects can not be
+ * determined exactly (for example: what is the memory consumption
+ * of an STL <tt>std::map</tt> type with a certain number of
+ * elements?), this is only an estimate. however often quite close
+ * to the true value.
+ */
+ std::size_t memory_consumption () const;
+ };
+
+ /**
+ * Flags controlling the DataOutFilter.
+ *
+ * @ingroup output
+ */
+
+ struct DataOutFilterFlags
+ {
+ /**
+ * Filter duplicate vertices and associated values. This will
+ * drastically reduce the output data size but may affect the
+ * correctness of some calculated values.
+ */
+ bool filter_duplicate_vertices;
+
+ /**
+ * Whether the XDMF output refers to HDF5 files.
+ * This affects how output is structured.
+ */
+ bool xdmf_hdf5_output;
+
+ /**
+ * Constructor.
+ */
+ DataOutFilterFlags (const bool filter_duplicate_vertices = false,
+ const bool xdmf_hdf5_output = false);
+
/**
* Declare all flags with name
* and type as offered by this
* The flags thus obtained overwrite
* all previous contents of this object.
*/
- void parse_parameters (const ParameterHandler &prm) const;
+ void parse_parameters (const ParameterHandler &prm);
/**
* Determine an estimate for
* the memory consumption (in
* bytes) of this
- * object. Since sometimes
- * the size of objects can
- * not be determined exactly
- * (for example: what is the
- * memory consumption of an
- * STL <tt>std::map</tt> type with a
- * certain number of
- * elements?), this is only
- * an estimate. however often
- * quite close to the true
- * value.
+ * object.
*/
std::size_t memory_consumption () const;
};
/**
- * Provide a data type specifying
- * the presently supported output
+ * DataOutFilter provides a way to remove redundant vertices and values
+ * generated by the deal.II output. By default, DataOutBase and the classes
+ * that build on it output data at each corner of each cell. This means
+ * that data is output multiple times for each vertex of the mesh. The
+ * purpose of this scheme is to support output of discontinuous quantities,
+ * either because the finite element space is discontinuous or because the
+ * quantity that is output is computed from a solution field and is
+ * discontinuous across faces.
+ *
+ * This class is an attempt to rein in the amount of data that is written.
+ * If the fields that are written to files are indeed discontinuous, the
+ * only way to faithfully represent them is indeed to write multiple
+ * values for each vertex (this is typically done by writing multiple
+ * node locations for the same vertex and defining data at these nodes).
+ * However, for fine meshes, one may not necessarily be interested in an
+ * exact representation of output fields that will likely only have
+ * small discontinuities. Rather, it may be sufficient to just output one
+ * value per vertex, which may be chosen arbitrarily from among those that
+ * are defined at this vertex from any of the adjacent cells.
+ */
+ class DataOutFilter
+ {
+ private:
+ /**
+ * Empty class to provide comparison function for Map3DPoint.
+ */
+ struct Point3Comp
+ {
+ bool operator() (const Point<3> &lhs, const Point<3> &rhs) const
+ {
+ return (lhs(0) < rhs(0) || (!(rhs(0) < lhs(0)) && (lhs(1) < rhs(1) || (!(rhs(1) < lhs(1)) && lhs(2) < rhs(2)))));
+ }
+ };
+
+ typedef std::multimap<Point<3>, unsigned int, Point3Comp> Map3DPoint;
+
+ /// Flags used to specify filtering behavior
+ DataOutBase::DataOutFilterFlags flags;
+
+ /// Dimensionality of the nodes, used to properly output filtered data
+ int node_dim;
+
+ /// Number of vertices per cell
+ int n_cell_verts;
+
+ /// Map of points to an internal index
+ Map3DPoint existing_points;
+
+ /// Map of actual point index to internal point index
+ std::map<unsigned int, unsigned int> filtered_points;
+
+ /// Map of cells to the filtered points
+ std::map<unsigned int, unsigned int> filtered_cells;
+
+ /// Data set names
+ std::vector<std::string> data_set_names;
+
+ /// Data set dimensions
+ std::vector<unsigned int> data_set_dims;
+
+ /// Data set data
+ std::vector<std::vector<double> > data_sets;
+
+ /**
+ * Record a cell vertex index based on the internal reordering.
+ */
+ void internal_add_cell(const unsigned int &cell_index, const unsigned int &pt_index);
+
+ public:
+ DataOutFilter() : flags(false, true) {};
+ DataOutFilter(const DataOutBase::DataOutFilterFlags &flags) : flags(flags) {};
+
+ /**
+ * Write a point with the specified index into the filtered
+ * data set. If the point already exists and we are filtering
+ * redundant values, the provided index will internally refer
+ * to another recorded point.
+ */
+ template<int dim>
+ void write_point(const unsigned int &index, const Point<dim> &p);
+
+ /**
+ * Record a deal.II cell in the internal reordered format.
+ */
+ template<int dim>
+ void write_cell(unsigned int index, unsigned int start, unsigned int d1, unsigned int d2, unsigned int d3);
+
+ /**
+ * Filter and record a data set. If there are multiple values
+ * at a given vertex and redundant values are being removed, one
+ * is arbitrarily chosen as the recorded value. In the future
+ * this can be expanded to average/min/max multiple values
+ * at a given vertex.
+ */
+ void write_data_set(const std::string &name, const unsigned int &dimension, const unsigned int &set_num, const Table<2,double> &data_vectors);
+
+ /**
+ * Resize and fill a vector with all the filtered
+ * node vertex points, for output to a file.
+ */
+ void fill_node_data(std::vector<double> &node_data) const;
+
+ /**
+ * Resize and fill a vector with all the filtered
+ * cell vertex indices, for output to a file.
+ */
+ void fill_cell_data(const unsigned int &local_node_offset, std::vector<unsigned int> &cell_data) const;
+
+ /**
+ * Get the name of the data set indicated by the set number.
+ */
+ std::string get_data_set_name(const unsigned int &set_num) const
+ {
+ return data_set_names.at(set_num);
+ };
+
+ /**
+ * Get the dimensionality of the data set indicated by the set number.
+ */
+ unsigned int get_data_set_dim(const unsigned int &set_num) const
+ {
+ return data_set_dims.at(set_num);
+ };
+
+ /**
+ * Get the raw double valued data of the data set indicated by the set number.
+ */
+ const double *get_data_set(const unsigned int &set_num) const
+ {
+ return &data_sets[set_num][0];
+ };
+
+ /**
+ * Return the number of nodes in this DataOutFilter. This may be smaller
+ * than the original number of nodes if filtering is enabled.
+ */
+ unsigned int n_nodes() const
+ {
+ return existing_points.size();
+ };
+
+ /**
+ * Return the number of filtered cells in this DataOutFilter. Cells are
+ * not filtered so this will be the original number of cells.
+ */
+ unsigned int n_cells() const
+ {
+ return filtered_cells.size()/n_cell_verts;
+ };
+
+ /**
+ * Return the number of filtered data sets in this DataOutFilter. Data sets are
+ * not filtered so this will be the original number of data sets.
+ */
+ unsigned int n_data_sets() const
+ {
+ return data_set_names.size();
+ };
+
+ /**
+ * Empty functions to do base class inheritance.
+ */
+ void flush_points () {};
+
+ /**
+ * Empty functions to do base class inheritance.
+ */
+ void flush_cells () {};
+
+ };
+
+
+ /**
+ * Provide a data type specifying the presently supported output
* formats.
*/
enum OutputFormat
{
/**
- * Use the format already
- * stored in the object.
+ * Use the format already stored in the object.
*/
default_format,
/**
*/
dx,
/**
- * Output in the UCD format
- * for AVS.
+ * Output in the UCD format for AVS.
*/
ucd,
/**
- * Output for the
- * Gnuplot tool.
+ * Output for the Gnuplot tool.
*/
gnuplot,
/**
- * Output for the
- * Povray
- * raytracer.
+ * Output for the Povray raytracer.
*/
povray,
/**
- * Output in encapsulated
- * PostScript.
+ * Output in encapsulated PostScript.
*/
eps,
/**
*/
gmv,
/**
- * Output for
- * Tecplot in text
- * format.
+ * Output for Tecplot in text format.
*/
tecplot,
/**
- * Output for
- * Tecplot in
- * binary format. Faster
- * and smaller than text
- * format.
+ * Output for Tecplot in binary format. Faster and smaller than
+ * text format.
*/
tecplot_binary,
/**
- * Output in
- * VTK format.
+ * Output in VTK format.
*/
vtk,
/**
- * Output in
- * VTK format.
+ * Output in VTK format.
*/
vtu,
/**
- * Output in
- * SVG format.
+ * Output in SVG format.
*/
svg,
/**
- * Output in deal.II
- * intermediate format.
+ * Output in deal.II intermediate format.
*/
deal_II_intermediate,
/**
- * Output in
- * HDF5 format.
+ * Output in HDF5 format.
*/
hdf5
};
/**
- * Write the given list of patches to the output stream in
- * OpenDX format.
+ * Write the given list of patches to the output stream in OpenDX
+ * format.
*
* Since OpenDX uses some kind of visual data flow oriented
* programming language, some of these programs are provided in
* Write the given list of patches to the output stream in eps format.
*
* Output in this format circumvents the use of auxiliary graphic
- * programs converting some output format into a graphics format. This
- * has the advantage that output is easy and fast, and the
- * disadvantage that you have to give a whole bunch of parameters
- * which determine the direction of sight, the mode of colorization,
- * the scaling of the height axis, etc. (Of course, all these
- * parameters have reasonable default values, which you may want to
- * change from time to time.) At present, this format only supports
- * output for two-dimensional data, with values in the third direction
- * taken from a data vector.
+ * programs converting some output format into a graphics
+ * format. This has the advantage that output is easy and fast, and
+ * the disadvantage that you have to give a whole bunch of
+ * parameters which determine the direction of sight, the mode of
+ * colorization, the scaling of the height axis, etc. (Of course,
+ * all these parameters have reasonable default values, which you
+ * may want to change from time to time.) At present, this format
+ * only supports output for two-dimensional data, with values in the
+ * third direction taken from a data vector.
*
* Basically, output consists of the mesh and the cells in between
* them. You can draw either of these, or both, or none if you are
* DataOutInterface::write_vtu_footer() and DataOutInterface::write_vtu_main()
* by DataOutBase::write_vtu().
*/
- static void write_vtu_header (std::ostream &out);
+ static void write_vtu_header (std::ostream &out,
+ const VtkFlags &flags);
/**
* This writes the footer for the xml based vtu file format. This
const std::vector<std_cxx1x::tuple<unsigned int, unsigned int, std::string> > &vector_data_ranges,
const VtkFlags &flags,
std::ostream &out);
-
+
/**
* Write the given list of patches to the output stream in SVG format.
*
- * SVG (Scalable Vector Graphics) is an XML-based vector image format
- * developed and maintained by the World Wide Web Consortium (W3C).
- * This function conforms to the latest specification SVG 1.1,
+ * SVG (Scalable Vector Graphics) is an XML-based vector image format
+ * developed and maintained by the World Wide Web Consortium (W3C).
+ * This function conforms to the latest specification SVG 1.1,
* released on August 16, 2011. Controlling the graphic output is
- * possible by setting or clearing the respective flags (see the
- * SvgFlags struct). At present, this format only supports output
+ * possible by setting or clearing the respective flags (see the
+ * SvgFlags struct). At present, this format only supports output
* for two-dimensional data, with values in the third direction
* taken from a data vector.
- *
- * For the output, each patch is subdivided into four triangles
- * which are then written as polygons and filled with a linear
- * color gradient. The arising coloring of the patches visualizes
- * the data values at the vertices taken from the specified data
+ *
+ * For the output, each patch is subdivided into four triangles
+ * which are then written as polygons and filled with a linear
+ * color gradient. The arising coloring of the patches visualizes
+ * the data values at the vertices taken from the specified data
* vector. A colorbar can be drawn to encode the coloring.
*
* @note Yet only implemented for two dimensions with an additional
const std::vector<std_cxx1x::tuple<unsigned int, unsigned int, std::string> > &vector_data_ranges,
const SvgFlags &flags,
std::ostream &out);
-
+
/**
* Write the given list of patches to the output stream in deal.II
* intermediate format. This is not a format understood by any other
const Deal_II_IntermediateFlags &flags,
std::ostream &out);
+ /**
+ * Write the data in data_filter to a single HDF5 file containing both
+ * the mesh and solution values.
+ */
template <int dim, int spacedim>
- static void write_hdf5_parallel (
- const std::vector<Patch<dim,spacedim> > &patches,
- const std::vector<std::string> &data_names,
- const std::vector<std_cxx1x::tuple<unsigned int, unsigned int, std::string> > &vector_data_ranges,
- const char *filename,
- MPI_Comm comm);
+ static void write_hdf5_parallel (const std::vector<Patch<dim,spacedim> > &patches,
+ const DataOutFilter &data_filter,
+ const std::string &filename,
+ MPI_Comm comm);
+ /**
+ * Write the data in data_filter to HDF5 file(s). If write_mesh_file
+ * is false, the mesh data will not be written and the solution
+ * file will contain only the solution values. If write_mesh_file
+ * is true and the filenames are the same, the resulting file will
+ * contain both mesh data and solution values.
+ */
template <int dim, int spacedim>
- static XDMFEntry create_xdmf_entry (const std::vector<Patch<dim,spacedim> > &patches,
- const std::vector<std::string> &data_names,
- const std::vector<std_cxx1x::tuple<unsigned int, unsigned int, std::string> > &vector_data_ranges,
- const char *h5_filename,
- const double cur_time,
- MPI_Comm comm);
+ static void write_hdf5_parallel (const std::vector<Patch<dim,spacedim> > &patches,
+ const DataOutFilter &data_filter,
+ const bool write_mesh_file,
+ const std::string &mesh_filename,
+ const std::string &solution_filename,
+ MPI_Comm comm);
+ /**
+ * DataOutFilter is an intermediate data format that reduces the amount of
+ * data that will be written to files. The object filled by this function
+ * can then later be used again to write data in a concrete file format;
+ * see, for example, DataOutBase::write_hdf5_parallel().
+ */
template <int dim, int spacedim>
- static void write_xdmf_file (
- const std::vector<Patch<dim,spacedim> > &patches,
- const std::vector<XDMFEntry> &entries,
- const char *filename,
- MPI_Comm comm);
-
- /**
- * Given an input stream that contains
- * data written by
- * write_deal_II_intermediate, determine
- * the <tt>dim</tt> and <tt>spacedim</tt>
- * template parameters with which that
- * function was called, and return them
- * as a pair of values.
- *
- * Note that this function eats a number
- * of elements at the present position of
- * the stream, and therefore alters
- * it. In order to read from it using,
- * for example, the DataOutReader class,
- * you may wish to either reset the
- * stream to its previous position, or
- * close and reopen it.
+ static void write_filtered_data (const std::vector<Patch<dim,spacedim> > &patches,
+ const std::vector<std::string> &data_names,
+ const std::vector<std_cxx1x::tuple<unsigned int, unsigned int, std::string> > &vector_data_ranges,
+ DataOutFilter &filtered_data);
+
+ /**
+ * Given an input stream that contains data written by
+ * write_deal_II_intermediate(), determine the <tt>dim</tt> and
+ * <tt>spacedim</tt> template parameters with which that function
+ * was called, and return them as a pair of values.
+ *
+ * Note that this function eats a number of elements at the present
+ * position of the stream, and therefore alters it. In order to read
+ * from it using, for example, the DataOutReader class, you may wish
+ * to either reset the stream to its previous position, or close and
+ * reopen it.
*/
static
std::pair<unsigned int, unsigned int>
determine_intermediate_format_dimensions (std::istream &input);
/**
- * Return the <tt>OutputFormat</tt>
- * value corresponding to the
- * given string. If the string
- * does not match any known
- * format, an exception is
- * thrown.
- *
- * Since this function does not
- * need data from this object, it
- * is static and can thus be
- * called without creating an
- * object of this class. Its main
- * purpose is to allow a program
- * to use any implemented output
- * format without the need to
- * extend the program's parser
- * each time a new format is
- * implemented.
- *
- * To get a list of presently
- * available format names,
- * e.g. to give it to the
- * ParameterHandler class,
- * use the function
+ * Return the OutputFormat value corresponding to the given
+ * string. If the string does not match any known format, an
+ * exception is thrown.
+ *
+ * Since this function does not need data from this object, it is
+ * static and can thus be called without creating an object of this
+ * class. Its main purpose is to allow a program to use any
+ * implemented output format without the need to extend the
+ * program's parser each time a new format is implemented.
+ *
+ * To get a list of presently available format names, e.g. to give
+ * it to the ParameterHandler class, use the function
* get_output_format_names().
*/
static OutputFormat parse_output_format (const std::string &format_name);
/**
- * Return a list of implemented
- * output formats. The different
- * names are separated by
- * vertical bar signs (<tt>`|'</tt>)
- * as used by the
+ * Return a list of implemented output formats. The different names
+ * are separated by vertical bar signs (<tt>`|'</tt>) as used by the
* ParameterHandler classes.
*/
static std::string get_output_format_names ();
/**
- * Provide a function which tells us which
- * suffix a file with a given output format
- * usually has. At present the following
- * formats are defined:
+ * Provide a function which tells us which suffix a file with a
+ * given output format usually has. At present the following formats
+ * are defined:
* <ul>
* <li> <tt>dx</tt>: <tt>.dx</tt>
* <li> <tt>ucd</tt>: <tt>.inp</tt>
static std::string default_suffix (const OutputFormat output_format);
/**
- * Determine an estimate for
- * the memory consumption (in
- * bytes) of this
- * object. Since sometimes
- * the size of objects can
- * not be determined exactly
- * (for example: what is the
- * memory consumption of an
- * STL <tt>std::map</tt> type with a
- * certain number of
- * elements?), this is only
- * an estimate. however often
- * quite close to the true
- * value.
+ * Determine an estimate for the memory consumption (in bytes) of
+ * this object. Since sometimes the size of objects can not be
+ * determined exactly (for example: what is the memory consumption
+ * of an STL <tt>std::map</tt> type with a certain number of
+ * elements?), this is only an estimate. however often quite close
+ * to the true value.
*/
static std::size_t memory_consumption ();
<< "The number of points in this data set is " << arg1
<< ", but we expected " << arg2 << " in each space direction.");
/**
- * An output function did not
- * receive any patches for
- * writing.
+ * An output function did not receive any patches for writing.
*/
DeclException0 (ExcNoPatches);
/**
//@}
private:
/**
- * Write the coordinates of nodes
- * in the desired format.
+ * Write the coordinates of nodes in the desired format.
*/
template <int dim, int spacedim, typename STREAM>
static void write_nodes (const std::vector<Patch<dim,spacedim> > &patches,
STREAM &out);
/**
- * Write the node numbers of a
- * cell in the desired format.
+ * Write the node numbers of a cell in the desired format.
*/
template <int dim, int spacedim, typename STREAM>
static void write_cells (const std::vector<Patch<dim,spacedim> > &patches,
STREAM &out);
/**
- * Write data in the desired
- * format.
+ * Write data in the desired format.
*/
template <int dim, int spacedim, class STREAM>
static void write_data (const std::vector<Patch<dim,spacedim> > &patches,
/**
- * This function projects a three-dimensional point (Point<3> point)
- * onto a two-dimensional image plane, specified by the position of
- * the camera viewing system (Point<3> camera_position), camera
- * direction (Point<3> camera_position), camera horizontal (Point<3>
- * camera_horizontal, necessary for the correct alignment of the
+ * This function projects a three-dimensional point (Point<3> point)
+ * onto a two-dimensional image plane, specified by the position of
+ * the camera viewing system (Point<3> camera_position), camera
+ * direction (Point<3> camera_position), camera horizontal (Point<3>
+ * camera_horizontal, necessary for the correct alignment of the
* later images), and the focus of the camera (float camera_focus).
*
* For SVG output.
*/
- static Point<2> svg_project_point(Point<3> point,
- Point<3> camera_position,
- Point<3> camera_direction,
- Point<3> camera_horizontal,
+ static Point<2> svg_project_point(Point<3> point,
+ Point<3> camera_position,
+ Point<3> camera_direction,
+ Point<3> camera_horizontal,
float camera_focus);
/**
- * Function to compute the gradient parameters for
- * a triangle with given values for the vertices.
+ * Function to compute the gradient parameters for a triangle with
+ * given values for the vertices.
*
* Used for svg output.
*/
/**
* Class holding the data of one cell of a patch in two space
* dimensions for output. It is the projection of a cell in
- * three-dimensional space (two coordinates, one height value)
- * to the direction of sight.
+ * three-dimensional space (two coordinates, one height value) to
+ * the direction of sight.
*/
class SvgCell
{
Point<3> vertices[4];
/**
- * Depth into the picture, which
- * is defined as the distance from
- * an observer at an the origin in
- * direction of the line of sight.
+ * Depth into the picture, which is defined as the distance from
+ * an observer at an the origin in direction of the line of sight.
*/
float depth;
Point<2> projected_center;
/**
- * Comparison operator for
- * sorting.
+ * Comparison operator for sorting.
*/
bool operator < (const SvgCell &) const;
};
/**
- * Class holding the data of one
- * cell of a patch in two space
- * dimensions for output. It is
- * the projection of a cell in
- * three-dimensional space (two
- * coordinates, one height value)
- * to the direction of sight.
+ * Class holding the data of one cell of a patch in two space
+ * dimensions for output. It is the projection of a cell in
+ * three-dimensional space (two coordinates, one height value) to
+ * the direction of sight.
*/
class EpsCell2d
{
Point<2> vertices[4];
/**
- * Data value from which the actual
- * colors will be computed by
- * the colorization function stated
- * in the <tt>EpsFlags</tt> class.
+ * Data value from which the actual colors will be computed by the
+ * colorization function stated in the <tt>EpsFlags</tt> class.
*/
float color_value;
/**
- * Depth into the picture, which
- * is defined as the distance from
- * an observer at an the origin in
- * direction of the line of sight.
+ * Depth into the picture, which is defined as the distance from
+ * an observer at an the origin in direction of the line of sight.
*/
float depth;
/**
- * Comparison operator for
- * sorting.
+ * Comparison operator for sorting.
*/
bool operator < (const EpsCell2d &) const;
};
/**
- * This is a helper function for
- * the <tt>write_gmv</tt>
- * function. There, the data in
- * the patches needs to be copied
- * around as output is one
- * variable globally at a time,
- * rather than all data on each
- * vertex at a time. This copying
- * around can be done detached
- * from the main thread, and is
- * thus moved into this separate
- * function.
+ * This is a helper function for the write_gmv() function. There,
+ * the data in the patches needs to be copied around as output is
+ * one variable globally at a time, rather than all data on each
+ * vertex at a time. This copying around can be done detached from
+ * the main thread, and is thus moved into this separate function.
*
- * Note that because of the
- * similarity of the formats,
- * this function is also used by
- * the Vtk and Tecplot output
- * functions.
+ * Note that because of the similarity of the formats, this function
+ * is also used by the Vtk and Tecplot output functions.
*/
template <int dim, int spacedim>
static void
*
* This class is thought as a base class to classes actually
* generating data for output. It has two abstract virtual functions,
- * <tt>get_patches</tt> and <tt>get_dataset_names</tt> which are to produce the data
- * which is actually needed. These are the only functions that need to
- * be overloaded by a derived class. In additional to that, it has a
+ * get_patches() and get_dataset_names() produce the data which is
+ * actually needed. These are the only functions that need to be
+ * overloaded by a derived class. In additional to that, it has a
* function for each output format supported by the underlying base
* class which gets the output data using these two virtual functions
* and passes them to the raw output functions.
* @endcode
*
* @note See DataOutBase::write_vtu or
- * DataOutInterface::write_pvtu_record for
- * writing solutions at each timestep.
+ * DataOutInterface::write_pvtu_record for writing solutions at each
+ * timestep.
*
* @note The second element of each pair, i.e., the file in which
* the graphical data for each time is stored, may itself be again
const std::vector<std::pair<double,std::string> > ×_and_names) const;
/**
- * This function is the exact
- * equivalent of the
- * write_pvtu_record() function
- * but for the VisIt
- * visualization program. See
- * there for the purpose of this
- * function.
+ * This function is the exact equivalent of the write_pvtu_record()
+ * function but for the VisIt visualization program and for one visualization graph
+ * (or one time step only). See there for the purpose of this function.
*
- * This function is documented
- * in the "Creating a master file
- * for parallel" section (section 5.7)
- * of the "Getting data into VisIt"
+ * This function is documented in the "Creating a master file for
+ * parallel" section (section 5.7) of the "Getting data into VisIt"
* report that can be found here:
* https://wci.llnl.gov/codes/visit/2.0.0/GettingDataIntoVisIt2.0.0.pdf
*/
const std::vector<std::string> &piece_names) const;
/**
- * Obtain data through get_patches()
- * and write it to <tt>out</tt>
- * in SVG format. See
- * DataOutBase::write_svg.
+ * This function is equivalent to the write_visit_record() above but for multiple
+ * time steps. Here is an example of how the function would be used:
+ * @code
+ * DataOut<dim> data_out;
+ *
+ * const unsigned int number_of_time_steps = 3;
+ * std::vector<std::vector<std::string > > piece_names(number_of_time_steps);
+ *
+ * piece_names[0].push_back("subdomain_01.time_step_0.vtk");
+ * piece_names[0].push_back("subdomain_02.time_step_0.vtk");
+ *
+ * piece_names[1].push_back("subdomain_01.time_step_1.vtk");
+ * piece_names[1].push_back("subdomain_02.time_step_1.vtk");
+ *
+ * piece_names[2].push_back("subdomain_01.time_step_2.vtk");
+ * piece_names[2].push_back("subdomain_02.time_step_2.vtk");
+ *
+ * std::ofstream visit_output ("master_file.visit");
+ *
+ * data_out.write_visit_record(visit_output, piece_names);
+ * @endcode
+ *
+ * This function is documented in the "Creating a master file for
+ * parallel" section (section 5.7) of the "Getting data into VisIt"
+ * report that can be found here:
+ * https://wci.llnl.gov/codes/visit/2.0.0/GettingDataIntoVisIt2.0.0.pdf
*/
- void write_svg(std::ostream &out) const;
+ void write_visit_record (std::ostream &out,
+ const std::vector<std::vector<std::string> > &piece_names) const;
/**
- * Obtain data through get_patches()
- * and write it to <tt>out</tt>
- * in deal.II intermediate
- * format. See
+ * Obtain data through get_patches() and write it to <tt>out</tt> in
+ * SVG format. See DataOutBase::write_svg.
+ */
+ void write_svg(std::ostream &out) const;
+
+ /**
+ * Obtain data through get_patches() and write it to <tt>out</tt> in
+ * deal.II intermediate format. See
* DataOutBase::write_deal_II_intermediate.
*
- * Note that the intermediate
- * format is what its name
- * suggests: a direct
- * representation of internal
- * data. It isn't standardized
- * and will change whenever we
- * change our internal
- * representation. You can only
- * expect to process files
- * written in this format using
- * the same version of deal.II
- * that was used for writing.
+ * Note that the intermediate format is what its name suggests: a
+ * direct representation of internal data. It isn't standardized and
+ * will change whenever we change our internal representation. You
+ * can only expect to process files written in this format using the
+ * same version of deal.II that was used for writing.
*/
void write_deal_II_intermediate (std::ostream &out) const;
- XDMFEntry create_xdmf_entry (const char *h5_filename,
+ /**
+ * Create an XDMFEntry based on the data in this DataOutInterface.
+ @deprecated: use create_xdmf_entry(DataOutFilter, ...) instead
+ */
+ XDMFEntry create_xdmf_entry (const std::string &h5_filename,
+ const double cur_time,
+ MPI_Comm comm) const DEAL_II_DEPRECATED;
+
+ /**
+ * Create an XDMFEntry based on the data in the data_filter. This assumes
+ * the mesh and solution data were written to a single file. See
+ * write_xdmf_file() for an example of usage.
+ */
+ XDMFEntry create_xdmf_entry (const DataOutFilter &data_filter,
+ const std::string &h5_filename,
+ const double cur_time,
+ MPI_Comm comm) const;
+
+ /**
+ * Create an XDMFEntry based on the data in the data_filter. This assumes
+ * the mesh and solution data were written to separate files. See
+ * write_xdmf_file() for an example of usage.
+ */
+ XDMFEntry create_xdmf_entry (const DataOutFilter &data_filter,
+ const std::string &h5_mesh_filename,
+ const std::string &h5_solution_filename,
const double cur_time,
MPI_Comm comm) const;
+ /**
+ * Write an XDMF file based on the provided vector of XDMFEntry objects. Below is
+ * an example of how to use this function with HDF5 and the DataOutFilter:
+ *
+ * @code
+ * DataOutBase::DataOutFilter data_filter(DataOutBase::DataOutFilterFlags(true, true));
+ * std::vector<XDMFEntry> xdmf_entries;
+ * // Filter the data and store it in data_filter
+ * data_out.write_filtered_data(data_filter);
+ * // Write the filtered data to HDF5
+ * data_out.write_hdf5_parallel(data_filter, "solution.h5", MPI_COMM_WORLD);
+ * // Create an XDMF entry detailing the HDF5 file
+ * new_xdmf_entry = data_out.create_xdmf_entry(data_filter, "solution.h5", simulation_time, MPI_COMM_WORLD);
+ * // Add the XDMF entry to the list
+ * xdmf_entries.push_back(new_xdmf_entry);
+ * // Create an XDMF file from all stored entries
+ * data_out.write_xdmf_file(xdmf_entries, "solution.xdmf", MPI_COMM_WORLD);
+ * @endcode
+ */
void write_xdmf_file (const std::vector<XDMFEntry> &entries,
- const char *filename,
+ const std::string &filename,
MPI_Comm comm) const;
- void write_hdf5_parallel (const char *filename, MPI_Comm comm) const;
+ /**
+ * Write the data in this class without redundancy filtering to a
+ * single HDF5 file containing both the mesh and solution values.
+ @deprecated: use write_hdf5_parallel(DataOutFilter, ...) instead
+ */
+ void write_hdf5_parallel (const std::string &filename, MPI_Comm comm) const DEAL_II_DEPRECATED;
+
+ /**
+ * Write the data in data_filter to a single HDF5 file containing both
+ * the mesh and solution values. Below is an example of how to use this
+ * function with the DataOutFilter:
+ *
+ * @code
+ * DataOutBase::DataOutFilter data_filter(DataOutBase::DataOutFilterFlags(true, true));
+ * // Filter the data and store it in data_filter
+ * data_out.write_filtered_data(data_filter);
+ * // Write the filtered data to HDF5
+ * data_out.write_hdf5_parallel(data_filter, "solution.h5", MPI_COMM_WORLD);
+ * @endcode
+ */
+ void write_hdf5_parallel (const DataOutFilter &data_filter, const std::string &filename, MPI_Comm comm) const;
+
+ /**
+ * Write the data in data_filter to HDF5 file(s). If write_mesh_file
+ * is false, the mesh data will not be written and the solution
+ * file will contain only the solution values. If write_mesh_file
+ * is true and the filenames are the same, the resulting file will
+ * contain both mesh data and solution values.
+ */
+ void write_hdf5_parallel (const DataOutFilter &data_filter, const bool write_mesh_file, const std::string &mesh_filename, const std::string &solution_filename, MPI_Comm comm) const;
+
+ /**
+ * DataOutFilter is an intermediate data format that reduces the amount of
+ * data that will be written to files. The object filled by this function
+ * can then later be used again to write data in a concrete file format;
+ * see, for example, DataOutBase::write_hdf5_parallel().
+ */
+ void write_filtered_data (DataOutFilter &filtered_data) const;
+
+
/**
* Write data and grid to <tt>out</tt>
* according to the given data
const OutputFormat output_format = default_format) const;
/**
- * Set the default format. The
- * value set here is used
- * anytime, output for format
- * <tt>default_format</tt> is
- * requested.
+ * Set the default format. The value set here is used anytime,
+ * output for format <tt>default_format</tt> is requested.
*/
void set_default_format (const OutputFormat default_format);
/**
- * Set the flags to be used for
- * output in OpenDX format.
+ * Set the flags to be used for output in OpenDX format.
*/
void set_flags (const DXFlags &dx_flags);
/**
- * Set the flags to be used for
- * output in UCD format.
+ * Set the flags to be used for output in UCD format.
*/
void set_flags (const UcdFlags &ucd_flags);
/**
- * Set the flags to be used for
- * output in GNUPLOT format.
+ * Set the flags to be used for output in GNUPLOT format.
*/
void set_flags (const GnuplotFlags &gnuplot_flags);
/**
- * Set the flags to be used for
- * output in POVRAY format.
+ * Set the flags to be used for output in POVRAY format.
*/
void set_flags (const PovrayFlags &povray_flags);
/**
- * Set the flags to be used for
- * output in EPS output.
+ * Set the flags to be used for output in EPS output.
*/
void set_flags (const EpsFlags &eps_flags);
/**
- * Set the flags to be used for
- * output in GMV format.
+ * Set the flags to be used for output in GMV format.
*/
void set_flags (const GmvFlags &gmv_flags);
/**
- * Set the flags to be used for
- * output in Tecplot format.
+ * Set the flags to be used for output in Tecplot format.
*/
void set_flags (const TecplotFlags &tecplot_flags);
/**
- * Set the flags to be used for
- * output in VTK format.
+ * Set the flags to be used for output in VTK format.
*/
void set_flags (const VtkFlags &vtk_flags);
/**
- * Set the flags to be used for
- * output in SVG format.
+ * Set the flags to be used for output in SVG format.
*/
void set_flags (const SvgFlags &svg_flags);
/**
- * Set the flags to be used for output in
- * deal.II intermediate format.
+ * Set the flags to be used for output in deal.II intermediate
+ * format.
*/
void set_flags (const Deal_II_IntermediateFlags &deal_II_intermediate_flags);
/**
- * A function that returns the same
- * string as the respective function in
- * the base class does; the only
- * exception being that if the parameter
- * is omitted, then the value for the
- * present default format is returned,
- * i.e. the correct suffix for the format
- * that was set through
- * set_default_format() or
- * parse_parameters() before calling this
- * function.
+ * A function that returns the same string as the respective
+ * function in the base class does; the only exception being that if
+ * the parameter is omitted, then the value for the present default
+ * format is returned, i.e. the correct suffix for the format that
+ * was set through set_default_format() or parse_parameters() before
+ * calling this function.
*/
std::string
default_suffix (const OutputFormat output_format = default_format) const;
/**
- * Declare parameters for all
- * output formats by declaring
- * subsections within the
- * parameter file for each output
- * format and call the respective
- * <tt>declare_parameters</tt>
- * functions of the flag classes
- * for each output format.
- *
- * Some of the declared
- * subsections may not contain
- * entries, if the respective
- * format does not export any
- * flags.
- *
- * Note that the top-level
- * parameters denoting the number
- * of subdivisions per patch and
- * the output format are not
- * declared, since they are only
- * passed to virtual functions
- * and are not stored inside
- * objects of this type. You have
- * to declare them yourself.
+ * Declare parameters for all output formats by declaring
+ * subsections within the parameter file for each output format and
+ * call the respective <tt>declare_parameters</tt> functions of the
+ * flag classes for each output format.
+ *
+ * Some of the declared subsections may not contain entries, if the
+ * respective format does not export any flags.
+ *
+ * Note that the top-level parameters denoting the number of
+ * subdivisions per patch and the output format are not declared,
+ * since they are only passed to virtual functions and are not
+ * stored inside objects of this type. You have to declare them
+ * yourself.
*/
static void declare_parameters (ParameterHandler &prm);
/**
- * Read the parameters declared
- * in <tt>declare_parameters</tt> and
- * set the flags for the output
- * formats accordingly.
+ * Read the parameters declared in declare_parameters() and
+ * set the flags for the output formats accordingly.
*
- * The flags thus obtained
- * overwrite all previous
- * contents of the flag objects
- * as default-constructed or set
- * by the set_flags() function.
+ * The flags thus obtained overwrite all previous contents of the
+ * flag objects as default-constructed or set by the set_flags()
+ * function.
*/
void parse_parameters (ParameterHandler &prm);
/**
- * Determine an estimate for
- * the memory consumption (in
- * bytes) of this
- * object. Since sometimes
- * the size of objects can
- * not be determined exactly
- * (for example: what is the
- * memory consumption of an
- * STL <tt>std::map</tt> type with a
- * certain number of
- * elements?), this is only
- * an estimate. however often
- * quite close to the true
- * value.
+ * Determine an estimate for the memory consumption (in bytes) of
+ * this object. Since sometimes the size of objects can not be
+ * determined exactly (for example: what is the memory consumption
+ * of an STL <tt>std::map</tt> type with a certain number of
+ * elements?), this is only an estimate. however often quite close
+ * to the true value.
*/
std::size_t memory_consumption () const;
protected:
/**
- * This is the abstract function
- * through which derived classes
- * propagate preprocessed data in
- * the form of Patch
- * structures (declared in the
- * base class DataOutBase) to
- * the actual output
- * function. You need to overload
- * this function to allow the
- * output functions to know what
- * they shall print.
+ * This is the abstract function through which derived classes
+ * propagate preprocessed data in the form of Patch structures
+ * (declared in the base class DataOutBase) to the actual output
+ * function. You need to overload this function to allow the output
+ * functions to know what they shall print.
*/
virtual
const std::vector<typename DataOutBase::Patch<dim,spacedim> > &
get_patches () const = 0;
/**
- * Abstract virtual function
- * through which the names of
- * data sets are obtained by the
- * output functions of the base
- * class.
+ * Abstract virtual function through which the names of data sets
+ * are obtained by the output functions of the base class.
*/
virtual
std::vector<std::string>
get_dataset_names () const = 0;
/**
- * This functions returns
- * information about how the
- * individual components of
- * output files that consist of
- * more than one data set are to
- * be interpreted.
- *
- * It returns a list of index
- * pairs and corresponding name
- * indicating which components of
- * the output are to be
- * considered vector-valued
- * rather than just a collection
- * of scalar data. The index
- * pairs are inclusive; for
- * example, if we have a Stokes
- * problem in 2d with components
- * (u,v,p), then the
- * corresponding vector data
- * range should be (0,1), and the
- * returned list would consist of
- * only a single element with a
- * tuple such as (0,1,"velocity").
- *
- * Since some of the derived
- * classes do not know about
- * vector data, this function has
- * a default implementation that
- * simply returns an empty
- * string, meaning that all data
- * is to be considered a
+ * This functions returns information about how the individual
+ * components of output files that consist of more than one data set
+ * are to be interpreted.
+ *
+ * It returns a list of index pairs and corresponding name
+ * indicating which components of the output are to be considered
+ * vector-valued rather than just a collection of scalar data. The
+ * index pairs are inclusive; for example, if we have a Stokes
+ * problem in 2d with components (u,v,p), then the corresponding
+ * vector data range should be (0,1), and the returned list would
+ * consist of only a single element with a tuple such as
+ * (0,1,"velocity").
+ *
+ * Since some of the derived classes do not know about vector data,
+ * this function has a default implementation that simply returns an
+ * empty string, meaning that all data is to be considered a
* collection of scalar fields.
*/
virtual
get_vector_data_ranges () const;
/**
- * The default number of
- * subdivisions for patches. This
- * is filled by parse_parameters()
- * and should be obeyed by
- * build_patches() in derived
- * classes.
+ * The default number of subdivisions for patches. This is filled by
+ * parse_parameters() and should be obeyed by build_patches() in
+ * derived classes.
*/
unsigned int default_subdivisions;
private:
/**
- * Standard output format. Use
- * this format, if output format
- * default_format is
- * requested. It can be changed
- * by the <tt>set_format</tt> function
- * or in a parameter file.
+ * Standard output format. Use this format, if output format
+ * default_format is requested. It can be changed by the
+ * <tt>set_format</tt> function or in a parameter file.
*/
OutputFormat default_fmt;
/**
- * Flags to be used upon output
- * of OpenDX data. Can be changed by
- * using the <tt>set_flags</tt>
- * function.
+ * Flags to be used upon output of OpenDX data. Can be changed by
+ * using the <tt>set_flags</tt> function.
*/
DXFlags dx_flags;
/**
- * Flags to be used upon output
- * of UCD data. Can be changed by
- * using the <tt>set_flags</tt>
- * function.
+ * Flags to be used upon output of UCD data. Can be changed by using
+ * the <tt>set_flags</tt> function.
*/
UcdFlags ucd_flags;
/**
- * Flags to be used upon output
- * of GNUPLOT data. Can be
- * changed by using the
- * <tt>set_flags</tt> function.
+ * Flags to be used upon output of GNUPLOT data. Can be changed by
+ * using the <tt>set_flags</tt> function.
*/
GnuplotFlags gnuplot_flags;
/**
- * Flags to be used upon output
- * of POVRAY data. Can be changed
- * by using the <tt>set_flags</tt>
- * function.
+ * Flags to be used upon output of POVRAY data. Can be changed by
+ * using the <tt>set_flags</tt> function.
*/
PovrayFlags povray_flags;
/**
- * Flags to be used upon output
- * of EPS data in one space
- * dimension. Can be changed by
- * using the <tt>set_flags</tt>
+ * Flags to be used upon output of EPS data in one space
+ * dimension. Can be changed by using the <tt>set_flags</tt>
* function.
*/
EpsFlags eps_flags;
/**
- * Flags to be used upon output
- * of gmv data in one space
- * dimension. Can be changed by
- * using the <tt>set_flags</tt>
+ * Flags to be used upon output of gmv data in one space
+ * dimension. Can be changed by using the <tt>set_flags</tt>
* function.
*/
GmvFlags gmv_flags;
/**
- * Flags to be used upon output
- * of Tecplot data in one space
- * dimension. Can be changed by
- * using the <tt>set_flags</tt>
+ * Flags to be used upon output of Tecplot data in one space
+ * dimension. Can be changed by using the <tt>set_flags</tt>
* function.
*/
TecplotFlags tecplot_flags;
/**
- * Flags to be used upon output
- * of vtk data in one space
- * dimension. Can be changed by
- * using the <tt>set_flags</tt>
+ * Flags to be used upon output of vtk data in one space
+ * dimension. Can be changed by using the <tt>set_flags</tt>
* function.
*/
VtkFlags vtk_flags;
/**
- * Flags to be used upon output
- * of svg data in one space
- * dimension. Can be changed by
- * using the <tt>set_flags</tt>
+ * Flags to be used upon output of svg data in one space
+ * dimension. Can be changed by using the <tt>set_flags</tt>
* function.
*/
SvgFlags svg_flags;
/**
- * Flags to be used upon output of
- * deal.II intermediate data in one space
- * dimension. Can be changed by using the
- * <tt>set_flags</tt> function.
+ * Flags to be used upon output of deal.II intermediate data in one
+ * space dimension. Can be changed by using the <tt>set_flags</tt>
+ * function.
*/
Deal_II_IntermediateFlags deal_II_intermediate_flags;
};
{
public:
/**
- * Read a sequence of patches as
- * written previously by
- * <tt>DataOutBase::write_deal_II_intermediate</tt>
- * and store them in the present
- * object. This overwrites any
- * previous content.
+ * Read a sequence of patches as written previously by
+ * <tt>DataOutBase::write_deal_II_intermediate</tt> and store them
+ * in the present object. This overwrites any previous content.
*/
void read (std::istream &in);
/**
- * This function can be used to
- * merge the patches read by the
- * other object into the patches
- * that this present object
- * stores. This is sometimes
- * handy if one has, for example,
- * a domain decomposition
- * algorithm where each block is
- * represented by a DoFHandler of
- * its own, but one wants to
- * output the solution on all the
- * blocks at the same
- * time. Alternatively, it may
- * also be used for parallel
- * programs, where each process
- * only generates output for its
- * share of the cells, even if
- * all processes can see all
- * cells.
- *
- * For this to work, the input
- * files for the present object
- * and the given argument need to
- * have the same number of output
- * vectors, and they need to use
- * the same number of
- * subdivisions per patch. The
- * output will probably look
- * rather funny if patches in
+ * This function can be used to merge the patches read by the other
+ * object into the patches that this present object stores. This is
+ * sometimes handy if one has, for example, a domain decomposition
+ * algorithm where each block is represented by a DoFHandler of its
+ * own, but one wants to output the solution on all the blocks at
+ * the same time. Alternatively, it may also be used for parallel
+ * programs, where each process only generates output for its share
+ * of the cells, even if all processes can see all cells.
+ *
+ * For this to work, the input files for the present object and the
+ * given argument need to have the same number of output vectors,
+ * and they need to use the same number of subdivisions per
+ * patch. The output will probably look rather funny if patches in
* both objects overlap in space.
*
- * If you call read() for this
- * object after merging in
- * patches, the previous state is
- * overwritten, and the merged-in
- * patches are lost.
+ * If you call read() for this object after merging in patches, the
+ * previous state is overwritten, and the merged-in patches are
+ * lost.
*
- * This function will fail if
- * either this or the other
- * object did not yet set up any
- * patches.
+ * This function will fail if either this or the other object did
+ * not yet set up any patches.
*
- * The use of this function is
- * demonstrated in step-19.
+ * The use of this function is demonstrated in step-19.
*/
void merge (const DataOutReader<dim,spacedim> &other);
protected:
/**
- * This is the function
- * through which this class
- * propagates preprocessed data in
- * the form of Patch
- * structures (declared in the
- * base class DataOutBase) to
- * the actual output
- * function.
+ * This is the function through which this class propagates
+ * preprocessed data in the form of Patch structures (declared in
+ * the base class DataOutBase) to the actual output function.
*
- * It returns the patches as read
- * the last time a stream was
- * given to the read() function.
+ * It returns the patches as read the last time a stream was given
+ * to the read() function.
*/
virtual const std::vector<typename dealii::DataOutBase::Patch<dim,spacedim> > &
get_patches () const;
/**
- * Abstract virtual function
- * through which the names of
- * data sets are obtained by the
- * output functions of the base
- * class.
+ * Abstract virtual function through which the names of data sets
+ * are obtained by the output functions of the base class.
*
- * Return the names of the
- * variables as read the last
- * time we read a file.
+ * Return the names of the variables as read the last time we read a
+ * file.
*/
virtual std::vector<std::string> get_dataset_names () const;
/**
- * This functions returns
- * information about how the
- * individual components of
- * output files that consist of
- * more than one data set are to
- * be interpreted.
- *
- * It returns a list of index
- * pairs and corresponding name
- * indicating which components of
- * the output are to be
- * considered vector-valued
- * rather than just a collection
- * of scalar data. The index
- * pairs are inclusive; for
- * example, if we have a Stokes
- * problem in 2d with components
- * (u,v,p), then the
- * corresponding vector data
- * range should be (0,1), and the
- * returned list would consist of
- * only a single element with a
- * tuple such as (0,1,"velocity").
- *
- * Since some of the derived
- * classes do not know about
- * vector data, this function has
- * a default implementation that
- * simply returns an empty
- * string, meaning that all data
- * is to be considered a
+ * This functions returns information about how the individual
+ * components of output files that consist of more than one data set
+ * are to be interpreted.
+ *
+ * It returns a list of index pairs and corresponding name
+ * indicating which components of the output are to be considered
+ * vector-valued rather than just a collection of scalar data. The
+ * index pairs are inclusive; for example, if we have a Stokes
+ * problem in 2d with components (u,v,p), then the corresponding
+ * vector data range should be (0,1), and the returned list would
+ * consist of only a single element with a tuple such as
+ * (0,1,"velocity").
+ *
+ * Since some of the derived classes do not know about vector data,
+ * this function has a default implementation that simply returns an
+ * empty string, meaning that all data is to be considered a
* collection of scalar fields.
*/
virtual
private:
/**
- * Arrays holding the set of
- * patches as well as the names
- * of output variables, all of
- * which we read from an input
- * stream.
+ * Arrays holding the set of patches as well as the names of output
+ * variables, all of which we read from an input stream.
*/
std::vector<typename dealii::DataOutBase::Patch<dim,spacedim> > patches;
std::vector<std::string> dataset_names;
/**
- * Information about whether
- * certain components of the
- * output field are to be
- * considered vectors.
+ * Information about whether certain components of the output field
+ * are to be considered vectors.
*/
std::vector<std_cxx1x::tuple<unsigned int, unsigned int, std::string> >
vector_data_ranges;
-// A class to store relevant data to use when writing the light data XDMF file
-// This should only contain valid data on the root node which writes the files,
-// the rest of the nodes will have valid set to false
+/**
+ * A class to store relevant data to use when writing the light data
+ * XDMF file. This should only contain valid data on the root node which
+ * writes the files, the rest of the nodes will have valid set to false.
+ * The XDMF file in turn points to heavy data files (such as HDF5) where
+ * the actual simulation data is stored. This allows flexibility in
+ * arranging the data, and also allows the mesh to be separated from
+ * the the point data.
+ */
class XDMFEntry
{
private:
- // Whether this entry is valid and contains data to be written
+ /// Whether this entry is valid and contains data to be written
bool valid;
- // The name of the HDF5 heavy data file this entry references
- std::string h5_filename;
- // The simulation time associated with this entry
+ /// The name of the HDF5 heavy data solution and/or mesh files this entry references
+ std::string h5_sol_filename, h5_mesh_filename;
+ /// The simulation time associated with this entry
double entry_time;
- // The number of nodes, cells and dimensionality associated with the data
+ /// The number of nodes, cells and dimensionality associated with the data
unsigned int num_nodes, num_cells, dimension;
- // The attributes associated with this entry and their dimension
+ /// The attributes associated with this entry and their dimension
std::map<std::string, unsigned int> attribute_dims;
- // Small function to create indentation for XML file
+ /// Small function to create indentation for XML file
std::string indent(const unsigned int indent_level) const
{
std::string res = "";
}
public:
- XDMFEntry(void) : valid(false) {};
- XDMFEntry(const std::string filename, const double time, const unsigned int nodes, const unsigned int cells, const unsigned int dim) : valid(true), h5_filename(filename), entry_time(time), num_nodes(nodes), num_cells(cells), dimension(dim) {};
+ XDMFEntry() : valid(false) {};
+ XDMFEntry(const std::string filename, const double time, const unsigned int nodes, const unsigned int cells, const unsigned int dim) : valid(true), h5_sol_filename(filename), h5_mesh_filename(filename), entry_time(time), num_nodes(nodes), num_cells(cells), dimension(dim) {};
+ XDMFEntry(const std::string mesh_filename, const std::string solution_filename, const double time, const unsigned int nodes, const unsigned int cells, const unsigned int dim) : valid(true), h5_sol_filename(solution_filename), h5_mesh_filename(mesh_filename), entry_time(time), num_nodes(nodes), num_cells(cells), dimension(dim) {};
- // Record an attribute and associated dimensionality
+ /**
+ * Record an attribute and associated dimensionality.
+ */
void add_attribute(const std::string &attr_name, const unsigned int dimension)
{
attribute_dims[attr_name] = dimension;
}
- // Get the XDMF content associated with this entry
- // If the entry is not valid, this returns false
+ /**
+ * Read or write the data of this object for serialization
+ */
+ template <class Archive>
+ void serialize(Archive &ar, const unsigned int version) {
+ ar &valid
+ &h5_sol_filename
+ &h5_mesh_filename
+ &entry_time
+ &num_nodes
+ &num_cells
+ &dimension
+ &attribute_dims;
+ }
+
+ /// Get the XDMF content associated with this entry.
+ /// If the entry is not valid, this returns an empty string.
std::string get_xdmf_content(const unsigned int indent_level) const;
};
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__derivative_form_h
#define __deal2__derivative_form_h
In deal.II we represent these derivaties using objects of
type DerivativeForm<1,dim,spacedim>, DerivativeForm<2,dim,spacedim> and so on.
-
@author Sebastian Pauletti, 2011
-
*/
-
template <int order, int dim, int spacedim>
class DerivativeForm
{
Tensor<2,dim> DF_t (dealii::transpose(invert( (Tensor<2,dim>)(*this) )));
DerivativeForm<1,dim, spacedim> result = DF_t;
- return(result);
+ return (result);
}
else
{
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__event_h
#define __deal2__event_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__exceptions_h
#define __deal2__exceptions_h
/**
* Print more specific information about the exception which
- * occured. Overload this function in your own exception classes.
+ * occurred. Overload this function in your own exception classes.
*/
virtual void print_info (std::ostream &out) const;
* processes is redirected to the same console window. In this case,
* it is convenient to set as additional name the name of the host on
* which the program runs, so that one can see in which instance of the
- * program the exception occured.
+ * program the exception occurred.
*
* The string pointed to by the argument is copied, so doesn't need to be
* stored after the call to this function.
ExcIndexRange((index),0,(range)))
#define AssertGlobalIndexRange(index,range) Assert((index) < (range), \
- ExcIndexRange<types::global_dof_index>((index),0,(range)))
+ ExcIndexRange<types::global_dof_index>((index),0,(range)))
using namespace StandardExceptions;
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2007, 2008, 2010, 2012 by the deal.II authors
+// Copyright (C) 2007 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__flow_function_h
#define __deal2__flow_function_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__function_h
#define __deal2__function_h
{
public:
/**
- * Export the value of the
- * template parameter as a static
- * member constant. Sometimes
- * useful for some expression
- * template programming.
+ * Export the value of the template parameter as a static member
+ * constant. Sometimes useful for some expression template programming.
*/
static const unsigned int dimension = dim;
const unsigned int n_components;
/**
- * Constructor. May take an
- * initial value for the number
- * of components (which defaults
- * to one, i.e. a scalar
- * function), and the time
- * variable, which defaults to
- * zero.
+ * Constructor. May take an initial value for the number of components
+ * (which defaults to one, i.e. a scalar function), and the time
+ * variable, which defaults to zero.
*/
Function (const unsigned int n_components = 1,
const double initial_time = 0.0);
/**
- * Virtual destructor; absolutely
- * necessary in this case.
+ * Virtual destructor; absolutely necessary in this case.
*
* This destructor is declared pure virtual, such that objects of this class
* cannot be created. Since all the other virtual functions have a
* the abstractness of any derived class even if they do not have an
* explicitly declared destructor.
*
- * Nonetheless, since derived
- * classes want to call the
- * destructor of a base class,
- * this destructor is implemented
- * (despite it being pure
+ * Nonetheless, since derived classes want to call the destructor of a
+ * base class, this destructor is implemented (despite it being pure
* virtual).
*/
virtual ~Function () = 0;
/**
- * Assignment operator. This is
- * here only so that you can have
- * objects of derived classes in
- * containers, or assign them
- * otherwise. It will raise an
- * exception if the object from
- * which you assign has a
- * different number of components
- * than the one being assigned
- * to.
+ * Assignment operator. This is here only so that you can have objects of
+ * derived classes in containers, or assign them otherwise. It will raise
+ * an exception if the object from which you assign has a different
+ * number of components than the one being assigned to.
*/
Function &operator= (const Function &f);
/**
- * Return the value of the
- * function at the given
- * point. Unless there is only
- * one component (i.e. the
- * function is scalar), you
- * should state the component you
- * want to have evaluated; it
- * defaults to zero, i.e. the
+ * Return the value of the function at the given point. Unless there is
+ * only one component (i.e. the function is scalar), you should state the
+ * component you want to have evaluated; it defaults to zero, i.e. the
* first component.
*/
virtual double value (const Point<dim> &p,
const unsigned int component = 0) const;
/**
- * Return all components of a
- * vector-valued function at a
- * given point.
+ * Return all components of a vector-valued function at a given point.
*
- * <tt>values</tt> shall have the right
- * size beforehand,
- * i.e. #n_components.
+ * <tt>values</tt> shall have the right size beforehand, i.e.
+ * #n_components.
*/
virtual void vector_value (const Point<dim> &p,
Vector<double> &values) const;
/**
- * Set <tt>values</tt> to the point
- * values of the specified
- * component of the function at
- * the <tt>points</tt>. It is assumed
- * that <tt>values</tt> already has the
- * right size, i.e. the same
- * size as the <tt>points</tt> array.
+ * Set <tt>values</tt> to the point values of the specified component of
+ * the function at the <tt>points</tt>. It is assumed that
+ * <tt>values</tt> already has the right size, i.e. the same size as the
+ * <tt>points</tt> array.
*
- * Be default, this function
- * repeatedly calls value() for
- * each point separately, to
- * fill the output array.
+ * Be default, this function repeatedly calls value() for each point
+ * separately, to fill the output array.
*/
virtual void value_list (const std::vector<Point<dim> > &points,
std::vector<double> &values,
const unsigned int component = 0) const;
/**
- * Set <tt>values</tt> to the point
- * values of the function at the
- * <tt>points</tt>. It is assumed that
- * <tt>values</tt> already has the right
- * size, i.e. the same size as
- * the <tt>points</tt> array, and that
- * all elements be vectors with
- * the same number of components
- * as this function has.
+ * Set <tt>values</tt> to the point values of the function at the
+ * <tt>points</tt>. It is assumed that <tt>values</tt> already has the
+ * right size, i.e. the same size as the <tt>points</tt> array, and that
+ * all elements be vectors with the same number of components as this
+ * function has.
*
- * Be default, this function
- * repeatedly calls vector_value() for
- * each point separately, to
- * fill the output array.
+ * Be default, this function repeatedly calls vector_value() for each
+ * point separately, to fill the output array.
*/
virtual void vector_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values) const;
/**
- * For each component of the
- * function, fill a vector of
- * values, one for each point.
+ * For each component of the function, fill a vector of values, one for
+ * each point.
*
- * The default implementation of
- * this function in Function calls
- * value_list() for each
- * component. In order to improve
- * performance, this can be
- * reimplemented in derived
- * classes to speed up performance.
+ * The default implementation of this function in Function calls
+ * value_list() for each component. In order to improve performance, this
+ * can be reimplemented in derived classes to speed up performance.
*/
virtual void vector_values (const std::vector<Point<dim> > &points,
std::vector<std::vector<double> > &values) const;
/**
- * Return the gradient of the
- * specified component of the
- * function at the given point.
+ * Return the gradient of the specified component of the function at the
+ * given point.
*/
virtual Tensor<1,dim> gradient (const Point<dim> &p,
const unsigned int component = 0) const;
/**
- * Return the gradient of all
- * components of the
- * function at the given point.
+ * Return the gradient of all components of the function at the given
+ * point.
*/
virtual void vector_gradient (const Point<dim> &p,
std::vector<Tensor<1,dim> > &gradients) const;
/**
- * Set <tt>gradients</tt> to the
- * gradients of the specified
- * component of the function at
- * the <tt>points</tt>. It is assumed
- * that <tt>gradients</tt> already has the
- * right size, i.e. the same
- * size as the <tt>points</tt> array.
+ * Set <tt>gradients</tt> to the gradients of the specified component of
+ * the function at the <tt>points</tt>. It is assumed that
+ * <tt>gradients</tt> already has the right size, i.e. the same size as
+ * the <tt>points</tt> array.
*/
virtual void gradient_list (const std::vector<Point<dim> > &points,
std::vector<Tensor<1,dim> > &gradients,
const unsigned int component = 0) const;
/**
- * For each component of the
- * function, fill a vector of
- * gradient values, one for each point.
+ * For each component of the function, fill a vector of gradient values,
+ * one for each point.
*
- * The default implementation of
- * this function in Function calls
- * value_list() for each
- * component. In order to improve
- * performance, this can be
- * reimplemented in derived
- * classes to speed up performance.
+ * The default implementation of this function in Function calls
+ * value_list() for each component. In order to improve performance, this
+ * can be reimplemented in derived classes to speed up performance.
*/
virtual void vector_gradients (const std::vector<Point<dim> > &points,
std::vector<std::vector<Tensor<1,dim> > > &gradients) const;
/**
- * Set <tt>gradients</tt> to the gradients of
- * the function at the <tt>points</tt>,
- * for all components.
- * It is assumed that <tt>gradients</tt>
- * already has the right size, i.e.
- * the same size as the <tt>points</tt> array.
+ * Set <tt>gradients</tt> to the gradients of the function at the
+ * <tt>points</tt>, for all components. It is assumed that
+ * <tt>gradients</tt> already has the right size, i.e. the same size as
+ * the <tt>points</tt> array.
*
- * The outer loop over
- * <tt>gradients</tt> is over the points
- * in the list, the inner loop
- * over the different components
- * of the function.
+ * The outer loop over <tt>gradients</tt> is over the points in the list,
+ * the inner loop over the different components of the function.
*/
virtual void vector_gradient_list (const std::vector<Point<dim> > &points,
std::vector<std::vector<Tensor<1,dim> > > &gradients) const;
/**
- * Compute the Laplacian of a
- * given component at point <tt>p</tt>.
+ * Compute the Laplacian of a given component at point <tt>p</tt>.
*/
virtual double laplacian (const Point<dim> &p,
const unsigned int component = 0) const;
/**
- * Compute the Laplacian of all
- * components at point <tt>p</tt> and
- * store them in <tt>values</tt>.
+ * Compute the Laplacian of all components at point <tt>p</tt> and store
+ * them in <tt>values</tt>.
*/
virtual void vector_laplacian (const Point<dim> &p,
Vector<double> &values) const;
/**
- * Compute the Laplacian of one
- * component at a set of points.
+ * Compute the Laplacian of one component at a set of points.
*/
virtual void laplacian_list (const std::vector<Point<dim> > &points,
std::vector<double> &values,
const unsigned int component = 0) const;
/**
- * Compute the Laplacians of all
- * components at a set of points.
+ * Compute the Laplacians of all components at a set of points.
*/
virtual void vector_laplacian_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values) const;
/**
- * Determine an estimate for
- * the memory consumption (in
- * bytes) of this
- * object. Since sometimes
- * the size of objects can
- * not be determined exactly
- * (for example: what is the
- * memory consumption of an
- * STL <tt>std::map</tt> type with a
- * certain number of
- * elements?), this is only
- * an estimate. however often
- * quite close to the true
- * value.
+ * Determine an estimate for the memory consumption (in bytes) of this
+ * object. Since sometimes the size of objects can not be determined
+ * exactly (for example: what is the memory consumption of an STL
+ * <tt>std::map</tt> type with a certain number of elements?), this is
+ * only an estimate. however often quite close to the true value.
*/
std::size_t memory_consumption () const;
};
+
/**
* Provide a function which always returns zero. Obviously, also the
* derivates of this function are zero. Also, it returns zero on all
{
public:
/**
- * Constructor. The number of
- * components is preset to one.
+ * Constructor. The number of components is preset to one.
*/
ZeroFunction (const unsigned int n_components = 1);
/**
- * Virtual destructor; absolutely
- * necessary in this case.
+ * Virtual destructor; absolutely necessary in this case.
+ *
*/
virtual ~ZeroFunction ();
- /**
- * Return the value of the function
- * at the given point for one
- * component.
- */
virtual double value (const Point<dim> &p,
const unsigned int component) const;
- /**
- * Return the value of the function
- * at the given point for all
- * components.
- */
virtual void vector_value (const Point<dim> &p,
Vector<double> &return_value) const;
- /**
- * Set <tt>values</tt> to the point values
- * of the function at the <tt>points</tt>,
- * for the given component.
- * It is assumed that <tt>values</tt>
- * already has the right size, i.e.
- * the same size as the <tt>points</tt>
- * array.
- */
virtual void value_list (const std::vector<Point<dim> > &points,
std::vector<double> &values,
const unsigned int component = 0) const;
- /**
- * Set <tt>values</tt> to the point values
- * of the function at the <tt>points</tt>,
- * for all components.
- * It is assumed that <tt>values</tt>
- * already has the right size, i.e.
- * the same size as the <tt>points</tt>
- * array.
- */
virtual void vector_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values) const;
- /**
- * Return the gradient of the function
- * at the given point, for the
- * given component.
- */
virtual Tensor<1,dim> gradient (const Point<dim> &p,
const unsigned int component = 0) const;
- /**
- * Return the gradient of the
- * specified component of the
- * function at the given point,
- * for all components.
- */
virtual void vector_gradient (const Point<dim> &p,
std::vector<Tensor<1,dim> > &gradients) const;
- /**
- * Set <tt>gradients</tt> to the gradients of
- * the function at the <tt>points</tt>,
- * for the given component.
- * It is assumed that <tt>values</tt>
- * already has the right size, i.e.
- * the same size as the <tt>points</tt> array.
- */
virtual void gradient_list (const std::vector<Point<dim> > &points,
std::vector<Tensor<1,dim> > &gradients,
const unsigned int component = 0) const;
- /**
- * Set <tt>gradients</tt> to the gradients of
- * the function at the <tt>points</tt>,
- * for all components.
- * It is assumed that <tt>gradients</tt>
- * already has the right size, i.e.
- * the same size as the <tt>points</tt> array.
- *
- * The outer loop over
- * <tt>gradients</tt> is over the points
- * in the list, the inner loop
- * over the different components
- * of the function.
- */
virtual void vector_gradient_list (const std::vector<Point<dim> > &points,
std::vector<std::vector<Tensor<1,dim> > > &gradients) const;
};
+
/**
* Provide a function which always returns the constant value
* handed to the constructor.
*
- * Obviously, the derivates of this
- * function are zero, which is why we derive this class from
- * <tt>ZeroFunction</tt>: we then only have to overload the value functions,
- * not all the derivatives. In some way, it would be more obvious to
- * do the derivation in the opposite direction, i.e. let
- * <tt>ZeroFunction</tt> be a more specialized version of <tt>ConstantFunction</tt>;
- * however, this would be less efficient, since we could not make
- * use of the fact that the function value of the <tt>ZeroFunction</tt> is
- * known at compile time and need not be looked up somewhere in
- * memory.
+ * Obviously, the derivates of this function are zero, which is why we
+ * derive this class from <tt>ZeroFunction</tt>: we then only have to
+ * overload the value functions, not all the derivatives. In some way, it
+ * would be more obvious to do the derivation in the opposite direction,
+ * i.e. let <tt>ZeroFunction</tt> be a more specialized version of
+ * <tt>ConstantFunction</tt>; however, this would be less efficient, since
+ * we could not make use of the fact that the function value of the
+ * <tt>ZeroFunction</tt> is known at compile time and need not be looked up
+ * somewhere in memory.
*
* You can pass to the constructor an integer denoting the number of
* components this function shall have. It defaults to one. If it is
- * greater than one, then the function will return the constant value
- * in all its components, which might not be overly useful a feature
- * in most cases, however.
+ * greater than one, then the function will return the constant value in
+ * all its components, which might not be overly useful a feature in most
+ * cases, however.
*
* @ingroup functions
* @author Wolfgang Bangerth, 1998, 1999
{
public:
/**
- * Constructor; takes the constant function
- * value as an argument. The number of
- * components is preset to one.
+ * Constructor; takes the constant function value as an argument. The
+ * number of components is preset to one.
*/
ConstantFunction (const double value,
const unsigned int n_components = 1);
/**
- * Virtual destructor; absolutely
- * necessary in this case.
+ * Virtual destructor; absolutely necessary in this case.
*/
virtual ~ConstantFunction ();
- /**
- * Return the value of the function
- * at the given point for one
- * component.
- */
virtual double value (const Point<dim> &p,
const unsigned int component) const;
- /**
- * Return the value of the function
- * at the given point for all
- * components.
- */
virtual void vector_value (const Point<dim> &p,
Vector<double> &return_value) const;
- /**
- * Set <tt>values</tt> to the point values
- * of the function at the <tt>points</tt>,
- * for the given component.
- * It is assumed that <tt>values</tt>
- * already has the right size, i.e.
- * the same size as the <tt>points</tt>
- * array.
- */
virtual void value_list (const std::vector<Point<dim> > &points,
std::vector<double> &values,
const unsigned int component = 0) const;
- /**
- * Set <tt>values</tt> to the point values
- * of the function at the <tt>points</tt>,
- * for all components.
- * It is assumed that <tt>values</tt>
- * already has the right size, i.e.
- * the same size as the <tt>points</tt>
- * array.
- */
virtual void vector_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values) const;
- /**
- * Determine an estimate for
- * the memory consumption (in
- * bytes) of this
- * object. Since sometimes
- * the size of objects can
- * not be determined exactly
- * (for example: what is the
- * memory consumption of an
- * STL <tt>std::map</tt> type with a
- * certain number of
- * elements?), this is only
- * an estimate. however often
- * quite close to the true
- * value.
- */
std::size_t memory_consumption () const;
protected:
/**
* This is a constant vector-valued function, in which one or more
- * components of the vector have a constant value and all other
- * components are zero. It is especially useful as a weight function
- * for VectorTools::integrate_difference, where it allows to
- * integrate only one or a few vector components, rather than the
- * entire vector-valued solution. In other words, it acts as a
- * component mask with a single component selected (see the
- * @ref GlossComponentMask "the glossary entry on component masks").
- * See the step-20
- * tutorial program for a detailed explanation and a use case.
+ * components of the vector have a constant value and all other components
+ * are zero. It is especially useful as a weight function for
+ * VectorTools::integrate_difference, where it allows to integrate only one
+ * or a few vector components, rather than the entire vector-valued
+ * solution. In other words, it acts as a component mask with a single
+ * component selected (see the @ref GlossComponentMask "the glossary entry
+ * on component masks"). See the step-20 tutorial program for a detailed
+ * explanation and a use case.
*
* @ingroup functions
* @author Guido Kanschat, 2000, Wolfgang Bangerth 2006
{
public:
/**
- * Constructor if only a single
- * component shall be
- * non-zero. Arguments denote the
- * component selected, the value
- * for that component and the
- * total number of vector
- * components.
+ * Constructor if only a single component shall be non-zero. Arguments
+ * denote the component selected, the value for that component and the
+ * total number of vector components.
*/
ComponentSelectFunction (const unsigned int selected,
const double value,
const unsigned int n_components);
/**
- * Constructor. As before, but
- * the value for the selected
- * component is assumed to be
- * one. In essence, this function
- * then works as a mask.
+ * Constructor. As before, but the value for the selected component is
+ * assumed to be one. In essence, this function then works as a mask.
*/
ComponentSelectFunction (const unsigned int selected,
const unsigned int n_components);
/**
- * Constructor if multiple
- * components shall have
- * non-zero, unit values
- * (i.e. this should be a mask
- * for multiple components). The
- * first argument denotes a
- * half-open interval of
- * components (for example
- * std::pair(0,dim) for the first
- * dim components), and the
- * second argument is the total
- * number of vector components.
+ * Constructor if multiple components shall have non-zero, unit values
+ * (i.e. this should be a mask for multiple components). The first
+ * argument denotes a half-open interval of components (for example
+ * std::pair(0,dim) for the first dim components), and the second
+ * argument is the total number of vector components.
*/
ComponentSelectFunction (const std::pair<unsigned int, unsigned int> &selected,
const unsigned int n_components);
/**
- * Return the value of the function
- * at the given point for all
+ * Return the value of the function at the given point for all
* components.
*/
virtual void vector_value (const Point<dim> &p,
Vector<double> &return_value) const;
/**
- * Set <tt>values</tt> to the point values
- * of the function at the <tt>points</tt>,
- * for all components.
- * It is assumed that <tt>values</tt>
- * already has the right size, i.e.
- * the same size as the <tt>points</tt>
- * array.
+ * Set <tt>values</tt> to the point values of the function at the
+ * <tt>points</tt>, for all components. It is assumed that
+ * <tt>values</tt> already has the right size, i.e. the same size as the
+ * <tt>points</tt> array.
*/
virtual void vector_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &values) const;
/**
- * Determine an estimate for
- * the memory consumption (in
- * bytes) of this
- * object. Since sometimes
- * the size of objects can
- * not be determined exactly
- * (for example: what is the
- * memory consumption of an
- * STL <tt>std::map</tt> type with a
- * certain number of
- * elements?), this is only
- * an estimate. however often
- * quite close to the true
- * value.
+ * Determine an estimate for the memory consumption (in bytes) of this
+ * object. Since sometimes the size of objects can not be determined
+ * exactly (for example: what is the memory consumption of an STL
+ * <tt>std::map</tt> type with a certain number of elements?), this is
+ * only an estimate. however often quite close to the true value.
*/
std::size_t memory_consumption () const;
protected:
/**
- * Half-open interval of the
- * indices of selected
- * components.
+ * Half-open interval of the indices of selected components.
*/
const std::pair<unsigned int,unsigned int> selected_components;
};
+
/**
* This class provides a way to convert a scalar function of the kind
* @code
* double foo (const Point<dim> &);
* @endcode
- * into an object of type Function@<dim@>.
- * Since the argument returns a scalar, the result is clearly a
- * Function object for which <code>function.n_components==1</code>.
- * The class works by storing a pointer to the given function and
- * every time <code>function.value(p,component)</code> is called,
- * calls <code>foo(p)</code> and returns the corresponding value. It
- * also makes sure that <code>component</code> is in fact zero, as needs
- * be for scalar functions.
+ * into an object of type Function@<dim@>. Since the argument returns a
+ * scalar, the result is clearly a Function object for which
+ * <code>function.n_components==1</code>. The class works by storing a
+ * pointer to the given function and every time
+ * <code>function.value(p,component)</code> is called, calls
+ * <code>foo(p)</code> and returns the corresponding value. It also makes
+ * sure that <code>component</code> is in fact zero, as needs be for scalar
+ * functions.
*
* The class provides an easy way to turn a simple global function into
* something that has the required Function@<dim@> interface for operations
- * like VectorTools::interpolate_boundary_values() etc., and thereby
- * allows for simpler experimenting without having to write all the
- * boiler plate code of declaring a class that is derived from Function
- * and implementing the Function::value() function.
+ * like VectorTools::interpolate_boundary_values() etc., and thereby allows
+ * for simpler experimenting without having to write all the boiler plate
+ * code of declaring a class that is derived from Function and implementing
+ * the Function::value() function.
*
* The class gains additional expressvive power because the argument it
* takes does not have to be a pointer to an actual function. Rather, it is
- * a function object, i.e., it can also be the result of call to
- * std::bind (or boost::bind) or some other object that can be called with
- * a single argument. For example, if you need a Function object that
- * returns the norm of a point, you could write it like so:
+ * a function object, i.e., it can also be the result of call to std::bind
+ * (or boost::bind) or some other object that can be called with a single
+ * argument. For example, if you need a Function object that returns the
+ * norm of a point, you could write it like so:
* @code
* template <int dim>
* class Norm : public Function<dim> {
*
* Norm<2> my_norm_object;
* @endcode
- * and then pass the <code>my_norm_object</code> around, or you could write it
- * like so:
+ * and then pass the <code>my_norm_object</code> around, or you could write
+ * it like so:
* @code
* ScalarFunctionFromFunctionObject<dim> my_norm_object (&Point<dim>::norm);
* @endcode
{
public:
/**
- * Given a function object that takes a Point and returns a double
- * value, convert this into an object that matches the Function<dim>
- * interface.
+ * Given a function object that takes a Point and returns a double value,
+ * convert this into an object that matches the Function<dim> interface.
*/
ScalarFunctionFromFunctionObject (const std_cxx1x::function<double (const Point<dim> &)> &function_object);
/**
- * Return the value of the
- * function at the given
- * point. Returns the value the
- * function given to the constructor
- * produces for this point.
+ * Return the value of the function at the given point. Returns the value
+ * the function given to the constructor produces for this point.
*/
virtual double value (const Point<dim> &p,
const unsigned int component = 0) const;
};
+
/**
- * This class is similar to the ScalarFunctionFromFunctionObject class in that it
- * allows for the easy conversion of a function object to something that
- * satisfies the interface of the Function base class. The difference is
- * that here, the given function object is still a scalar function
- * (i.e. it has a single value at each space point) but that the Function
- * object generated is vector valued. The number of vector components
- * is specified in the constructor, where one also selectes a single
- * one of these vector components that should be filled by the passed
- * object. The result is a vector Function object that returns zero in
- * each component except the single selected one where it returns the
- * value returned by the given as the first argument to the constructor.
+ * This class is similar to the ScalarFunctionFromFunctionObject class in
+ * that it allows for the easy conversion of a function object to something
+ * that satisfies the interface of the Function base class. The difference
+ * is that here, the given function object is still a scalar function (i.e.
+ * it has a single value at each space point) but that the Function object
+ * generated is vector valued. The number of vector components is specified
+ * in the constructor, where one also selectes a single one of these vector
+ * components that should be filled by the passed object. The result is a
+ * vector Function object that returns zero in each component except the
+ * single selected one where it returns the value returned by the given as
+ * the first argument to the constructor.
*
- * @note In the above discussion, note the difference between the
- * (scalar) "function object" (i.e., a C++ object <code>x</code> that can
- * be called as in <code>x(p)</code>) and the capitalized (vector valued)
- * "Function object" (i.e., an object of a class that is derived from
- * the Function base class).
+ * @note In the above discussion, note the difference between the (scalar)
+ * "function object" (i.e., a C++ object <code>x</code> that can be called
+ * as in <code>x(p)</code>) and the capitalized (vector valued) "Function
+ * object" (i.e., an object of a class that is derived from the Function
+ * base class).
*
* To be more concrete, let us consider the following example:
* @code
* VectorFunctionFromScalarFunctionObject<2>
* component_mask (&one, 1, 3);
* @endcode
- * Here, <code>component_mask</code> then represents a Function object
- * that for every point returns the vector $(0, 1, 0)^T$, i.e. a mask
- * function that could, for example, be passed to VectorTools::integrate_difference().
- * This effect can also be achieved using the ComponentSelectFunction
- * class but is obviously easily extended to functions that are
- * non-constant in their one component.
+ * Here, <code>component_mask</code> then represents a Function object that
+ * for every point returns the vector $(0, 1, 0)^T$, i.e. a mask function
+ * that could, for example, be passed to
+ * VectorTools::integrate_difference(). This effect can also be achieved
+ * using the ComponentSelectFunction class but is obviously easily extended
+ * to functions that are non-constant in their one component.
*
* @author Wolfgang Bangerth, 2011
*/
const unsigned int n_components);
/**
- * Return the value of the
- * function at the given
- * point. Returns the value the
- * function given to the constructor
- * produces for this point.
+ * Return the value of the function at the given point. Returns the value
+ * the function given to the constructor produces for this point.
*/
virtual double value (const Point<dim> &p,
const unsigned int component = 0) const;
/**
- * Return all components of a
- * vector-valued function at a
- * given point.
+ * Return all components of a vector-valued function at a given point.
*
- * <tt>values</tt> shall have the right
- * size beforehand,
- * i.e. #n_components.
+ * <tt>values</tt> shall have the right size beforehand, i.e.
+ * #n_components.
*/
virtual void vector_value (const Point<dim> &p,
Vector<double> &values) const;
const std_cxx1x::function<double (const Point<dim> &)> function_object;
/**
- * The vector component whose value is to be filled by the
- * given scalar function.
+ * The vector component whose value is to be filled by the given scalar
+ * function.
*/
const unsigned int selected_component;
};
/**
- * This class is built as a means of translating
- * the <code>Tensor<1,dim> </code> values produced by objects of type
- * TensorFunction and returning them as a multiple
- * component version of the same thing as a Vector for use in, for example,
- * the VectorTools::interpolate or the many other functions taking Function objects.
- * It allows the user to place the desired components into an <tt>n_components</tt>
- * long vector starting at the <tt>selected_component</tt> location in that vector and have all other
- * components be 0.
+ * This class is built as a means of translating the <code>Tensor<1,dim>
+ * </code> values produced by objects of type TensorFunction and returning
+ * them as a multiple component version of the same thing as a Vector for
+ * use in, for example, the VectorTools::interpolate or the many other
+ * functions taking Function objects. It allows the user to place the
+ * desired components into an <tt>n_components</tt> long vector starting at
+ * the <tt>selected_component</tt> location in that vector and have all
+ * other components be 0.
*
* For example: Say you created a class called
* @code
* RightHandSide<1,dim> rhs;
* @endcode
* of that class which you want to interpolate onto your mesh using the
- * VectorTools::interpolate function, but the finite element you use for the DoFHandler
- * object has 3 copies of a finite element with <tt>dim</tt> components, for a total of 3*dim
- * components. To interpolate onto that DoFHandler, you need an object of type Function
- * that has 3*dim vector components. Creating such an object from the existing <code>rhs</code>
- * object is done using this piece of code:
+ * VectorTools::interpolate function, but the finite element you use for
+ * the DoFHandler object has 3 copies of a finite element with
+ * <tt>dim</tt> components, for a total of 3*dim components. To
+ * interpolate onto that DoFHandler, you need an object of type Function
+ * that has 3*dim vector components. Creating such an object from the
+ * existing <code>rhs</code> object is done using this piece of code:
* @code
* RighHandSide<1,dim> rhs;
* VectorFunctionFromTensorFunction<dim> rhs_vector_function (rhs, 0, 3*dim);
{
public:
/**
- * Given a TensorFunction object that takes a <tt>Point</tt> and returns a <tt>Tensor<1,dim></tt>
- * value, convert this into an object that matches the Function@<dim@>
- * interface.
+ * Given a TensorFunction object that takes a <tt>Point</tt> and returns
+ * a <tt>Tensor<1,dim></tt> value, convert this into an object that
+ * matches the Function@<dim@> interface.
*
- * By default, create a Vector object of the same size as <tt>tensor_function</tt>
- * returns, i.e., with <tt>dim</tt> components.
+ * By default, create a Vector object of the same size as
+ * <tt>tensor_function</tt> returns, i.e., with <tt>dim</tt> components.
*
* @param tensor_function The TensorFunction that will form one component
* of the resulting Vector Function object.
* @param n_components The total number of vector components of the
* resulting TensorFunction object.
* @param selected_component The first component that should be
- * filled by the first argument. This should be such that the entire tensor_function
- * fits inside the <tt>n_component</tt> length return vector.
+ * filled by the first argument. This should be such that the entire
+ * tensor_function fits inside the <tt>n_component</tt> length return
+ * vector.
*/
VectorFunctionFromTensorFunction (const TensorFunction<1,dim> &tensor_function,
const unsigned int selected_component=0,
const unsigned int n_components=dim);
/**
- * This destructor is defined as
- * virtual so as to coincide with all
- * other aspects of class.
+ * This destructor is defined as virtual so as to coincide with all other
+ * aspects of class.
*/
virtual ~VectorFunctionFromTensorFunction();
/**
- * Return a single component of a
- * vector-valued function at a
- * given point.
+ * Return a single component of a vector-valued function at a given
+ * point.
*/
virtual double value (const Point<dim> &p,
const unsigned int component = 0) const;
/**
- * Return all components of a
- * vector-valued function at a
- * given point.
+ * Return all components of a vector-valued function at a given point.
*
- * <tt>values</tt> shall have the right
- * size beforehand,
- * i.e. #n_components.
+ * <tt>values</tt> shall have the right size beforehand, i.e.
+ * #n_components.
*/
virtual void vector_value (const Point<dim> &p,
Vector<double> &values) const;
/**
- * Return all components of a
- * vector-valued function at a
- * list of points.
+ * Return all components of a vector-valued function at a list of points.
*
- * <tt>value_list</tt> shall be the same
- * size as <tt>points</tt> and each element
- * of the vector will be passed to
- * vector_value() to evaluate
- * the function
+ * <tt>value_list</tt> shall be the same size as <tt>points</tt> and each
+ * element of the vector will be passed to vector_value() to evaluate the
+ * function
*/
virtual void vector_value_list (const std::vector<Point<dim> > &points,
std::vector<Vector<double> > &value_list) const;
private:
/**
- * The TensorFunction object which we call when this class's vector_value()
- * or vector_value_list() functions are called.
+ * The TensorFunction object which we call when this class's
+ * vector_value() or vector_value_list() functions are called.
**/
- const TensorFunction<1,dim> & tensor_function;
+ const TensorFunction<1,dim> &tensor_function;
/**
- * The first vector component whose value is to be filled by the
- * given TensorFunction. The values will be placed in components
- * selected_component to selected_component+dim-1 for a <tt>TensorFunction<1,dim></tt> object.
+ * The first vector component whose value is to be filled by the given
+ * TensorFunction. The values will be placed in components
+ * selected_component to selected_component+dim-1 for a
+ * <tt>TensorFunction<1,dim></tt> object.
*/
const unsigned int selected_component;
};
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__function_bessel_h
#define __deal2__function_bessel_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__function_derivative_h
#define __deal2__function_derivative_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__function_lib_h
#define __deal2__function_lib_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2012 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#ifndef __deal2__function_parser_h
#define __deal2__function_parser_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__function_time_h
#define __deal2__function_time_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__geometry_info_h
#define __deal2__geometry_info_h
void
alternating_form_at_vertices
(const Point<spacedim> (&vertices)[vertices_per_cell],
- Tensor<spacedim-dim,spacedim> (&forms)[vertices_per_cell])
- ;
+ Tensor<spacedim-dim,spacedim> (&forms)[vertices_per_cell]);
/**
* For each face of the reference
--- /dev/null
+
+// ---------------------------------------------------------------------
+// $Id: graph_coloring.h 30494 2013-08-26 10:04:44Z kronbichler $
+//
+// Copyright (C) 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+#ifndef __deal2__graph_coloring_h
+#define __deal2__graph_coloring_h
+
+
+#include <deal.II/base/config.h>
+#include <deal.II/base/std_cxx1x/function.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <boost/unordered_map.hpp>
+#include <boost/unordered_set.hpp>
+
+#include <vector>
+
+DEAL_II_NAMESPACE_OPEN
+
+/// This namespace contains the functions necessary to color a graph.
+namespace graph_coloring {
+
+ /**
+ * Create the partitioning using a simplified version of the Cuthill-McKee
+ * algorithm (Breadth First Search algorithm).
+ */
+ template <typename Iterator>
+ std::vector<std::vector<Iterator> > create_partitioning(Iterator const &begin,
+ typename identity<Iterator>::type const &end,
+ std_cxx1x::function<std::vector<types::global_dof_index> (Iterator const &)>
+ const &get_conflict_indices)
+ {
+ std::vector<std::vector<Iterator> > partitioning(1,std::vector<Iterator> (1,begin));
+ // Number of iterators.
+ unsigned int n_iterators(0);
+ // Create a map from conflict indices to iterators
+ boost::unordered_map<types::global_dof_index,std::vector<Iterator> > indices_to_iterators;
+ for (Iterator it=begin; it!=end; ++it)
+ {
+ std::vector<types::global_dof_index> conflict_indices = get_conflict_indices(it);
+ const unsigned int n_conflict_indices(conflict_indices.size());
+ for (unsigned int i=0; i<n_conflict_indices; ++i)
+ indices_to_iterators[conflict_indices[i]].push_back(it);
+ ++n_iterators;
+ }
+
+ // Create the partitioning.
+ std::set<Iterator> used_it;
+ used_it.insert(begin);
+ while (used_it.size()!=n_iterators)
+ {
+ typename std::vector<Iterator>::iterator vector_it(partitioning.back().begin());
+ typename std::vector<Iterator>::iterator vector_end(partitioning.back().end());
+ std::vector<Iterator> new_zone;
+ for (; vector_it!=vector_end; ++vector_it)
+ {
+ std::vector<types::global_dof_index> conflict_indices = get_conflict_indices(*vector_it);
+ const unsigned int n_conflict_indices(conflict_indices.size());
+ for (unsigned int i=0; i<n_conflict_indices; ++i)
+ {
+ std::vector<Iterator> iterator_vector(indices_to_iterators[conflict_indices[i]]);
+ for (unsigned int j=0; j<iterator_vector.size(); ++j)
+ {
+ // Check that the iterator is not associated to a zone yet.
+ if (used_it.count(iterator_vector[j])==0)
+ {
+ new_zone.push_back(iterator_vector[j]);
+ used_it.insert(iterator_vector[j]);
+ }
+ }
+ }
+ }
+ // If there are iterators in the new zone, then the zone is added to the
+ // partition. Otherwise, the graph is disconnected and we need to find
+ // an iterator on the other part of the graph.
+ if (new_zone.size()!=0)
+ partitioning.push_back(new_zone);
+ else
+ for (Iterator it=begin; it!=end; ++it)
+ if (used_it.count(it)==0)
+ {
+ partitioning.push_back(std::vector<Iterator> (1,it));
+ break;
+ }
+ }
+
+ return partitioning;
+ }
+
+
+
+ /**
+ * This function uses DSATUR (Degree SATURation) to color one zone of the
+ * partition. DSATUR works as follows:
+ * -# Arrange the vertices by decreasing order of degrees.
+ * -# Color a vertex of maximal degree with color 1.
+ * -# Choose a vertex with a maximal saturation degree. If there is equality,
+ * choose any vertex of maximal degree in the uncolored subgraph.
+ * -# Color the chosen vertex with the least possible (lowest numbered) color.
+ * -# If all the vertices are colored, stop. Otherwise, return to 3.
+ */
+ template <typename Iterator>
+ std::vector<std::vector<Iterator> > make_dsatur_coloring(std::vector<Iterator> &partition,
+ std_cxx1x::function<std::vector<types::global_dof_index> (Iterator const &)>
+ const &get_conflict_indices)
+ {
+ std::vector<std::vector<Iterator> > partition_coloring;
+ // Number of zones composing the partitioning.
+ const unsigned int partition_size(partition.size());
+ std::vector<unsigned int> sorted_vertices(partition_size);
+ std::vector<unsigned int> degrees(partition_size);
+ std::vector<std::vector<types::global_dof_index> > conflict_indices(partition_size);
+ std::vector<std::vector<unsigned int> > graph(partition_size);
+
+ // Get the conflict indices associated to each iterator. The conflict_indices have to be sorted so
+ // set_intersection can be used later.
+ for (unsigned int i=0; i<partition_size; ++i)
+ {
+ conflict_indices[i] = get_conflict_indices(partition[i]);
+ std::sort(conflict_indices[i].begin(),conflict_indices[i].end());
+ }
+
+ // Compute the degree of each vertex of the graph using the
+ // intersection of the conflict indices.
+ std::vector<types::global_dof_index> conflict_indices_intersection;
+ std::vector<types::global_dof_index>::iterator intersection_it;
+ for (unsigned int i=0; i<partition_size; ++i)
+ for (unsigned int j=i+1; j<partition_size; ++j)
+ {
+ conflict_indices_intersection.resize(std::max(conflict_indices[i].size(),
+ conflict_indices[j].size()));
+ intersection_it = std::set_intersection(conflict_indices[i].begin(),
+ conflict_indices[i].end(),conflict_indices[j].begin(),
+ conflict_indices[j].end(),conflict_indices_intersection.begin());
+ // If the two iterators share indices then we increase the degree of the
+ // vertices and create an ''edge'' in the graph.
+ if (intersection_it!=conflict_indices_intersection.begin())
+ {
+ ++degrees[i];
+ ++degrees[j];
+ graph[i].push_back(j);
+ graph[j].push_back(i);
+ }
+ }
+
+ // Sort the vertices by decreasing degree.
+ std::vector<unsigned int>::iterator degrees_it;
+ for (unsigned int i=0; i<partition_size; ++i)
+ {
+ // Find the largest element.
+ degrees_it = std::max_element(degrees.begin(),degrees.end());
+ sorted_vertices[i] = degrees_it-degrees.begin();
+ // Zero the largest element.
+ *degrees_it = 0;
+ }
+
+ // Color the graph.
+ std::vector<boost::unordered_set<unsigned int> > colors_used;
+ for (unsigned int i=0; i<partition_size; ++i)
+ {
+ const unsigned int current_vertex(sorted_vertices[i]);
+ bool new_color(true);
+ // Try to use an existing color, i.e., try to find a color which is not
+ // associated to one of the vertices linked to current_vertex.
+ // Loop over the color.
+ for (unsigned int j=0; j<partition_coloring.size(); ++j)
+ {
+ // Loop on the vertices linked to current_vertex. If one vertex linked
+ // to current_vertex is already using the color j, this color cannot
+ // be used anymore.
+ bool unused_color(true);
+ for (unsigned int k=0; k<graph[current_vertex].size(); ++k)
+ if (colors_used[j].count(graph[current_vertex][k])==1)
+ {
+ unused_color = false;
+ break;
+ }
+ if (unused_color)
+ {
+ partition_coloring[j].push_back(partition[current_vertex]);
+ colors_used[j].insert(current_vertex);
+ new_color = false;
+ break;
+ }
+ }
+ // Add a new color.
+ if (new_color)
+ {
+ partition_coloring.push_back(std::vector<Iterator> (1,
+ partition[current_vertex]));
+ boost::unordered_set<unsigned int> tmp;
+ tmp.insert(current_vertex);
+ colors_used.push_back(tmp);
+ }
+ }
+
+ return partition_coloring;
+ }
+
+
+
+ /**
+ * Given a partition-coloring graph, gather the colors together. All the
+ * colors on even (resp. odd) partition can be executed simultaneously. This
+ * function tries to create colors of similar number of elements.
+ */
+ template <typename Iterator>
+ std::vector<std::vector<Iterator> >
+ gather_colors(std::vector<std::vector<std::vector<Iterator> > > const &partition_coloring)
+ {
+ std::vector<std::vector<Iterator> > coloring;
+
+ // Count the number of iterators in each color.
+ const unsigned int partition_size(partition_coloring.size());
+ std::vector<std::vector<unsigned int> > colors_counter(partition_size);
+ for (unsigned int i=0; i<partition_size; ++i)
+ {
+ const unsigned int n_colors(partition_coloring[i].size());
+ colors_counter[i].resize(n_colors);
+ for (unsigned int j=0; j<n_colors; ++j)
+ colors_counter[i][j] = partition_coloring[i][j].size();
+ }
+
+ // Find the partition with the largest number of colors for the even partition.
+ unsigned int i_color(0);
+ unsigned int max_even_n_colors(0);
+ const unsigned int colors_size(colors_counter.size());
+ for (unsigned int i=0; i<colors_size; i+=2)
+ {
+ if (max_even_n_colors<colors_counter[i].size())
+ {
+ max_even_n_colors = colors_counter[i].size();
+ i_color = i;
+ }
+ }
+ coloring.resize(max_even_n_colors);
+ for (unsigned int j=0; j<colors_counter[i_color].size(); ++j)
+ coloring[j] = partition_coloring[i_color][j];
+
+ for (unsigned int i=0; i<partition_size; i+=2)
+ {
+ if (i!=i_color)
+ {
+ boost::unordered_set<unsigned int> used_k;
+ for (unsigned int j=0; j<colors_counter[i].size(); ++j)
+ {
+ // Find the color in the current partition with the largest number of
+ // iterators.
+ std::vector<unsigned int>::iterator it;
+ it = std::max_element(colors_counter[i].begin(),colors_counter[i].end());
+ unsigned int min_iterators(-1);
+ unsigned int pos(0);
+ // Find the color of coloring with the least number of colors among
+ // the colors that have not been used yet.
+ for (unsigned int k=0; k<max_even_n_colors; ++k)
+ if (used_k.count(k)==0)
+ if (colors_counter[i_color][k]<min_iterators)
+ {
+ min_iterators = colors_counter[i_color][k];
+ pos = k;
+ }
+ colors_counter[i_color][pos] += *it;
+ // Concatenate the current color with the existing coloring.
+ coloring[pos].insert(coloring[pos].end(),
+ partition_coloring[i][it-colors_counter[i].begin()].begin(),
+ partition_coloring[i][it-colors_counter[i].begin()].end());
+ used_k.insert(pos);
+ // Put the number of iterators to the current color to zero.
+ *it = 0;
+ }
+ }
+ }
+
+ // Do the same thing that we did for the even partitions to the odd
+ // partitions
+ unsigned int max_odd_n_colors(0);
+ for (unsigned int i=1; i<partition_size; i+=2)
+ {
+ if (max_odd_n_colors<colors_counter[i].size())
+ {
+ max_odd_n_colors = colors_counter[i].size();
+ i_color = i;
+ }
+ }
+ coloring.resize(max_even_n_colors+max_odd_n_colors);
+ for (unsigned int j=0; j<colors_counter[i_color].size(); ++j)
+ coloring[max_even_n_colors+j] = partition_coloring[i_color][j];
+
+ for (unsigned int i=1; i<partition_size; i+=2)
+ {
+ if (i!=i_color)
+ {
+ boost::unordered_set<unsigned int> used_k;
+ for (unsigned int j=0; j<colors_counter[i].size(); ++j)
+ {
+ // Find the color in the current partition with the largest number of
+ // iterators.
+ std::vector<unsigned int>::iterator it;
+ it = std::max_element(colors_counter[i].begin(),colors_counter[i].end());
+ unsigned int min_iterators(-1);
+ unsigned int pos(0);
+ // Find the color of coloring with the least number of colors among
+ // the colors that have not been used yet.
+ for (unsigned int k=0; k<max_odd_n_colors; ++k)
+ if (used_k.count(k)==0)
+ if (colors_counter[i_color][k]<min_iterators)
+ {
+ min_iterators = colors_counter[i_color][k];
+ pos = k;
+ }
+ colors_counter[i_color][pos] += *it;
+ // Concatenate the current color with the existing coloring.
+ coloring[max_even_n_colors+pos].insert(coloring[max_even_n_colors+pos].end(),
+ partition_coloring[i][it-colors_counter[i].begin()].begin(),
+ partition_coloring[i][it-colors_counter[i].begin()].end());
+ used_k.insert(pos);
+ // Put the number of iterators to the current color to zero.
+ *it = 0;
+ }
+ }
+ }
+
+ return coloring;
+ }
+
+
+
+ /**
+ * This function creates a coloring given two iterators on the DoFHandler
+ * and a function that return the conflict indices given an iterator. When
+ * using continuous finite elements, the conflict_indices can be the dofs
+ * indices.
+ */
+ template <typename Iterator>
+ std::vector<std::vector<Iterator> >
+ make_graph_coloring(Iterator const &begin,typename identity<Iterator>::type const &end,
+ std_cxx1x::function<std::vector<types::global_dof_index> (Iterator const &)>
+ const &get_conflict_indices)
+ {
+ // Create the partitioning.
+ std::vector<std::vector<Iterator> > partitioning = create_partitioning(begin,end,
+ get_conflict_indices);
+
+ // Color the iterators within each partition.
+ const unsigned int partitioning_size(partitioning.size());
+ std::vector<std::vector<std::vector<Iterator> > > partition_coloring(
+ partitioning_size);
+ for (unsigned int i=0; i<partitioning_size; ++i)
+ {
+ // Compute the coloring of the graph using the DSATUR algorithm
+ partition_coloring[i] = make_dsatur_coloring(partitioning[i],get_conflict_indices);
+ }
+
+ // Gather the colors together.
+ std::vector<std::vector<Iterator> > coloring = gather_colors(partition_coloring);
+
+ return coloring;
+ }
+
+} // End graph_coloring namespace
+
+DEAL_II_NAMESPACE_CLOSE
+
+
+//---------------------------- graph_coloring.h ---------------------------
+// end of #ifndef __deal2__graph_coloring_h
+#endif
+//---------------------------- graph_coloring.h ---------------------------
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__index_set_h
#define __deal2__index_set_h
#include <mpi.h>
#else
typedef int MPI_Comm;
-#define MPI_COMM_WORLD 0
+# ifndef MPI_COMM_WORLD
+# define MPI_COMM_WORLD 0
+# endif
#endif
DEAL_II_NAMESPACE_OPEN
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2010, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__job_identifier_h
#define __deal2__job_identifier_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__logstream_h
#define __deal2__logstream_h
/**
* Enable output to a second stream <tt>o</tt>.
*
- * The optional argument @p print_job_id specifies whether
+ * The optional argument @p print_job_id specifies whether
*/
void attach (std::ostream &o,
const bool print_job_id = true);
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__memory_consumption_h
#define __deal2__memory_consumption_h
{
return sizeof(int);
}
-
+
inline
return sizeof(unsigned int);
}
-
+
+
+ inline
+ std::size_t memory_consumption (const unsigned long int)
+ {
+ return sizeof(unsigned long int);
+ }
+
+
inline
std::size_t memory_consumption (const unsigned long long int)
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2005, 2006, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mg_level_object_h
#define __deal2__mg_level_object_h
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2011, 2012 by deal.II authors
+// Copyright (C) 2011 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mpi_h
#define __deal2__mpi_h
* Called by the constructors.
*/
void do_init(int &argc,
- char ** &argv,
- unsigned int max_num_threads);
+ char ** &argv,
+ unsigned int max_num_threads);
};
namespace internal
{
return MPI_UNSIGNED_LONG;
}
-
+
inline MPI_Datatype mpi_type_id (const unsigned long long int *)
{
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2010, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__multithread_info_h
#define __deal2__multithread_info_h
//---------------------------------------------------------------------------
* To set n_default_threads add the following at the start of your main():
* <code>
* multithread_info.n_default_threads=1;
- * </code>
+ * </code>
*
* @ingroup threads
* @author Thomas Richter, Wolfgang Bangerth, 2000
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__named_data_h
#define __deal2__named_data_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2007, 2010, 2012 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__numbers_h
#define __deal2__numbers_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2009, 2011, 2012 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__parallel_h
#define __deal2__parallel_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__parameter_handler_h
#define __deal2__parameter_handler_h
{
/**
- * Base class to declare common
- * interface. The purpose of this
- * class is mostly to define the
- * interface of patterns, and to
- * force derived classes to have a
- * <tt>clone</tt> function. It is thus,
- * in the languages of the "Design
- * Patterns" book (Gamma et al.), a
- * "prototype".
+ * Base class to declare common interface. The purpose of this class is
+ * mostly to define the interface of patterns, and to force derived
+ * classes to have a <tt>clone</tt> function. It is thus, in the
+ * languages of the "Design Patterns" book (Gamma et al.), a "prototype".
*/
class PatternBase
{
public:
/**
- * Make destructor of this and all
- * derived classes virtual.
+ * Make destructor of this and all derived classes virtual.
*/
virtual ~PatternBase ();
/**
- * Return <tt>true</tt> if the given string
- * matches the pattern.
+ * Return <tt>true</tt> if the given string matches the pattern.
*/
virtual bool match (const std::string &test_string) const = 0;
/**
- * Return a string describing the
- * pattern.
+ * Return a string describing the pattern.
*/
virtual std::string description () const = 0;
/**
- * Return a pointer to an
- * exact copy of the
- * object. This is necessary
- * since we want to store
- * objects of this type in
- * containers, were we need
- * to copy objects without
- * knowledge of their actual
- * data type (we only have
- * pointers to the base
- * class).
+ * Return a pointer to an exact copy of the object. This is necessary
+ * since we want to store objects of this type in containers, were we
+ * need to copy objects without knowledge of their actual data type (we
+ * only have pointers to the base class).
*
- * Ownership of the objects
- * returned by this function
- * is passed to the caller of
- * this function.
+ * Ownership of the objects returned by this function is passed to the
+ * caller of this function.
*/
virtual PatternBase *clone () const = 0;
/**
- * Determine an estimate for
- * the memory consumption (in
- * bytes) of this object. To
- * avoid unnecessary
- * overhead, we do not force
- * derived classes to provide
- * this function as a virtual
- * overloaded one, but rather
- * try to cast the present
- * object to one of the known
- * derived classes and if
- * that fails then take the
- * size of this base class
- * instead and add 32 byte
- * (this value is arbitrary,
- * it should account for
- * virtual function tables,
- * and some possible data
- * elements). Since there are
- * usually not many thousands
- * of objects of this type
- * around, and since the
- * memory_consumption
- * mechanism is used to find
- * out where memory in the
- * range of many megabytes
- * is, this seems like a
+ * Determine an estimate for the memory consumption (in bytes) of this
+ * object. To avoid unnecessary overhead, we do not force derived
+ * classes to provide this function as a virtual overloaded one, but
+ * rather try to cast the present object to one of the known derived
+ * classes and if that fails then take the size of this base class
+ * instead and add 32 byte (this value is arbitrary, it should account
+ * for virtual function tables, and some possible data elements). Since
+ * there are usually not many thousands of objects of this type around,
+ * and since the memory_consumption mechanism is used to find out where
+ * memory in the range of many megabytes is, this seems like a
* reasonable approximation.
*
- * On the other hand, if you
- * know that your class
- * deviates from this
- * assumption significantly,
- * you can still overload
- * this function.
+ * On the other hand, if you know that your class deviates from this
+ * assumption significantly, you can still overload this function.
*/
virtual std::size_t memory_consumption () const;
};
/**
- * Returns pointer to the correct
- * derived class based on description.
+ * Returns pointer to the correct derived class based on description.
*/
PatternBase *pattern_factory (const std::string &description);
/**
- * Test for the string being an
- * integer. If bounds are given
- * to the constructor, then the
- * integer given also needs to be
- * within the interval specified
- * by these bounds. Note that
- * unlike common convention in
- * the C++ standard library, both
- * bounds of this interval are
- * inclusive; the reason is that
- * in practice in most cases, one
- * needs closed intervals, but
- * these can only be realized
- * with inclusive bounds for
- * non-integer values. We thus
- * stay consistent by always
- * using closed intervals.
+ * Test for the string being an integer. If bounds are given to the
+ * constructor, then the integer given also needs to be within the
+ * interval specified by these bounds. Note that unlike common convention
+ * in the C++ standard library, both bounds of this interval are
+ * inclusive; the reason is that in practice in most cases, one needs
+ * closed intervals, but these can only be realized with inclusive bounds
+ * for non-integer values. We thus stay consistent by always using closed
+ * intervals.
*
- * If the upper bound given to
- * the constructor is smaller
- * than the lower bound, then the
- * infinite interval is implied,
- * i.e. every integer is allowed.
+ * If the upper bound given to the constructor is smaller than the lower
+ * bound, then the infinite interval is implied, i.e. every integer is
+ * allowed.
*
- * Giving bounds may be useful if
- * for example a value can only
- * be positive and less than a
- * reasonable upper bound (for
- * example the number of
- * refinement steps to be
- * performed), or in many other
- * cases.
+ * Giving bounds may be useful if for example a value can only be
+ * positive and less than a reasonable upper bound (for example the
+ * number of refinement steps to be performed), or in many other cases.
*/
class Integer : public PatternBase
{
public:
/**
- * Minimal integer value. If
- * the numeric_limits class
- * is available use this
- * information to obtain the
- * extremal values, otherwise
- * set it so that this class
- * understands that all values
- * are allowed.
+ * Minimal integer value. If the numeric_limits class is available use
+ * this information to obtain the extremal values, otherwise set it so
+ * that this class understands that all values are allowed.
*/
static const int min_int_value;
/**
- * Maximal integer value. If
- * the numeric_limits class
- * is available use this
- * information to obtain the
- * extremal values, otherwise
- * set it so that this class
- * understands that all values
- * are allowed.
+ * Maximal integer value. If the numeric_limits class is available use
+ * this information to obtain the extremal values, otherwise set it so
+ * that this class understands that all values are allowed.
*/
static const int max_int_value;
/**
- * Constructor. Bounds can be
- * specified within which a
- * valid parameter has to
- * be. If the upper bound is
- * smaller than the lower
- * bound, then the infinite
- * interval is meant. The
- * default values are chosen
- * such that no bounds are
- * enforced on parameters.
+ * Constructor. Bounds can be specified within which a valid parameter
+ * has to be. If the upper bound is smaller than the lower bound, then
+ * the infinite interval is meant. The default values are chosen such
+ * that no bounds are enforced on parameters.
*/
Integer (const int lower_bound = min_int_value,
const int upper_bound = max_int_value);
/**
- * Return <tt>true</tt> if the
- * string is an integer and
- * its value is within the
- * specified range.
+ * Return <tt>true</tt> if the string is an integer and its value is
+ * within the specified range.
*/
virtual bool match (const std::string &test_string) const;
/**
- * Return a description of
- * the pattern that valid
- * strings are expected to
- * match. If bounds were
- * specified to the
- * constructor, then include
- * them into this
- * description.
+ * Return a description of the pattern that valid strings are expected
+ * to match. If bounds were specified to the constructor, then include
+ * them into this description.
*/
virtual std::string description () const;
/**
- * Return a copy of the
- * present object, which is
- * newly allocated on the
- * heap. Ownership of that
- * object is transferred to
- * the caller of this
+ * Return a copy of the present object, which is newly allocated on the
+ * heap. Ownership of that object is transferred to the caller of this
* function.
*/
virtual PatternBase *clone () const;
/**
- * Creates new object if the start of
- * description matches
- * description_init. Ownership of that
- * object is transferred to the caller
- * of this function.
+ * Creates new object if the start of description matches
+ * description_init. Ownership of that object is transferred to the
+ * caller of this function.
*/
static Integer *create (const std::string &description);
private:
/**
- * Value of the lower
- * bound. A number that
- * satisfies the @ref match
- * operation of this class
- * must be equal to this
- * value or larger, if the
- * bounds of the interval for
- * a valid range.
+ * Value of the lower bound. A number that satisfies the @ref match
+ * operation of this class must be equal to this value or larger, if
+ * the bounds of the interval for a valid range.
*/
const int lower_bound;
/**
- * Value of the upper
- * bound. A number that
- * satisfies the @ref match
- * operation of this class
- * must be equal to this
- * value or less, if the
- * bounds of the interval for
- * a valid range.
+ * Value of the upper bound. A number that satisfies the @ref match
+ * operation of this class must be equal to this value or less, if the
+ * bounds of the interval for a valid range.
*/
const int upper_bound;
};
/**
- * Test for the string being a
- * <tt>double</tt>. If bounds are
- * given to the constructor, then
- * the integer given also needs
- * to be within the interval
- * specified by these
- * bounds. Note that unlike
- * common convention in the C++
- * standard library, both bounds
- * of this interval are
- * inclusive; the reason is that
- * in practice in most cases, one
- * needs closed intervals, but
- * these can only be realized
- * with inclusive bounds for
- * non-integer values. We thus
- * stay consistent by always
- * using closed intervals.
+ * Test for the string being a <tt>double</tt>. If bounds are given to
+ * the constructor, then the integer given also needs to be within the
+ * interval specified by these bounds. Note that unlike common convention
+ * in the C++ standard library, both bounds of this interval are
+ * inclusive; the reason is that in practice in most cases, one needs
+ * closed intervals, but these can only be realized with inclusive bounds
+ * for non-integer values. We thus stay consistent by always using closed
+ * intervals.
*
- * If the upper bound given to
- * the constructor is smaller
- * than the lower bound, then the
- * infinite interval is implied,
- * i.e. every integer is allowed.
+ * If the upper bound given to the constructor is smaller than the lower
+ * bound, then the infinite interval is implied, i.e. every integer is
+ * allowed.
*
- * Giving bounds may be useful if
- * for example a value can only
- * be positive and less than a
- * reasonable upper bound (for
- * example damping parameters are
- * frequently only reasonable if
- * between zero and one), or in
- * many other cases.
+ * Giving bounds may be useful if for example a value can only be
+ * positive and less than a reasonable upper bound (for example damping
+ * parameters are frequently only reasonable if between zero and one), or
+ * in many other cases.
*/
class Double : public PatternBase
{
public:
/**
- * Minimal double value. If the
- * <tt>std::numeric_limits</tt>
- * class is available use this
- * information to obtain the
- * extremal values, otherwise
- * set it so that this class
- * understands that all values
- * are allowed.
+ * Minimal double value. If the <tt>std::numeric_limits</tt> class is
+ * available use this information to obtain the extremal values,
+ * otherwise set it so that this class understands that all values are
+ * allowed.
*/
static const double min_double_value;
/**
- * Maximal double value. If the
- * numeric_limits class is
- * available use this
- * information to obtain the
- * extremal values, otherwise
- * set it so that this class
- * understands that all values
- * are allowed.
+ * Maximal double value. If the numeric_limits class is available use
+ * this information to obtain the extremal values, otherwise set it so
+ * that this class understands that all values are allowed.
*/
static const double max_double_value;
/**
- * Constructor. Bounds can be
- * specified within which a
- * valid parameter has to
- * be. If the upper bound is
- * smaller than the lower
- * bound, then the infinite
- * interval is meant. The
- * default values are chosen
- * such that no bounds are
- * enforced on parameters.
+ * Constructor. Bounds can be specified within which a valid parameter
+ * has to be. If the upper bound is smaller than the lower bound, then
+ * the infinite interval is meant. The default values are chosen such
+ * that no bounds are enforced on parameters.
*/
Double (const double lower_bound = min_double_value,
const double upper_bound = max_double_value);
/**
- * Return <tt>true</tt> if the
- * string is a number and its
- * value is within the
- * specified range.
+ * Return <tt>true</tt> if the string is a number and its value is
+ * within the specified range.
*/
virtual bool match (const std::string &test_string) const;
/**
- * Return a description of
- * the pattern that valid
- * strings are expected to
- * match. If bounds were
- * specified to the
- * constructor, then include
- * them into this
- * description.
+ * Return a description of the pattern that valid strings are expected
+ * to match. If bounds were specified to the constructor, then include
+ * them into this description.
*/
virtual std::string description () const;
/**
- * Return a copy of the
- * present object, which is
- * newly allocated on the
- * heap. Ownership of that
- * object is transferred to
- * the caller of this
+ * Return a copy of the present object, which is newly allocated on the
+ * heap. Ownership of that object is transferred to the caller of this
* function.
*/
virtual PatternBase *clone () const;
/**
- * Creates new object if the start of
- * description matches
- * description_init. Ownership of that
- * object is transferred to the caller
- * of this function.
+ * Creates new object if the start of description matches
+ * description_init. Ownership of that object is transferred to the
+ * caller of this function.
*/
static Double *create (const std::string &description);
private:
/**
- * Value of the lower
- * bound. A number that
- * satisfies the @ref match
- * operation of this class
- * must be equal to this
- * value or larger, if the
- * bounds of the interval for
- * a valid range.
+ * Value of the lower bound. A number that satisfies the @ref match
+ * operation of this class must be equal to this value or larger, if
+ * the bounds of the interval for a valid range.
*/
const double lower_bound;
/**
- * Value of the upper
- * bound. A number that
- * satisfies the @ref match
- * operation of this class
- * must be equal to this
- * value or less, if the
- * bounds of the interval for
- * a valid range.
+ * Value of the upper bound. A number that satisfies the @ref match
+ * operation of this class must be equal to this value or less, if the
+ * bounds of the interval for a valid range.
*/
const double upper_bound;
};
/**
- * Test for the string being one
- * of a sequence of values given
- * like a regular expression. For
- * example, if the string given
- * to the constructor is
- * <tt>"red|blue|black"</tt>, then the
- * @ref match function returns
- * <tt>true</tt> exactly if the string
- * is either "red" or "blue" or
- * "black". Spaces around the
- * pipe signs do not matter and
- * are eliminated.
+ * Test for the string being one of a sequence of values given like a
+ * regular expression. For example, if the string given to the
+ * constructor is <tt>"red|blue|black"</tt>, then the @ref match function
+ * returns <tt>true</tt> exactly if the string is either "red" or "blue"
+ * or "black". Spaces around the pipe signs do not matter and are
+ * eliminated.
*/
class Selection : public PatternBase
{
public:
/**
- * Constructor. Take the
- * given parameter as the
- * specification of valid
+ * Constructor. Take the given parameter as the specification of valid
* strings.
*/
Selection (const std::string &seq);
/**
- * Return <tt>true</tt> if the
- * string is an element of
- * the description list
- * passed to the constructor.
+ * Return <tt>true</tt> if the string is an element of the description
+ * list passed to the constructor.
*/
virtual bool match (const std::string &test_string) const;
/**
- * Return a description of
- * the pattern that valid
- * strings are expected to
- * match. Here, this is the
- * list of valid strings
- * passed to the constructor.
+ * Return a description of the pattern that valid strings are expected
+ * to match. Here, this is the list of valid strings passed to the
+ * constructor.
*/
virtual std::string description () const;
/**
- * Return a copy of the
- * present object, which is
- * newly allocated on the
- * heap. Ownership of that
- * object is transferred to
- * the caller of this
+ * Return a copy of the present object, which is newly allocated on the
+ * heap. Ownership of that object is transferred to the caller of this
* function.
*/
virtual PatternBase *clone () const;
/**
- * Determine an estimate for
- * the memory consumption (in
- * bytes) of this object.
+ * Determine an estimate for the memory consumption (in bytes) of this
+ * object.
*/
std::size_t memory_consumption () const;
/**
- * Creates new object if the start of
- * description matches
- * description_init. Ownership of that
- * object is transferred to the caller
- * of this function.
+ * Creates new object if the start of description matches
+ * description_init. Ownership of that object is transferred to the
+ * caller of this function.
*/
static Selection *create (const std::string &description);
private:
/**
- * List of valid strings as
- * passed to the
- * constructor. We don't make
- * this string constant, as
- * we process it somewhat in
- * the constructor.
+ * List of valid strings as passed to the constructor. We don't make
+ * this string constant, as we process it somewhat in the constructor.
*/
std::string sequence;
/**
- * This pattern matches a list of
- * comma-separated values each of which
- * have to match a pattern given to the
- * constructor. With two additional
- * parameters, the number of elements this
- * list has to have can be specified. If
- * none is specified, the list may have
- * zero or more entries.
+ * This pattern matches a list of values separated by commas (or another
+ * string), each of which
+ * have to match a pattern given to the constructor. With two additional
+ * parameters, the number of elements this list has to have can be
+ * specified. If none is specified, the list may have zero or more
+ * entries.
*/
class List : public PatternBase
{
public:
/**
- * Maximal integer value. If
- * the numeric_limits class
- * is available use this
- * information to obtain the
- * extremal values, otherwise
- * set it so that this class
- * understands that all values
- * are allowed.
+ * Maximal integer value. If the numeric_limits class is available use
+ * this information to obtain the extremal values, otherwise set it so
+ * that this class understands that all values are allowed.
*/
static const unsigned int max_int_value;
/**
- * Constructor. Take the
- * given parameter as the
- * specification of valid
+ * Constructor. Take the given parameter as the specification of valid
* elements of the list.
*
- * The two other arguments can
- * be used to denote minimal
- * and maximal allowable
- * lengths of the list.
+ * The three other arguments can be used to denote minimal and maximal
+ * allowable lengths of the list, and the string that is used as a
+ * separator between elements of the list.
*/
List (const PatternBase &base_pattern,
const unsigned int min_elements = 0,
- const unsigned int max_elements = max_int_value);
+ const unsigned int max_elements = max_int_value,
+ const std::string &separator = ",");
/**
* Destructor.
/**
* Return <tt>true</tt> if the
- * string is a comma-separated
- * list of strings each of
- * which match the pattern
- * given to the constructor.
+ * string is a comma-separated list of strings each of which match the
+ * pattern given to the constructor.
*/
virtual bool match (const std::string &test_string) const;
/**
- * Return a description of
- * the pattern that valid
- * strings are expected to
- * match.
+ * Return a description of the pattern that valid strings are expected
+ * to match.
*/
virtual std::string description () const;
/**
- * Return a copy of the
- * present object, which is
- * newly allocated on the
- * heap. Ownership of that
- * object is transferred to
- * the caller of this
+ * Return a copy of the present object, which is newly allocated on the
+ * heap. Ownership of that object is transferred to the caller of this
* function.
*/
virtual PatternBase *clone () const;
/**
- * Creates new object if the start of
- * description matches
- * description_init. Ownership of that
- * object is transferred to the caller
- * of this function.
+ * Creates new object if the start of description matches
+ * description_init. Ownership of that object is transferred to the
+ * caller of this function.
*/
static List *create (const std::string &description);
/**
- * Determine an estimate for
- * the memory consumption (in
- * bytes) of this object.
+ * Determine an estimate for the memory consumption (in bytes) of this
+ * object.
*/
std::size_t memory_consumption () const;
//@}
private:
/**
- * Copy of the pattern that
- * each element of the list has
- * to satisfy.
+ * Copy of the pattern that each element of the list has to satisfy.
*/
PatternBase *pattern;
/**
- * Minimum number of elements
- * the list must have.
+ * Minimum number of elements the list must have.
*/
const unsigned int min_elements;
/**
- * Maximum number of elements
- * the list must have.
+ * Maximum number of elements the list must have.
*/
const unsigned int max_elements;
+ /**
+ * Separator between elements of the list.
+ */
+ const std::string separator;
+
/**
* Initial part of description
*/
/**
- * This pattern matches a list of
- * comma-separated values each of which
- * denotes a pair of key and value. Both key and value
- * have to match a pattern given to the
- * constructor. For each entry of the map,
- * parameters have to be entered in the form
- * <code>key: value</code>. In other words, a
- * map is described in the form
- * <code>key1: value1, key2: value2, key3: value3, ...</code>.
+ * This pattern matches a list of comma-separated values each of which
+ * denotes a pair of key and value. Both key and value have to match a
+ * pattern given to the constructor. For each entry of the map,
+ * parameters have to be entered in the form <code>key: value</code>. In
+ * other words, a map is described in the form
+ * <code>key1: value1, key2: value2, key3: value3, ...</code>. A constructor
+ * argument allows to choose a delimiter between pairs other than the comma.
*
- * With two additional
- * parameters, the number of elements this
- * list has to have can be specified. If
- * none is specified, the map may have
- * zero or more entries.
+ * With two additional parameters, the number of elements this list has
+ * to have can be specified. If none is specified, the map may have zero
+ * or more entries.
*/
class Map : public PatternBase
{
public:
/**
- * Maximal integer value. If
- * the numeric_limits class
- * is available use this
- * information to obtain the
- * extremal values, otherwise
- * set it so that this class
- * understands that all values
- * are allowed.
+ * Maximal integer value. If the numeric_limits class is available use
+ * this information to obtain the extremal values, otherwise set it so
+ * that this class understands that all values are allowed.
*/
static const unsigned int max_int_value;
/**
- * Constructor. Take the
- * given parameter as the
- * specification of valid
+ * Constructor. Take the given parameter as the specification of valid
* elements of the list.
*
- * The two other arguments can
- * be used to denote minimal
- * and maximal allowable
- * lengths of the list.
+ * The three other arguments can be used to denote minimal and maximal
+ * allowable lengths of the list as well as the separator used to delimit
+ * pairs of the map.
*/
Map (const PatternBase &key_pattern,
const PatternBase &value_pattern,
const unsigned int min_elements = 0,
- const unsigned int max_elements = max_int_value);
+ const unsigned int max_elements = max_int_value,
+ const std::string &separator = ",");
/**
* Destructor.
virtual ~Map ();
/**
- * Return <tt>true</tt> if the
- * string is a comma-separated
- * list of strings each of
- * which match the pattern
- * given to the constructor.
+ * Return <tt>true</tt> if the string is a comma-separated list of
+ * strings each of which match the pattern given to the constructor.
*/
virtual bool match (const std::string &test_string) const;
/**
- * Return a description of
- * the pattern that valid
- * strings are expected to
- * match.
+ * Return a description of the pattern that valid strings are expected
+ * to match.
*/
virtual std::string description () const;
/**
- * Return a copy of the
- * present object, which is
- * newly allocated on the
- * heap. Ownership of that
- * object is transferred to
- * the caller of this
+ * Return a copy of the present object, which is newly allocated on the
+ * heap. Ownership of that object is transferred to the caller of this
* function.
*/
virtual PatternBase *clone () const;
/**
- * Creates new object if the start of
- * description matches
- * description_init. Ownership of that
- * object is transferred to the caller
- * of this function.
+ * Creates new object if the start of description matches
+ * description_init. Ownership of that object is transferred to the
+ * caller of this function.
*/
static Map *create (const std::string &description);
/**
- * Determine an estimate for
- * the memory consumption (in
- * bytes) of this object.
+ * Determine an estimate for the memory consumption (in bytes) of this
+ * object.
*/
std::size_t memory_consumption () const;
//@}
private:
/**
- * Copy of the patterns that
- * each key and each value of the map has
- * to satisfy.
+ * Copy of the patterns that each key and each value of the map has to
+ * satisfy.
*/
PatternBase *key_pattern;
PatternBase *value_pattern;
/**
- * Minimum number of elements
- * the list must have.
+ * Minimum number of elements the list must have.
*/
const unsigned int min_elements;
/**
- * Maximum number of elements
- * the list must have.
+ * Maximum number of elements the list must have.
*/
const unsigned int max_elements;
+ /**
+ * Separator between elements of the list.
+ */
+ const std::string separator;
+
/**
* Initial part of description
*/
/**
- * This class is much like the
- * Selection class, but it
- * allows the input to be a
- * comma-separated list of values
- * which each have to be given in
- * the constructor
- * argument. Alternatively, it
- * could be viewed as a
- * specialization of the List
- * class. For example, if the
- * string to the constructor was
- * <tt>"ucd|gmv|eps"</tt>, then the
- * following would be legal input:
- * <tt>eps</tt>, <tt>gmv</tt>. You may give an
- * arbitrarily long list of values,
- * where there may be as many
- * spaces around commas as you
- * like. However, commas are not
- * allowed inside the values given
+ * This class is much like the Selection class, but it allows the input
+ * to be a comma-separated list of values which each have to be given in
+ * the constructor argument. Alternatively, it could be viewed as a
+ * specialization of the List class. For example, if the string to the
+ * constructor was <tt>"ucd|gmv|eps"</tt>, then the following would be
+ * legal input: <tt>eps</tt>, <tt>gmv</tt>. You may give an arbitrarily
+ * long list of values, where there may be as many spaces around commas
+ * as you like. However, commas are not allowed inside the values given
* to the constructor.
*/
class MultipleSelection : public PatternBase
{
public:
/**
- * Constructor. Take the
- * given parameter as the
- * specification of valid
+ * Constructor. Take the given parameter as the specification of valid
* strings.
*/
MultipleSelection (const std::string &seq);
/**
- * Return <tt>true</tt> if the
- * string is an element of
- * the description list
- * passed to the constructor.
+ * Return <tt>true</tt> if the string is an element of the description
+ * list passed to the constructor.
*/
virtual bool match (const std::string &test_string) const;
/**
- * Return a description of
- * the pattern that valid
- * strings are expected to
- * match. Here, this is the
- * list of valid strings
- * passed to the constructor.
+ * Return a description of the pattern that valid strings are expected
+ * to match. Here, this is the list of valid strings passed to the
+ * constructor.
*/
virtual std::string description () const;
/**
- * Return a copy of the
- * present object, which is
- * newly allocated on the
- * heap. Ownership of that
- * object is transferred to
- * the caller of this
+ * Return a copy of the present object, which is newly allocated on the
+ * heap. Ownership of that object is transferred to the caller of this
* function.
*/
virtual PatternBase *clone () const;
/**
- * Creates new object if the start of
- * description matches
- * description_init. Ownership of that
- * object is transferred to the caller
- * of this function.
+ * Creates new object if the start of description matches
+ * description_init. Ownership of that object is transferred to the
+ * caller of this function.
*/
static MultipleSelection *create (const std::string &description);
/**
- * Determine an estimate for
- * the memory consumption (in
- * bytes) of this object.
+ * Determine an estimate for the memory consumption (in bytes) of this
+ * object.
*/
std::size_t memory_consumption () const;
//@}
private:
/**
- * List of valid strings as
- * passed to the
- * constructor. We don't make
- * this string constant, as
- * we process it somewhat in
- * the constructor.
+ * List of valid strings as passed to the constructor. We don't make
+ * this string constant, as we process it somewhat in the constructor.
*/
std::string sequence;
};
/**
- * Test for the string being
- * either "true" or "false". This
- * is mapped to the Selection
- * class.
+ * Test for the string being either "true" or "false". This is mapped to
+ * the Selection class.
*/
class Bool : public Selection
{
Bool ();
/**
- * Return a description of
- * the pattern that valid
- * strings are expected to
- * match.
+ * Return a description of the pattern that valid strings are expected
+ * to match.
*/
virtual std::string description () const;
/**
- * Return a copy of the
- * present object, which is
- * newly allocated on the
- * heap. Ownership of that
- * object is transferred to
- * the caller of this
+ * Return a copy of the present object, which is newly allocated on the
+ * heap. Ownership of that object is transferred to the caller of this
* function.
*/
virtual PatternBase *clone () const;
/**
- * Creates new object if the start of
- * description matches
- * description_init. Ownership of that
- * object is transferred to the caller
- * of this function.
+ * Creates new object if the start of description matches
+ * description_init. Ownership of that object is transferred to the
+ * caller of this function.
*/
static Bool *create (const std::string &description);
};
/**
- * Always returns <tt>true</tt> when testing a
- * string.
+ * Always returns <tt>true</tt> when testing a string.
*/
class Anything : public PatternBase
{
public:
/**
- * Constructor. (Allow for at
- * least one non-virtual
- * function in this class, as
- * otherwise sometimes no
- * virtual table is emitted.)
+ * Constructor. (Allow for at least one non-virtual function in this
+ * class, as otherwise sometimes no virtual table is emitted.)
*/
Anything ();
/**
- * Return <tt>true</tt> if the
- * string matches its
- * constraints, i.e. always.
+ * Return <tt>true</tt> if the string matches its constraints, i.e.
+ * always.
*/
virtual bool match (const std::string &test_string) const;
/**
- * Return a description of
- * the pattern that valid
- * strings are expected to
- * match. Here, this is the
- * string <tt>"[Anything]"</tt>.
+ * Return a description of the pattern that valid strings are expected
+ * to match. Here, this is the string <tt>"[Anything]"</tt>.
*/
virtual std::string description () const;
/**
- * Return a copy of the
- * present object, which is
- * newly allocated on the
- * heap. Ownership of that
- * object is transferred to
- * the caller of this
+ * Return a copy of the present object, which is newly allocated on the
+ * heap. Ownership of that object is transferred to the caller of this
* function.
*/
virtual PatternBase *clone () const;
/**
- * Creates new object if the start of
- * description matches
- * description_init. Ownership of that
- * object is transferred to the caller
- * of this function.
+ * Creates new object if the start of description matches
+ * description_init. Ownership of that object is transferred to the
+ * caller of this function.
*/
static Anything *create (const std::string &description);
/**
- * A pattern that can be used to indicate
- * when a parameter is intended to be the
- * name of a file. By itself, this class
- * does not check whether the string that
- * is given in a parameter file actually
- * corresponds to an existing file (it
- * could, for example, be the name of a
- * file to which you want to write
- * output). Functionally, the class is
- * therefore equivalent to the Anything
- * class. However, it allows to specify the
- * <i>intent</i> of a parameter. The flag
- * given to the constructor also allows to
- * specify whether the file is supposed to
- * be an input or output file.
+ * A pattern that can be used to indicate when a parameter is intended to
+ * be the name of a file. By itself, this class does not check whether
+ * the string that is given in a parameter file actually corresponds to
+ * an existing file (it could, for example, be the name of a file to
+ * which you want to write output). Functionally, the class is therefore
+ * equivalent to the Anything class. However, it allows to specify the
+ * <i>intent</i> of a parameter. The flag given to the constructor also
+ * allows to specify whether the file is supposed to be an input or
+ * output file.
*
- * The reason for the existence of this
- * class is to support graphical user
- * interfaces for editing parameter
- * files. These may open a file selection
- * dialog if the filename is supposed to
- * represent an input file.
+ * The reason for the existence of this class is to support graphical
+ * user interfaces for editing parameter files. These may open a file
+ * selection dialog if the filename is supposed to represent an input
+ * file.
*/
class FileName : public PatternBase
{
public:
/**
- * Files can be used for input
- * or output. This can be
- * specified in the constructor
- * by choosing the flag <tt>type</tt>.
+ * Files can be used for input or output. This can be specified in the
+ * constructor by choosing the flag <tt>type</tt>.
*/
enum FileType {input = 0, output = 1};
/**
- * Constructor. The type of the file
- * can be specified by choosing the
+ * Constructor. The type of the file can be specified by choosing the
* flag.
*/
FileName (const FileType type = input);
/**
- * Return <tt>true</tt> if the
- * string matches its
- * constraints, i.e. always.
+ * Return <tt>true</tt> if the string matches its constraints, i.e.
+ * always.
*/
virtual bool match (const std::string &test_string) const;
/**
- * Return a description of
- * the pattern that valid
- * strings are expected to
- * match. Here, this is the
- * string <tt>"[Filename]"</tt>.
+ * Return a description of the pattern that valid strings are expected
+ * to match. Here, this is the string <tt>"[Filename]"</tt>.
*/
virtual std::string description () const;
/**
- * Return a copy of the
- * present object, which is
- * newly allocated on the
- * heap. Ownership of that
- * object is transferred to
- * the caller of this
+ * Return a copy of the present object, which is newly allocated on the
+ * heap. Ownership of that object is transferred to the caller of this
* function.
*/
virtual PatternBase *clone () const;
FileType file_type;
/**
- * Creates new object if the start of
- * description matches
- * description_init. Ownership of that
- * object is transferred to the caller
- * of this function.
+ * Creates new object if the start of description matches
+ * description_init. Ownership of that object is transferred to the
+ * caller of this function.
*/
static FileName *create (const std::string &description);
/**
- * A pattern that can be used to indicate
- * when a parameter is intended to be the
- * name of a directory. By itself, this
- * class does not check whether the string
- * that is given in a parameter file
- * actually corresponds to an existing
- * directory. Functionally, the class is
- * therefore equivalent to the Anything
- * class. However, it allows to specify the
- * <i>intent</i> of a parameter.
+ * A pattern that can be used to indicate when a parameter is intended to
+ * be the name of a directory. By itself, this class does not check
+ * whether the string that is given in a parameter file actually
+ * corresponds to an existing directory. Functionally, the class is
+ * therefore equivalent to the Anything class. However, it allows to
+ * specify the <i>intent</i> of a parameter.
*
- * The reason for the existence of this
- * class is to support graphical user
- * interfaces for editing parameter
- * files. These may open a file selection
- * dialog to select or create a directory.
+ * The reason for the existence of this class is to support graphical
+ * user interfaces for editing parameter files. These may open a file
+ * selection dialog to select or create a directory.
*/
class DirectoryName : public PatternBase
{
DirectoryName ();
/**
- * Return <tt>true</tt> if the
- * string matches its
- * constraints, i.e. always.
+ * Return <tt>true</tt> if the string matches its constraints, i.e.
+ * always.
*/
virtual bool match (const std::string &test_string) const;
/**
- * Return a description of
- * the pattern that valid
- * strings are expected to
- * match. Here, this is the
- * string <tt>"[Filename]"</tt>.
+ * Return a description of the pattern that valid strings are expected
+ * to match. Here, this is the string <tt>"[Filename]"</tt>.
*/
virtual std::string description () const;
/**
- * Return a copy of the
- * present object, which is
- * newly allocated on the
- * heap. Ownership of that
- * object is transferred to
- * the caller of this
+ * Return a copy of the present object, which is newly allocated on the
+ * heap. Ownership of that object is transferred to the caller of this
* function.
*/
virtual PatternBase *clone () const;
/**
- * Creates new object if the start of
- * description matches
- * description_init. Ownership of that
- * object is transferred to the caller
- * of this function.
+ * Creates new object if the start of description matches
+ * description_init. Ownership of that object is transferred to the
+ * caller of this function.
*/
static DirectoryName *create (const std::string &description);
/**
- * The ParameterHandler class provides a standard interface to an input file
- * which provides at run-time for program parameters such as time step
- * sizes, geometries, right hand sides etc. The input for the program is
- * given in files, streams or strings in memory using text like
+ * The ParameterHandler class provides a standard interface to an input
+ * file which provides at run-time for program parameters such as time
+ * step sizes, geometries, right hand sides etc. The input for the
+ * program is given in files, streams or strings in memory using text
+ * like
* @code
* set Time step size = 0.3
* set Geometry = [0,1]x[0,3]
* @endcode
* Input may be sorted into subsection trees in order to give the input a
- * logical structure.
+ * logical structure, and input files may include other files.
*
- * The ParameterHandler class is discussed in detail in the @ref
- * step_19 "step-19" example program, and is used in more realistic
- * situations in step-29, step-33
- * and step-34.
+ * The ParameterHandler class is discussed in detail in the @ref step_19
+ * "step-19" example program, and is used in more realistic situations in
+ * step-29, step-33 and step-34.
*
* <h3>Declaring entries</h3>
*
- * In order to use the facilities of a ParameterHandler object, one first has
- * to make known the different entries the input file may or may not contain. This
- * is done in the following way:
+ * In order to use the facilities of a ParameterHandler object, one first
+ * has to make known the different entries the input file may or may not
+ * contain. This is done in the following way:
*
* @code
* ...
* Patterns::Anything());
* ...
* @endcode
- * Each entry is declared using the function declare_entry(). The
- * first parameter is the name of the entry (in short: the
- * entry). The second is the default answer to be taken in case the
- * entry is not specified in the input file. The third parameter is
- * a regular expression which the input (and the default answer) has
- * to match. Several such regular expressions are defined in
- * Patterns. This parameter can be omitted, in which case it
- * will default to Patterns::Anything, i.e. a pattern that
+ * Each entry is declared using the function declare_entry(). The first
+ * parameter is the name of the entry (in short: the entry). The second
+ * is the default answer to be taken in case the entry is not specified
+ * in the input file. The third parameter is a regular expression which
+ * the input (and the default answer) has to match. Several such regular
+ * expressions are defined in Patterns. This parameter can be omitted, in
+ * which case it will default to Patterns::Anything, i.e. a pattern that
* matches every input string. The fourth parameter can be used to
* document the intent or expected format of an entry; its value is
- * printed as a comment when writing all entries of a
- * ParameterHandler object using the print_parameters()
- * function to allow for easier understanding of a parameter
- * file. It can be omitted as well, in which case no such
- * documentation will be printed.
- *
- * Entries may be located in subsections which form a kind of input tree. For example
- * input parameters for linear solver routines should be classified in a subsection
- * named <tt>Linear solver</tt> or any other suitable name. This is accomplished in the
- * following way:
+ * printed as a comment when writing all entries of a ParameterHandler
+ * object using the print_parameters() function to allow for easier
+ * understanding of a parameter file. It can be omitted as well, in which
+ * case no such documentation will be printed.
+ *
+ * Entries may be located in subsections which form a kind of input tree.
+ * For example input parameters for linear solver routines should be
+ * classified in a subsection named <tt>Linear solver</tt> or any other
+ * suitable name. This is accomplished in the following way:
* @code
* ...
* LinEq eq;
* }
* @endcode
*
- * Subsections may be nested. For example a nonlinear solver may have a linear solver
- * as member object. Then the function call tree would be something like (if the class
- * <tt>NonLinEq</tt> has a member variables <tt>eq</tt> of type <tt>LinEq</tt>):
+ * Subsections may be nested. For example a nonlinear solver may have a
+ * linear solver as member object. Then the function call tree would be
+ * something like (if the class <tt>NonLinEq</tt> has a member variables
+ * <tt>eq</tt> of type <tt>LinEq</tt>):
* @code
* void NonLinEq::declare_parameters (ParameterHandler &prm) {
* prm.enter_subsection ("Nonlinear solver");
* }
* @endcode
*
- * For class member functions which declare the different entries we propose
- * to use the common name <tt>declare_parameters</tt>. In normal cases this
- * method can be <tt>static</tt> since the entries will not depend on any
- * previous knowledge. Classes for which entries should logically be grouped
- * into subsections should declare these subsections themselves. If a class
- * has two or more member variables of the same type both of which should
- * have their own parameters, this parent class' method
- * <tt>declare_parameters</tt> is responsible to group them into different
- * subsections:
+ * For class member functions which declare the different entries we
+ * propose to use the common name <tt>declare_parameters</tt>. In normal
+ * cases this method can be <tt>static</tt> since the entries will not
+ * depend on any previous knowledge. Classes for which entries should
+ * logically be grouped into subsections should declare these subsections
+ * themselves. If a class has two or more member variables of the same
+ * type both of which should have their own parameters, this parent
+ * class' method <tt>declare_parameters</tt> is responsible to group them
+ * into different subsections:
* @code
* void NonLinEq::declare_parameters (ParameterHandler &prm) {
* prm.enter_subsection ("Nonlinear solver");
* end
* ... # other stuff
* @endcode
- * The words <tt>subsection</tt>, <tt>set</tt> and <tt>end</tt> may be either written in lowercase or uppercase
- * letters. Leading and trailing whitespace is removed, multiple whitespace is condensed into
- * only one. Since the latter applies also to the name of an entry, an entry name will not
- * be recognized if in the declaration multiple whitespace is used.
+ * The words <tt>subsection</tt>, <tt>set</tt> and <tt>end</tt> may be
+ * either written in lowercase or uppercase letters. Leading and trailing
+ * whitespace is removed, multiple whitespace is condensed into only one.
+ * Since the latter applies also to the name of an entry, an entry name
+ * will not be recognized if in the declaration multiple whitespace is
+ * used.
*
- * In entry names and values the following characters are not allowed: <tt>\#</tt>, <tt>{</tt>,
- * <tt>}</tt>, <tt>|</tt>. Their use is reserved for the MultipleParameterLoop class.
+ * In entry names and values the following characters are not allowed:
+ * <tt>\#</tt>, <tt>{</tt>, <tt>}</tt>, <tt>|</tt>. Their use is reserved
+ * for the MultipleParameterLoop class.
*
* Comments starting with \# are skipped.
*
- * We propose to use the following
- * scheme to name entries: start the first word with a capital letter and use lowercase
- * letters further on. The same applies to the possible entry values to the right of the
+ * We propose to use the following scheme to name entries: start the
+ * first word with a capital letter and use lowercase letters further on.
+ * The same applies to the possible entry values to the right of the
* <tt>=</tt> sign.
*
*
+ * <h3>Including other input files</h3>
+ *
+ * An input file can include other include files using the syntax
+ * @code
+ * ...
+ * include some_other_file.prm
+ * ...
+ * @endcode
+ * The file so referenced is searched for relative to the current
+ * directory (not relative to the directory in which the including
+ * parameter file is located, since this is not known to all three
+ * versions of the read_input() function).
+ *
+ *
* <h3>Reading data from input sources</h3>
*
- * In order to read input you can use three possibilities: reading from an
- * <tt>std::istream</tt> object, reading from a file of which the name is
- * given and reading from a string in memory in which the lines are
+ * In order to read input there are three possibilities: reading from
+ * an <tt>std::istream</tt> object, reading from a file of which the name
+ * is given and reading from a string in memory in which the lines are
* separated by <tt>@\n</tt> characters. These possibilities are used as
* follows:
* @code
* prm.read_input_from_string (in);
* ...
* @endcode
- * You can use several sources of input successively. Entries which are changed more than
- * once will be overwritten every time they are used.
+ * You can use several sources of input successively. Entries which are
+ * changed more than once will be overwritten every time they are used.
*
* You should not try to declare entries using declare_entry() and
* enter_subsection() with as yet unknown subsection names after
* using read_input(). The results in this case are unspecified.
*
- * If an error occurs upon reading the input, error messages are written to
- * <tt>std::cerr</tt> and the reader function returns with a return value of
- * <code>false</code>. This is opposed to almost all other functions in
- * deal.II, which would normally throw an exception if an error occurs; this
- * difference in behavior is a relic of the fact that this class predates
- * deal.II and had previously been written for a different project.
+ * If an error occurs upon reading the input, error messages are written
+ * to <tt>std::cerr</tt> and the reader function returns with a return
+ * value of <code>false</code>. This is opposed to almost all other
+ * functions in deal.II, which would normally throw an exception if an
+ * error occurs; this difference in behavior is a relic of the fact that
+ * this class predates deal.II and had previously been written for a
+ * different project.
*
*
* <h3>Using the %ParameterHandler Graphical User Interface</h3>
*
* An alternative to using the hand-written input files shown above is to
- * use the graphical user interface (GUI) that accompanies this class. For
- * this, you first need to write a description of all the parameters, their
- * default values, patterns and documentation strings into a file in a
- * format that the GUI can understand; this is done using the
- * ParameterHandler::print_parameters() function with ParameterHandler::XML
- * as second argument, as discussed in more detail below in the
- * <i>Representation of Parameters</i> section. This file can then be loaded
- * using the executable for the GUI, which should be located in
- * <code>lib/bin/dealii_parameter_gui</code> of your deal.II installation,
- * assuming that you have a sufficiently recent version of the <a
- * href="http://qt.nokia.com/">Qt toolkit</a> installed.
+ * use the graphical user interface (GUI) that accompanies this class.
+ * For this, you first need to write a description of all the parameters,
+ * their default values, patterns and documentation strings into a file
+ * in a format that the GUI can understand; this is done using the
+ * ParameterHandler::print_parameters() function with
+ * ParameterHandler::XML as second argument, as discussed in more detail
+ * below in the <i>Representation of Parameters</i> section. This file
+ * can then be loaded using the executable for the GUI, which should be
+ * located in <code>lib/bin/dealii_parameter_gui</code> of your deal.II
+ * installation, assuming that you have a sufficiently recent version of
+ * the <a href="http://qt.nokia.com/">Qt toolkit</a> installed.
*
* Once loaded, the GUI displays subsections and individual parameters in
* tree form (see also the discussion in the <i>Representation of
- * Parameters</i> section below). Here is a screen shot with some
- * sub-sections expanded and one parameter selected for editing:
+ * Parameters</i> section below). Here is a screen shot
+ * with some sub-sections expanded and one parameter selected for
+ * editing:
*
* @image html parameter_gui.png "Parameter GUI"
*
* prm.leave_subsection ();
* }
* @endcode
- * get() returns the value of the given entry. If the entry was not specified in the input
- * source(s), the default value is returned. You have to enter and leave subsections
- * exactly as you did when declaring subsection. You may chose the order in which to
- * transverse the subsection tree.
- *
- * It is guaranteed that only entries matching the given regular expression are returned,
- * i.e. an input entry value which does not match the regular expression is not stored.
- *
- * You can use get() to retrieve the parameter in text form, get_integer() to get an integer
- * or get_double() to get a double. You can also use get_bool().
- * It will cause an internal error if the string could not be
- * converted to an integer, double or a bool. This should, though, not
- * happen if you correctly specified the regular expression for this entry; you should not
- * try to get out an integer or a double from an entry for which no according regular
- * expression was set. The internal error is raised through the Assert() macro family
- * which only works in debug mode.
+ * get() returns the value of the given entry. If the entry was not
+ * specified in the input source(s), the default value is returned. You
+ * have to enter and leave subsections exactly as you did when declaring
+ * subsection. You may chose the order in which to transverse the
+ * subsection tree.
+ *
+ * It is guaranteed that only entries matching the given regular
+ * expression are returned, i.e. an input entry value which does not
+ * match the regular expression is not stored.
+ *
+ * You can use get() to retrieve the parameter in text form,
+ * get_integer() to get an integer or get_double() to get a double. You
+ * can also use get_bool(). It will cause an internal error if the string
+ * could not be converted to an integer, double or a bool. This should,
+ * though, not happen if you correctly specified the regular expression
+ * for this entry; you should not try to get out an integer or a double
+ * from an entry for which no according regular expression was set. The
+ * internal error is raised through the Assert() macro family which only
+ * works in debug mode.
*
* If you want to print out all user selectable features, use the
- * print_parameters() function. It is generally a good idea to print all parameters
- * at the beginning of a log file, since this way input and output are together in
- * one file which makes matching at a later time easier. Additionally, the function
- * also print those entries which have not been modified in the input file und are
- * thus set to default values; since default values may change in the process of
- * program development, you cannot know the values of parameters not specified in the
- * input file.
+ * print_parameters() function. It is generally a good idea to print all
+ * parameters at the beginning of a log file, since this way input and
+ * output are together in one file which makes matching at a later time
+ * easier. Additionally, the function also print those entries which have
+ * not been modified in the input file und are thus set to default
+ * values; since default values may change in the process of program
+ * development, you cannot know the values of parameters not specified in
+ * the input file.
*
*
* <h3>Style guide for data retrieval</h3>
*
- * We propose that every class which gets data out of a
- * ParameterHandler object provides a function named
- * <tt>get_parameters</tt>. This should be declared
- * <tt>virtual</tt>. <tt>get_parameters</tt> functions in derived classes
- * should call the <tt>BaseClass::get_parameters</tt> function.
+ * We propose that every class which gets data out of a ParameterHandler
+ * object provides a function named <tt>get_parameters</tt>. This should
+ * be declared <tt>virtual</tt>. <tt>get_parameters</tt> functions in
+ * derived classes should call the <tt>BaseClass::get_parameters</tt>
+ * function.
*
*
* <h3>Experience with large parameter lists</h3>
*
- * Experience has shown that in programs defining larger numbers of parameters (more than,
- * say, fifty) it is advantageous to define an additional class holding these parameters.
- * This class is more like a C-style structure, having a large number of variables,
- * usually public. It then has at least two functions, which declare and parse the
- * parameters. In the main program, the main class has an object of this parameter class
- * and delegates declaration and parsing of parameters to this object.
+ * Experience has shown that in programs defining larger numbers of
+ * parameters (more than, say, fifty) it is advantageous to define an
+ * additional class holding these parameters. This class is more like a
+ * C-style structure, having a large number of variables, usually public.
+ * It then has at least two functions, which declare and parse the
+ * parameters. In the main program, the main class has an object of this
+ * parameter class and delegates declaration and parsing of parameters to
+ * this object.
*
- * The advantage of this approach is that you can keep out the technical details
- * (declaration and parsing) out of the main class and additionally don't clutter
- * up your main class with dozens or more variables denoting the parameters.
+ * The advantage of this approach is that you can keep out the technical
+ * details (declaration and parsing) out of the main class and
+ * additionally don't clutter up your main class with dozens or more
+ * variables denoting the parameters.
*
*
*
* prm.leave_subsection ();
* @endcode
*
- * We can think of the parameters so arranged as a file system in which every
- * parameter is a directory. The name of this directory is the name of the
- * parameter, and in this directory lie files that describe the
+ * We can think of the parameters so arranged as a file system in which
+ * every parameter is a directory. The name of this directory is the name
+ * of the parameter, and in this directory lie files that describe the
* parameter. These files are:
* - <code>value</code>: The content of this file is the current value of this
* parameter; initially, the content of the file equals the default value of
* With the exception of the <code>value</code> file, the contents of files
* are never changed after declaration of a parameter.
*
- * Alternatively, a directory in this file system may not have a file called
- * <code>value</code> in it. In that case, the directory represents a
- * subsection as declared above, and the directory's name will correspond to
- * the name of the subsection. It will then have no files in it at all, but
- * it may have further directories in it: some of these directories will be
- * parameters (indicates by the presence of files) or further nested
- * subsections.
+ * Alternatively, a directory in this file system may not have a file
+ * called <code>value</code> in it. In that case, the directory
+ * represents a subsection as declared above, and the directory's name
+ * will correspond to the name of the subsection. It will then have no
+ * files in it at all, but it may have further directories in it: some of
+ * these directories will be parameters (indicates by the presence of
+ * files) or further nested subsections.
*
* Given this explanation, the code above will lead to a hierarchical
* representation of data that looks like this (the content of files is
{
private:
/**
- * Inhibit automatic
- * CopyConstructor.
+ * Inhibit automatic CopyConstructor.
*/
ParameterHandler (const ParameterHandler &);
/**
- * Inhibit automatic
- * assignment operator.
+ * Inhibit automatic assignment operator.
*/
ParameterHandler &operator= (const ParameterHandler &);
public:
/**
- * List of possible output
- * formats.
+ * List of possible output formats.
*
- * The formats down the list with
- * prefix <em>Short</em> and bit
- * 6 and 7 set reproduce the old
- * behavior of not writing
- * comments or original values to
- * the files.
+ * The formats down the list with prefix <em>Short</em> and bit 6 and 7
+ * set reproduce the old behavior of not writing comments or original
+ * values to the files.
*/
enum OutputStyle
{
/**
- * Write human readable
- * output suitable to be
- * read by ParameterHandler
+ * Write human readable output suitable to be read by ParameterHandler
* again.
*/
Text = 1,
/**
- * Write parameters as a
- * LaTeX table.
+ * Write parameters as a LaTeX table.
*/
LaTeX = 2,
/**
- * Write out declared parameters
- * with description and possible
- * values.
+ * Write out declared parameters with description and possible values.
*/
Description = 3,
/**
- * Write out everything as
- * an <a href="http://en.wikipedia.org/wiki/XML">XML</a>
- * file.
+ * Write out everything as an <a
+ * href="http://en.wikipedia.org/wiki/XML">XML</a> file.
*
- * See the general
- * documentation of this
- * class for an example of
+ * See the general documentation of this class for an example of
* output.
*/
XML = 4,
/**
- * Write out everything as
- * a <a href="http://en.wikipedia.org/wiki/JSON">JSON</a>
- * file.
+ * Write out everything as a <a
+ * href="http://en.wikipedia.org/wiki/JSON">JSON</a> file.
*/
JSON = 5,
/**
- * Write input for
- * ParameterHandler without
- * comments or changed
- * default values.
+ * Write input for ParameterHandler without comments or changed default
+ * values.
*/
ShortText = 193
};
ParameterHandler ();
/**
- * Destructor. Declare this only
- * to have a virtual destructor,
- * which is safer as we have
- * virtual functions. It
- * actually does nothing
+ * 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 <tt>eof</tt>
- * condition or error.
+ * Read input from a stream until the stream returns the <tt>eof</tt> condition
+ * or error. The second argument can be used to denote the name of the file
+ * (if that's what the input stream represents) we are reading from; this
+ * is only used when creating output for error messages.
*
- * Return whether the read was
- * successful.
+ * Return whether the read was successful.
*/
- virtual bool read_input (std::istream &input);
+ virtual bool read_input (std::istream &input,
+ const std::string &filename = "input file");
/**
- * Read input from a file the
- * name of which is given. The
- * PathSearch class "PARAMETERS"
- * is used to find the file.
+ * Read input from a file the name of which is given. The PathSearch
+ * class "PARAMETERS" is used to find the file.
*
- * Return whether the read was
- * successful.
+ * Return whether the read was successful.
*
- * Unless <tt>optional</tt> is
- * <tt>true</tt>, this function
- * will automatically generate
- * the requested file with
- * default values if the file did
- * not exist. This file will not
- * contain additional comments if
- * <tt>write_stripped_file</tt>
- * is <tt>true</tt>.
+ * Unless <tt>optional</tt> is <tt>true</tt>, this function will
+ * automatically generate the requested file with default values if the
+ * file did not exist. This file will not contain additional comments if
+ * <tt>write_stripped_file</tt> is <tt>true</tt>.
*/
virtual bool read_input (const std::string &filename,
const bool optional = false,
const bool write_stripped_file = false);
/**
- * Read input from a string in
- * memory. The lines in memory
- * have to be separated by <tt>@\n</tt>
- * characters.
+ * Read input from a string in memory. The lines in memory have to be
+ * separated by <tt>@\n</tt> characters.
*
- * Return whether the read was
- * successful.
+ * Return whether the read was successful.
*/
virtual bool read_input_from_string (const char *s);
/**
- * Read a parameter file in XML
- * format. This could be from a file
- * originally written by the
- * print_parameters() function using the
- * XML output style and then modified by
- * hand as necessary; or from a file
- * written using this method and then
- * modified by the graphical parameter
- * GUI (see the general documentation of
- * this class).
+ * Read a parameter file in XML format. This could be from a file
+ * originally written by the print_parameters() function using the XML
+ * output style and then modified by hand as necessary; or from a file
+ * written using this method and then modified by the graphical parameter
+ * GUI (see the general documentation of this class).
*
- * Return whether the read was
- * successful.
+ * Return whether the read was successful.
*/
virtual bool read_input_from_xml (std::istream &input);
/**
- * Declare a new entry with name
- * <tt>entry</tt>, default and for
- * which any input has to match
- * the <tt>pattern</tt> (default: any
- * pattern).
+ * Declare a new entry with name <tt>entry</tt>, default and for which
+ * any input has to match the <tt>pattern</tt> (default: any pattern).
*
- * The last parameter defaulting
- * to an empty string is used to
- * add a documenting text to each
- * entry which will be printed as
- * a comment when this class is
- * asked to write out all
- * declarations to a stream using
- * the print_parameters()
- * function.
+ * The last parameter defaulting to an empty string is used to add a
+ * documenting text to each entry which will be printed as a comment when
+ * this class is asked to write out all declarations to a stream using
+ * the print_parameters() function.
*
- * The function generates an
- * exception if the default value
- * doesn't match the given
- * pattern. An entry can be
- * declared more than once
- * without generating an error,
- * for example to override an
- * earlier default value.
+ * The function generates an exception of type ExcValueDoesNotMatchPattern
+ * if the default value doesn't match the given pattern, using the C++
+ * throw mechanism. However, this exception is only generated <i>after</i>
+ * the entry has been created; if you have code where no sensible default
+ * value for a parameter is possible, you can then catch and ignore this
+ * exception.
+ *
+ * @note An entry can be declared more than once without
+ * generating an error, for example to override an earlier default value.
*/
void declare_entry (const std::string &entry,
const std::string &default_value,
const std::string &documentation = std::string());
/**
- * Enter a subsection; if not yet
- * existent, declare it.
+ * Enter a subsection; if not yet existent, declare it.
*/
void enter_subsection (const std::string &subsection);
/**
- * Leave present subsection.
- * Return <tt>false</tt> if there is
- * no subsection to leave; <tt>true</tt>
- * otherwise.
+ * Leave present subsection. Return <tt>false</tt> if there is no
+ * subsection to leave; <tt>true</tt> otherwise.
*/
bool leave_subsection ();
/**
- * Return value of entry
- * <tt>entry_string</tt>. If the
- * entry was changed, then the
- * changed value is returned,
- * otherwise the default
- * value. If the value of an
- * undeclared entry is required,
- * an exception will be thrown.
+ * Return value of entry <tt>entry_string</tt>. If the entry was
+ * changed, then the changed value is returned, otherwise the default
+ * value. If the value of an undeclared entry is required, an exception
+ * will be thrown.
*/
std::string get (const std::string &entry_string) const;
/**
- * Return value of entry
- * <tt>entry_string</tt> as <tt>long
- * int</tt>. (A long int is chosen so
- * that even very large unsigned values
- * can be returned by this function).
+ * Return value of entry <tt>entry_string</tt> as <tt>long int</tt>. (A
+ * long int is chosen so that even very large unsigned values can be
+ * returned by this function).
*/
long int get_integer (const std::string &entry_string) const;
/**
- * Return value of entry
- * <tt>entry_name</tt> as
- * <tt>double</tt>.
+ * Return value of entry <tt>entry_name</tt> as <tt>double</tt>.
*/
double get_double (const std::string &entry_name) const;
/**
- * Return value of entry
- * <tt>entry_name</tt> as <tt>bool</tt>.
- * The entry may be "true" or "yes"
- * for <tt>true</tt>, "false" or
- * "no" for <tt>false</tt> respectively.
+ * Return value of entry <tt>entry_name</tt> as <tt>bool</tt>. The entry
+ * may be "true" or "yes" for <tt>true</tt>, "false" or "no" for
+ * <tt>false</tt> respectively.
*/
bool get_bool (const std::string &entry_name) const;
/**
- * Change the value presently stored for
- * <tt>entry_name</tt> to the one given
- * in the second argument.
+ * Change the value presently stored for <tt>entry_name</tt> to the one
+ * given in the second argument.
*
- * The parameter must already exist in
- * the present subsection.
+ * The parameter must already exist in the present subsection.
*
- * The function throws an
- * exception of type
- * ExcValueDoesNotMatchPattern
- * if the new value does not
- * conform to the pattern for
- * this entry.
+ * The function throws an exception of type ExcValueDoesNotMatchPattern
+ * if the new value does not conform to the pattern for this entry.
*/
void set (const std::string &entry_name,
const std::string &new_value);
/**
- * Same as above, but an overload where
- * the second argument is a character
- * pointer. This is necessary, since
- * otherwise the call to
- * <tt>set("abc","def")</code> will be
- * mapped to the function taking one
- * string and a bool as arguments, which
- * is certainly not what is most often
- * intended.
+ * Same as above, but an overload where the second argument is a
+ * character pointer. This is necessary, since otherwise the call to
+ * <tt>set("abc","def")</code> will be mapped to the function taking one
+ * string and a bool as arguments, which is certainly not what is most
+ * often intended.
*
- * The function throws an
- * exception of type
- * ExcValueDoesNotMatchPattern
- * if the new value does not
- * conform to the pattern for
- * this entry.
+ * The function throws an exception of type ExcValueDoesNotMatchPattern
+ * if the new value does not conform to the pattern for this entry.
*/
void set (const std::string &entry_name,
const char *new_value);
/**
- * Change the value presently stored for
- * <tt>entry_name</tt> to the one given
- * in the second argument.
+ * Change the value presently stored for <tt>entry_name</tt> to the one
+ * given in the second argument.
*
- * The parameter must already exist in
- * the present subsection.
+ * The parameter must already exist in the present subsection.
*
- * The function throws an
- * exception of type
- * ExcValueDoesNotMatchPattern
- * if the new value does not
- * conform to the pattern for
- * this entry.
+ * The function throws an exception of type ExcValueDoesNotMatchPattern
+ * if the new value does not conform to the pattern for this entry.
*/
void set (const std::string &entry_name,
const long int &new_value);
/**
- * Change the value presently stored for
- * <tt>entry_name</tt> to the one given
- * in the second argument.
+ * Change the value presently stored for <tt>entry_name</tt> to the one
+ * given in the second argument.
*
- * The parameter must already exist in
- * the present subsection.
+ * The parameter must already exist in the present subsection.
*
- * For internal purposes, the new value
- * needs to be converted to a
- * string. This is done using 16 digits
- * of accuracy, so the set value and the
- * one you can get back out using
- * get_double() may differ in the 16th
+ * For internal purposes, the new value needs to be converted to a
+ * string. This is done using 16 digits of accuracy, so the set value and
+ * the one you can get back out using get_double() may differ in the 16th
* digit.
*
- * The function throws an
- * exception of type
- * ExcValueDoesNotMatchPattern
- * if the new value does not
- * conform to the pattern for
- * this entry.
+ * The function throws an exception of type ExcValueDoesNotMatchPattern
+ * if the new value does not conform to the pattern for this entry.
*/
void set (const std::string &entry_name,
const double &new_value);
/**
- * Change the value presently stored for
- * <tt>entry_name</tt> to the one given
- * in the second argument.
+ * Change the value presently stored for <tt>entry_name</tt> to the one
+ * given in the second argument.
*
- * The parameter must already exist in
- * the present subsection.
+ * The parameter must already exist in the present subsection.
*
- * The function throws an
- * exception of type
- * ExcValueDoesNotMatchPattern
- * if the new value does not
- * conform to the pattern for
- * this entry.
+ * The function throws an exception of type ExcValueDoesNotMatchPattern
+ * if the new value does not conform to the pattern for this entry.
*/
void set (const std::string &entry_name,
const bool &new_value);
/**
- * Print all parameters with the
- * given style to
- * <tt>out</tt>. Presently only
- * <tt>Text</tt> and <tt>LaTeX</tt> are
- * implemented.
+ * Print all parameters with the given style to <tt>out</tt>. Presently
+ * only <tt>Text</tt> and <tt>LaTeX</tt> are implemented.
*
- * In <tt>Text</tt> format, the output
- * is formatted in such a way
- * that it is possible to use it
- * for later input again. This is
- * most useful to record the
- * parameters for a specific run,
- * since if you output the
- * parameters using this function
- * into a log file, you can
- * always recover the results by
- * simply copying the output to
- * your input file.
+ * In <tt>Text</tt> format, the output is formatted in such a way that it
+ * is possible to use it for later input again. This is most useful to
+ * record the parameters for a specific run, since if you output the
+ * parameters using this function into a log file, you can always recover
+ * the results by simply copying the output to your input file.
*
- * Besides the name and value of
- * each entry, the output also
- * contains the default value of
- * entries if it is different
- * from the actual value, as well
- * as the documenting string
- * given to the
- * declare_entry() function
+ * Besides the name and value of each entry, the output also contains the
+ * default value of entries if it is different from the actual value, as
+ * well as the documenting string given to the declare_entry() function
* if available.
*
- * In <tt>Text</tt> format, the
- * output contains the same information
- * but in a format so that the
- * resulting file can be input into
- * a latex document such as a manual
- * for the code for which this object
- * handles run-time parameters.
- * The various sections of parameters
- * are then represented by latex
- * section and subsection commands
- * as well as by nested enumerations.
+ * In <tt>Text</tt> format, the output contains the same information but
+ * in a format so that the resulting file can be input into a latex
+ * document such as a manual for the code for which this object handles
+ * run-time parameters. The various sections of parameters are then
+ * represented by latex section and subsection commands as well as by
+ * nested enumerations.
*
- * In addition, all parameter names
- * are listed with <code>@\index</code>
- * statements in two indices called
- * <code>prmindex</code> (where the
- * name of each parameter is listed
- * in the index) and <code>prmindexfull</code>
- * where parameter names are listed
- * sorted by the section in which
- * they exist. By default, the LaTeX
- * program ignores these <code>@\index</code>
- * commands, but they can be used to
- * generate an index by using the
- * following commands in the preamble
- * of the latex file:
+ * In addition, all parameter names are listed with <code>@\index</code>
+ * statements in two indices called <code>prmindex</code> (where the name
+ * of each parameter is listed in the index) and
+ * <code>prmindexfull</code> where parameter names are listed sorted by
+ * the section in which they exist. By default, the LaTeX program ignores
+ * these <code>@\index</code> commands, but they can be used to generate
+ * an index by using the following commands in the preamble of the latex
+ * file:
* @code
* \usepackage{imakeidx}
* \makeindex[name=prmindex, title=Index of run-time parameter entries]
* \makeindex[name=prmindexfull, title=Index of run-time parameters with section names]
* @endcode
- * and at the end of the file
- * this:
+ * and at the end of the file this:
* @code
* \printindex[prmindex]
* \printindex[prmindexfull]
const OutputStyle style);
/**
- * Print out the parameters of
- * the present subsection as
- * given by the
- * <tt>subsection_path</tt> member
- * variable. This variable is
- * controlled by entering and
- * leaving subsections through
- * the enter_subsection() and
- * leave_subsection()
- * functions.
+ * Print out the parameters of the present subsection as given by the
+ * <tt>subsection_path</tt> member variable. This variable is controlled
+ * by entering and leaving subsections through the enter_subsection() and
+ * leave_subsection() functions.
*
- * In most cases, you will not
- * want to use this function
- * directly, but have it called
- * recursively by the previous
- * function.
+ * In most cases, you will not want to use this function directly, but
+ * have it called recursively by the previous function.
*/
void print_parameters_section (std::ostream &out,
const OutputStyle style,
const unsigned int indent_level);
/**
- * Print parameters to a
- * logstream. This function
- * allows to print all parameters
- * into a log-file. Sections
- * will be indented in the usual
+ * Print parameters to a logstream. This function allows to print all
+ * parameters into a log-file. Sections will be indented in the usual
* log-file style.
*/
void log_parameters (LogStream &out);
/**
- * Log parameters in the present
- * subsection. The subsection is
- * determined by the
- * <tt>subsection_path</tt> member
- * variable. This variable is
- * controlled by entering and
- * leaving subsections through
- * the enter_subsection() and
- * leave_subsection()
- * functions.
+ * Log parameters in the present subsection. The subsection is determined
+ * by the <tt>subsection_path</tt> member variable. This variable is
+ * controlled by entering and leaving subsections through the
+ * enter_subsection() and leave_subsection() functions.
*
- * In most cases, you will not
- * want to use this function
- * directly, but have it called
- * recursively by the previous
- * function.
+ * In most cases, you will not want to use this function directly, but
+ * have it called recursively by the previous function.
*/
void log_parameters_section (LogStream &out);
/**
- * Determine an estimate for
- * the memory consumption (in
- * bytes) of this
+ * Determine an estimate for the memory consumption (in bytes) of this
* object.
*/
std::size_t memory_consumption () const;
/**
- * Write the data of this object to a
- * stream for the purpose of
+ * Write the data of this object to a stream for the purpose of
* serialization.
*/
template <class Archive>
void save (Archive &ar, const unsigned int version) const;
/**
- * Read the data of this object from a
- * stream for the purpose of
+ * Read the data of this object from a stream for the purpose of
* serialization.
*/
template <class Archive>
//@}
private:
/**
- * The separator used when
- * accessing elements of a path
- * into the parameter tree.
+ * The separator used when accessing elements of a path into the
+ * parameter tree.
*/
static const char path_separator = '.';
/**
- * The complete tree of sections
- * and entries. See the general
- * documentation of this class
- * for a description how data is
- * stored in this variable.
+ * The complete tree of sections and entries. See the general
+ * documentation of this class for a description how data is stored in
+ * this variable.
*
- * The variable is a pointer so
- * that we can use an incomplete
- * type, rather than having to
- * include all of the
- * property_tree stuff from
- * boost. This works around a
- * problem with gcc 4.5.
+ * The variable is a pointer so that we can use an incomplete type,
+ * rather than having to include all of the property_tree stuff from
+ * boost. This works around a problem with gcc 4.5.
*/
std::auto_ptr<boost::property_tree::ptree> entries;
/**
- * A list of patterns that are
- * used to describe the
- * parameters of this object. The
- * are indexed by nodes in the
- * property tree.
+ * A list of patterns that are used to describe the parameters of this
+ * object. The are indexed by nodes in the property tree.
*/
std::vector<std_cxx1x::shared_ptr<const Patterns::PatternBase> > patterns;
/**
- * Mangle a string so that it
- * doesn't contain any special
- * characters or spaces.
+ * Mangle a string so that it doesn't contain any special characters or
+ * spaces.
*/
static std::string mangle (const std::string &s);
/**
- * Unmangle a string into its
- * original form.
+ * Unmangle a string into its original form.
*/
static std::string demangle (const std::string &s);
/**
- * Return whether a given node is
- * a parameter node or a
- * subsection node.
+ * Return whether a given node is a parameter node or a subsection node.
*/
static bool is_parameter_node (const boost::property_tree::ptree &);
/**
- * Path of presently selected
- * subsections; empty list means
- * top level
+ * Path of presently selected subsections; empty list means top level
*/
std::vector<std::string> subsection_path;
/**
- * Return the string that
- * identifies the current path
- * into the property tree. This
- * is only a path, i.e. it is not
- * terminated by the
+ * Return the string that identifies the current path into the property
+ * tree. This is only a path, i.e. it is not terminated by the
* path_separator character.
*/
std::string get_current_path () const;
/**
- * Given the name of an entry as
- * argument, the function
- * computes a full path into the
- * parameter tree using the
- * current subsection.
+ * Given the name of an entry as argument, the function computes a full
+ * path into the parameter tree using the current subsection.
*/
std::string get_current_full_path (const std::string &name) const;
/**
- * Scan one line of input.
- * <tt>lineno</tt> is the number of
- * the line presently scanned
- * (for the logs if there are
- * messages). Return <tt>false</tt> if
- * line contained stuff that
- * could not be understood, the
- * uppermost subsection was to be
- * left by an <tt>END</tt> or <tt>end</tt>
- * statement, a value for a
- * non-declared entry was given
- * or the entry value did not
- * match the regular
- * expression. <tt>true</tt> otherwise.
+ * Scan one line of input. <tt>input_filename</tt> and <tt>lineno</tt>
+ * are the name of the input file and the current number of the line
+ * presently scanned (for the logs if there are messages). Return
+ * <tt>false</tt> if line contained stuff that could not be understood,
+ * the uppermost subsection was to be left by an <tt>END</tt> or
+ * <tt>end</tt> statement, a value for a non-declared entry was given or
+ * the entry value did not match the regular expression. <tt>true</tt>
+ * otherwise.
*
- * The function modifies its
- * argument, but also takes it by
- * value, so the caller's
- * variable is not changed.
+ * The function modifies its argument, but also takes it by value, so the
+ * caller's variable is not changed.
*/
bool scan_line (std::string line,
+ const std::string &input_filename,
const unsigned int lineno);
friend class MultipleParameterLoop;
/**
- * The class MultipleParameterLoop offers an easy possibility to test several
- * parameter sets during one run of the program. For this it uses the
- * ParameterHandler class to read in data in a standardized form, searches for
- * variant entry values and performs a loop over all combinations of parameters.
+ * The class MultipleParameterLoop offers an easy possibility to test
+ * several parameter sets during one run of the program. For this it uses
+ * the ParameterHandler class to read in data in a standardized form,
+ * searches for variant entry values and performs a loop over all
+ * combinations of parameters.
*
* Variant entry values are given like this:
* @verbatim
* set Time step size = { 0.1 | 0.2 | 0.3 }
* @endverbatim
- * The loop will then perform three runs of the program, one for each value
- * of <tt>Time step size</tt>, while all other parameters are as specified or with their
- * default value. If there are several variant entry values in the input, a loop is
- * performed for each combination of variant values:
+ * The loop will then perform three runs of the program, one for each
+ * value of <tt>Time step size</tt>, while all other parameters are as
+ * specified or with their default value. If there are several variant
+ * entry values in the input, a loop is performed for each combination of
+ * variant values:
* @verbatim
* set Time step size = { 0.1 | 0.2 }
* set Solver = { CG | GMRES }
* @endverbatim
- * will result in four runs of the programs, with time step 0.1 and 0.2 for each
- * of the two solvers.
+ * will result in four runs of the programs, with time step 0.1 and 0.2
+ * for each of the two solvers.
*
- * In addition to variant entries, this class also supports <i>array entries</i> that look like this:
+ * In addition to variant entries, this class also supports <i>array
+ * entries</i> that look like this:
* @verbatim
* set Output file = ofile.{{ 1 | 2 | 3 | 4 }}
* @endverbatim
- * This indicates that if there are variant entries producing a total of four
- * different runs, then we will write their results to the files <tt>ofile.1</tt>, <tt>ofile.2</tt>,
- * <tt>ofile.3</tt> and <tt>ofile.4</tt>, respectively. Array entries do not generate multiple
- * runs of the main loop themselves, but if there are variant entries, then in
- * the <i>n</i>th run of the main loop, also the <i>n</i>th value of an array is returned.
- *
- * Since the different variants are constructed in the order of declaration, not in
- * the order in which the variant entries appear in the input file, it may be
- * difficult to guess the mapping between the different variants and the appropriate
- * entry in an array. You will have to check the order of declaration, or use
- * only one variant entry.
- *
- * It is guaranteed that only selections which match the regular expression (pattern) given
- * upon declaration of an entry are given back to the program. If a variant value
- * does not match the regular expression, the default value is stored and an error
- * is issued. Before the first run of the loop, all possible values are checked
- * for their conformance, so that the error is issued at the very beginning of the
+ * This indicates that if there are variant entries producing a total of
+ * four different runs, then we will write their results to the files
+ * <tt>ofile.1</tt>, <tt>ofile.2</tt>, <tt>ofile.3</tt> and
+ * <tt>ofile.4</tt>, respectively. Array entries do not generate multiple
+ * runs of the main loop themselves, but if there are variant entries,
+ * then in the <i>n</i>th run of the main loop, also the <i>n</i>th value
+ * of an array is returned.
+ *
+ * Since the different variants are constructed in the order of
+ * declaration, not in the order in which the variant entries appear in
+ * the input file, it may be difficult to guess the mapping between the
+ * different variants and the appropriate entry in an array. You will
+ * have to check the order of declaration, or use only one variant entry.
+ *
+ * It is guaranteed that only selections which match the regular
+ * expression (pattern) given upon declaration of an entry are given back
+ * to the program. If a variant value does not match the regular
+ * expression, the default value is stored and an error is issued. Before
+ * the first run of the loop, all possible values are checked for their
+ * conformance, so that the error is issued at the very beginning of the
* program.
*
*
* <h3>Usage</h3>
*
- * The usage of this class is similar to the ParameterHandler class. First the
- * entries and subsections have to be declared, then a loop is performed in which
- * the different parameter sets are set, a new instance of a user class is created
- * which is then called. Taking the classes of the example for the
- * ParameterHandler class, the extended program would look like this:
+ * The usage of this class is similar to the ParameterHandler class.
+ * First the entries and subsections have to be declared, then a loop is
+ * performed in which the different parameter sets are set, a new
+ * instance of a user class is created which is then called. Taking the
+ * classes of the example for the ParameterHandler class, the extended
+ * program would look like this:
* @code
* class HelperClass : public MultipleParameterLoop::UserClass {
* public:
* }
* @endcode
*
- * As can be seen, first a new helper class has to be set up. This must contain
- * a virtual constructor for a problem class. You can also derive your problem
- * class from MultipleParameterLoop::UserClass and let <tt>create_new</tt> clear all
- * member variables. If you have access to all inherited member variables in
- * some way this is the recommended procedure. A third possibility is to use
- * multiple inheritance and derive a helper class from both the
- * MultipleParameterLoop::UserClass and the problem class. In any case,
- * <tt>create_new</tt> has to provide a clean problem object which is the problem in
- * the second and third possibility.
- *
- * The derived class also
- * has to provide for member functions which declare the entries and which run
- * the program. Running the program includes getting the parameters out of the
- * ParameterHandler object.
+ * As can be seen, first a new helper class has to be set up. This must
+ * contain a virtual constructor for a problem class. You can also derive
+ * your problem class from MultipleParameterLoop::UserClass and let
+ * <tt>create_new</tt> clear all member variables. If you have access to
+ * all inherited member variables in some way this is the recommended
+ * procedure. A third possibility is to use multiple inheritance and
+ * derive a helper class from both the MultipleParameterLoop::UserClass
+ * and the problem class. In any case, <tt>create_new</tt> has to provide
+ * a clean problem object which is the problem in the second and third
+ * possibility.
+ *
+ * The derived class also has to provide for member functions which
+ * declare the entries and which run the program. Running the program
+ * includes getting the parameters out of the ParameterHandler object.
*
* After defining an object of this helper class and an object of the
- * MultipleParameterLoop class, the entries have to be declared in the same way
- * as for the ParameterHandler class. Then the input has to be read. Finally
- * the loop is called. This executes the following steps:
+ * MultipleParameterLoop class, the entries have to be declared in the
+ * same way as for the ParameterHandler class. Then the input has to be
+ * read. Finally the loop is called. This executes the following steps:
* @code
* for (each combination)
* {
* UserObject.run (*this);
* }
* @endcode
- * <tt>UserObject</tt> is the parameter to the <tt>loop</tt> function. <tt>create_new</tt> is given the number
- * of the run (starting from one) to enable naming output files differently for each
- * run.
+ * <tt>UserObject</tt> is the parameter to the <tt>loop</tt> function.
+ * <tt>create_new</tt> is given the number of the run (starting from one)
+ * to enable naming output files differently for each run.
*
*
* <h3>Syntax for variant and array entry values</h3>
*
* <h3>Worked example</h3>
*
- * Given the above extensions to the example program for the ParameterHandler and the
- * following input file
+ * Given the above extensions to the example program for the
+ * ParameterHandler and the following input file
* @verbatim
* set Equation 1 = Poisson
* set Equation 2 = Navier-Stokes
* eq1=Poisson, eq2=Navier-Stokes
* Matrix1=Sparse, Matrix2=Full
* @endverbatim
- * Since <tt>create_new</tt> gets the number of the run it would also be possible to output
- * the number of the run.
+ * Since <tt>create_new</tt> gets the number of the run it would also be
+ * possible to output the number of the run.
*
*
* @ingroup input
{
public:
/**
- * This is the class the helper class or the
- * problem class has to be derived of.
+ * This is the class the helper class or the problem class has to be
+ * derived of.
*/
class UserClass
{
public:
/**
- * Destructor. It doesn't actually do
- * anything, but is declared to force
- * derived classes to have a virtual
- * destructor.
+ * Destructor. It doesn't actually do anything, but is declared to
+ * force derived classes to have a virtual destructor.
*/
virtual ~UserClass ();
/**
- * <tt>create_new</tt> must provide a clean
- * object, either by creating a new one
- * or by cleaning an old one.
+ * <tt>create_new</tt> must provide a clean object, either by creating
+ * a new one or by cleaning an old one.
*/
virtual void create_new (const unsigned int run_no) = 0;
/**
- * This should declare parameters and call
- * the <tt>declare_parameters</tt> function of the
- * problem class.
+ * This should declare parameters and call the
+ * <tt>declare_parameters</tt> function of the problem class.
*/
virtual void declare_parameters (ParameterHandler &prm) = 0;
/**
- * Get the parameters and run any
- * necessary action.
+ * Get the parameters and run any necessary action.
*/
virtual void run (ParameterHandler &prm) = 0;
};
MultipleParameterLoop ();
/**
- * Destructor. Declare this only to have
- * a virtual destructor, which is safer
- * as we have virtual functions.
- * It actually does nothing spectacular.
+ * Destructor. Declare this only to have a virtual destructor, which is
+ * safer as we have virtual functions. It actually does nothing
+ * spectacular.
*/
virtual ~MultipleParameterLoop ();
- virtual bool read_input (std::istream &Input);
+ /**
+ * Read input from a stream until the stream returns the <tt>eof</tt> condition
+ * or error. The second argument can be used to denote the name of the file
+ * (if that's what the input stream represents) we are reading from; this
+ * is only used when creating output for error messages.
+ *
+ * Return whether the read was successful.
+ */
+ virtual bool read_input (std::istream &input,
+ const std::string &filename = "input file");
+
+ /**
+ * Read input from a file the name of which is given. The PathSearch
+ * class "PARAMETERS" is used to find the file.
+ *
+ * Return whether the read was successful.
+ *
+ * Unless <tt>optional</tt> is <tt>true</tt>, this function will
+ * automatically generate the requested file with default values if the
+ * file did not exist. This file will not contain additional comments if
+ * <tt>write_stripped_file</tt> is <tt>true</tt>.
+ */
virtual bool read_input (const std::string &FileName,
const bool optional = false,
const bool write_stripped_file = false);
/**
- * Read input from a string in memory. The
- * lines in memory have to be separated by
- * <tt>@\n</tt> characters.
+ * Read input from a string in memory. The lines in memory have to be
+ * separated by <tt>@\n</tt> characters.
*/
virtual bool read_input_from_string (const char *s);
void loop (UserClass &uc);
/**
- * Determine an estimate for
- * the memory consumption (in
- * bytes) of this
+ * Determine an estimate for the memory consumption (in bytes) of this
* object.
*/
std::size_t memory_consumption () const;
private:
/**
- * An object in the list of entries with
- * multiple values.
+ * An object in the list of entries with multiple values.
*/
class Entry
{
public:
/**
- * Declare what a multiple entry
- * is: a variant * entry (in
- * curly braces <tt>{</tt>, <tt>}</tt>) or an
- * array (in double curly braces
+ * Declare what a multiple entry is: a variant * entry (in curly braces
+ * <tt>{</tt>, <tt>}</tt>) or an array (in double curly braces
* <tt>{{</tt>, <tt>}}</tt>).
*/
enum MultipleEntryType
Entry () : type (array) {}
/**
- * Construct an object with given subsection
- * path, name and value. The splitting up
- * into the different variants is done
- * later by <tt>split_different_values</tt>.
+ * Construct an object with given subsection path, name and value. The
+ * splitting up into the different variants is done later by
+ * <tt>split_different_values</tt>.
*/
Entry (const std::vector<std::string> &Path,
const std::string &Name,
const std::string &Value);
/**
- * Split the entry value into the different
- * branches.
+ * Split the entry value into the different branches.
*/
void split_different_values ();
std::string entry_value;
/**
- * List of entry values constructed out of
- * what was given in the input file (that
- * is stored in EntryValue.
+ * List of entry values constructed out of what was given in the input
+ * file (that is stored in EntryValue.
*/
std::vector<std::string> different_values;
/**
- * Store whether this entry is a variant
- * entry or an array.
+ * Store whether this entry is a variant entry or an array.
*/
MultipleEntryType type;
/**
- * Determine an estimate for
- * the memory consumption (in
- * bytes) of this
+ * Determine an estimate for the memory consumption (in bytes) of this
* object.
*/
std::size_t memory_consumption () const;
std::vector<Entry> multiple_choices;
/**
- * Number of branches constructed
- * from the different
- * combinations of the variants.
- * This obviously equals the
- * number of runs to be
- * performed.
+ * Number of branches constructed from the different combinations of the
+ * variants. This obviously equals the number of runs to be performed.
*/
unsigned int n_branches;
/**
- * Initialize the different
- * branches, i.e. construct the
- * combinations.
+ * Initialize the different branches, i.e. construct the combinations.
*/
void init_branches ();
/**
- * Traverse the section currently
- * set by
- * enter_subsection()/leave_subsection()
- * and see which of the entries
- * are variante/array
- * entries. Then fill the
- * multiple_choices variable
- * using this information.
+ * Traverse the section currently set by
+ * enter_subsection()/leave_subsection() and see which of the entries are
+ * variante/array entries. Then fill the multiple_choices variable using
+ * this information.
*/
void init_branches_current_section ();
/**
- * Transfer the entry values for one run
- * to the entry tree.
+ * Transfer the entry values for one run to the entry tree.
*/
void fill_entry_values (const unsigned int run_no);
};
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2007, 2009, 2012 by the deal.II authors
+// Copyright (C) 2007 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__parsed_function_h
#define __deal2__parsed_function_h
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2011, 2012, 2013 by deal.II authors
+// Copyright (C) 2011 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__partitioner_h
#define __deal2__partitioner_h
* where other processors might require information from. In a
* sense, these import indices form the dual of the ghost
* indices. This information is gathered once when constructing the
- * partitioner, which obviates subsequent global communcation steps
+ * partitioner, which obviates subsequent global communication steps
* when exchanging data.
*
- * The partitioner includes a mechanism for converting global to
- * local and local to global indices. The storage convention for the
- * partitioner is as follows. The local range is associated with
+ * The partitioner includes a mechanism for converting global to local and
+ * local to global indices. Internally, this class stores vector elements
+ * using the convention as follows: The local range is associated with
* local indices [0,@p local_size), and ghost indices are stored
* consecutively in [@p local_size, @p local_size + @p
* n_ghost_indices). The ghost indices are sorted according to their
* Returns the MPI communicator underlying the
* partitioner object.
*/
- const MPI_Comm& get_communicator() const;
+ const MPI_Comm &get_communicator() const;
/**
* Computes the memory consumption of this
*/
DeclException2 (ExcIndexNotPresent,
types::global_dof_index,
- unsigned int,
+ unsigned int,
<< "Global index " << arg1
<< " neither owned nor ghost on proc " << arg2);
{
types::global_dof_index size= local_range_data.second - local_range_data.first;
Assert(size<=std::numeric_limits<unsigned int>::max(),
- ExcNotImplemented());
+ ExcNotImplemented());
return static_cast<unsigned int>(size);
}
inline
- const MPI_Comm&
+ const MPI_Comm &
Partitioner::get_communicator() const
{
return communicator;
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2007, 2008, 2012 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__path_search_h
#define __deal2__path_search_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2010, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__point_h
#define __deal2__point_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__polynomial_h
#define __deal2__polynomial_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2009, 2012 by the deal.II authors
+// Copyright (C) 2002 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__polynomial_space_h
#define __deal2__polynomial_space_h
* p<sub>i</sub>(x)p<sub>j</sub>(y)p<sub>k</sub>(z)</i>.
*/
void compute_index (const unsigned int n,
- unsigned int (&index)[dim]) const;
+ unsigned int (&index)[dim>0?dim:1]) const;
private:
/**
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2010, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__polynomials_abf_h
#define __deal2__polynomials_abf_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2012 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__polynomials_adini_h
#define __deal2__polynomials_adini_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__polynomials_BDM_h
#define __deal2__polynomials_BDM_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__polynomials_nedelec_h
#define __deal2__polynomials_nedelec_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2009, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__polynomials_P_h
#define __deal2__polynomials_P_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__polynomials_piecewise_h
#define __deal2__polynomials_piecewise_h
y = offset+step+step-x;
}
else
- {
+ {
const number offset = step * interval;
if (x<offset || x>offset+step)
return 0;
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__polynomials_raviart_thomas_h
#define __deal2__polynomials_raviart_thomas_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2012 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__qprojector_h
#define __deal2__qprojector_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__quadrature_h
#define __deal2__quadrature_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__quadrature_lib_h
#define __deal2__quadrature_lib_h
* $[x_0,1]$, the actual location of the
* singularity, the scale factor inside
* the logarithmic function and a flag
- * that decides wether the singularity is
+ * that decides whether the singularity is
* left inside the quadrature formula or
* it is factored out, to be included in
* the integrand.
* original quadrature, and this process is repeated for the next half
* element.
*
- * Upon construction it is possible to specify wether we want the
+ * Upon construction it is possible to specify whether we want the
* singularity removed, or not. In other words, this quadrature can be
* used to integrate $g(x) = 1/R\ f(x)$, or simply $f(x)$, with the $1/R$
* factor already included in the quadrature weights.
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__quadrature_selector_h
#define __deal2__quadrature_selector_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__smartpointer_h
#define __deal2__smartpointer_h
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__std_cxx1x_array_h
#define __deal2__std_cxx1x_array_h
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__std_cxx1x_bind_h
#define __deal2__std_cxx1x_bind_h
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__std_cxx1x_condition_variable_h
#define __deal2__std_cxx1x_condition_variable_h
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__std_cxx1x_function_h
#define __deal2__std_cxx1x_function_h
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__std_cxx1x_mutex_h
#define __deal2__std_cxx1x_mutex_h
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__std_cxx1x_shared_ptr_h
#define __deal2__std_cxx1x_shared_ptr_h
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__std_cxx1x_thread_h
#define __deal2__std_cxx1x_thread_h
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__std_cxx1x_tuple_h
#define __deal2__std_cxx1x_tuple_h
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2012 by the deal.II authors
+// Copyright (C) 2012 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__std_cxx1x_type_traits_h
#define __deal2__std_cxx1x_type_traits_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2010, 2012, 2013 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__subscriptor_h
#define __deal2__subscriptor_h
* same. The handling in SmartPointer will take care of this.
*
* @note Due to a problem with <tt>volatile</tt> declarations, this
- * additional feature is switched of if multithreading is used.
+ * additional feature is switched off if multithreading is used.
*
* @ingroup memory
* @author Guido Kanschat, 1998 - 2005
int, char *, std::string &,
<< "Object of class " << arg2
<< " is still used by " << arg1 << " other objects.\n"
- << "(Additional information: " << arg3 << ")\n"
- << "Note the entry in the Frequently Asked Questions of "
- << "deal.II (linked to from http://www.dealii.org/) for "
- << "more information on what this error means.");
+ << "(Additional information: " << arg3 << ")\n"
+ << "Note the entry in the Frequently Asked Questions of "
+ << "deal.II (linked to from http://www.dealii.org/) for "
+ << "more information on what this error means.");
/**
* A subscriber with the
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__symmetric_tensor_h
#define __deal2__symmetric_tensor_h
* one.
*
* If the present object is a
- * rank-4 tensor, the the result
- * is a rank-2 tensor, the
+ * rank-4 tensor, then the result
+ * is a rank-2 tensor, i.e., the
* operation contracts over the
* last two indices of the
* present object and the indices
return tt;
}
+/**
+ * Compute the scalar product $a:b=\sum_{i,j} a_{ij}b_{ij}$ between two
+ * tensors $a,b$ of rank 2. In the current case where both arguments are
+ * symmetric tensors, this is equivalent to calling the expression
+ * <code>t1*t2</code> which uses the overloaded <code>operator*</code>
+ * between two symmetric tensors of rank 2.
+ *
+ * @relates SymmetricTensor
+ */
+template <int dim, typename Number>
+inline
+Number
+scalar_product (const SymmetricTensor<2,dim,Number> &t1,
+ const SymmetricTensor<2,dim,Number> &t2)
+{
+ return (t1*t2);
+}
+
+
+/**
+ * Compute the scalar product $a:b=\sum_{i,j} a_{ij}b_{ij}$ between two
+ * tensors $a,b$ of rank 2. We don't use <code>operator*</code> for this
+ * operation since the product between two tensors is usually assumed to be
+ * the contraction over the last index of the first tensor and the first index
+ * of the second tensor, for example $(a\cdot b)_{ij}=\sum_k a_{ik}b_{kj}$.
+ *
+ * @relates Tensor
+ * @relates SymmetricTensor
+ */
+template <int dim, typename Number>
+inline
+Number
+scalar_product (const SymmetricTensor<2,dim,Number> &t1,
+ const Tensor<2,dim,Number> &t2)
+{
+ Number s = 0;
+ for (unsigned int i=0; i<dim; ++i)
+ for (unsigned int j=0; j<dim; ++j)
+ s += t1[i][j] * t2[i][j];
+ return s;
+}
+
+/**
+ * Compute the scalar product $a:b=\sum_{i,j} a_{ij}b_{ij}$ between two
+ * tensors $a,b$ of rank 2. We don't use <code>operator*</code> for this
+ * operation since the product between two tensors is usually assumed to be
+ * the contraction over the last index of the first tensor and the first index
+ * of the second tensor, for example $(a\cdot b)_{ij}=\sum_k a_{ik}b_{kj}$.
+ *
+ * @relates Tensor
+ * @relates SymmetricTensor
+ */
+template <int dim, typename Number>
+inline
+Number
+scalar_product (const Tensor<2,dim,Number> &t1,
+ const SymmetricTensor<2,dim,Number> &t2)
+{
+ return scalar_product(t2, t1);
+}
/**
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2009, 2012 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__synchronous_iterator_h
#define __deal2__synchronous_iterator_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2002 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__table_h
#define __deal2__table_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2011, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__table_handler_h
#define __deal2__table_handler_h
* 2 13 a
* 1 0 ""
* @endcode
- *
- **/
+ * - <code>org_mode_table</code>: Outputs to org-mode (http://orgmode.org/) table
+ * format. It is easy to convert org-mode tables to HTML/LaTeX/csv.
+ * Example output:
+ * @code
+ * | key1 | key2 | key3 |
+ * | 0 | 0 | "" |
+ * | 1 | 0 | "" |
+ * | 2 | 13 | a |
+ * | 1 | 0 | "" |
+ * @endcode
+ */
enum TextOutputFormat
{
table_with_headers,
table_with_separate_column_description,
- simple_table_with_separate_column_description
+ simple_table_with_separate_column_description,
+ org_mode_table
};
/**
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2009, 2012 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__table_indices_h
#define __deal2__table_indices_h
*/
unsigned int operator[] (const unsigned int i) const;
+ /**
+ * Write access the value of the
+ * <tt>i</tt>th index.
+ */
+ unsigned int &operator[] (const unsigned int i);
+
/**
* Compare two index fields for
* equality.
return indices[i];
}
+template <int N>
+inline
+unsigned int &
+TableIndicesBase<N>::operator [] (const unsigned int i)
+{
+ Assert (i < N, ExcIndexRange (i, 0, N));
+ return indices[i];
+}
template <int N>
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2012 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__template_constraints_h
#define __deal2__template_constraints_h
* template <>
* void X<dim>::f<0> () { ...operate on the vertices of a cell... }
*
- * template <int dim, int subdim> void f(X<dim> &x) {
+ * template <int dim, int subdim> void g(X<dim> &x) {
* x.f<subdim> ();
* }
* @endcode
* template <int dim>
* void X<dim>::f (int2type<1>) { ...operate on the lines of a cell... }
*
- * template <int dim, int subdim> void f(X<dim> &x) {
+ * template <int dim, int subdim> void g(X<dim> &x) {
* x.f (int2type<subdim>());
* }
* @endcode
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2011, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__tensor_h
#define __deal2__tensor_h
*/
static const unsigned int rank = rank_;
+ /**
+ * Number of independent components of a
+ * tensor of current rank. This is dim times the
+ * number of independent components of each sub-tensor.
+ */
+ static const unsigned int
+ n_independent_components = Tensor<rank_-1,dim>::n_independent_components *dim;
+
/**
* Type of stored objects. This
* is a tensor of lower rank.
*/
const Tensor<rank_-1,dim,Number> &operator [] (const unsigned int i) const;
+ /**
+ * Read access using TableIndices <tt>indices</tt>
+ */
+ Number operator [](const TableIndices<rank_> &indices) const;
+
+ /**
+ * Read and write access using TableIndices <tt>indices</tt>
+ */
+ Number &operator [](const TableIndices<rank_> &indices);
+
/**
* Assignment operator.
*/
template <typename Number2>
void unroll (Vector<Number2> &result) const;
+ /**
+ * Returns an unrolled index in
+ * the range [0,dim^rank-1] for the element of the tensor indexed by
+ * the argument to the function.
+ */
+ static
+ unsigned int
+ component_to_unrolled_index(const TableIndices<rank_> &indices);
+
+ /**
+ * Opposite of component_to_unrolled_index: For an index in the
+ * range [0,dim^rank-1], return which set of indices it would
+ * correspond to.
+ */
+ static
+ TableIndices<rank_> unrolled_to_component_indices(const unsigned int i);
+
+
/**
* Reset all values to zero.
return subtensor[i];
}
+template <int rank_, int dim, typename Number>
+inline
+Number
+Tensor<rank_,dim,Number>::operator[] (const TableIndices<rank_> &indices) const
+{
+ const unsigned int inner_ind = indices[0];
+ Assert (inner_ind<dim, ExcIndexRange(inner_ind, 0, dim));
+ TableIndices<rank_-1> indices1;
+ for (unsigned int i = 0; i < rank_-1; i++)
+ indices1[i] = indices[i+1];
+ return (subtensor[inner_ind])[indices1];
+}
+
+template <int rank_, int dim, typename Number>
+inline
+Number &
+Tensor<rank_,dim,Number>::operator[] (const TableIndices<rank_> &indices)
+{
+ const unsigned int inner_ind = indices[0];
+ Assert (inner_ind<dim, ExcIndexRange(inner_ind, 0, dim));
+
+ TableIndices<rank_-1> indices1;
+ for (unsigned int i = 0; i < rank_-1; i++)
+ indices1[i] = indices[i+1];
+ return (subtensor[inner_ind])[indices1];
+}
template <int rank_, int dim, typename Number>
inline
}
}
+template <int rank_, int dim, typename Number>
+inline
+unsigned int
+Tensor<rank_, dim, Number>::component_to_unrolled_index(const TableIndices<rank_> &indices)
+{
+ TableIndices<rank_-1> indices1;
+ for (unsigned int i = 0; i < rank_-1; i++)
+ indices1[i] = indices[i];
+
+ Assert (indices[rank_-1] < dim,
+ ExcIndexRange (indices[rank_-1], 0, dim));
+ return ( Tensor<rank_-1,dim,Number>::component_to_unrolled_index(indices1) * dim + indices[rank_-1]);
+}
+
+template <int rank_, int dim, typename Number>
+inline
+TableIndices<rank_>
+Tensor<rank_, dim, Number>::unrolled_to_component_indices(const unsigned int i)
+{
+ Assert (i < n_independent_components,
+ ExcIndexRange (i, 0, n_independent_components));
+
+ TableIndices<rank_> indices;
+
+ unsigned int remainder = i;
+ for (int r=rank_-1; r>=0; --r)
+ {
+ indices[r] = (remainder % dim);
+ remainder /= dim;
+ }
+ Assert (remainder == 0, ExcInternalError());
+
+ return indices;
+}
+
template <int rank_, int dim, typename Number>
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__tensor_base_h
#define __deal2__tensor_base_h
#include <deal.II/base/config.h>
#include <deal.II/base/exceptions.h>
+#include <deal.II/base/table_indices.h>
#include <vector>
#include <cmath>
*/
static const unsigned int rank = 1;
+ /**
+ * Number of independent components of a
+ * tensor of rank 1.
+ */
+ static const unsigned int
+ n_independent_components = dim;
+
/**
* Type of stored objects. This
* is a Number for a rank 1 tensor.
*/
Number &operator [] (const unsigned int index);
+ /**
+ * Read access using TableIndices <tt>indices</tt>
+ */
+ Number operator [](const TableIndices<1> &indices) const;
+
+ /**
+ * Read and write access using TableIndices <tt>indices</tt>
+ */
+ Number &operator [](const TableIndices<1> &indices);
+
/**
* Assignment operator.
*/
template <typename Number2>
void unroll (Vector<Number2> &result) const;
+ /**
+ * Returns an unrolled index in
+ * the range [0,dim-1] for the element of the tensor indexed by
+ * the argument to the function.
+ *
+ * Given that this is a rank-1 object, the returned value
+ * is simply the value of the only index stored by the argument.
+ */
+ static
+ unsigned int
+ component_to_unrolled_index(const TableIndices<1> &indices);
+
+ /**
+ * Opposite of component_to_unrolled_index: For an index in the
+ * range [0,dim-1], return which set of indices it would
+ * correspond to.
+ *
+ * Given that this is a rank-1 object, the returned set of indices
+ * consists of only a single element with value equal to the argument
+ * to this function.
+ */
+ static
+ TableIndices<1> unrolled_to_component_indices(const unsigned int i);
+
+
/**
* Determine an estimate for
* the memory consumption (in
return values[index];
}
+template <int dim, typename Number>
+inline
+Number Tensor<1,dim,Number>::operator [] (const TableIndices<1> &indices) const
+{
+ Assert (indices[0]<dim, ExcIndexRange (indices[0], 0, dim));
+ return values[indices[0]];
+}
+
+template <int dim, typename Number>
+inline
+Number &Tensor<1,dim,Number>::operator [] (const TableIndices<1> &indices)
+{
+ Assert (indices[0]<dim, ExcIndexRange (indices[0], 0, dim));
+ return values[indices[0]];
+}
+
template <>
}
+template <int dim, typename Number>
+inline
+unsigned int
+Tensor<1, dim, Number>::component_to_unrolled_index (const TableIndices<1> &indices)
+{
+ return indices[0];
+}
+
+template <int dim, typename Number>
+inline
+TableIndices<1>
+Tensor<1, dim, Number>::unrolled_to_component_indices (const unsigned int i)
+{
+ return TableIndices<1>(i);
+}
+
+
template <int dim, typename Number>
inline
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__tensor_function_h
#define __deal2__tensor_function_h
{
public:
/**
- * Define typedefs for the return
- * types of the <tt>value</tt>
- * functions.
+ * Define typedefs for the return types of the <tt>value</tt> functions.
*/
typedef Tensor<rank,dim> value_type;
typedef Tensor<rank+1,dim> gradient_type;
/**
- * Constructor. May take an
- * initial value for the time
- * variable, which defaults to
- * zero.
+ * Constructor. May take an initial value for the time variable, which
+ * defaults to zero.
*/
TensorFunction (const double initial_time = 0.0);
/**
- * Virtual destructor; absolutely
- * necessary in this case, as
- * classes are usually not used
- * by their true type, but rather
- * through pointers to this base
- * class.
+ * Virtual destructor; absolutely necessary in this case, as classes are
+ * usually not used by their true type, but rather through pointers to
+ * this base class.
*/
virtual ~TensorFunction ();
/**
- * Return the value of the function
- * at the given point.
+ * Return the value of the function at the given point.
*/
virtual value_type value (const Point<dim> &p) const;
/**
- * Set <tt>values</tt> to the point
- * values of the function at the
- * <tt>points</tt>. It is assumed
- * that <tt>values</tt> already has
- * the right size, i.e. the same
- * size as the <tt>points</tt> array.
+ * Set <tt>values</tt> to the point values of the function at the
+ * <tt>points</tt>. It is assumed that <tt>values</tt> already has the
+ * right size, i.e. the same size as the <tt>points</tt> array.
*/
virtual void value_list (const std::vector<Point<dim> > &points,
std::vector<value_type> &values) const;
/**
- * Return the gradient of the
- * function at the given point.
+ * Return the gradient of the function at the given point.
*/
virtual gradient_type gradient (const Point<dim> &p) const;
/**
- * Set <tt>gradients</tt> to the
- * gradients of the function at
- * the <tt>points</tt>. It is assumed
- * that <tt>values</tt> already has
- * the right size, i.e. the same
- * size as the <tt>points</tt> array.
+ * Set <tt>gradients</tt> to the gradients of the function at the
+ * <tt>points</tt>. It is assumed that <tt>values</tt> already has the
+ * right size, i.e. the same size as the <tt>points</tt> array.
*/
virtual void gradient_list (const std::vector<Point<dim> > &points,
std::vector<gradient_type> &gradients) const;
};
+
+
+/**
+ * Provide a tensor valued function which always returns a constant tensor
+ * value. Obviously, all derivates of this function are zero.
+ *
+ * @ingroup functions
+ * @author Matthias Maier, 2013
+ */
+template <int rank, int dim>
+class ConstantTensorFunction : public TensorFunction<rank, dim>
+{
+public:
+ /**
+ * Constructor; takes the constant tensor value as an argument.
+ * The reference value is copied internally.
+ *
+ * An initial value for the time variable may be specified, otherwise it
+ * defaults to zero.
+ */
+ ConstantTensorFunction (const dealii::Tensor<rank, dim> &value,
+ const double initial_time = 0.0);
+
+ virtual ~ConstantTensorFunction ();
+
+ virtual typename dealii::TensorFunction<rank, dim>::value_type value (const Point<dim> &p) const;
+
+ virtual void value_list (const std::vector<Point<dim> > &points,
+ std::vector<typename dealii::TensorFunction<rank, dim>::value_type> &values) const;
+
+ virtual typename dealii::TensorFunction<rank, dim>::gradient_type gradient (const Point<dim> &p) const;
+
+ virtual void gradient_list (const std::vector<Point<dim> > &points,
+ std::vector<typename dealii::TensorFunction<rank, dim>::gradient_type> &gradients) const;
+
+private:
+ const dealii::Tensor<rank, dim> _value;
+};
+
+
+
+/**
+ * Provide a tensor valued function which always returns zero.
+ * Obviously, all derivates of this function are zero.
+ *
+ * @ingroup functions
+ * @author Matthias Maier, 2013
+ */
+template <int rank, int dim>
+class ZeroTensorFunction : public ConstantTensorFunction<rank, dim>
+{
+public:
+ /**
+ * Constructor.
+ *
+ * An initial value for the time variable may be specified, otherwise it
+ * defaults to zero.
+ */
+ ZeroTensorFunction (const double initial_time = 0.0);
+};
+
+
DEAL_II_NAMESPACE_CLOSE
#endif
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__tensor_product_polynomials_h
#define __deal2__tensor_product_polynomials_h
-//---------------------------------------------------------------------------
-// $Id: tensor_product_polynomials.h 27628 2012-11-20 22:49:26Z heister $
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2012, 2013 by the deal.II authors
+// Copyright (C) 2012 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__tensor_product_polynomials_const_h
#define __deal2__tensor_product_polynomials_const_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2011, 2012 by the deal.II authors
+// Copyright (C) 2011 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__thread_local_storage_h
#define __deal2__thread_local_storage_h
namespace Threads
{
- template <typename T>
/**
* @brief A class that provides a separate storage location on each thread that accesses the object.
*
* provides a reference to a unique object when accessed from different threads.
* Objects of type T are created lazily, i.e. they are only created whenever a
* thread actually calls get().
- **/
+ */
+ template <typename T>
class ThreadLocalStorage
{
public:
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__thread_management_h
#define __deal2__thread_management_h
// descriptor
// object. if all
// Threads::Thread
- // object that
+ // objects that
// pointed here
// should have gone
// out of scope
inline
internal::fun_encapsulator<RT,
std_cxx1x::tuple<Arg1, Arg2, Arg3, Arg4, Arg5, Arg6>,6>
- spawn (const C &c, RT (C::*fun_ptr)(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6) const) DEAL_II_DEPRECATED;
+ spawn (const C &c, RT (C::*fun_ptr)(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6) const) DEAL_II_DEPRECATED;
template <typename RT, typename C,
inline
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1, Arg2, Arg3,
Arg4, Arg5, Arg6, Arg7>,7>
- spawn (RT (*fun_ptr)(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7)) DEAL_II_DEPRECATED;
+ spawn (RT (*fun_ptr)(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7)) DEAL_II_DEPRECATED;
template <typename RT,
- typename Arg1, typename Arg2, typename Arg3,
- typename Arg4, typename Arg5, typename Arg6,
- typename Arg7>
+ typename Arg1, typename Arg2, typename Arg3,
+ typename Arg4, typename Arg5, typename Arg6,
+ typename Arg7>
inline
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1, Arg2, Arg3,
Arg4, Arg5, Arg6, Arg7>,7>
inline
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1, Arg2, Arg3,
Arg4, Arg5, Arg6, Arg7>,7>
- spawn (C &c, RT (C::*fun_ptr)(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7)) DEAL_II_DEPRECATED;
+ spawn (C &c, RT (C::*fun_ptr)(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7)) DEAL_II_DEPRECATED;
template <typename RT, typename C,
- typename Arg1, typename Arg2, typename Arg3,
- typename Arg4, typename Arg5, typename Arg6,
- typename Arg7>
+ typename Arg1, typename Arg2, typename Arg3,
+ typename Arg4, typename Arg5, typename Arg6,
+ typename Arg7>
inline
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1, Arg2, Arg3,
Arg4, Arg5, Arg6, Arg7>,7>
internal::fun_encapsulator<RT,
std_cxx1x::tuple<Arg1, Arg2, Arg3,
Arg4, Arg5, Arg6, Arg7>,7>
- spawn (const C &c, RT (C::*fun_ptr)(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7) const) DEAL_II_DEPRECATED;
+ spawn (const C &c, RT (C::*fun_ptr)(Arg1,Arg2,Arg3,Arg4,Arg5,Arg6,Arg7) const) DEAL_II_DEPRECATED;
template <typename RT, typename C,
- typename Arg1, typename Arg2, typename Arg3,
- typename Arg4, typename Arg5, typename Arg6,
- typename Arg7>
+ typename Arg1, typename Arg2, typename Arg3,
+ typename Arg4, typename Arg5, typename Arg6,
+ typename Arg7>
inline
internal::fun_encapsulator<RT,
std_cxx1x::tuple<Arg1, Arg2, Arg3,
template <typename RT,
- typename Arg1, typename Arg2, typename Arg3,
- typename Arg4, typename Arg5, typename Arg6,
- typename Arg7, typename Arg8>
+ typename Arg1, typename Arg2, typename Arg3,
+ typename Arg4, typename Arg5, typename Arg6,
+ typename Arg7, typename Arg8>
inline
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1, Arg2, Arg3,
Arg4, Arg5, Arg6,
template <typename RT, typename C,
- typename Arg1, typename Arg2, typename Arg3,
- typename Arg4, typename Arg5, typename Arg6,
- typename Arg7, typename Arg8>
+ typename Arg1, typename Arg2, typename Arg3,
+ typename Arg4, typename Arg5, typename Arg6,
+ typename Arg7, typename Arg8>
inline
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1, Arg2, Arg3,
Arg4, Arg5, Arg6,
template <typename RT, typename C,
- typename Arg1, typename Arg2, typename Arg3,
- typename Arg4, typename Arg5, typename Arg6,
- typename Arg7, typename Arg8>
+ typename Arg1, typename Arg2, typename Arg3,
+ typename Arg4, typename Arg5, typename Arg6,
+ typename Arg7, typename Arg8>
inline
internal::fun_encapsulator<RT,
std_cxx1x::tuple<Arg1, Arg2, Arg3,
template <typename RT,
- typename Arg1, typename Arg2, typename Arg3,
- typename Arg4, typename Arg5, typename Arg6,
- typename Arg7, typename Arg8, typename Arg9>
+ typename Arg1, typename Arg2, typename Arg3,
+ typename Arg4, typename Arg5, typename Arg6,
+ typename Arg7, typename Arg8, typename Arg9>
inline
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1, Arg2, Arg3,
Arg4, Arg5, Arg6,
template <typename RT, typename C,
- typename Arg1, typename Arg2, typename Arg3,
- typename Arg4, typename Arg5, typename Arg6,
- typename Arg7, typename Arg8, typename Arg9>
+ typename Arg1, typename Arg2, typename Arg3,
+ typename Arg4, typename Arg5, typename Arg6,
+ typename Arg7, typename Arg8, typename Arg9>
inline
internal::fun_encapsulator<RT,std_cxx1x::tuple<Arg1, Arg2, Arg3,
Arg4, Arg5, Arg6,
template <typename RT, typename C,
- typename Arg1, typename Arg2, typename Arg3,
- typename Arg4, typename Arg5, typename Arg6,
- typename Arg7, typename Arg8, typename Arg9>
+ typename Arg1, typename Arg2, typename Arg3,
+ typename Arg4, typename Arg5, typename Arg6,
+ typename Arg7, typename Arg8, typename Arg9>
inline
internal::fun_encapsulator<RT,
std_cxx1x::tuple<Arg1, Arg2, Arg3,
template <typename RT = void>
class Task
{
+ public:
/**
* Construct a task object
* given a function object to
* execute on the task.
*/
- public:
Task (const std_cxx1x::function<RT ()> &function_object)
{
// create a task descriptor and tell it
task_descriptor->queue_task ();
}
+
+ /**
+ * Copy constructor.
+ */
+ Task (const Task<RT> &t)
+ :
+ task_descriptor (t.task_descriptor)
+ {}
+
+
/**
* Default constructor. You
* can't do much with a task
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__timer_h
#define __deal2__timer_h
/**
* Reference to the TimerOutput object
*/
- dealii::TimerOutput & timer;
+ dealii::TimerOutput &timer;
/**
* Do we still need to exit the section we are in?
*/
inline
TimerOutput::Scope::Scope(dealii::TimerOutput &timer_, const std::string §ion_name)
-:
-timer(timer_), in(true)
+ :
+ timer(timer_), in(true)
{
timer.enter_section(section_name);
}
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2012, 2013 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__types_h
#define __deal2__types_h
* The data type always indicates an
* unsigned integer type.
*/
- typedef unsigned int global_dof_index;
+ typedef unsigned int global_dof_index;
- /**
- * An identifier that denotes the MPI type
- * associated with types::global_dof_index.
- */
+ /**
+ * An identifier that denotes the MPI type
+ * associated with types::global_dof_index.
+ */
# define DEAL_II_DOF_INDEX_MPI_TYPE MPI_UNSIGNED
#endif
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__utilities_h
#define __deal2__utilities_h
* templates.
*
* Use this class as in
- * <code>fixed_int_power@<5,2@>::value</code>
+ * <code>fixed_int_power@<5,2@>::%value</code>
* to compute 5<sup>2</sup>.
*/
template <int a, int N>
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2010, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__vector_slice_h
#define __deal2__vector_slice_h
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2011 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__vectorization_h
#define __deal2__vectorization_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2009, 2010, 2012, 2013 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__work_stream_h
#define __deal2__work_stream_h
#include <deal.II/base/config.h>
+#include <deal.II/base/graph_coloring.h>
#include <deal.II/base/multithread_info.h>
#include <deal.II/base/thread_management.h>
#include <deal.II/base/template_constraints.h>
#include <deal.II/base/std_cxx1x/function.h>
#include <deal.II/base/std_cxx1x/bind.h>
+#include <deal.II/base/thread_local_storage.h>
#ifdef DEAL_II_WITH_THREADS
# include <deal.II/base/thread_management.h>
#include <vector>
#include <utility>
+#include <memory>
DEAL_II_NAMESPACE_OPEN
#ifdef DEAL_II_WITH_THREADS
-
namespace internal
{
+
+//TODO: The following classes all use std_cxx1x::shared_ptr, but the
+// correct pointer class would actually be std::unique_ptr. make this
+// replacement whenever we have a class that provides these semantics
+// and that is available also as a fall-back whenever via boost or similar
+
/**
* A class that creates a sequence of
* items from a range of iterators.
public:
/**
* A data type that we use to identify
- * items to be worked on.
- *
- * The first element indicates an array
- * of iterators to work on; the second
- * the scratch space; the third an
- * array of copy data spaces; and the
- * last the number of elements to work
- * on. This last argument is an integer
- * between one and chunk_size. The
- * arrays have a length of chunk_size.
+ * items to be worked on. This is the structure
+ * that is passed around between the different parts of
+ * the WorkStream implementation to identify what needs
+ * to be done by the various stages of the pipeline.
*/
- typedef
- std_cxx1x::tuple<std::vector<Iterator>,
- ScratchData *,
- std::vector<CopyData>,
- unsigned int>
- ItemType;
+ struct ItemType
+ {
+ /**
+ * A structure that contains a pointer to a scratch data object along
+ * with a flag that indicates whether this object is currently in use.
+ */
+ struct ScratchDataObject
+ {
+ std_cxx1x::shared_ptr<ScratchData> scratch_data;
+ bool currently_in_use;
+
+ /**
+ * Default constructor.
+ */
+ ScratchDataObject ()
+ :
+ currently_in_use (false)
+ {}
+
+ ScratchDataObject (ScratchData *p,
+ const bool in_use)
+ :
+ scratch_data (p),
+ currently_in_use (in_use)
+ {}
+
+ ScratchDataObject (const ScratchDataObject &o)
+ :
+ scratch_data (new ScratchData(*o.scratch_data)),
+ currently_in_use (false)
+ {}
+ };
+
+
+ /**
+ * Typedef to a list of scratch data objects. The rationale for this
+ * list is provided in the variables that use these lists.
+ */
+ typedef std::list<ScratchDataObject> ScratchDataList;
+
+ /**
+ * A list of iterators that need to be worked on. Only the first
+ * n_items are relevant.
+ */
+ std::vector<Iterator> work_items;
+
+ /**
+ * The CopyData objects that the Worker part of the pipeline
+ * fills for each work item. Again, only the first n_items
+ * elements are what we care about.
+ */
+ std::vector<CopyData> copy_datas;
+
+ /**
+ * Number of items identified by the work_items array that the
+ * Worker and Copier pipeline stage need to work on. The maximum
+ * value of this variable will be chunk_size.
+ */
+ unsigned int n_items;
+
+ /**
+ * Pointer to a thread local variable identifying the scratch data objects
+ * this thread will use. The initial implementation of this
+ * class using thread local variables provided only a single
+ * scratch object per thread. This doesn't work, because
+ * the worker functions may start tasks itself and then call
+ * Threads::TaskGroup::join_all() or a similar function, which the
+ * TBB scheduler may use to run something else on the current
+ * thread -- for example another instance of the worker function.
+ * Consequently, there would be two instances of the worker
+ * function that use the same scratch object if we only
+ * provided a single scratch object per thread. The solution is
+ * to provide a list of scratch objects for each thread, together
+ * with a flag indicating whether this scratch object is currently
+ * used. If a thread needs a scratch object, it walks this list
+ * until it finds an unused object, or, if there is none, creates one
+ * itself. Note that we need not use synchronization primitives
+ * for this process since the lists are thread-local and
+ * we are guaranteed that only a single thread accesses them as long
+ * as we have no yield point in between the accesses to the list.
+ *
+ * The pointers to scratch objects stored in each of these lists must
+ * be so that they are deleted on all threads when the thread
+ * local object is destroyed. This is achieved by using shared_ptr.
+ *
+ * Note that when a worker needs to create a scratch object, it allocates
+ * it using sample_scratch_data to copy from. This has
+ * the advantage of a first-touch initialization, i.e., the
+ * memory for the scratch data object is allocated and initialized
+ * by the same thread that will later use it.
+ */
+ Threads::ThreadLocalStorage<ScratchDataList> *scratch_data;
+
+ /**
+ * Pointer to a sample scratch data object, to be used to initialize
+ * the scratch data objects created for each individual thread.
+ */
+ const ScratchData *sample_scratch_data;
+
+
+ /**
+ * Default constructor.
+ * Initialize everything that doesn't
+ * have a default constructor itself.
+ */
+ ItemType ()
+ :
+ n_items (0),
+ scratch_data (0),
+ sample_scratch_data (0)
+ {}
+ };
/**
* copier function invokation.
*/
IteratorRangeToItemStream (const Iterator &begin,
- const Iterator &end,
- const unsigned int buffer_size,
- const unsigned int chunk_size,
- const ScratchData &sample_scratch_data,
- const CopyData &sample_copy_data)
+ const Iterator &end,
+ const unsigned int buffer_size,
+ const unsigned int chunk_size,
+ const ScratchData &sample_scratch_data,
+ const CopyData &sample_copy_data)
:
- tbb::filter (/*is_serial=*/true),
- remaining_iterator_range (begin, end),
- ring_buffer (buffer_size),
- n_emitted_items (0),
- chunk_size (chunk_size)
+ tbb::filter (/*is_serial=*/true),
+ remaining_iterator_range (new std::pair<Iterator,Iterator> (begin, end)),
+ ring_buffer (buffer_size),
+ sample_scratch_data (sample_scratch_data),
+ color(false),
+ n_emitted_items (0),
+ chunk_size (chunk_size)
{
- // initialize copies of
- // additional_data. since
- // this is frequently
- // expensive (creating
- // FEValues objects etc) do
- // that in parallel
- Threads::TaskGroup<> tasks;
- for (unsigned int i=0; i<ring_buffer.size(); ++i)
- tasks += Threads::new_task (&IteratorRangeToItemStream::init_buffer_elements,
- *this,
- i,
- std_cxx1x::cref(sample_scratch_data),
- std_cxx1x::cref(sample_copy_data));
- tasks.join_all ();
+ // initialize the elements of the ring buffer
+ for (unsigned int element=0; element<ring_buffer.size(); ++element)
+ {
+ Assert (ring_buffer[element].n_items == 0,
+ ExcInternalError());
+
+ ring_buffer[element].work_items.resize (chunk_size,
+ remaining_iterator_range->second);
+ ring_buffer[element].scratch_data = &thread_local_scratch;
+ ring_buffer[element].sample_scratch_data = &sample_scratch_data;
+ ring_buffer[element].copy_datas.resize (chunk_size,
+ sample_copy_data);
+ }
}
- /**
- * Destructor.
- */
- ~IteratorRangeToItemStream ()
+ IteratorRangeToItemStream (const typename std::vector<Iterator>::iterator &begin,
+ const typename std::vector<Iterator>::iterator &end,
+ const unsigned int buffer_size,
+ const unsigned int chunk_size,
+ const ScratchData &sample_scratch_data,
+ const CopyData &sample_copy_data)
+ :
+ tbb::filter (/*is_serial=*/true),
+ color_remaining_iterator_range (new std::pair<typename std::vector<Iterator>::iterator,
+ typename std::vector<Iterator>::iterator> (begin,end)),
+ ring_buffer (buffer_size),
+ sample_scratch_data (sample_scratch_data),
+ color(true),
+ n_emitted_items (0),
+ chunk_size (chunk_size)
{
- for (unsigned int i=0; i<ring_buffer.size(); ++i)
- delete std_cxx1x::get<1>(ring_buffer[i]);
+ for (unsigned int element=0; element<ring_buffer.size(); ++element)
+ {
+ Assert (ring_buffer[element].n_items == 0,
+ ExcInternalError());
+
+ // work_items is templated on iterator. Therefore, the resize must
+ // be done given *(color_remaining_iterator_range->firts) because
+ // iterator may not have a default constructor and
+ // *(color_remaining_iterator_range->second) is invalid.
+ ring_buffer[element].work_items.resize (chunk_size,
+ *(color_remaining_iterator_range->first));
+ ring_buffer[element].scratch_data = &thread_local_scratch;
+ ring_buffer[element].sample_scratch_data = &sample_scratch_data;
+ ring_buffer[element].copy_datas.resize (chunk_size,
+ sample_copy_data);
+ }
}
/**
// initialize the next item. it may
// consist of at most chunk_size
// elements
- std_cxx1x::get<3>(*current_item) = 0;
- while ((remaining_iterator_range.first !=
- remaining_iterator_range.second)
- &&
- (std_cxx1x::get<3>(*current_item) < chunk_size))
+ current_item->n_items = 0;
+ if (color==false)
+ while ((remaining_iterator_range->first !=
+ remaining_iterator_range->second)
+ &&
+ (current_item->n_items < chunk_size))
+ {
+ current_item->work_items[current_item->n_items]
+ = remaining_iterator_range->first;
+
+ ++remaining_iterator_range->first;
+ ++current_item->n_items;
+ }
+ else
+ while ((color_remaining_iterator_range->first !=
+ color_remaining_iterator_range->second)
+ &&
+ (current_item->n_items < chunk_size))
{
- std_cxx1x::get<0>(*current_item)[std_cxx1x::get<3>(*current_item)]
- = remaining_iterator_range.first;
+ current_item->work_items[current_item->n_items]
+ = *(color_remaining_iterator_range->first);
- ++remaining_iterator_range.first;
- ++std_cxx1x::get<3>(*current_item);
+ ++color_remaining_iterator_range->first;
+ ++current_item->n_items;
}
- if (std_cxx1x::get<3>(*current_item) == 0)
+ if (current_item->n_items == 0)
// there were no items
// left. terminate the pipeline
return 0;
else
- {
- ++n_emitted_items;
- return current_item;
- }
+ {
+ ++n_emitted_items;
+ return current_item;
+ }
}
private:
* be worked on. This range will shrink
* over time.
*/
- std::pair<Iterator,Iterator> remaining_iterator_range;
+ std_cxx1x::shared_ptr<std::pair<Iterator,Iterator> > remaining_iterator_range;
+
+ /**
+ * When graph coloring is used the iterators to be worked on are given
+ * in a vector defined by a pair of iterators.
+ */
+ std_cxx1x::shared_ptr<std::pair<typename std::vector<Iterator>::iterator,
+ typename std::vector<Iterator>::iterator> >
+ color_remaining_iterator_range;
/**
* A ring buffer that will store items.
*/
std::vector<ItemType> ring_buffer;
+ /**
+ * Pointer to a thread local variable identifying the scratch data objects
+ * this thread will use. The initial implementation of this
+ * class using thread local variables provided only a single
+ * scratch object per thread. This doesn't work, because
+ * the worker functions may start tasks itself and then call
+ * Threads::TaskGroup::join_all() or a similar function, which the
+ * TBB scheduler may use to run something else on the current
+ * thread -- for example another instance of the worker function.
+ * Consequently, there would be two instances of the worker
+ * function that use the same scratch object if we only
+ * provided a single scratch object per thread. The solution is
+ * to provide a list of scratch objects for each thread, together
+ * with a flag indicating whether this scratch object is currently
+ * used. If a thread needs a scratch object, it walks this list
+ * until it finds an unused object, or, if there is none, creates one
+ * itself. Note that we need not use synchronization primitives
+ * for this process since the lists are thread-local and
+ * we are guaranteed that only a single thread accesses them as long
+ * as we have no yield point in between the accesses to the list.
+ *
+ * The pointers to scratch objects stored in each of these lists must
+ * be so that they are deleted on all threads when the thread
+ * local object is destroyed. This is achieved by using shared_ptr.
+ *
+ * Note that when a worker needs to create a scratch object, it allocates
+ * it using sample_scratch_data to copy from. This has
+ * the advantage of a first-touch initialization, i.e., the
+ * memory for the scratch data object is allocated and initialized
+ * by the same thread that will later use it.
+ */
+ Threads::ThreadLocalStorage<typename ItemType::ScratchDataList> thread_local_scratch;
+
+ /**
+ * A reference to a sample scratch data that will be used to
+ * initialize the thread-local pointers to a scratch data object
+ * each of the worker tasks uses.
+ */
+ const ScratchData &sample_scratch_data;
+
+ /**
+ * This flag is used to know if graph coloring is used or not.
+ */
+ bool color;
+
/**
* Counter for the number of emitted
* items. Each item may consist of up
* to chunk_size iterator elements.
*/
- unsigned int n_emitted_items;
+ unsigned int n_emitted_items;
/**
* Number of elements of the
* the ring buffer.
*/
void init_buffer_elements (const unsigned int element,
- const ScratchData &sample_scratch_data,
- const CopyData &sample_copy_data)
+ const CopyData &sample_copy_data)
{
- Assert (std_cxx1x::get<1>(ring_buffer[element]) == 0,
- ExcInternalError());
-
- std_cxx1x::get<0>(ring_buffer[element])
- .resize (chunk_size, remaining_iterator_range.second);
- std_cxx1x::get<1>(ring_buffer[element])
- = new ScratchData(sample_scratch_data);
- std_cxx1x::get<2>(ring_buffer[element])
- .resize (chunk_size, sample_copy_data);
+ Assert (ring_buffer[element].n_items == 0,
+ ExcInternalError());
+
+ ring_buffer[element].work_items
+ .resize (chunk_size, remaining_iterator_range->second);
+ ring_buffer[element].scratch_data
+ = &thread_local_scratch;
+ ring_buffer[element].sample_scratch_data
+ = &sample_scratch_data;
+ ring_buffer[element].copy_datas
+ .resize (chunk_size, sample_copy_data);
}
};
class Worker : public tbb::filter
{
public:
- /**
- * Constructor. Takes a
- * reference to the object on
- * which we will operate as
- * well as a pointer to the
- * function that will do the
- * assembly.
- */
- Worker (const std_cxx1x::function<void (const Iterator &,
- ScratchData &,
- CopyData &)> &worker)
- :
- tbb::filter (/* is_serial= */ false),
- worker (worker)
- {}
-
-
- /**
- * Work on an item.
- */
- void *operator () (void *item)
- {
- // first unpack the current item
- typedef
- typename IteratorRangeToItemStream<Iterator,ScratchData,CopyData>::ItemType
- ItemType;
-
- ItemType *current_item = static_cast<ItemType *> (item);
-
- // then call the worker function on each element of the chunk we were
- // given. since these worker functions are called on separate threads,
- // nothing good can happen if they throw an exception and we are best
- // off catching it and showing an error message
- for (unsigned int i=0; i<std_cxx1x::get<3>(*current_item); ++i)
- {
- try
- {
- worker (std_cxx1x::get<0>(*current_item)[i],
- *std_cxx1x::get<1>(*current_item),
- std_cxx1x::get<2>(*current_item)[i]);
- }
- catch (const std::exception &exc)
- {
- Threads::internal::handle_std_exception (exc);
- }
- catch (...)
- {
- Threads::internal::handle_unknown_exception ();
- }
- }
-
- // then return the original pointer
- // to the now modified object
- return item;
- }
-
-
- private:
- /**
- * Pointer to the function
- * that does the assembling
- * on the sequence of cells.
- */
- const std_cxx1x::function<void (const Iterator &,
- ScratchData &,
- CopyData &)> worker;
- };
+ /**
+ * Constructor. Takes a
+ * reference to the object on
+ * which we will operate as
+ * well as a pointer to the
+ * function that will do the
+ * assembly.
+ */
+ Worker (const std_cxx1x::function<void (const Iterator &,
+ ScratchData &,
+ CopyData &)> &worker)
+ :
+ tbb::filter (/* is_serial= */ false),
+ worker (worker)
+ {}
+
+
+ /**
+ * Work on an item.
+ */
+ void *operator () (void *item)
+ {
+ // first unpack the current item
+ typedef
+ typename IteratorRangeToItemStream<Iterator,ScratchData,CopyData>::ItemType
+ ItemType;
+
+ ItemType *current_item = static_cast<ItemType *> (item);
+
+ // we need to find an unused scratch data object in the list that
+ // corresponds to the current thread and then mark it as used. if
+ // we can't find one, create one
+ //
+ // as discussed in the discussion of the documentation of the
+ // IteratorRangeToItemStream::scratch_data variable, there is no
+ // need to synchronize access to this variable using a mutex
+ // as long as we have no yield-point in between. this means that
+ // we can't take an iterator into the list now and expect it to
+ // still be valid after calling the worker, but we at least do
+ // not have to lock the following section
+ ScratchData *scratch_data = 0;
+ {
+ typename ItemType::ScratchDataList &
+ scratch_data_list = current_item->scratch_data->get();
+
+ // see if there is an unused object. if so, grab it and mark
+ // it as used
+ for (typename ItemType::ScratchDataList::iterator
+ p = scratch_data_list.begin();
+ p != scratch_data_list.end(); ++p)
+ if (p->currently_in_use == false)
+ {
+ scratch_data = p->scratch_data.get();
+ p->currently_in_use = true;
+ break;
+ }
+
+ // if no object was found, create one and mark it as used
+ if (scratch_data == 0)
+ {
+ scratch_data = new ScratchData(*current_item->sample_scratch_data);
+
+ typename ItemType::ScratchDataList::value_type
+ new_scratch_object (scratch_data, true);
+ scratch_data_list.push_back (new_scratch_object);
+ }
+ }
+
+ // then call the worker function on each element of the chunk we were
+ // given. since these worker functions are called on separate threads,
+ // nothing good can happen if they throw an exception and we are best
+ // off catching it and showing an error message
+ for (unsigned int i=0; i<current_item->n_items; ++i)
+ {
+ try
+ {
+ if (worker)
+ worker (current_item->work_items[i],
+ *scratch_data,
+ current_item->copy_datas[i]);
+ }
+ catch (const std::exception &exc)
+ {
+ Threads::internal::handle_std_exception (exc);
+ }
+ catch (...)
+ {
+ Threads::internal::handle_unknown_exception ();
+ }
+ }
+
+ // finally mark the scratch object as unused again. as above, there
+ // is no need to lock anything here since the object we work on
+ // is thread-local
+ {
+ typename ItemType::ScratchDataList &
+ scratch_data_list = current_item->scratch_data->get();
+
+ for (typename ItemType::ScratchDataList::iterator p =
+ scratch_data_list.begin(); p != scratch_data_list.end();
+ ++p)
+ if (p->scratch_data.get() == scratch_data)
+ {
+ Assert(p->currently_in_use == true, ExcInternalError());
+ p->currently_in_use = false;
+ }
+ }
+
+
+
+ // then return the original pointer
+ // to the now modified object
+ return item;
+ }
+
+
+ private:
+ /**
+ * Pointer to the function
+ * that does the assembling
+ * on the sequence of cells.
+ */
+ const std_cxx1x::function<void (const Iterator &,
+ ScratchData &,
+ CopyData &)> worker;
+ };
template <typename Iterator,
typename ScratchData,
typename CopyData>
- class Copier : public tbb::filter
- {
- public:
- /**
- * Constructor. Takes a
- * reference to the object on
- * which we will operate as
- * well as a pointer to the
- * function that will do the
- * copying from the
- * additional data object to
- * the global matrix or
- * similar.
- */
- Copier (const std_cxx1x::function<void (const CopyData &)> &copier)
- :
- tbb::filter (/* is_serial= */ true),
- copier (copier)
- {}
-
-
- /**
- * Work on a single item.
- */
- void *operator () (void *item)
- {
- // first unpack the current item
- typedef
- typename IteratorRangeToItemStream<Iterator,ScratchData,CopyData>::ItemType
- ItemType;
-
- ItemType *current_item = static_cast<ItemType *> (item);
-
- // initiate copying data. for the same reasons as in the worker class
- // above, catch exceptions rather than letting it propagate into
- // unknown territories
- for (unsigned int i=0; i<std_cxx1x::get<3>(*current_item); ++i)
- {
- try
- {
- copier (std_cxx1x::get<2>(*current_item)[i]);
- }
- catch (const std::exception &exc)
- {
- Threads::internal::handle_std_exception (exc);
- }
- catch (...)
- {
- Threads::internal::handle_unknown_exception ();
- }
- }
-
-
- // return an invalid
- // item since we are at
- // the end of the
- // pipeline
- return 0;
- }
-
-
- private:
- /**
- * Pointer to the function
- * that does the copying of
- * data.
- */
- const std_cxx1x::function<void (const CopyData &)> copier;
- };
+ class Copier : public tbb::filter
+ {
+ public:
+ /**
+ * Constructor. Takes a
+ * reference to the object on
+ * which we will operate as
+ * well as a pointer to the
+ * function that will do the
+ * copying from the
+ * additional data object to
+ * the global matrix or
+ * similar.
+ */
+ Copier (const std_cxx1x::function<void (const CopyData &)> &copier,bool is_serial)
+ :
+ tbb::filter (is_serial),
+ copier (copier)
+ {}
+
+
+ /**
+ * Work on a single item.
+ */
+ void *operator () (void *item)
+ {
+ // first unpack the current item
+ typedef
+ typename IteratorRangeToItemStream<Iterator,ScratchData,CopyData>::ItemType
+ ItemType;
+
+ ItemType *current_item = static_cast<ItemType *> (item);
+
+ // initiate copying data. for the same reasons as in the worker class
+ // above, catch exceptions rather than letting it propagate into
+ // unknown territories
+ for (unsigned int i=0; i<current_item->n_items; ++i)
+ {
+ try
+ {
+ if (copier)
+ copier (current_item->copy_datas[i]);
+ }
+ catch (const std::exception &exc)
+ {
+ Threads::internal::handle_std_exception (exc);
+ }
+ catch (...)
+ {
+ Threads::internal::handle_unknown_exception ();
+ }
+ }
+
+
+ // return an invalid
+ // item since we are at
+ // the end of the
+ // pipeline
+ return 0;
+ }
+
+
+ private:
+ /**
+ * Pointer to the function
+ * that does the copying of
+ * data.
+ */
+ const std_cxx1x::function<void (const CopyData &)> copier;
+ };
}
typename Iterator,
typename ScratchData,
typename CopyData>
- void
- run (const Iterator &begin,
+ void
+ run (const Iterator &begin,
const typename identity<Iterator>::type &end,
Worker worker,
Copier copier,
const ScratchData &sample_scratch_data,
const CopyData &sample_copy_data,
const unsigned int queue_length = 2*multithread_info.n_default_threads,
- const unsigned int chunk_size = 8)
+ const unsigned int chunk_size = 8)
{
Assert (queue_length > 0,
ExcMessage ("The queue length must be at least one, and preferably "
// create the three stages of the
// pipeline
internal::IteratorRangeToItemStream<Iterator,ScratchData,CopyData>
- iterator_range_to_item_stream (begin, end,
- queue_length,
- chunk_size,
- sample_scratch_data,
- sample_copy_data);
+ iterator_range_to_item_stream (begin, end,
+ queue_length,
+ chunk_size,
+ sample_scratch_data,
+ sample_copy_data);
+
internal::Worker<Iterator, ScratchData, CopyData> worker_filter (worker);
- internal::Copier<Iterator, ScratchData, CopyData> copier_filter (copier);
+ internal::Copier<Iterator, ScratchData, CopyData> copier_filter (copier,true);
// now create a pipeline from
// these stages
for (Iterator i=begin; i!=end; ++i)
{
- worker (i, scratch_data, copy_data);
- copier (copy_data);
+ if (static_cast<const std_cxx1x::function<void (const Iterator &,
+ ScratchData &,
+ CopyData &)> >(worker))
+ worker (i, scratch_data, copy_data);
+ if (static_cast<const std_cxx1x::function<void (const CopyData &)> >
+ (copier))
+ copier (copy_data);
}
#endif
}
+ /**
+ * This is the main function of the
+ * WorkStream concept, doing work as
+ * described in the introduction to this
+ * namespace.
+ *
+ * This is the function that can be used
+ * for worker and copier objects that are
+ * either pointers to non-member
+ * functions or objects that allow to be
+ * called with an operator(), for example
+ * objects created by std::bind.
+ *
+ * The argument passed as @p end must be
+ * convertible to the same type as
+ * @p begin, but doesn't have to be of the
+ * same type itself. This allows to write
+ * code like
+ * <code>WorkStream().run(dof_handler.begin_active(),
+ * dof_handler.end(), ...</code> where
+ * the first is of type
+ * DoFHandler::active_cell_iterator
+ * whereas the second is of type
+ * DoFHandler::raw_cell_iterator.
+ *
+ * The two data types
+ * <tt>ScratchData</tt> and
+ * <tt>CopyData</tt> need to have a
+ * working copy
+ * constructor. <tt>ScratchData</tt>
+ * is only used in the
+ * <tt>worker</tt> function, while
+ * <tt>CopyData</tt> is the object
+ * passed from the <tt>worker</tt>
+ * to the <tt>copier</tt>.
+ *
+ * The @p get_conflict_indices argument, is a function
+ * that given an iterator computes the conflict indices
+ * necessary for the graph_coloring.
+ *
+ * The @p queue_length argument indicates
+ * the number of items that can be live
+ * at any given time. Each item consists
+ * of @p chunk_size elements of the input
+ * stream that will be worked on by the
+ * worker and copier functions one after
+ * the other on the same thread.
+ *
+ * @note If your data objects are large,
+ * or their constructors are expensive,
+ * it is helpful to keep in mind
+ * that <tt>queue_length</tt>
+ * copies of the <tt>ScratchData</tt>
+ * object and
+ * <tt>queue_length*chunk_size</tt>
+ * copies of the <tt>CopyData</tt>
+ * object are generated.
+ */
+ template <typename Worker,
+ typename Copier,
+ typename Iterator,
+ typename ScratchData,
+ typename CopyData>
+ void
+ run (const Iterator &begin,
+ const typename identity<Iterator>::type &end,
+ Worker worker,
+ Copier copier,
+ const ScratchData &sample_scratch_data,
+ const CopyData &sample_copy_data,
+ const std_cxx1x::function<std::vector<types::global_dof_index> (const Iterator &)>
+ &get_conflict_indices,
+ const unsigned int queue_length = 2*multithread_info.n_default_threads,
+ const unsigned int chunk_size = 8)
+ {
+ Assert (queue_length > 0,
+ ExcMessage ("The queue length must be at least one, and preferably "
+ "larger than the number of processors on this system."));
+ (void)queue_length; // removes -Wunused-parameter warning in optimized mode
+ Assert (chunk_size > 0,
+ ExcMessage ("The chunk_size must be at least one."));
+ (void)chunk_size; // removes -Wunused-parameter warning in optimized mode
+
+ // if no work then skip. (only use
+ // operator!= for iterators since we may
+ // not have an equality comparison
+ // operator)
+ if (!(begin != end))
+ return;
+
+#ifdef DEAL_II_WITH_THREADS
+ // color the graph
+ std::vector<std::vector<Iterator> > coloring = graph_coloring::make_graph_coloring(
+ begin,end,get_conflict_indices);
+
+ for (unsigned int color=0; color<coloring.size(); ++color)
+ {
+ // create the three stages of the
+ // pipeline
+ internal::IteratorRangeToItemStream<Iterator,ScratchData,CopyData>
+ iterator_range_to_item_stream (coloring[color].begin(), coloring[color].end(),
+ queue_length,
+ chunk_size,
+ sample_scratch_data,
+ sample_copy_data);
+
+ internal::Worker<Iterator, ScratchData, CopyData> worker_filter (worker);
+ internal::Copier<Iterator, ScratchData, CopyData> copier_filter (copier,false);
+
+ // now create a pipeline from
+ // these stages
+ tbb::pipeline assembly_line;
+ assembly_line.add_filter (iterator_range_to_item_stream);
+ assembly_line.add_filter (worker_filter);
+ assembly_line.add_filter (copier_filter);
+
+ // and run it
+ assembly_line.run (queue_length);
+
+ assembly_line.clear ();
+ }
+#else
+
+ // need to copy the sample since it is
+ // marked const
+ ScratchData scratch_data = sample_scratch_data;
+ CopyData copy_data = sample_copy_data;
+
+ for (Iterator i=begin; i!=end; ++i)
+ {
+ if (static_cast<const std_cxx1x::function<void (const Iterator &,
+ ScratchData &,
+ CopyData &)> >(worker))
+ worker (i, scratch_data, copy_data);
+ if (static_cast<const std_cxx1x::function<void (const CopyData &)> >
+ (copier))
+ copier (copy_data);
+ }
+#endif
+ }
+
+
+
+ /**
+ * This is the main function of the
+ * WorkStream concept, doing work as
+ * described in the introduction to this
+ * namespace.
+ *
+ * This is the function that can be
+ * used for worker and copier functions
+ * that are member functions of a class.
+ *
+ * The argument passed as @p end must be
+ * convertible to the same type as
+ * @p begin, but doesn't have to be of the
+ * same type itself. This allows to write
+ * code like
+ * <code>WorkStream().run(dof_handler.begin_active(),
+ * dof_handler.end(), ...</code> where
+ * the first is of type
+ * DoFHandler::active_cell_iterator
+ * whereas the second is of type
+ * DoFHandler::raw_cell_iterator.
+ *
+ * The @p queue_length argument indicates
+ * the number of items that can be live
+ * at any given time. Each item consists
+ * of @p chunk_size elements of the input
+ * stream that will be worked on by the
+ * worker and copier functions one after
+ * the other on the same thread.
+ *
+ * @note If your data objects are large,
+ * or their constructors are expensive,
+ * it is helpful to keep in mind
+ * that <tt>queue_length</tt>
+ * copies of the <tt>ScratchData</tt>
+ * object and
+ * <tt>queue_length*chunk_size</tt>
+ * copies of the <tt>CopyData</tt>
+ * object are generated.
+ */
+ template <typename MainClass,
+ typename Iterator,
+ typename ScratchData,
+ typename CopyData>
+ void
+ run (const Iterator &begin,
+ const typename identity<Iterator>::type &end,
+ MainClass &main_object,
+ void (MainClass::*worker) (const Iterator &,
+ ScratchData &,
+ CopyData &),
+ void (MainClass::*copier) (const CopyData &),
+ const ScratchData &sample_scratch_data,
+ const CopyData &sample_copy_data,
+ const unsigned int queue_length = 2*multithread_info.n_default_threads,
+ const unsigned int chunk_size = 8)
+ {
+ // forward to the other function
+ run (begin, end,
+ std_cxx1x::bind (worker,
+ std_cxx1x::ref (main_object),
+ std_cxx1x::_1, std_cxx1x::_2, std_cxx1x::_3),
+ std_cxx1x::bind (copier,
+ std_cxx1x::ref (main_object),
+ std_cxx1x::_1),
+ sample_scratch_data,
+ sample_copy_data,
+ queue_length,
+ chunk_size);
+ }
+
+
+
+
/**
* This is the main function of the
* WorkStream concept, doing work as
* whereas the second is of type
* DoFHandler::raw_cell_iterator.
*
+ * The @p get_conflict_indices argument, is a function
+ * that given an iterator computes the conflict indices
+ * necessary for the graph_coloring.
+ *
* The @p queue_length argument indicates
* the number of items that can be live
* at any given time. Each item consists
void (MainClass::*copier) (const CopyData &),
const ScratchData &sample_scratch_data,
const CopyData &sample_copy_data,
+ std::vector<types::global_dof_index> (MainClass::*get_conflict_indices)(const Iterator &),
const unsigned int queue_length = 2*multithread_info.n_default_threads,
const unsigned int chunk_size = 8)
{
std_cxx1x::_1),
sample_scratch_data,
sample_copy_data,
+ std_cxx1x::bind(get_conflict_indices,
+ std_cxx1x::ref (main_object)),
queue_length,
chunk_size);
}
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__distribute_grid_refinement_h
#define __deal2__distribute_grid_refinement_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__distributed_solution_transfer_h
#define __deal2__distributed_solution_transfer_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__distributed_tria_h
#define __deal2__distributed_tria_h
#include <deal.II/grid/tria.h>
#include <deal.II/base/std_cxx1x/function.h>
+#include <deal.II/base/std_cxx1x/tuple.h>
+#include <set>
#include <vector>
#include <list>
#include <utility>
}
}
-
+//forward declaration of the data type for periodic face pairs
+namespace GridTools {template <typename CellIterator> struct PeriodicFacePair;}
namespace parallel
{
const std::vector<types::global_dof_index> &
get_p4est_tree_to_coarse_cell_permutation() const;
+
+
+ /**
+ * Join faces in the p4est forest due to periodic boundary conditions.
+ *
+ * The vector can be filled by the function
+ * GridTools::collect_periodic_faces.
+ *
+ * @todo At the moment just default orientation is implemented.
+ *
+ * @note Before this function can be used the triangulation has to be
+ * initialized and must not be refined.
+ * Calling this function more than once is possible, but not recommended:
+ * The function destroys and rebuilds the p4est forest each time it is called.
+ */
+ void
+ add_periodicity
+ (const std::vector<GridTools::PeriodicFacePair<cell_iterator> >&);
+
+ /**
+ * Same as the function above, but takes a different argument.
+ *
+ * The entries in the std::vector should have the form
+ * std_cxx1x::tuple<cell1, face_no1, cell2, face_no2>.
+ *
+ * The vector can be filled by the function
+ * GridTools::identify_periodic_face_pairs.
+ *
+ * @note This function can only be used if the faces are in
+ * default orientation.
+ *
+ * @note Before this function can be used the triangulation has to be
+ * initialized and must not be refined.
+ * Calling this function more than once is possible, but not recommended:
+ * The function destroys and rebuilds the p4est forest each time it is called.
+ */
+ void
+ add_periodicity
+ (const std::vector<std_cxx1x::tuple<cell_iterator, unsigned int,
+ cell_iterator, unsigned int> >&);
+
+
+
private:
/**
* MPI communicator to be
* triangulation.
*/
typename dealii::internal::p4est::types<dim>::forest *parallel_forest;
+ /**
+ * A data structure that holds some
+ * information about the ghost cells of the triangulation.
+ */
+ typename dealii::internal::p4est::types<dim>::ghost *parallel_ghost;
/**
* A flag that indicates
*/
void attach_mesh_data();
+ /**
+ * fills a map that, for each vertex, lists all the processors whose
+ * subdomains are adjacent to that vertex. Used by
+ * DoFHandler::Policy::ParallelDistributed.
+ */
+ void
+ fill_vertices_with_ghost_neighbors
+ (std::map<unsigned int, std::set<dealii::types::subdomain_id> >
+ &vertices_with_ghost_neighbors);
template <int, int> friend class dealii::internal::DoFHandler::Policy::ParallelDistributed;
};
* in hierarchical ordering is the ith deal cell starting
* from begin(0).
*/
- const std::vector<unsigned int> &
+ const std::vector<types::global_dof_index> &
get_p4est_tree_to_coarse_cell_permutation() const;
/**
mesh_reconstruction_after_repartitioning = 0x1,
construct_multigrid_hierarchy = 0x2
};
+
+
+//TODO: The following variable should really be private, but it is used in dof_handler_policy.cc ...
/**
* dummy settings object
*/
Settings settings;
+ /**
+ * Like above, this method, which is only implemented for dim = 2 or 3,
+ * needs a stub because it is used in dof_handler_policy.cc
+ */
+ void
+ fill_vertices_with_ghost_neighbors
+ (std::map<unsigned int, std::set<dealii::types::subdomain_id> >
+ &vertices_with_ghost_neighbors);
+
};
}
}
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__block_info_h
#define __deal2__block_info_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__dof_accessor_h
#define __deal2__dof_accessor_h
* level this line lives on.
*/
void get_mg_dof_indices (const int level,
- std::vector<types::global_dof_index> &dof_indices,
- const unsigned int fe_index = DH::default_fe_index) const;
+ std::vector<types::global_dof_index> &dof_indices,
+ const unsigned int fe_index = DH::default_fe_index) const;
/**
* Sets the level DoF indices that are returned by get_mg_dof_indices.
*/
void set_mg_dof_indices (const int level,
- const std::vector<types::global_dof_index> &dof_indices,
- const unsigned int fe_index = DH::default_fe_index);
+ const std::vector<types::global_dof_index> &dof_indices,
+ const unsigned int fe_index = DH::default_fe_index);
/**
* Global DoF index of the <i>i</i>
* level @p level. Also see vertex_dof_index().
*/
types::global_dof_index mg_vertex_dof_index (const int level,
- const unsigned int vertex,
- const unsigned int i,
- const unsigned int fe_index = DH::default_fe_index) const;
+ const unsigned int vertex,
+ const unsigned int i,
+ const unsigned int fe_index = DH::default_fe_index) const;
/**
* Index of the <i>i</i>th degree
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__dof_accessor_templates_h
#define __deal2__dof_accessor_templates_h
#include <deal.II/dofs/dof_accessor.h>
#include <deal.II/dofs/dof_levels.h>
#include <deal.II/dofs/dof_faces.h>
-#include <deal.II/hp/dof_levels.h>
+#include <deal.II/hp/dof_level.h>
#include <deal.II/hp/dof_faces.h>
#include <deal.II/grid/tria_iterator.h>
#include <deal.II/grid/tria_iterator.templates.h>
const unsigned int local_index,
const dealii::internal::int2type<1> &)
{
- return dof_handler.levels[obj_level]->dof_object.
- get_dof_index (dof_handler,
- obj_index,
+ return dof_handler.levels[obj_level]->
+ get_dof_index (obj_index,
fe_index,
- local_index,
- obj_level);
+ local_index);
}
const dealii::internal::int2type<1> &,
const types::global_dof_index global_index)
{
- dof_handler.levels[obj_level]->dof_object.
- set_dof_index (dof_handler,
- obj_index,
+ dof_handler.levels[obj_level]->
+ set_dof_index (obj_index,
fe_index,
local_index,
- global_index,
- obj_level);
+ global_index);
}
{
return dof_handler.faces->lines.
get_dof_index (dof_handler,
- obj_index,
+ obj_index,
fe_index,
local_index,
obj_level);
const unsigned int local_index,
const dealii::internal::int2type<2> &)
{
- return dof_handler.levels[obj_level]->dof_object.
- get_dof_index (dof_handler,
- obj_index,
+ return dof_handler.levels[obj_level]->
+ get_dof_index (obj_index,
fe_index,
- local_index,
- obj_level);
+ local_index);
}
const dealii::internal::int2type<2> &,
const types::global_dof_index global_index)
{
- dof_handler.levels[obj_level]->dof_object.
- set_dof_index (dof_handler,
- obj_index,
+ dof_handler.levels[obj_level]->
+ set_dof_index (obj_index,
fe_index,
local_index,
- global_index,
- obj_level);
+ global_index);
}
const unsigned int local_index,
const dealii::internal::int2type<3> &)
{
- return dof_handler.levels[obj_level]->dof_object.
- get_dof_index (dof_handler,
- obj_index,
+ return dof_handler.levels[obj_level]->
+ get_dof_index (obj_index,
fe_index,
- local_index,
- obj_level);
+ local_index);
}
const dealii::internal::int2type<3> &,
const types::global_dof_index global_index)
{
- dof_handler.levels[obj_level]->dof_object.
- set_dof_index (dof_handler,
- obj_index,
+ dof_handler.levels[obj_level]->
+ set_dof_index (obj_index,
fe_index,
local_index,
- global_index,
- obj_level);
+ global_index);
}
const unsigned int fe_index,
const dealii::internal::int2type<1> &)
{
- return dof_handler.levels[obj_level]->dof_object.fe_index_is_active(dof_handler,
- obj_index,
- fe_index,
- obj_level);
+ return dof_handler.levels[obj_level]->fe_index_is_active(obj_index,
+ fe_index);
}
template <int spacedim>
static
unsigned int
- n_active_fe_indices (const dealii::hp::DoFHandler<1,spacedim> &dof_handler,
+ n_active_fe_indices (const dealii::hp::DoFHandler<1,spacedim> &,
const unsigned int obj_level,
const unsigned int obj_index,
const dealii::internal::int2type<1> &)
{
- return dof_handler.levels[obj_level]->dof_object.n_active_fe_indices (dof_handler,
- obj_index);
+ // on a cell, the number of active elements is one
+ return 1;
}
const unsigned int n,
const dealii::internal::int2type<1> &)
{
- return dof_handler.levels[obj_level]->dof_object.nth_active_fe_index (dof_handler,
- obj_level,
- obj_index,
- n);
+ Assert (n==0, ExcMessage("On cells, there can only be one active FE index"));
+ return dof_handler.levels[obj_level]->active_fe_index (obj_index);
}
const unsigned int fe_index,
const dealii::internal::int2type<2> &)
{
- return dof_handler.levels[obj_level]->dof_object.fe_index_is_active(dof_handler,
- obj_index,
- fe_index,
- obj_level);
+ return dof_handler.levels[obj_level]->fe_index_is_active(obj_index,
+ fe_index);
}
template <int spacedim>
static
unsigned int
- n_active_fe_indices (const dealii::hp::DoFHandler<2,spacedim> &dof_handler,
+ n_active_fe_indices (const dealii::hp::DoFHandler<2,spacedim> &,
const unsigned int obj_level,
const unsigned int obj_index,
const dealii::internal::int2type<2> &)
{
- return dof_handler.levels[obj_level]->dof_object.n_active_fe_indices (dof_handler,
- obj_index);
+ // on a cell, the number of active elements is one
+ return 1;
}
const unsigned int n,
const dealii::internal::int2type<2> &)
{
- return dof_handler.levels[obj_level]->dof_object.nth_active_fe_index (dof_handler,
- obj_level,
- obj_index,
- n);
+ Assert (n==0, ExcMessage("On cells, there can only be one active FE index"));
+ return dof_handler.levels[obj_level]->active_fe_index (obj_index);
}
const unsigned int fe_index,
const dealii::internal::int2type<3> &)
{
- return dof_handler.levels[obj_level]->dof_object.fe_index_is_active(dof_handler,
- obj_index,
- fe_index,
- obj_level);
+ return dof_handler.levels[obj_level]->fe_index_is_active(obj_index,
+ fe_index);
}
template <int spacedim>
static
unsigned int
- n_active_fe_indices (const dealii::hp::DoFHandler<3,spacedim> &dof_handler,
+ n_active_fe_indices (const dealii::hp::DoFHandler<3,spacedim> &,
const unsigned int obj_level,
const unsigned int obj_index,
const dealii::internal::int2type<3> &)
{
- return dof_handler.levels[obj_level]->dof_object.n_active_fe_indices (dof_handler,
- obj_index);
+ // on a cell, the number of active elements is one
+ return 1;
}
const unsigned int n,
const dealii::internal::int2type<3> &)
{
- return dof_handler.levels[obj_level]->dof_object.nth_active_fe_index (dof_handler,
- obj_level,
- obj_index,
- n);
+ Assert (n==0, ExcMessage("On cells, there can only be one active FE index"));
+ return dof_handler.levels[obj_level]->active_fe_index (obj_index);
}
/**
}
else
pointer += static_cast<types::global_dof_index>(
- (*dof_handler.finite_elements)[this_fe_index].dofs_per_vertex + 1);
+ (*dof_handler.finite_elements)[this_fe_index].dofs_per_vertex + 1);
}
}
return *(pointer + 1 + local_index);
else
pointer += static_cast<types::global_dof_index>(
- (*dof_handler.finite_elements)[this_fe_index].dofs_per_vertex + 1);
+ (*dof_handler.finite_elements)[this_fe_index].dofs_per_vertex + 1);
}
}
else
{
pointer += static_cast<types::global_dof_index>(
- (*dof_handler.finite_elements)[this_fe_index].dofs_per_vertex + 1);
+ (*dof_handler.finite_elements)[this_fe_index].dofs_per_vertex + 1);
++counter;
}
}
ExcInternalError());
pointer += static_cast<types::global_dof_index>(
- (*dof_handler.finite_elements)[this_fe_index].dofs_per_vertex + 1);
+ (*dof_handler.finite_elements)[this_fe_index].dofs_per_vertex + 1);
++counter;
}
}
inline
types::global_dof_index
DoFAccessor<structdim, DH,lda>::mg_dof_index (const int level,
- const unsigned int i) const
+ const unsigned int i) const
{
return this->dof_handler->template get_dof_index<structdim> (level, this->present_index, 0, i);
}
inline
types::global_dof_index
DoFAccessor<structdim, DH,lda>::mg_vertex_dof_index (const int level,
- const unsigned int vertex,
- const unsigned int i,
- const unsigned int fe_index) const
+ const unsigned int vertex,
+ const unsigned int i,
+ const unsigned int fe_index) const
{
Assert (this->dof_handler != 0, ExcInvalidObject ());
Assert (&this->dof_handler->get_fe () != 0, ExcInvalidObject ());
void
DoFAccessor<structdim, DH,lda>::set_vertex_dof_index (const unsigned int vertex,
const unsigned int i,
- const types::global_dof_index index,
+ const types::global_dof_index index,
const unsigned int fe_index) const
{
dealii::internal::DoFAccessor::Implementation::set_vertex_dof_index
inline
void
DoFAccessor<structdim, DH,lda>::set_mg_vertex_dof_index (const int level,
- const unsigned int vertex,
- const unsigned int i,
- const types::global_dof_index index,
- const unsigned int fe_index) const
+ const unsigned int vertex,
+ const unsigned int i,
+ const types::global_dof_index index,
+ const unsigned int fe_index) const
{
Assert (this->dof_handler != 0, ExcInvalidObject ());
Assert (&this->dof_handler->get_fe () != 0, ExcInvalidObject ());
inline
void
DoFAccessor<structdim, DH,lda>::set_mg_dof_index (const int level,
- const unsigned int i,
- const types::global_dof_index index) const
+ const unsigned int i,
+ const types::global_dof_index index) const
{
this->dof_handler->template set_dof_index<structdim> (level, this->present_index, 0, i, index);
}
// checking of 'i' happens in line_index(i)
return typename dealii::internal::DoFHandler::Iterators<DH,lda>::line_iterator
- (this->tria,
- 0, // only sub-objects are allowed, which have no level
- this->line_index(i),
- this->dof_handler);
+ (this->tria,
+ 0, // only sub-objects are allowed, which have no level
+ this->line_index(i),
+ this->dof_handler);
}
// checking of 'i' happens in quad_index(i)
return typename dealii::internal::DoFHandler::Iterators<DH,lda>::quad_iterator
- (this->tria,
- 0, // only sub-objects are allowed, which have no level
- this->quad_index(i),
- this->dof_handler);
+ (this->tria,
+ 0, // only sub-objects are allowed, which have no level
+ this->quad_index(i),
+ this->dof_handler);
}
template <int dim, int spacedim, bool lda>
static
void
- update_cell_dof_indices_cache (const DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim>, lda> &)
+ update_cell_dof_indices_cache (const DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim>, lda> &accessor)
{
-//TODO[WB]: should implement a dof indices cache for hp as well
+ // caches are only for cells with DoFs, i.e., for active ones
+ if (accessor.has_children())
+ return;
- // not implemented, but should also
- // not be called
- Assert (false, ExcNotImplemented());
+ const unsigned int dofs_per_cell = accessor.get_fe().dofs_per_cell;
+
+ // make sure the cache is at least
+ // as big as we need it when
+ // writing to the last element of
+ // this cell
+ Assert (static_cast<unsigned int>(accessor.present_index)
+ <
+ accessor.dof_handler->levels[accessor.present_level]
+ ->cell_cache_offsets.size(),
+ ExcInternalError());
+ Assert (accessor.dof_handler->levels[accessor.present_level]
+ ->cell_cache_offsets[accessor.present_index]
+ <=
+ accessor.dof_handler->levels[accessor.present_level]
+ ->cell_dof_indices_cache.size(),
+ ExcInternalError());
+
+ std::vector<types::global_dof_index> dof_indices (dofs_per_cell);
+ static_cast<const dealii::DoFAccessor<dim,dealii::hp::DoFHandler<dim,spacedim>,lda> &>
+ (accessor).get_dof_indices (dof_indices, accessor.active_fe_index());
+
+ types::global_dof_index *next_dof_index
+ = &accessor.dof_handler->levels[accessor.present_level]
+ ->cell_dof_indices_cache[accessor.dof_handler->levels[accessor.present_level]
+ ->cell_cache_offsets[accessor.present_index]];
+ for (unsigned int i=0; i<dofs_per_cell; ++i, ++next_dof_index)
+ *next_dof_index = dof_indices[i];
}
+
+
/**
* Implement setting dof
* indices on a
}
- /**
- * A function that collects the
- * global indices of degrees of
- * freedom. This function works
- * for ::DoFHandler and all
- * template arguments and copies
- * the data out of the cache that
- * we hold for each cell.
- */
- template <int dim, int spacedim, bool lda>
- static
- void
- get_dof_indices (const DoFCellAccessor<DoFHandler<dim,spacedim>, lda> &accessor,
- std::vector<types::global_dof_index> &dof_indices)
- {
- AssertDimension (dof_indices.size(), accessor.get_fe().dofs_per_cell);
-
- Assert (!accessor.has_children(),
- ExcMessage ("Cell must be active."));
-
- types::global_dof_index *cache = &accessor.dof_handler->levels[accessor.level()]
- ->cell_dof_indices_cache[accessor.present_index * accessor.get_fe().dofs_per_cell];
- for (unsigned int i=0; i<accessor.get_fe().dofs_per_cell; ++i, ++cache)
- dof_indices[i] = *cache;
- }
-
- /**
- * Same function as above except
- * that it works for
- * hp::DoFHandler objects that do
- * not have a cache for the local
- * DoF indices.
- */
- template <int dim, int spacedim, bool lda>
- static
- void
- get_dof_indices (const DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim>, lda> &accessor,
- std::vector<types::global_dof_index> &dof_indices)
- {
- // no caching for
- // hp::DoFHandler
- // implemented
- typedef
- dealii::DoFAccessor<dim,dealii::hp::DoFHandler<dim,spacedim>, lda>
- DoFAccessor;
- accessor.DoFAccessor::get_dof_indices (dof_indices,
- accessor.active_fe_index());
- }
-
- /**
- * A function that collects the
- * values of degrees of freedom. This
- * function works for ::DoFHandler
- * and all template arguments and
- * uses the data from the cache of
- * indices that we hold for each
- * cell.
- */
- template <int dim, int spacedim, bool lda, class InputVector, typename ForwardIterator>
- static
- void
- get_dof_values (const DoFCellAccessor<DoFHandler<dim,spacedim>, lda> &accessor,
- const InputVector &values,
- ForwardIterator local_values_begin,
- ForwardIterator local_values_end)
- {
- typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim>, lda> BaseClass;
- Assert (static_cast<unsigned int>(local_values_end-local_values_begin)
- == accessor.get_fe().dofs_per_cell,
- typename BaseClass::ExcVectorDoesNotMatch());
- Assert (values.size() == accessor.get_dof_handler().n_dofs(),
- typename BaseClass::ExcVectorDoesNotMatch());
-
- Assert (!accessor.has_children(),
- ExcMessage ("Cell must be active."));
-
- types::global_dof_index *cache = &accessor.dof_handler->levels[accessor.level()]
- ->cell_dof_indices_cache[accessor.present_index *
- accessor.get_fe().dofs_per_cell];
- for ( ; local_values_begin != local_values_end; ++local_values_begin, ++cache)
- *local_values_begin = values(*cache);
- }
-
- /**
- * Same function as above except
- * that it works for
- * hp::DoFHandler objects that do
- * not have a cache for the local
- * DoF indices.
- */
- template <int dim, int spacedim, bool lda, class InputVector, typename ForwardIterator>
- static
- void
- get_dof_values (const DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim>, lda> &accessor,
- const InputVector &values,
- ForwardIterator local_values_begin,
- ForwardIterator local_values_end)
- {
- typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim>, lda> BaseClass;
-
- // no caching for hp::DoFHandler
- // implemented
- Assert (static_cast<unsigned int>(local_values_end-local_values_begin)
- == accessor.get_fe().dofs_per_cell,
- typename BaseClass::ExcVectorDoesNotMatch());
- const unsigned int dofs_per_cell = accessor.get_fe().dofs_per_cell;
-
- std::vector<types::global_dof_index> local_dof_indices (dofs_per_cell);
- get_dof_indices (accessor, local_dof_indices);
-
- for (unsigned int i=0; i<dofs_per_cell; ++i, ++local_values_begin)
- *local_values_begin = values(local_dof_indices[i]);
- }
-
-
- /**
- * A function that collects the
- * values of degrees of freedom. This
- * function works for ::DoFHandler
- * and all template arguments and
- * uses the data from the cache of
- * indices that we hold for each
- * cell.
- */
- template <int dim, int spacedim, bool lda, class InputVector, typename ForwardIterator>
- static
- void
- get_dof_values (const DoFCellAccessor<DoFHandler<dim,spacedim>, lda> &accessor,
- const ConstraintMatrix &constraints,
- const InputVector &values,
- ForwardIterator local_values_begin,
- ForwardIterator local_values_end)
- {
- typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim>, lda> BaseClass;
- Assert (static_cast<unsigned int>(local_values_end-local_values_begin)
- == accessor.get_fe().dofs_per_cell,
- typename BaseClass::ExcVectorDoesNotMatch());
- Assert (values.size() == accessor.get_dof_handler().n_dofs(),
- typename BaseClass::ExcVectorDoesNotMatch());
-
- Assert (!accessor.has_children(),
- ExcMessage ("Cell must be active."));
-
- types::global_dof_index *cache = &accessor.dof_handler->levels[accessor.level()]
- ->cell_dof_indices_cache[accessor.present_index *
- accessor.get_fe().dofs_per_cell];
- constraints.get_dof_values(values, *cache, local_values_begin,
- local_values_end);
- }
-
- /**
- * Same function as above except
- * that it works for
- * hp::DoFHandler objects that do
- * not have a cache for the local
- * DoF indices.
- */
- template <int dim, int spacedim, bool lda, class InputVector, typename ForwardIterator>
- static
- void
- get_dof_values (const DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim>, lda> &accessor,
- const ConstraintMatrix &constraints,
- const InputVector &values,
- ForwardIterator local_values_begin,
- ForwardIterator local_values_end)
- {
- // no caching for hp::DoFHandler
- // implemented
- typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim>, lda> BaseClass;
- Assert (static_cast<unsigned int>(local_values_end-local_values_begin)
- == accessor.get_fe().dofs_per_cell,
- typename BaseClass::ExcVectorDoesNotMatch());
- const unsigned int dofs_per_cell = accessor.get_fe().dofs_per_cell;
-
- std::vector<types::global_dof_index> local_dof_indices (dofs_per_cell);
- get_dof_indices (accessor, local_dof_indices);
-
- constraints.get_dof_values (values, local_dof_indices.begin(),
- local_values_begin, local_values_end);
- }
-
-
- /**
- * Same set of functions as above
- * except that it sets rather than
- * gets values
- */
- template <int dim, int spacedim, bool lda, class OutputVector, typename number>
- static
- void
- set_dof_values (const DoFCellAccessor<DoFHandler<dim,spacedim>, lda> &accessor,
- const dealii::Vector<number> &local_values,
- OutputVector &values)
- {
- typedef dealii::DoFAccessor<dim,DoFHandler<dim,spacedim>, lda> BaseClass;
- Assert (local_values.size() == accessor.get_fe().dofs_per_cell,
- typename BaseClass::ExcVectorDoesNotMatch());
- Assert (values.size() == accessor.get_dof_handler().n_dofs(),
- typename BaseClass::ExcVectorDoesNotMatch());
-
- Assert (!accessor.has_children(),
- ExcMessage ("Cell must be active."));
-
- types::global_dof_index *cache = &accessor.dof_handler->levels[accessor.level()]
- ->cell_dof_indices_cache[accessor.present_index * accessor.get_fe().dofs_per_cell];
- for (unsigned int i=0; i<accessor.get_fe().dofs_per_cell; ++i, ++cache)
- values(*cache) = local_values(i);
- }
-
-
-
- template <int dim, int spacedim, bool lda, class OutputVector, typename number>
- static
- void
- set_dof_values (const DoFCellAccessor<dealii::hp::DoFHandler<dim,spacedim>, lda> &accessor,
- const dealii::Vector<number> &local_values,
- OutputVector &values)
- {
- // no caching for hp::DoFHandler
- // implemented
- const unsigned int dofs_per_cell = accessor.get_fe().dofs_per_cell;
-
- std::vector<types::global_dof_index> local_dof_indices (dofs_per_cell);
- get_dof_indices (accessor, local_dof_indices);
-
- for (unsigned int i=0; i<dofs_per_cell; ++i)
- values(local_dof_indices[i]) = local_values(i);
- }
-
/**
* Do what the active_fe_index
{
Assert (static_cast<unsigned int>(accessor.level()) < accessor.dof_handler->levels.size(),
ExcMessage ("DoFHandler not initialized"));
- Assert (static_cast<std::vector<unsigned int>::size_type>(accessor.present_index) <
- accessor.dof_handler->levels[accessor.level()]->active_fe_indices.size (),
- ExcIndexRange (accessor.present_index, 0,
- accessor.dof_handler->levels[accessor.level()]->active_fe_indices.size ()));
+
return accessor.dof_handler->levels[accessor.level()]
- ->active_fe_indices[accessor.present_index];
+ ->active_fe_index(accessor.present_index);
}
Assert (static_cast<unsigned int>(accessor.level()) <
accessor.dof_handler->levels.size(),
ExcMessage ("DoFHandler not initialized"));
- Assert (static_cast<std::vector<unsigned int>::size_type>(accessor.present_index) <
- accessor.dof_handler->levels[accessor.level()]->active_fe_indices.size (),
- ExcIndexRange (accessor.present_index, 0,
- accessor.dof_handler->levels[accessor.level()]->active_fe_indices.size ()));
+
accessor.dof_handler->levels[accessor.level()]
- ->active_fe_indices[accessor.present_index] = i;
+ ->set_active_fe_index (accessor.present_index, i);
}
dealii::TriaAccessor<0, 1, DH::space_dimension>::interior_vertex)),
cell.vertex_index(i),
&cell.get_dof_handler());
- return typename dealii::TriaIterator<dealii::DoFAccessor<DH::dimension-1,DH,lda> > (a);
+ return dealii::TriaIterator<dealii::DoFAccessor<0,DH,lda> > (a);
}
template <class DH, bool lda>
+inline
TriaIterator<DoFAccessor<DH::dimension-1,DH,lda> >
DoFCellAccessor<DH,lda>::face (const unsigned int i) const
{
ExcMessage ("Can't ask for DoF indices on artificial cells."));
AssertDimension (dof_indices.size(), this->get_fe().dofs_per_cell);
- dealii::internal::DoFCellAccessor::Implementation::get_dof_indices (*this, dof_indices);
+ const types::global_dof_index *cache
+ = this->dof_handler->levels[this->present_level]
+ ->get_cell_cache_start (this->present_index, this->get_fe().dofs_per_cell);
+ for (unsigned int i=0; i<this->get_fe().dofs_per_cell; ++i, ++cache)
+ dof_indices[i] = *cache;
}
+
template<class DH, bool lda>
inline
void DoFCellAccessor<DH,lda>::get_mg_dof_indices (std::vector<types::global_dof_index> &dof_indices) const
DoFAccessor<dim, DH,lda>::get_mg_dof_indices (this->level (), dof_indices);
}
+
+
template<class DH, bool lda>
inline
void DoFCellAccessor<DH,lda>::set_mg_dof_indices (const std::vector<types::global_dof_index> &dof_indices)
}
+
template<class DH, bool lda>
inline
void DoFCellAccessor<DH,lda>::get_active_or_mg_dof_indices (std::vector<types::global_dof_index> &dof_indices) const
template <class DH, bool lda>
template <class InputVector, typename number>
+inline
void
DoFCellAccessor<DH,lda>::get_dof_values (const InputVector &values,
Vector<number> &local_values) const
{
- Assert (this->is_artificial() == false,
- ExcMessage ("Can't ask for DoF indices on artificial cells."));
- AssertDimension (local_values.size(), this->get_fe().dofs_per_cell);
-
- dealii::internal::DoFCellAccessor::Implementation
- ::get_dof_values (*this, values, local_values.begin(), local_values.end());
+ get_dof_values (values, local_values.begin(), local_values.end());
}
template <class DH, bool lda>
template <class InputVector, typename ForwardIterator>
+inline
void
DoFCellAccessor<DH,lda>::get_dof_values (const InputVector &values,
ForwardIterator local_values_begin,
{
Assert (this->is_artificial() == false,
ExcMessage ("Can't ask for DoF indices on artificial cells."));
- dealii::internal::DoFCellAccessor::Implementation
- ::get_dof_values (*this, values, local_values_begin, local_values_end);
+ Assert (!this->has_children(),
+ ExcMessage ("Cell must be active."));
+
+ Assert (static_cast<unsigned int>(local_values_end-local_values_begin)
+ == this->get_fe().dofs_per_cell,
+ typename DoFCellAccessor::ExcVectorDoesNotMatch());
+ Assert (values.size() == this->get_dof_handler().n_dofs(),
+ typename DoFCellAccessor::ExcVectorDoesNotMatch());
+
+ const types::global_dof_index *cache
+ = this->dof_handler->levels[this->present_level]
+ ->get_cell_cache_start (this->present_index, this->get_fe().dofs_per_cell);
+
+ values.extract_subvector_to (cache,
+ cache + this->get_fe().dofs_per_cell,
+ local_values_begin);
}
template <class DH, bool lda>
template <class InputVector, typename ForwardIterator>
+inline
void
DoFCellAccessor<DH,lda>::get_dof_values (const ConstraintMatrix &constraints,
const InputVector &values,
{
Assert (this->is_artificial() == false,
ExcMessage ("Can't ask for DoF indices on artificial cells."));
- dealii::internal::DoFCellAccessor::Implementation
- ::get_dof_values (*this, constraints, values,
- local_values_begin, local_values_end);
+ Assert (!this->has_children(),
+ ExcMessage ("Cell must be active."));
+
+ Assert (static_cast<unsigned int>(local_values_end-local_values_begin)
+ == this->get_fe().dofs_per_cell,
+ typename DoFCellAccessor::ExcVectorDoesNotMatch());
+ Assert (values.size() == this->get_dof_handler().n_dofs(),
+ typename DoFCellAccessor::ExcVectorDoesNotMatch());
+
+
+ const types::global_dof_index *cache
+ = this->dof_handler->levels[this->present_level]
+ ->get_cell_cache_start (this->present_index, this->get_fe().dofs_per_cell);
+
+ constraints.get_dof_values(values, *cache, local_values_begin,
+ local_values_end);
}
template <class DH, bool lda>
template <class OutputVector, typename number>
+inline
void
DoFCellAccessor<DH,lda>::set_dof_values (const Vector<number> &local_values,
OutputVector &values) const
{
Assert (this->is_artificial() == false,
ExcMessage ("Can't ask for DoF indices on artificial cells."));
- dealii::internal::DoFCellAccessor::Implementation
- ::set_dof_values (*this, local_values, values);
+ Assert (!this->has_children(),
+ ExcMessage ("Cell must be active."));
+
+ Assert (static_cast<unsigned int>(local_values.size())
+ == this->get_fe().dofs_per_cell,
+ typename DoFCellAccessor::ExcVectorDoesNotMatch());
+ Assert (values.size() == this->get_dof_handler().n_dofs(),
+ typename DoFCellAccessor::ExcVectorDoesNotMatch());
+
+
+ const types::global_dof_index *cache
+ = this->dof_handler->levels[this->present_level]
+ ->get_cell_cache_start (this->present_index, this->get_fe().dofs_per_cell);
+
+ for (unsigned int i=0; i<this->get_fe().dofs_per_cell; ++i, ++cache)
+ values(*cache) = local_values(i);
}
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2007, 2008, 2010, 2012 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__dof_faces_h
#define __deal2__dof_faces_h
* the hierarchical structure of cells, which are organized in levels. In 2D we store
* information on degrees of freedom located on lines whereas in 3D we store information on
* degrees of freedom located on quads and lines. In 1D we do nothing, as the faces of
- * lines are vertices which are treated seperately.
+ * lines are vertices which are treated separately.
*
* Apart from the DoFObjects object containing the data to store (degree of freedom
* indices) we do not store any data or provide any functionality. However, we do implement
/**
* Store the indices of degrees of freedom on faces in 1D. As these would be vertices, which
- * are treted seperately, don't do anything.
+ * are treted separately, don't do anything.
*
* @author Tobias Leicht, 2006
*/
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__dof_handler_h
#define __deal2__dof_handler_h
#include <deal.II/base/exceptions.h>
#include <deal.II/base/smartpointer.h>
#include <deal.II/base/index_set.h>
+#include <deal.II/base/std_cxx1x/shared_ptr.h>
#include <deal.II/dofs/block_info.h>
#include <deal.II/dofs/dof_iterator_selector.h>
#include <deal.II/dofs/number_cache.h>
cell_iterator begin (const unsigned int level = 0) const;
/**
- * Iterator to the first active
- * cell on level @p level.
+ * Iterator to the first active cell on level @p level. If the
+ * given level does not contain any active cells (i.e., all cells
+ * on this level are further refined, then this function returns
+ * <code>end_active(level)</code> so that loops of the kind
+ * @code
+ * for (cell=dof_handler.begin_active(level); cell!=dof_handler.end_active(level); ++cell)
+ * ...
+ * @endcode
+ * have zero iterations, as may be expected if there are no active
+ * cells on this level.
*/
active_cell_iterator begin_active(const unsigned int level = 0) const;
cell_iterator end (const unsigned int level) const;
/**
- * Return an active iterator
- * which is the first iterator
- * not on level. If @p level is
- * the last level, then this
+ * Return an active iterator which is the first active iterator not
+ * on the given level. If @p level is the last level, then this
* returns <tt>end()</tt>.
*/
active_cell_iterator end_active (const unsigned int level) const;
* given (inclusive) range of levels.
*/
void init (const unsigned int coarsest_level,
- const unsigned int finest_level,
- const unsigned int dofs_per_vertex);
+ const unsigned int finest_level,
+ const unsigned int dofs_per_vertex);
/**
* Return the coarsest level for which this structure
*/
types::global_dof_index
get_index (const unsigned int level,
- const unsigned int dof_number) const;
+ const unsigned int dof_number) const;
/**
* Set the index of the <code>dof_number</code>th degree of
* to <code>index</code>.
*/
void set_index (const unsigned int level,
- const unsigned int dof_number,
- const types::global_dof_index index);
+ const unsigned int dof_number,
+ const types::global_dof_index index);
/**
* Exception.
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__dof_handler_policy_h
#define __deal2__dof_handler_policy_h
-//----------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2006, 2007, 2008, 2010, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//----------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__dof_iterators_h
#define __deal2__dof_iterators_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__dof_levels_h
#define __deal2__dof_levels_h
*/
DoFObjects<dim> dof_object;
+ /**
+ * Return a pointer to the beginning of the DoF indices cache
+ * for a given cell.
+ *
+ * @param obj_index The number of the cell we are looking at.
+ * @param dofs_per_cell The number of DoFs per cell for this cell.
+ * @return A pointer to the first DoF index for the current cell. The
+ * next dofs_per_cell indices are for the current cell.
+ */
+ const types::global_dof_index *
+ get_cell_cache_start (const unsigned int obj_index,
+ const unsigned int dofs_per_cell) const;
/**
* Determine an estimate for the
};
+
+ template <int dim>
+ inline
+ const types::global_dof_index *
+ DoFLevel<dim>::get_cell_cache_start (const unsigned int obj_index,
+ const unsigned int dofs_per_cell) const
+ {
+ Assert (obj_index*dofs_per_cell+dofs_per_cell
+ <=
+ cell_dof_indices_cache.size(),
+ ExcInternalError());
+
+ return &cell_dof_indices_cache[obj_index*dofs_per_cell];
+ }
+
+
+
template <int dim>
inline
std::size_t
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2012 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__dof_objects_h
#define __deal2__dof_objects_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__dof_renumbering_h
#define __deal2__dof_renumbering_h
* The component_wise() function allows not only to honor enumeration based on
* vector components, but also allows to group together vector components into
* "blocks" using a defaulted argument to the various DoFRenumber::component_wise()
- * functinos (see @ref GlossComponent vs @ref GlossBlock for a description of
+ * functions (see @ref GlossComponent vs @ref GlossBlock for a description of
* the difference). The blocks designated through this argument may, but do not
* have to be, equal to the blocks that the finite element reports. For example,
* a typical Stokes element would be
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__dof_tools_h
#define __deal2__dof_tools_h
template <class GridClass> class InterGridMap;
template <int dim, int spacedim> class Mapping;
+namespace GridTools {template <typename CellIterator> struct PeriodicFacePair;}
//TODO: map_support_points_to_dofs should generate a multimap, rather than just a map, since several dofs may be located at the same support point
* More information on the topic can be found in the
* @ref GlossFaceOrientation "glossary" article.
*
- * @note This function will not work for DoFHandler objects that are
- * built on a parallel::distributed::Triangulation object unless both
- * faces (or their children) are owned by the current processor.
+ * @note For DoFHandler objects that are built on a
+ * parallel::distributed::Triangulation object
+ * parallel::distributed::Triangulation::add_periodicity has to be called
+ * before.
*
* @author Matthias Maier, 2012
*/
template<typename FaceIterator>
void
- make_periodicity_constraints (const FaceIterator &face_1,
- const typename identity<FaceIterator>::type &face_2,
- dealii::ConstraintMatrix &constraint_matrix,
- const ComponentMask &component_mask = ComponentMask(),
- const bool face_orientation = true,
- const bool face_flip = false,
- const bool face_rotation = false);
+ make_periodicity_constraints
+ (const FaceIterator &face_1,
+ const typename identity<FaceIterator>::type &face_2,
+ dealii::ConstraintMatrix &constraint_matrix,
+ const ComponentMask &component_mask = ComponentMask(),
+ const bool face_orientation = true,
+ const bool face_flip = false,
+ const bool face_rotation = false);
+
/**
* function will be used for which the respective flag was set in the
* component mask.
*
- * @note This function will not work for DoFHandler objects that are
- * built on a parallel::distributed::Triangulation object.
+ * @note For DoFHandler objects that are built on a
+ * parallel::distributed::Triangulation object
+ * parallel::distributed::Triangulation::add_periodicity has to be called
+ * before.
*
* @see @ref GlossBoundaryIndicator "Glossary entry on boundary indicators"
*
*/
template<typename DH>
void
- make_periodicity_constraints (const DH &dof_handler,
- const types::boundary_id b_id1,
- const types::boundary_id b_id2,
- const int direction,
- dealii::ConstraintMatrix &constraint_matrix,
- const ComponentMask &component_mask = ComponentMask());
+ make_periodicity_constraints
+ (const DH &dof_handler,
+ const types::boundary_id b_id1,
+ const types::boundary_id b_id2,
+ const int direction,
+ dealii::ConstraintMatrix &constraint_matrix,
+ const ComponentMask &component_mask = ComponentMask());
/**
* @p orthogonal_equality. This can be used to implement conditions such
* as $u(0,y)=u(1,y+1)$.
*
- * @note This function will not work for DoFHandler objects that are
- * built on a parallel::distributed::Triangulation object.
+ * @note For DoFHandler objects that are built on a
+ * parallel::distributed::Triangulation object
+ * parallel::distributed::Triangulation::add_periodicity has to be called
+ * before.
*
* @see @ref GlossBoundaryIndicator "Glossary entry on boundary indicators"
*
- * @author Matthias Maier, 2012
+ * @author Daniel Arndt, 2013, Matthias Maier, 2012
*/
template<typename DH>
void
- make_periodicity_constraints (const DH &dof_handler,
- const types::boundary_id b_id1,
- const types::boundary_id b_id2,
- const int direction,
- dealii::Tensor<1,DH::space_dimension> &offset,
- dealii::ConstraintMatrix &constraint_matrix,
- const ComponentMask &component_mask = ComponentMask());
+ make_periodicity_constraints
+ (const DH &dof_handler,
+ const types::boundary_id b_id1,
+ const types::boundary_id b_id2,
+ const int direction,
+ dealii::Tensor<1,DH::space_dimension> &offset,
+ dealii::ConstraintMatrix &constraint_matrix,
+ const ComponentMask &component_mask = ComponentMask());
/**
* meshes with cells not in @ref GlossFaceOrientation
* "standard orientation".
*
- * @note This function will not work for DoFHandler objects that are
- * built on a parallel::distributed::Triangulation object.
+ * @note For DoFHandler objects that are built on a
+ * parallel::distributed::Triangulation object
+ * parallel::distributed::Triangulation::add_periodicity has to be called
+ * before.
*
* @see @ref GlossBoundaryIndicator "Glossary entry on boundary indicators"
*/
template<typename DH>
void
- make_periodicity_constraints (const DH &dof_handler,
- const types::boundary_id b_id,
- const int direction,
- dealii::ConstraintMatrix &constraint_matrix,
- const ComponentMask &component_mask = ComponentMask());
+ make_periodicity_constraints
+ (const DH &dof_handler,
+ const types::boundary_id b_id,
+ const int direction,
+ dealii::ConstraintMatrix &constraint_matrix,
+ const ComponentMask &component_mask = ComponentMask());
/**
* meshes with cells not in @ref GlossFaceOrientation
* "standard orientation".
*
- * @note This function will not work for DoFHandler objects that are
- * built on a parallel::distributed::Triangulation object.
+ * @note For DoFHandler objects that are built on a
+ * parallel::distributed::Triangulation object
+ * parallel::distributed::Triangulation::add_periodicity has to be called
+ * before.
*
* @see @ref GlossBoundaryIndicator "Glossary entry on boundary indicators"
*/
template<typename DH>
void
- make_periodicity_constraints (const DH &dof_handler,
- const types::boundary_id b_id,
- const int direction,
- dealii::Tensor<1,DH::space_dimension> &offset,
- dealii::ConstraintMatrix &constraint_matrix,
- const ComponentMask &component_mask = ComponentMask());
+ make_periodicity_constraints
+ (const DH &dof_handler,
+ const types::boundary_id b_id,
+ const int direction,
+ dealii::Tensor<1,DH::space_dimension> &offset,
+ dealii::ConstraintMatrix &constraint_matrix,
+ const ComponentMask &component_mask = ComponentMask());
+
+ /**
+ * Same as above but the periodicity information is given by
+ * @p periodic_faces. This std::vector can be created by
+ * GridTools::collect_periodic_faces.
+ *
+ * @note For DoFHandler objects that are built on a
+ * parallel::distributed::Triangulation object
+ * parallel::distributed::Triangulation::add_periodicity has to be called
+ * before.
+ */
+ template<typename DH>
+ void
+ make_periodicity_constraints
+ (const std::vector<GridTools::PeriodicFacePair<typename DH::cell_iterator> >
+ &periodic_faces,
+ dealii::ConstraintMatrix &constraint_matrix,
+ const ComponentMask &component_mask = ComponentMask());
//@}
/**
* Do the same thing as the corresponding
- * extract_dofs() functino for one level
+ * extract_dofs() function for one level
* of a multi-grid DoF numbering.
*/
template <class DH>
/**
* Do the same thing as the corresponding
- * extract_dofs() functino for one level
+ * extract_dofs() function for one level
* of a multi-grid DoF numbering.
*/
template <class DH>
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__function_map_h
#define __deal2__function_map_h
-//----------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2006, 2007, 2008, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//----------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__number_cache_h
#define __deal2__number_cache_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_block_mask_h
#define __deal2__fe_block_mask_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_component_mask_h
#define __deal2__fe_component_mask_h
std::size_t
memory_consumption () const;
+ /**
+ * Exception
+ */
+ DeclException0 (ExcNoComponentSelected);
+
private:
/**
* The actual component mask.
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_h
#define __deal2__fe_h
std::pair<unsigned int, unsigned int>
face_system_to_component_index (const unsigned int index) const;
+ /**
+ * Given an index in the natural ordering of indices on a face, return the
+ * index of the same degree of freedom on the cell.
+ *
+ * To explain the concept, consider the case where we would like to know
+ * whether a degree of freedom on a face, for example as part of an FESystem
+ * element, is primitive. Unfortunately, the
+ * is_primitive() function in the FiniteElement class takes a cell index, so
+ * we would need to find the cell index of the shape function that
+ * corresponds to the present face index. This function does that.
+ *
+ * Code implementing this would then look like this:
+ * @code
+ * for (i=0; i<dofs_per_face; ++i)
+ * if (fe.is_primitive(fe.face_to_equivalent_cell_index(i, some_face_no)))
+ * ... do whatever
+ * @endcode
+ * The function takes additional arguments that account for the fact that
+ * actual faces can be in their standard ordering with respect to the cell
+ * under consideration, or can be flipped, oriented, etc.
+ *
+ * @param face_dof_index The index of the degree of freedom on a face.
+ * This index must be between zero and dofs_per_face.
+ * @param face The number of the face this degree of freedom lives on.
+ * This number must be between zero and GeometryInfo::faces_per_cell.
+ * @param face_orientation One part of the description of the orientation
+ * of the face. See @ref GlossFaceOrientation .
+ * @param face_flip One part of the description of the orientation
+ * of the face. See @ref GlossFaceOrientation .
+ * @param face_rotation One part of the description of the orientation
+ * of the face. See @ref GlossFaceOrientation .
+ * @return The index of this degree of freedom within the set
+ * of degrees of freedom on the entire cell. The returned value
+ * will be between zero and dofs_per_cell.
+ *
+ * @note This function exists in this class because that is where it
+ * was first implemented. However, it can't really work in the most
+ * general case without knowing what element we have. The reason is that
+ * when a face is flipped or rotated, we also need to know whether we
+ * need to swap the degrees of freedom on this face, or whether they
+ * are immune from this. For this, consider the situation of a $Q_3$
+ * element in 2d. If face_flip is true, then we need to consider
+ * the two degrees of freedom on the edge in reverse order. On the other
+ * hand, if the element were a $Q_1^2$, then because the two degrees of
+ * freedom on this edge belong to different vector components, they
+ * should not be considered in reverse order. What all of this shows is
+ * that the function can't work if there are more than one degree of
+ * freedom per line or quad, and that in these cases the function will
+ * throw an exception pointing out that this functionality will need
+ * to be provided by a derived class that knows what degrees of freedom
+ * actually represent.
+ */
+ virtual
+ unsigned int face_to_cell_index (const unsigned int face_dof_index,
+ const unsigned int face,
+ const bool face_orientation = true,
+ const bool face_flip = false,
+ const bool face_rotation = false) const;
+
/**
* For faces with non-standard face_orientation in 3D, the dofs on faces
* (quads) have to be permuted in order to be combined with the correct
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_abf_h
#define __deal2__fe_abf_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_base_h
#define __deal2__fe_base_h
*/
bool conforms (const Conformity) const;
- /**
- * Given an index in the natural ordering of indices on a face, return the
- * index of the same degree of freedom on the cell.
- *
- * @param face_dof_index The index of the degree of freedom on a face.
- * This index must be between zero and dofs_per_face.
- * @param face The number of the face this degree of freedom lives on.
- * This number must be between zero and GeometryInfo::faces_per_cell.
- * @param face_orientation One part of the description of the orientation
- * of the face. See @ref GlossFaceOrientation .
- * @param face_flip One part of the description of the orientation
- * of the face. See @ref GlossFaceOrientation .
- * @param face_rotation One part of the description of the orientation
- * of the face. See @ref GlossFaceOrientation .
- * @return The index of this degree of freedom within the set
- * of degrees of freedom on the entire cell. The returned value
- * will be between zero and dofs_per_cell.
- */
- unsigned int face_to_cell_index (const unsigned int face_dof_index,
- const unsigned int face,
- const bool face_orientation = true,
- const bool face_flip = false,
- const bool face_rotation = false) const;
-
- /**
- * @deprecated This function is just a special version of face_to_cell_index
- * for the face zero. It is therefore of limited use in aplications and most
- * of the time, the other function is what is required.
- *
- * Given an index in the natural ordering of indices on a face, return the
- * index of an equivalent degree of freedom on the cell.
- *
- * To explain the concept, consider the case where we would like to know
- * whether a degree of freedom on a face is primitive. Unfortunately, the
- * is_primitive() function in the FiniteElement class takes a cell index, so
- * we would need to find the cell index of the shape function that
- * corresponds to the present face index. This function does that.
- *
- * Code implementing this would then look like this:
- * @code
- * for (i=0; i<dofs_per_face; ++i)
- * if (fe.is_primitive(fe.face_to_equivalent_cell_index(i)))
- * ... do whatever
- * @endcode
- *
- */
- unsigned int face_to_equivalent_cell_index (const unsigned int index) const DEAL_II_DEPRECATED;
-
/**
* Comparison operator.
*/
}
-
-template <>
-inline
-unsigned int
-FiniteElementData<1>::
-face_to_equivalent_cell_index (const unsigned int index) const
-{
- Assert (index < dofs_per_face,
- ExcIndexRange (index, 0, dofs_per_face));
- return index;
-}
-
-
-
-template <>
-inline
-unsigned int
-FiniteElementData<2>::
-face_to_equivalent_cell_index (const unsigned int index) const
-{
- Assert (index < dofs_per_face,
- ExcIndexRange (index, 0, dofs_per_face));
-
- // on face 0, the vertices are 0 and 2
- if (index < this->dofs_per_vertex)
- return index;
- else if (index < 2*this->dofs_per_vertex)
- return index + this->dofs_per_vertex;
- else
- // this is a dof on line 0, so on the cell there are now 4 vertices
- // instead of only 2 ahead of this one
- return index + 2*this->dofs_per_vertex;
-}
-
-
-
-
-template <>
-inline
-unsigned int
-FiniteElementData<3>::
-face_to_equivalent_cell_index (const unsigned int index) const
-{
- // this case is just way too complicated. fall back to face_to_cell_index
- return face_to_cell_index(index, 0, true);
-}
-
#endif // DOXYGEN
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2012 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_bdm_h
#define __deal2__fe_bdm_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_dg_vector_h
#define __deal2__fe_dg_vector_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/fe/fe_dg_vector.h>
#include <deal.II/fe/fe_tools.h>
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2010, 2012, 2013 by the deal.II authors
+// Copyright (C) 2002 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_dgp_h
#define __deal2__fe_dgp_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2010, 2012, 2013 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_dgp_monomial_h
#define __deal2__fe_dgp_monomial_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2002 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_dgp_nonparametric_h
#define __deal2__fe_dgp_nonparametric_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_dgq_h
#define __deal2__fe_dgq_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_face_h
#define __deal2__fe_face_h
#include <deal.II/base/config.h>
#include <deal.II/base/tensor_product_polynomials.h>
+#include <deal.II/base/polynomial_space.h>
#include <deal.II/fe/fe_poly_face.h>
DEAL_II_NAMESPACE_OPEN
/**
- * A finite element, which is a tensor product polynomial on each face
- * and undefined in the interior of the cells. The basis functions on
- * the faces are from Polynomials::LagrangeEquidistant
+ * A finite element, which is a tensor product polynomial on each face and
+ * undefined in the interior of the cells. The basis functions on the faces
+ * are Lagrange polynomials based on the support points of the
+ * (dim-1)-dimensional Gauss--Lobatto quadrature rule. For element degree one
+ * and two, the polynomials hence correspond to the usual Lagrange polynomials
+ * on equidistant points.
*
- * This finite element is the trace space of FE_RaviartThomas on the
- * faces and serves in hybridized methods.
+ * This finite element is the trace space of FE_RaviartThomas on the faces and
+ * serves in hybridized methods, e.g. in combination with the FE_DGQ
+ * element. Its use is demonstrated in the step-51 tutorial program.
*
* @note Since these are only finite elements on faces, only
* FEFaceValues and FESubfaceValues will be able to extract reasonable
* element space, but all shape function values extracted will equal
* to zero.
*
- * @todo Polynomials::LagrangeEquidistant should be and will be
- * replaced by Polynomials::LagrangeGaussLobatto as soon as such a
- * polynomial set exists.
- *
* @ingroup fe
- * @author Guido Kanschat
- * @date 2009, 2011
+ * @author Guido Kanschat, Martin Kronbichler
+ * @date 2009, 2011, 2013
*/
template <int dim, int spacedim=dim>
class FE_FaceQ : public FE_PolyFace<TensorProductPolynomials<dim-1>, dim, spacedim>
*/
virtual std::string get_name () const;
+ /**
+ * Return the matrix interpolating from a face of of one element to the face
+ * of the neighboring element. The size of the matrix is then
+ * <tt>source.dofs_per_face</tt> times <tt>this->dofs_per_face</tt>. This
+ * element only provides interpolation matrices for elements of the same
+ * type and FE_Nothing. For all other elements, an exception of type
+ * FiniteElement<dim,spacedim>::ExcInterpolationNotImplemented is thrown.
+ */
+ virtual void
+ get_face_interpolation_matrix (const FiniteElement<dim,spacedim> &source,
+ FullMatrix<double> &matrix) const;
+
+ /**
+ * Return the matrix interpolating from a face of of one element to the face
+ * of the neighboring element. The size of the matrix is then
+ * <tt>source.dofs_per_face</tt> times <tt>this->dofs_per_face</tt>. This
+ * element only provides interpolation matrices for elements of the same
+ * type and FE_Nothing. For all other elements, an exception of type
+ * FiniteElement<dim,spacedim>::ExcInterpolationNotImplemented is thrown.
+ */
+ virtual void
+ get_subface_interpolation_matrix (const FiniteElement<dim,spacedim> &source,
+ const unsigned int subface,
+ FullMatrix<double> &matrix) const;
+
+ /**
+ * Check for non-zero values on a face.
+ *
+ * This function returns @p true, if the shape function @p shape_index has
+ * non-zero values on the face @p face_index.
+ *
+ * Implementation of the interface in FiniteElement
+ */
+ virtual bool has_support_on_face (const unsigned int shape_index,
+ const unsigned int face_index) const;
+
+ /**
+ * Return whether this element implements its hanging node constraints in
+ * the new way, which has to be used to make elements "hp compatible".
+ */
+ virtual bool hp_constraints_are_implemented () const;
+
+ /**
+ * Return whether this element dominates the one given as argument when they
+ * meet at a common face, whether it is the other way around, whether
+ * neither dominates, or if either could dominate.
+ *
+ * For a definition of domination, see FiniteElementBase::Domination and in
+ * particular the @ref hp_paper "hp paper".
+ */
+ virtual
+ FiniteElementDomination::Domination
+ compare_for_face_domination (const FiniteElement<dim,spacedim> &fe_other) const;
+
+private:
+ /**
+ * Return vector with dofs per vertex, line, quad, hex.
+ */
+ static std::vector<unsigned int> get_dpo_vector (const unsigned int deg);
+};
+
+
+
+
+/**
+ * A finite element, which is a Legendre on each face (i.e., FE_DGP)
+ * and undefined in the interior of the cells. The basis functions on
+ * the faces are from Polynomials::Legendre.
+ *
+ * This element is used in a hybridized method together with the FE_DGP
+ * element for the interior degrees of freedom.
+ *
+ * @note Since these are only finite elements on faces, only
+ * FEFaceValues and FESubfaceValues will be able to extract reasonable
+ * values from any face polynomial. In order to make the use of
+ * FESystem simpler, FEValues objects will not fail using this finite
+ * element space, but all shape function values extracted will equal
+ * to zero.
+ *
+ * @ingroup fe
+ * @author Martin Kronbichler
+ * @date 2013
+ */
+template <int dim, int spacedim=dim>
+class FE_FaceP : public FE_PolyFace<PolynomialSpace<dim-1>, dim, spacedim>
+{
+public:
+ /**
+ * Constructor for complete basis of polynomials of degree <tt>p</tt>. The
+ * shape functions created using this constructor correspond to Legendre
+ * polynomials in each coordinate direction.
+ */
+ FE_FaceP(unsigned int p);
+
+ /**
+ * Clone method.
+ */
+ virtual FiniteElement<dim,spacedim> *clone() const;
+
+ /**
+ * Return a string that uniquely identifies a finite element. This class
+ * returns <tt>FE_FaceP<dim>(degree)</tt> , with <tt>dim</tt> and
+ * <tt>degree</tt> replaced by appropriate values.
+ */
+ virtual std::string get_name () const;
+
+ /**
+ * Return the matrix interpolating from a face of of one element to the face
+ * of the neighboring element. The size of the matrix is then
+ * <tt>source.dofs_per_face</tt> times <tt>this->dofs_per_face</tt>. This
+ * element only provides interpolation matrices for elements of the same
+ * type and FE_Nothing. For all other elements, an exception of type
+ * FiniteElement<dim,spacedim>::ExcInterpolationNotImplemented is thrown.
+ */
+ virtual void
+ get_face_interpolation_matrix (const FiniteElement<dim,spacedim> &source,
+ FullMatrix<double> &matrix) const;
+
+ /**
+ * Return the matrix interpolating from a face of of one element to the face
+ * of the neighboring element. The size of the matrix is then
+ * <tt>source.dofs_per_face</tt> times <tt>this->dofs_per_face</tt>. This
+ * element only provides interpolation matrices for elements of the same
+ * type and FE_Nothing. For all other elements, an exception of type
+ * FiniteElement<dim,spacedim>::ExcInterpolationNotImplemented is thrown.
+ */
+ virtual void
+ get_subface_interpolation_matrix (const FiniteElement<dim,spacedim> &source,
+ const unsigned int subface,
+ FullMatrix<double> &matrix) const;
+
/**
* Check for non-zero values on a face.
*
virtual bool has_support_on_face (const unsigned int shape_index,
const unsigned int face_index) const;
+ /**
+ * Return whether this element implements its hanging node constraints in
+ * the new way, which has to be used to make elements "hp compatible".
+ */
+ virtual bool hp_constraints_are_implemented () const;
+
+ /**
+ * Return whether this element dominates the one given as argument when they
+ * meet at a common face, whether it is the other way around, whether
+ * neither dominates, or if either could dominate.
+ *
+ * For a definition of domination, see FiniteElementBase::Domination and in
+ * particular the @ref hp_paper "hp paper".
+ */
+ virtual
+ FiniteElementDomination::Domination
+ compare_for_face_domination (const FiniteElement<dim,spacedim> &fe_other) const;
+
private:
/**
* Return vector with dofs per vertex, line, quad, hex.
static std::vector<unsigned int> get_dpo_vector (const unsigned int deg);
};
+
DEAL_II_NAMESPACE_CLOSE
#endif
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2002 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_nedelec_h
#define __deal2__fe_nedelec_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_nothing_h
#define __deal2__fe_nothing_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_poly_h
#define __deal2__fe_poly_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/qprojector.h>
#include <deal.II/base/polynomial_space.h>
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_poly_face_h
#define __deal2__fe_poly_face_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/qprojector.h>
#include <deal.II/base/polynomial_space.h>
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_poly_tensor_h
#define __deal2__fe_poly_tensor_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_q_h
#define __deal2__fe_q_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_q_base_h
#define __deal2__fe_q_base_h
/**
* Return the matrix interpolating from a face of of one element to the face
* of the neighboring element. The size of the matrix is then
- * <tt>source.dofs_per_face</tt> times <tt>this->dofs_per_face</tt>.
- *
- * Derived elements will have to implement this function. They may only
- * provide interpolation matrices for certain source finite elements, for
- * example those from the same family. If they don't implement interpolation
- * from a given element, then they must throw an exception of type
- * FiniteElement<dim,spacedim>::ExcInterpolationNotImplemented.
+ * <tt>source.dofs_per_face</tt> times <tt>this->dofs_per_face</tt>. The
+ * FE_Q element family only provides interpolation matrices for elements of
+ * the same type and FE_Nothing. For all other elements, an exception of
+ * type FiniteElement<dim,spacedim>::ExcInterpolationNotImplemented is
+ * thrown.
*/
virtual void
get_face_interpolation_matrix (const FiniteElement<dim,spacedim> &source,
/**
* Return the matrix interpolating from a face of of one element to the face
* of the neighboring element. The size of the matrix is then
- * <tt>source.dofs_per_face</tt> times <tt>this->dofs_per_face</tt>.
- *
- * Derived elements will have to implement this function. They may only
- * provide interpolation matrices for certain source finite elements, for
- * example those from the same family. If they don't implement interpolation
- * from a given element, then they must throw an exception of type
- * FiniteElement<dim,spacedim>::ExcInterpolationNotImplemented.
+ * <tt>source.dofs_per_face</tt> times <tt>this->dofs_per_face</tt>. The
+ * FE_Q element family only provides interpolation matrices for elements of
+ * the same type and FE_Nothing. For all other elements, an exception of
+ * type FiniteElement<dim,spacedim>::ExcInterpolationNotImplemented is
+ * thrown.
*/
virtual void
get_subface_interpolation_matrix (const FiniteElement<dim,spacedim> &source,
get_prolongation_matrix (const unsigned int child,
const RefinementCase<dim> &refinement_case=RefinementCase<dim>::isotropic_refinement) const;
+ /**
+ * Given an index in the natural ordering of indices on a face, return the
+ * index of the same degree of freedom on the cell.
+ *
+ * To explain the concept, consider the case where we would like to know
+ * whether a degree of freedom on a face, for example as part of an FESystem
+ * element, is primitive. Unfortunately, the
+ * is_primitive() function in the FiniteElement class takes a cell index, so
+ * we would need to find the cell index of the shape function that
+ * corresponds to the present face index. This function does that.
+ *
+ * Code implementing this would then look like this:
+ * @code
+ * for (i=0; i<dofs_per_face; ++i)
+ * if (fe.is_primitive(fe.face_to_equivalent_cell_index(i, some_face_no)))
+ * ... do whatever
+ * @endcode
+ * The function takes additional arguments that account for the fact that
+ * actual faces can be in their standard ordering with respect to the cell
+ * under consideration, or can be flipped, oriented, etc.
+ *
+ * @param face_dof_index The index of the degree of freedom on a face.
+ * This index must be between zero and dofs_per_face.
+ * @param face The number of the face this degree of freedom lives on.
+ * This number must be between zero and GeometryInfo::faces_per_cell.
+ * @param face_orientation One part of the description of the orientation
+ * of the face. See @ref GlossFaceOrientation .
+ * @param face_flip One part of the description of the orientation
+ * of the face. See @ref GlossFaceOrientation .
+ * @param face_rotation One part of the description of the orientation
+ * of the face. See @ref GlossFaceOrientation .
+ * @return The index of this degree of freedom within the set
+ * of degrees of freedom on the entire cell. The returned value
+ * will be between zero and dofs_per_cell.
+ */
+ virtual
+ unsigned int face_to_cell_index (const unsigned int face_dof_index,
+ const unsigned int face,
+ const bool face_orientation = true,
+ const bool face_flip = false,
+ const bool face_rotation = false) const;
+
/**
* @name Functions to support hp
* @{
-//---------------------------------------------------------------------------
-// $Id: fe_q.h 29043 2013-03-26 19:51:19Z bangerth $
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2012, 2013 by the deal.II authors
+// Copyright (C) 2012 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_q_dg0_h
#define __deal2__fe_q_dg0_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2002 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_q_hierarchical_h
#define __deal2__fe_q_hierarchical_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_q_iso_q1_h
#define __deal2__fe_q_iso_q1_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_raviart_thomas_h
#define __deal2__fe_raviart_thomas_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_system_h
#define __deal2__fe_system_h
get_prolongation_matrix (const unsigned int child,
const RefinementCase<dim> &refinement_case=RefinementCase<dim>::isotropic_refinement) const;
+ /**
+ * Given an index in the natural ordering of indices on a face, return the
+ * index of the same degree of freedom on the cell.
+ *
+ * To explain the concept, consider the case where we would like to know
+ * whether a degree of freedom on a face, for example as part of an FESystem
+ * element, is primitive. Unfortunately, the
+ * is_primitive() function in the FiniteElement class takes a cell index, so
+ * we would need to find the cell index of the shape function that
+ * corresponds to the present face index. This function does that.
+ *
+ * Code implementing this would then look like this:
+ * @code
+ * for (i=0; i<dofs_per_face; ++i)
+ * if (fe.is_primitive(fe.face_to_equivalent_cell_index(i, some_face_no)))
+ * ... do whatever
+ * @endcode
+ * The function takes additional arguments that account for the fact that
+ * actual faces can be in their standard ordering with respect to the cell
+ * under consideration, or can be flipped, oriented, etc.
+ *
+ * @param face_dof_index The index of the degree of freedom on a face.
+ * This index must be between zero and dofs_per_face.
+ * @param face The number of the face this degree of freedom lives on.
+ * This number must be between zero and GeometryInfo::faces_per_cell.
+ * @param face_orientation One part of the description of the orientation
+ * of the face. See @ref GlossFaceOrientation .
+ * @param face_flip One part of the description of the orientation
+ * of the face. See @ref GlossFaceOrientation .
+ * @param face_rotation One part of the description of the orientation
+ * of the face. See @ref GlossFaceOrientation .
+ * @return The index of this degree of freedom within the set
+ * of degrees of freedom on the entire cell. The returned value
+ * will be between zero and dofs_per_cell.
+ */
+ virtual
+ unsigned int face_to_cell_index (const unsigned int face_dof_index,
+ const unsigned int face,
+ const bool face_orientation = true,
+ const bool face_flip = false,
+ const bool face_rotation = false) const;
+
/**
* Implementation of the respective function in the base class.
*/
public:
/**
* Constructor. Is called by the @p get_data function. Sets the size of
- * the @p base_fe_datas vector to @p n_base_elements.
+ * the @p base_fe_datas vector to @p n_base_elements and initializes
+ * the compute_hessians field.
*/
- InternalData (const unsigned int n_base_elements);
+ InternalData (const unsigned int n_base_elements,
+ const bool compute_hessians);
/**
* Destructor. Deletes all @p InternalDatas whose pointers are stored by
/**
* Flag indicating whether second derivatives shall be computed.
*/
- bool compute_hessians;
+ const bool compute_hessians;
/**
* Gives write-access to the pointer to a @p InternalData of the @p
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_tools_H
#define __deal2__fe_tools_H
* indices of each local block. If it is false, then the block sizes are
* returned.
*
- * @todo Which way does this vector map the numbers?
+ * The vector <tt>renumbering</tt> will be indexed by the standard
+ * numbering of local degrees of freedom, namely first first vertex,
+ * then second vertex, after vertices lines, quads, and hexes. For
+ * each index, the entry indicates the index which this degree of
+ * freedom receives in a numbering scheme, where the first block is
+ * numbered completely before the second.
*/
template<int dim, int spacedim>
void compute_block_renumbering (
* For all possible (isotropic and anisotropic) refinement cases compute the
* embedding matrices from a coarse cell to the child cells. Each column of
* the resulting matrices contains the representation of a coarse grid basis
- * functon by the fine grid basis; the matrices are split such that there is
+ * function by the fine grid basis; the matrices are split such that there is
* one matrix for every child.
*
* This function computes the coarse grid function in a sufficiently large
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_update_flags_h
#define __deal2__fe_update_flags_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_values_h
#define __deal2__fe_values_h
* gradient is a
* <code>Tensor@<1,dim@></code>.
*/
- typedef Tensor<1,spacedim> gradient_type;
+ typedef dealii::Tensor<1,spacedim> gradient_type;
/**
* A typedef for the type of second
* Hessian is a
* <code>Tensor@<2,dim@></code>.
*/
- typedef Tensor<2,spacedim> hessian_type;
+ typedef dealii::Tensor<2,spacedim> hessian_type;
/**
* A structure where for each shape
* this class should not be used for this
* context.
*
+ * This class allows to query the
+ * value, gradient and divergence of
+ * (components of) shape functions
+ * and solutions representing
+ * vectors. The
+ * gradient of a vector
+ * $d_{k}, 0\le k<\text{dim}$ is
+ * defined as
+ * $S_{ij} = \frac{\partial d_{i}}{\partial x_j},
+ * 0\le i,j<\text{dim}$.
+ *
* You get an object of this type if you
* apply a FEValuesExtractors::Vector to an
* FEValues, FEFaceValues or
* of <code>dim</code> components, the
* value type is a Tensor<1,spacedim>.
*/
- typedef Tensor<1,spacedim> value_type;
+ typedef dealii::Tensor<1,spacedim> value_type;
/**
* A typedef for the type of gradients
* <code>dim</code> components of the
* finite element, the gradient is a
* <code>Tensor@<2,spacedim@></code>.
+ *
+ * See the general documentation of this class for how exactly
+ * the gradient of a vector is defined.
*/
- typedef Tensor<2,spacedim> gradient_type;
+ typedef dealii::Tensor<2,spacedim> gradient_type;
/**
* A typedef for the type of
* finite element, the Hessian is a
* <code>Tensor@<3,dim@></code>.
*/
- typedef Tensor<3,spacedim> hessian_type;
+ typedef dealii::Tensor<3,spacedim> hessian_type;
/**
* A structure where for each shape
* function and quadrature point
* selected by the arguments.
*
+ * See the general documentation of this class for how exactly
+ * the gradient of a vector is defined.
+ *
* @note The meaning of the arguments
* is as documented for the value()
* function.
* definition of the
* divergence.
*/
- typedef Tensor<1, spacedim> divergence_type;
+ typedef dealii::Tensor<1, spacedim> divergence_type;
/**
* A structure where for each shape
*/
std::vector<ShapeFunctionData> shape_function_data;
};
+
+
+ template <int rank, int dim, int spacedim = dim>
+ class Tensor;
+
+ /**
+ * A class representing a view to a set of
+ * <code>dim*dim</code> components forming a
+ * second-order tensor from a
+ * vector-valued finite
+ * element. Views are discussed in the
+ * @ref vector_valued module.
+ *
+ * This class allows to query the
+ * value and divergence of
+ * (components of) shape functions
+ * and solutions representing
+ * tensors. The
+ * divergence of a tensor
+ * $T_{ij}, 0\le i,j<\text{dim}$ is
+ * defined as
+ * $d_i = \sum_j \frac{\partial T_{ji}}{\partial x_j},
+ * 0\le i<\text{dim}$.
+ *
+ * You get an object of this type if you
+ * apply a
+ * FEValuesExtractors::Tensor to
+ * an FEValues, FEFaceValues or
+ * FESubfaceValues object.
+ *
+ * @ingroup feaccess vector_valued
+ *
+ * @author Denis Davydov, 2013
+ */
+ template <int dim, int spacedim>
+ class Tensor<2,dim,spacedim>
+ {
+ public:
+
+ /**
+ * Data type for what you get when you apply an extractor
+ * of this kind to a vector-valued finite element.
+ */
+ typedef dealii::Tensor<2, spacedim> value_type;
+
+ /**
+ * Data type for taking the divergence of a tensor: a vector.
+ */
+ typedef dealii::Tensor<1, spacedim> divergence_type;
+
+ /**
+ * A structure where for each shape
+ * function we pre-compute a bunch of
+ * data that will make later accesses
+ * much cheaper.
+ */
+ struct ShapeFunctionData
+ {
+ /**
+ * For each pair (shape
+ * function,component within
+ * vector), store whether the
+ * selected vector component may be
+ * nonzero. For primitive shape
+ * functions we know for sure
+ * whether a certain scalar
+ * component of a given shape
+ * function is nonzero, whereas for
+ * non-primitive shape functions
+ * this may not be entirely clear
+ * (e.g. for RT elements it depends
+ * on the shape of a cell).
+ */
+ bool is_nonzero_shape_function_component[value_type::n_independent_components];
+
+ /**
+ * For each pair (shape function,
+ * component within vector), store
+ * the row index within the
+ * shape_values, shape_gradients,
+ * and shape_hessians tables (the
+ * column index is the quadrature
+ * point index). If the shape
+ * function is primitive, then we
+ * can get this information from
+ * the shape_function_to_row_table
+ * of the FEValues object;
+ * otherwise, we have to work a bit
+ * harder to compute this
+ * information.
+ */
+ unsigned int row_index[value_type::n_independent_components];
+
+ /**
+ * For each shape function say the
+ * following: if only a single
+ * entry in
+ * is_nonzero_shape_function_component
+ * for this shape function is
+ * nonzero, then store the
+ * corresponding value of row_index
+ * and
+ * single_nonzero_component_index
+ * represents the index between 0
+ * and (dim^2) for which it is
+ * attained. If multiple components
+ * are nonzero, then store -1. If
+ * no components are nonzero then
+ * store -2.
+ */
+ int single_nonzero_component;
+ unsigned int single_nonzero_component_index;
+ };
+
+ /**
+ * Default constructor. Creates an
+ * invalid object.
+ */
+ Tensor();
+
+
+ /**
+ * Constructor for an object that
+ * represents <code>(dim*dim)</code>
+ * components of a
+ * FEValuesBase object (or of one of
+ * the classes derived from
+ * FEValuesBase), representing the unique
+ * components comprising a second-order
+ * tensor valued variable.
+ *
+ * The second argument denotes the
+ * index of the first component of the
+ * selected symmetric second order tensor.
+ */
+ Tensor(const FEValuesBase<dim, spacedim> &fe_values_base,
+ const unsigned int first_tensor_component);
+
+
+ /**
+ * Copy operator. This is not a
+ * lightweight object so we don't allow
+ * copying and generate an exception if
+ * this function is called.
+ */
+ Tensor &operator=(const Tensor<2, dim, spacedim> &);
+
+ /**
+ * Return the value of the vector
+ * components selected by this view,
+ * for the shape function and
+ * quadrature point selected by the
+ * arguments. Here, since the view
+ * represents a vector-valued part of
+ * the FEValues object with
+ * <code>(dim*dim)</code> components
+ * (the unique components of a second-order tensor),
+ * the return type is a tensor of rank 2.
+ *
+ * @param shape_function Number
+ * of the shape function to be
+ * evaluated. Note that this
+ * number runs from zero to
+ * dofs_per_cell, even in the
+ * case of an FEFaceValues or
+ * FESubfaceValues object.
+ *
+ * @param q_point Number of
+ * the quadrature point at which
+ * function is to be evaluated
+ */
+ value_type
+ value (const unsigned int shape_function,
+ const unsigned int q_point) const;
+
+ /**
+ * Return the vector divergence of
+ * the vector components selected by
+ * this view, for the shape function
+ * and quadrature point selected by the
+ * arguments.
+ *
+ * See the general discussion
+ * of this class for a
+ * definition of the
+ * divergence.
+ *
+ * @note The meaning of the arguments
+ * is as documented for the value()
+ * function.
+ */
+ divergence_type
+ divergence (const unsigned int shape_function,
+ const unsigned int q_point) const;
+
+ /**
+ * Return the values of the selected
+ * vector components of the finite
+ * element function characterized by
+ * <tt>fe_function</tt> at the
+ * quadrature points of the cell, face
+ * or subface selected the last time
+ * the <tt>reinit</tt> function of the
+ * FEValues object was called.
+ *
+ * This function is the equivalent of
+ * the
+ * FEValuesBase::get_function_values
+ * function but it only works on the
+ * selected vector components.
+ */
+ template <class InputVector>
+ void get_function_values (const InputVector &fe_function,
+ std::vector<value_type> &values) const;
+
+
+ /**
+ * Return the divergence of the selected
+ * vector components of the finite
+ * element function characterized by
+ * <tt>fe_function</tt> at the
+ * quadrature points of the cell, face
+ * or subface selected the last time
+ * the <tt>reinit</tt> function of the
+ * FEValues object was called.
+ *
+ * There is no equivalent function such
+ * as
+ * FEValuesBase::get_function_divergences
+ * in the FEValues classes but the
+ * information can be obtained from
+ * FEValuesBase::get_function_gradients,
+ * of course.
+ *
+ * See the general discussion
+ * of this class for a
+ * definition of the
+ * divergence.
+ */
+ template <class InputVector>
+ void get_function_divergences (const InputVector &fe_function,
+ std::vector<divergence_type> &divergences) const;
+
+ private:
+ /**
+ * A reference to the FEValuesBase object
+ * we operate on.
+ */
+ const FEValuesBase<dim, spacedim> &fe_values;
+
+ /**
+ * The first component of the vector
+ * this view represents of the
+ * FEValuesBase object.
+ */
+ const unsigned int first_tensor_component;
+
+ /**
+ * Store the data about shape
+ * functions.
+ */
+ std::vector<ShapeFunctionData> shape_function_data;
+ };
+
}
std::vector<dealii::FEValuesViews::Vector<dim,spacedim> > vectors;
std::vector<dealii::FEValuesViews::SymmetricTensor<2,dim,spacedim> >
symmetric_second_order_tensors;
+ std::vector<dealii::FEValuesViews::Tensor<2,dim,spacedim> >
+ second_order_tensors;
/**
* Constructor.
const FEValuesViews::SymmetricTensor<2,dim,spacedim> &
operator[] (const FEValuesExtractors::SymmetricTensor<2> &tensor) const;
+
+ /**
+ * Create a view of the current FEValues
+ * object that represents a set of
+ * <code>(dim*dim)</code> scalar components
+ * (i.e. a 2nd order tensor)
+ * of the vector-valued
+ * finite element. The concept of views
+ * is explained in the documentation of
+ * the namespace FEValuesViews and in particular
+ * in the @ref vector_valued module.
+ */
+ const FEValuesViews::Tensor<2,dim,spacedim> &
+ operator[] (const FEValuesExtractors::Tensor<2> &tensor) const;
+
//@}
/// @name Access to the raw data
template <int, int> friend class FEValuesViews::Scalar;
template <int, int> friend class FEValuesViews::Vector;
template <int, int, int> friend class FEValuesViews::SymmetricTensor;
+ template <int, int, int> friend class FEValuesViews::Tensor;
};
inline
dealii::SymmetricTensor<2,1>
symmetrize_single_row (const unsigned int n,
- const Tensor<1,1> &t)
+ const dealii::Tensor<1,1> &t)
{
Assert (n < 1, ExcIndexRange (n, 0, 1));
(void)n; // removes -Wunused-parameter warning in optimized mode
inline
dealii::SymmetricTensor<2,2>
symmetrize_single_row (const unsigned int n,
- const Tensor<1,2> &t)
+ const dealii::Tensor<1,2> &t)
{
switch (n)
{
inline
dealii::SymmetricTensor<2,3>
symmetrize_single_row (const unsigned int n,
- const Tensor<1,3> &t)
+ const dealii::Tensor<1,3> &t)
{
switch (n)
{
// b_jj := \dfrac{\partial phi_{ii,jj}}{\partial x_jj}.
// again, all other entries of 'b' are
// zero
- const Tensor<1, spacedim> phi_grad = fe_values.shape_gradients[snc][q_point];
+ const dealii::Tensor<1, spacedim> phi_grad = fe_values.shape_gradients[snc][q_point];
divergence_type return_value;
return_value[ii] = phi_grad[jj];
}
}
+ template <int dim, int spacedim>
+ inline
+ typename Tensor<2, dim, spacedim>::value_type
+ Tensor<2, dim, spacedim>::value (const unsigned int shape_function,
+ const unsigned int q_point) const
+ {
+ typedef FEValuesBase<dim,spacedim> FVB;
+ Assert (shape_function < fe_values.fe->dofs_per_cell,
+ ExcIndexRange (shape_function, 0, fe_values.fe->dofs_per_cell));
+ Assert (fe_values.update_flags & update_values,
+ typename FVB::ExcAccessToUninitializedField());
+
+ // similar to the vector case where we
+ // have more then one index and we need
+ // to convert between unrolled and
+ // component indexing for tensors
+ const int snc
+ = shape_function_data[shape_function].single_nonzero_component;
+
+ if (snc == -2)
+ {
+ // shape function is zero for the
+ // selected components
+ return value_type();
+
+ }
+ else if (snc != -1)
+ {
+ value_type return_value;
+ const unsigned int comp =
+ shape_function_data[shape_function].single_nonzero_component_index;
+ const TableIndices<2> indices = dealii::Tensor<2,spacedim>::unrolled_to_component_indices(comp);
+ return_value[indices] = fe_values.shape_values(snc,q_point);
+ return return_value;
+ }
+ else
+ {
+ value_type return_value;
+ for (unsigned int d = 0; d < dim*dim; ++d)
+ if (shape_function_data[shape_function].is_nonzero_shape_function_component[d])
+ {
+ const TableIndices<2> indices = dealii::Tensor<2,spacedim>::unrolled_to_component_indices(d);
+ return_value[indices]
+ = fe_values.shape_values(shape_function_data[shape_function].row_index[d],q_point);
+ }
+ return return_value;
+ }
+ }
+
+
+ template <int dim, int spacedim>
+ inline
+ typename Tensor<2, dim, spacedim>::divergence_type
+ Tensor<2, dim, spacedim>::divergence(const unsigned int shape_function,
+ const unsigned int q_point) const
+ {
+ typedef FEValuesBase<dim,spacedim> FVB;
+ Assert (shape_function < fe_values.fe->dofs_per_cell,
+ ExcIndexRange (shape_function, 0, fe_values.fe->dofs_per_cell));
+ Assert (fe_values.update_flags & update_gradients,
+ typename FVB::ExcAccessToUninitializedField());
+
+ const int snc = shape_function_data[shape_function].single_nonzero_component;
+
+ if (snc == -2)
+ {
+ // shape function is zero for the
+ // selected components
+ return divergence_type();
+ }
+ else if (snc != -1)
+ {
+ // we have a single non-zero component
+ // when the tensor is
+ // represented in unrolled form.
+ //
+ // the divergence of a second-order tensor
+ // is a first order tensor.
+ //
+ // assume the second-order tensor is
+ // A with components A_{ij}.
+ // divergence as:
+ // b_j := \dfrac{\partial phi_{ij}}{\partial x_i}.
+ //
+ // Now, we know the nonzero component
+ // in unrolled form: it is indicated
+ // by 'snc'. we can figure out which
+ // tensor components belong to this:
+ const unsigned int comp =
+ shape_function_data[shape_function].single_nonzero_component_index;
+ const TableIndices<2> indices = dealii::Tensor<2,spacedim>::unrolled_to_component_indices(comp);
+ const unsigned int ii = indices[0];
+ const unsigned int jj = indices[1];
+
+ const dealii::Tensor<1, spacedim> phi_grad = fe_values.shape_gradients[snc][q_point];
+
+ divergence_type return_value;
+ return_value[jj] = phi_grad[ii];
+
+ return return_value;
+
+ }
+ else
+ {
+ Assert (false, ExcNotImplemented());
+ divergence_type return_value;
+ return return_value;
+ }
+ }
}
return fe_values_views_cache.symmetric_second_order_tensors[tensor.first_tensor_component];
}
+template <int dim, int spacedim>
+inline
+const FEValuesViews::Tensor<2,dim,spacedim> &
+FEValuesBase<dim,spacedim>::
+operator[] (const FEValuesExtractors::Tensor<2> &tensor) const
+{
+ Assert (tensor.first_tensor_component <
+ fe_values_views_cache.second_order_tensors.size(),
+ ExcIndexRange (tensor.first_tensor_component,
+ 0, fe_values_views_cache.second_order_tensors.size()));
+
+ return fe_values_views_cache.second_order_tensors[tensor.first_tensor_component];
+}
+
+
template <int dim, int spacedim>
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_values_extractors_h
#define __deal2__fe_values_extractors_h
*/
SymmetricTensor (const unsigned int first_tensor_component);
};
+
+
+ /**
+ * Extractor for a (possible non-)symmetric tensor of a
+ * rank specified by the template
+ * argument. For a second order
+ * tensor, this represents a collection of
+ * <code>(dim*dim)</code>
+ * components of a vector-valued
+ * element. The value of <code>dim</code>
+ * is defined by the FEValues object the
+ * extractor is applied to. The result of
+ * applying an object of this type to an
+ * FEValues, FEFaceValues or
+ * FESubfaceValues object is of type
+ * FEValuesViews::Tensor.
+ *
+ * The concept of
+ * extractors is defined in the
+ * documentation of the namespace
+ * FEValuesExtractors and in the @ref
+ * vector_valued module.
+ *
+ * @ingroup feaccess vector_valued
+ *
+ * @author Denis Davydov, 2013
+ */
+ template <int rank>
+ struct Tensor
+ {
+ /**
+ * The first component of the tensor
+ * view.
+ */
+ unsigned int first_tensor_component;
+
+ /**
+ * Default constructor. Initialize the
+ * object with an invalid component. This leads to
+ * an object that can not be used, but it allows
+ * objects of this kind to be put into arrays that
+ * require a default constructor upon resizing the
+ * array, and then later assigning a suitable
+ * object to each element of the array.
+ */
+ Tensor ();
+
+ /**
+ * Constructor. Take the first
+ * component of the selected tensor
+ * inside the FEValues object as
+ * argument.
+ */
+ Tensor (const unsigned int first_tensor_component);
+ };
}
:
first_tensor_component (first_tensor_component)
{}
+
+
+ template <int rank>
+ inline
+ Tensor<rank>::Tensor ()
+ :
+ first_tensor_component(numbers::invalid_unsigned_int)
+ {}
+
+
+ template <int rank>
+ inline
+ Tensor<rank>::Tensor (const unsigned int first_tensor_component)
+ :
+ first_tensor_component (first_tensor_component)
+ {}
}
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mapping_h
#define __deal2__mapping_h
* the transform() functions of
* inheriting classes in order to
* work.
+ *
+ * @ingroup mapping
*/
enum MappingType
{
</ul>
@note It would have been more reasonable to make this transform a template function
- with the rank in DerivativeForm<1, dim, rank>. Unfortunately C++ does not
- allow templatized virtual functions. This is why we identified
- DerivativeForm<1, dim, 1> with a Tensor<1,dim> when using mapping_covariant
- in the function transform above this one.
+ with the rank in <code>DerivativeForm@<1, dim, rank@></code>. Unfortunately C++ does not
+ allow templatized virtual functions. This is why we identify
+ <code>DerivativeForm@<1, dim, 1@></code> with a <code>Tensor@<1,dim@></code>
+ when using mapping_covariant() in the function transform above this one.
*/
virtual
@f]
</ul>
- @todo The formulas for @p mapping_covariant_gradient,
- @p mapping_contravariant_gradient and @p mapping_piola_gradient
- are only true as stated for linear mappings,
- if the mapping is bilinear for example then there is a missing
+ @todo The formulas for mapping_covariant_gradient(),
+ mapping_contravariant_gradient() and mapping_piola_gradient()
+ are only true as stated for linear mappings.
+ If, for example, the mapping is bilinear then there is a missing
term associated with the derivative of of J.
-
*/
virtual
void
const InternalDataBase &internal,
const MappingType type) const = 0;
-
-
-
-
-
-
-
-
/**
* @deprecated Use transform() instead.
*/
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2010, 2012 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mapping_c1_h
#define __deal2__mapping_c1_h
*
* To use this class, make sure that the
* Boundary::@p get_normals_at_vertices function is implemented
- * for the users boundary object.
+ * for the user's boundary object.
*
* For more information about the <tt>spacedim</tt> template parameter
* check the documentation of FiniteElement or the one of
{
public:
/**
- * Constructor. Pass the fixed
- * degree @p 3 down to the base
- * class, as a cubic mapping
- * suffices to generate a
- * continuous mapping of the
- * boundary.
+ * Constructor. Pass the fixed degree @p 3 down to the base class, as a
+ * cubic mapping suffices to generate a continuous mapping of the boundary.
*/
MappingC1 ();
/**
- * Return a pointer to a copy of the
- * present object. The caller of this
- * copy then assumes ownership of it.
+ * Return a pointer to a copy of the present object. The caller of this copy
+ * then assumes ownership of it.
*/
virtual
Mapping<dim,spacedim> *clone () const;
protected:
/**
- * For <tt>dim=2,3</tt>. Append the
- * support points of all shape
- * functions located on bounding
- * lines to the vector
- * @p a. Points located on the
- * line but on vertices are not
- * included.
+ * For <tt>dim=2,3</tt>. Append the support points of all shape functions
+ * located on bounding lines to the vector @p a. Points located on the line
+ * but on vertices are not included.
*
- * Needed by the
- * <tt>compute_support_points_simple(laplace)</tt>
- * functions. For <tt>dim=1</tt> this
- * function is empty.
+ * Needed by the <tt>compute_support_points_simple(laplace)</tt>
+ * functions. For <tt>dim=1</tt> this function is empty.
*
- * This function chooses the
- * respective points not such
- * that they are interpolating
- * the boundary (as does the base
- * class), but rather such that
- * the resulting cubic mapping is
- * a continuous one.
+ * This function chooses the respective points not such that they are
+ * interpolating the boundary (as does the base class), but rather such that
+ * the resulting cubic mapping is a continuous one.
*/
virtual void
add_line_support_points (const typename Triangulation<dim>::cell_iterator &cell,
std::vector<Point<dim> > &a) const;
/**
- * For <tt>dim=3</tt>. Append the
- * support points of all shape
- * functions located on bounding
- * faces (quads in 3d) to the
- * vector @p a. Points located
- * on the line but on vertices
- * are not included.
+ * For <tt>dim=3</tt>. Append the support points of all shape functions
+ * located on bounding faces (quads in 3d) to the vector @p a. Points
+ * located on the line but on vertices are not included.
*
- * Needed by the
- * @p compute_support_points_laplace
- * function. For <tt>dim=1</tt> and 2
- * this function is empty.
+ * Needed by the @p compute_support_points_laplace function. For
+ * <tt>dim=1</tt> and 2 this function is empty.
*
- * This function chooses the
- * respective points not such
- * that they are interpolating
- * the boundary (as does the base
- * class), but rather such that
- * the resulting cubic mapping is
- * a continuous one.
+ * This function chooses the respective points not such that they are
+ * interpolating the boundary (as does the base class), but rather such that
+ * the resulting cubic mapping is a continuous one.
*/
virtual void
add_quad_support_points(const typename Triangulation<dim>::cell_iterator &cell,
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mapping_cartesian_h
#define __deal2__mapping_cartesian_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mapping_q_h
#define __deal2__mapping_q_h
/*@{*/
/**
- * Mapping class that uses Qp-mappings on boundary cells. The mapping
- * shape functions make use of tensor product polynomials with
- * equidistant (on the unit cell) support points.
+ * Mapping class that uses Qp-mappings on boundary cells. The mapping shape
+ * functions make use of tensor product polynomials with unit cell support
+ * points equal to the points of the Gauss-Lobatto quadrature formula. These
+ * points give a well-conditioned interpolation also for very high orders and
+ * are therefore preferred over equidistant support points.
*
* For more details about Qp-mappings, see the `mapping' report at
* <tt>deal.II/doc/reports/mapping_q/index.html</tt> in the `Reports'
* check the documentation of FiniteElement or the one of
* Triangulation.
*
+ * @note Since the boundary description is closely tied to the unit cell
+ * support points, new boundary descriptions need to explicitly use the
+ * Gauss-Lobatto points.
+ *
* @author Ralf Hartmann, 2000, 2001, 2005; Guido Kanschat 2000, 2001
*/
template <int dim, int spacedim=dim>
{
public:
/**
- * Constructor. @p p gives the
- * degree of mapping polynomials
- * on boundary cells.
+ * Constructor. @p p gives the degree of mapping polynomials on boundary
+ * cells.
*
- * The second argument determines
- * whether the higher order
- * mapping should also be used on
- * interior cells. If its value
- * is <code>false</code> (the
- * default), the a lower-order
- * mapping is used in the
- * interior. This is sufficient
- * for most cases where higher
- * order mappings are only used
- * to better approximate the
- * boundary. In that case, cells
- * bounded by straight lines are
- * acceptable in the
- * interior. However, there are
- * cases where one would also
- * like to use a higher order
- * mapping in the interior. The
- * MappingQEulerian class is one
- * such case.
+ * The second argument determines whether the higher order mapping should
+ * also be used on interior cells. If its value is <code>false</code> (the
+ * default), the a lower-order mapping is used in the interior. This is
+ * sufficient for most cases where higher order mappings are only used to
+ * better approximate the boundary. In that case, cells bounded by straight
+ * lines are acceptable in the interior. However, there are cases where one
+ * would also like to use a higher order mapping in the interior. The
+ * MappingQEulerian class is one such case.
*/
MappingQ (const unsigned int p,
const bool use_mapping_q_on_all_cells = false);
/**
- * Copy constructor. Performs a
- * deep copy, i.e. duplicates
- * what #tensor_pols points to
- * instead of simply copying the
- * #tensor_pols pointer as done
- * by a default copy constructor.
+ * Copy constructor. Performs a deep copy, i.e. duplicates what #tensor_pols
+ * points to instead of simply copying the #tensor_pols pointer as done by a
+ * default copy constructor.
*/
MappingQ (const MappingQ<dim,spacedim> &mapping);
virtual ~MappingQ ();
/**
- * Transforms the point @p p on
- * the unit cell to the point
- * @p p_real on the real cell
- * @p cell and returns @p p_real.
+ * Transforms the point @p p on the unit cell to the point @p p_real on the
+ * real cell @p cell and returns @p p_real.
*/
virtual Point<spacedim>
transform_unit_to_real_cell (
const Point<dim> &p) const;
/**
- * Transforms the point @p p on
- * the real cell to the point
- * @p p_unit on the unit cell
- * @p cell and returns @p p_unit.
+ * Transforms the point @p p on the real cell to the point @p p_unit on the
+ * unit cell @p cell and returns @p p_unit.
*
- * Uses Newton iteration and the
- * @p transform_unit_to_real_cell
- * function.
+ * Uses Newton iteration and the @p transform_unit_to_real_cell function.
*
- * In the codimension one case,
- * this function returns the
- * normal projection of the real
- * point @p p on the curve or
- * surface identified by the @p
- * cell.
+ * In the codimension one case, this function returns the normal projection
+ * of the real point @p p on the curve or surface identified by the @p cell.
*
- * @note Polynomial mappings from
- * the reference (unit) cell coordinates
- * to the coordinate system of a real
- * cell are not always invertible if
- * the point for which the inverse
- * mapping is to be computed lies
- * outside the cell's boundaries.
- * In such cases, the current function
- * may fail to compute a point on
- * the reference cell whose image
- * under the mapping equals the given
- * point @p p. If this is the case
- * then this function throws an
- * exception of type
- * Mapping::ExcTransformationFailed .
- * Whether the given point @p p lies
- * outside the cell can therefore be
- * determined by checking whether the
- * return reference coordinates lie
- * inside of outside the reference
- * cell (e.g., using
- * GeometryInfo::is_inside_unit_cell)
- * or whether the exception mentioned
- * above has been thrown.
+ * @note Polynomial mappings from the reference (unit) cell coordinates to
+ * the coordinate system of a real cell are not always invertible if the
+ * point for which the inverse mapping is to be computed lies outside the
+ * cell's boundaries. In such cases, the current function may fail to
+ * compute a point on the reference cell whose image under the mapping
+ * equals the given point @p p. If this is the case then this function
+ * throws an exception of type Mapping::ExcTransformationFailed . Whether
+ * the given point @p p lies outside the cell can therefore be determined by
+ * checking whether the return reference coordinates lie inside of outside
+ * the reference cell (e.g., using GeometryInfo::is_inside_unit_cell) or
+ * whether the exception mentioned above has been thrown.
*/
virtual Point<dim>
transform_real_to_unit_cell (
const MappingType type) const;
/**
- * Return the degree of the
- * mapping, i.e. the value which
- * was passed to the constructor.
+ * Return the degree of the mapping, i.e. the value which was passed to the
+ * constructor.
*/
unsigned int get_degree () const;
/**
- * Return a pointer to a copy of the
- * present object. The caller of this
- * copy then assumes ownership of it.
+ * Return a pointer to a copy of the present object. The caller of this copy
+ * then assumes ownership of it.
*/
virtual
Mapping<dim,spacedim> *clone () const;
/**
- * Storage for internal data of
- * Q_degree transformation.
+ * Storage for internal data of Q_degree transformation.
*/
class InternalData : public MappingQ1<dim,spacedim>::InternalData
{
/**
- * Return an estimate (in
- * bytes) or the memory
- * consumption of this
- * object.
+ * Return an estimate (in bytes) or the memory consumption of this object.
*/
virtual std::size_t memory_consumption () const;
/**
- * Unit normal vectors. Used
- * for the alternative
- * computation of the normal
- * vectors. See doc of the
- * @p alternative_normals_computation
- * flag.
+ * Unit normal vectors. Used for the alternative computation of the normal
+ * vectors. See doc of the @p alternative_normals_computation flag.
*
- * Filled (hardcoded) once in
- * @p get_face_data.
+ * Filled (hardcoded) once in @p get_face_data.
*/
std::vector<std::vector<Point<dim> > > unit_normals;
/**
- * Flag that is set by the
- * <tt>fill_fe_[[sub]face]_values</tt>
- * function.
+ * Flag that is set by the <tt>fill_fe_[[sub]face]_values</tt> function.
*
- * If this flag is @p true
- * we are on an interior cell
- * and the
- * @p mapping_q1_data is
- * used.
+ * If this flag is @p true we are on an interior cell and the @p
+ * mapping_q1_data is used.
*/
bool use_mapping_q1_on_current_cell;
/**
- * On interior cells
- * @p MappingQ1 is used.
+ * On interior cells @p MappingQ1 is used.
*/
typename MappingQ1<dim,spacedim>::InternalData mapping_q1_data;
};
protected:
/**
- * Implementation of the interface in
- * Mapping.
+ * Implementation of the interface in Mapping.
*/
virtual void
fill_fe_values (const typename Triangulation<dim,spacedim>::cell_iterator &cell,
CellSimilarity::Similarity &cell_similarity) const ;
/**
- * Implementation of the interface in
- * Mapping.
+ * Implementation of the interface in Mapping.
*/
virtual void
fill_fe_face_values (const typename Triangulation<dim,spacedim>::cell_iterator &cell,
typename std::vector<Point<spacedim> > &normal_vectors) const ;
/**
- * Implementation of the interface in
- * Mapping.
+ * Implementation of the interface in Mapping.
*/
virtual void
fill_fe_subface_values (const typename Triangulation<dim,spacedim>::cell_iterator &cell,
typename std::vector<Point<spacedim> > &normal_vectors) const ;
/**
- * For <tt>dim=2,3</tt>. Append the
- * support points of all shape
- * functions located on bounding
- * lines to the vector
- * @p a. Points located on the
- * line but not on vertices are not
- * included.
+ * For <tt>dim=2,3</tt>. Append the support points of all shape functions
+ * located on bounding lines to the vector @p a. Points located on the line
+ * but not on vertices are not included.
*
- * Needed by the
- * @p compute_support_points_laplace
- * function . For <tt>dim=1</tt> this
- * function is empty.
+ * Needed by the @p compute_support_points_laplace function . For
+ * <tt>dim=1</tt> this function is empty.
*
- * This function is made virtual
- * in order to allow derived
- * classes to choose shape
- * function support points
- * differently than the present
- * class, which chooses the
- * points as interpolation points
- * on the boundary.
+ * This function is made virtual in order to allow derived classes to choose
+ * shape function support points differently than the present class, which
+ * chooses the points as interpolation points on the boundary.
*/
virtual void
add_line_support_points (const typename Triangulation<dim,spacedim>::cell_iterator &cell,
std::vector<Point<spacedim> > &a) const;
/**
- * For <tt>dim=3</tt>. Append the
- * support points of all shape
- * functions located on bounding
- * faces (quads in 3d) to the
- * vector @p a. Points located
- * on the quad but not on vertices
- * are not included.
+ * For <tt>dim=3</tt>. Append the support points of all shape functions
+ * located on bounding faces (quads in 3d) to the vector @p a. Points
+ * located on the quad but not on vertices are not included.
*
- * Needed by the
- * @p compute_support_points_laplace
- * function. For <tt>dim=1</tt> and
- * <tt>dim=2</tt> this function is
- * empty.
+ * Needed by the @p compute_support_points_laplace function. For
+ * <tt>dim=1</tt> and <tt>dim=2</tt> this function is empty.
*
- * This function is made virtual
- * in order to allow derived
- * classes to choose shape
- * function support points
- * differently than the present
- * class, which chooses the
- * points as interpolation points
- * on the boundary.
+ * This function is made virtual in order to allow derived classes to choose
+ * shape function support points differently than the present class, which
+ * chooses the points as interpolation points on the boundary.
*/
virtual void
add_quad_support_points(const typename Triangulation<dim,spacedim>::cell_iterator &cell,
const Quadrature<dim-1>& quadrature) const;
/**
- * Compute shape values and/or
- * derivatives.
+ * Compute shape values and/or derivatives.
*/
virtual void
compute_shapes_virtual (const std::vector<Point<dim> > &unit_points,
typename MappingQ1<dim,spacedim>::InternalData &data) const;
/**
- * This function is needed by the
- * constructor of <tt>MappingQ<dim,spacedim></tt>
- * for <tt>dim=</tt> 2 and 3.
+ * This function is needed by the constructor of
+ * <tt>MappingQ<dim,spacedim></tt> for <tt>dim=</tt> 2 and 3.
*
- * For <tt>degree<4</tt> this function
- * sets the
- * @p laplace_on_quad_vector to
- * the hardcoded data. For
- * <tt>degree>=4</tt> and MappingQ<2>
- * this vector is computed.
+ * For <tt>degree<4</tt> this function sets the @p laplace_on_quad_vector to
+ * the hardcoded data. For <tt>degree>=4</tt> and MappingQ<2> this vector is
+ * computed.
*
- * For the definition of the
- * @p laplace_on_quad_vector
- * please refer to equation (8)
- * of the `mapping' report.
+ * For the definition of the @p laplace_on_quad_vector please refer to
+ * equation (8) of the `mapping' report.
*/
void
set_laplace_on_quad_vector(Table<2,double> &loqvs) const;
/**
- * This function is needed by the
- * constructor of <tt>MappingQ<3></tt>.
+ * This function is needed by the constructor of <tt>MappingQ<3></tt>.
*
- * For <tt>degree==2</tt> this function
- * sets the
- * @p laplace_on_hex_vector to
- * the hardcoded data. For
- * <tt>degree>2</tt> this vector is
- * computed.
+ * For <tt>degree==2</tt> this function sets the @p laplace_on_hex_vector to
+ * the hardcoded data. For <tt>degree>2</tt> this vector is computed.
*
- * For the definition of the
- * @p laplace_on_hex_vector
- * please refer to equation (8)
- * of the `mapping' report.
+ * For the definition of the @p laplace_on_hex_vector please refer to
+ * equation (8) of the `mapping' report.
*/
void set_laplace_on_hex_vector(Table<2,double> &lohvs) const;
/**
- * Computes the
- * <tt>laplace_on_quad(hex)_vector</tt>.
+ * Computes the <tt>laplace_on_quad(hex)_vector</tt>.
*
- * Called by the
- * <tt>set_laplace_on_quad(hex)_vector</tt>
- * functions if the data is not
- * yet hardcoded.
+ * Called by the <tt>set_laplace_on_quad(hex)_vector</tt> functions if the
+ * data is not yet hardcoded.
*
- * For the definition of the
- * <tt>laplace_on_quad(hex)_vector</tt>
- * please refer to equation (8)
- * of the `mapping' report.
+ * For the definition of the <tt>laplace_on_quad(hex)_vector</tt> please
+ * refer to equation (8) of the `mapping' report.
*/
void compute_laplace_vector(Table<2,double> &lvs) const;
/**
- * Takes a
- * <tt>laplace_on_hex(quad)_vector</tt>
- * and applies it to the vector
- * @p a to compute the inner
- * support points as a linear
- * combination of the exterior
- * points.
+ * Takes a <tt>laplace_on_hex(quad)_vector</tt> and applies it to the vector
+ * @p a to compute the inner support points as a linear combination of the
+ * exterior points.
*
- * The vector @p a initially
- * contains the locations of the
- * @p n_outer points, the
- * @p n_inner computed inner
- * points are appended.
+ * The vector @p a initially contains the locations of the @p n_outer
+ * points, the @p n_inner computed inner points are appended.
*
- * See equation (7) of the
- * `mapping' report.
+ * See equation (7) of the `mapping' report.
*/
void apply_laplace_vector(const Table<2,double> &lvs,
std::vector<Point<spacedim> > &a) const;
/**
- * Computes the support points of
- * the mapping.
+ * Computes the support points of the mapping.
*/
virtual void compute_mapping_support_points(
const typename Triangulation<dim,spacedim>::cell_iterator &cell,
std::vector<Point<spacedim> > &a) const;
/**
- * Computes all support points of
- * the mapping shape
- * functions. The inner support
- * points (ie. support points in
- * quads for 2d, in hexes for 3d)
- * are computed using the
- * solution of a Laplace equation
- * with the position of the outer
- * support points as boundary
- * values, in order to make the
- * transformation as smooth as
- * possible.
+ * Computes all support points of the mapping shape functions. The inner
+ * support points (ie. support points in quads for 2d, in hexes for 3d) are
+ * computed using the solution of a Laplace equation with the position of
+ * the outer support points as boundary values, in order to make the
+ * transformation as smooth as possible.
*/
void compute_support_points_laplace(
const typename Triangulation<dim,spacedim>::cell_iterator &cell,
std::vector<Point<spacedim> > &a) const;
/**
- * Needed by the
- * @p laplace_on_quad function
- * (for <tt>dim==2</tt>). Filled by the
- * constructor.
+ * Needed by the @p laplace_on_quad function (for <tt>dim==2</tt>). Filled
+ * by the constructor.
*
* Sizes:
- * laplace_on_quad_vector.size()=
- * number of inner
- * unit_support_points
- * laplace_on_quad_vector[i].size()=
- * number of outer
- * unit_support_points, i.e.
- * unit_support_points on the
- * boundary of the quad
+ * laplace_on_quad_vector.size()= number of inner unit_support_points
+ * laplace_on_quad_vector[i].size()= number of outer unit_support_points,
+ * i.e. unit_support_points on the boundary of the quad
*
- * For the definition of this
- * vector see equation (8) of the
- * `mapping' report.
+ * For the definition of this vector see equation (8) of the `mapping'
+ * report.
*/
Table<2,double> laplace_on_quad_vector;
/**
- * Needed by the
- * @p laplace_on_hex function
- * (for <tt>dim==3</tt>). Filled by the
- * constructor.
+ * Needed by the @p laplace_on_hex function (for <tt>dim==3</tt>). Filled by
+ * the constructor.
*
- * For the definition of this
- * vector see equation (8) of the
- * `mapping' report.
+ * For the definition of this vector see equation (8) of the `mapping'
+ * report.
*/
Table<2,double> laplace_on_hex_vector;
<< "laplace_vector not set for degree=" << arg1 << ".");
/**
- * Degree @p p of the
- * polynomials used as shape
- * functions for the Qp mapping
+ * Degree @p p of the polynomials used as shape functions for the Qp mapping
* of cells at the boundary.
*/
const unsigned int degree;
/**
- * Number of inner mapping shape
- * functions.
+ * Number of inner mapping shape functions.
*/
const unsigned int n_inner;
/**
- * Number of mapping shape
- * functions on the boundary.
+ * Number of mapping shape functions on the boundary.
*/
const unsigned int n_outer;
/**
- * Pointer to the
- * @p dim-dimensional tensor
- * product polynomials used as
- * shape functions for the Qp
- * mapping of cells at the
- * boundary.
+ * Pointer to the @p dim-dimensional tensor product polynomials used as
+ * shape functions for the Qp mapping of cells at the boundary.
*/
const TensorProductPolynomials<dim> *tensor_pols;
/**
- * Number of the Qp tensor
- * product shape functions.
+ * Number of the Qp tensor product shape functions.
*/
const unsigned int n_shape_functions;
/**
- * Mapping from lexicographic to
- * to the Qp shape function
- * numbering. Its size is
- * @p dofs_per_cell.
+ * Mapping from lexicographic to to the Qp shape function numbering. Its
+ * size is @p dofs_per_cell.
*/
const std::vector<unsigned int> renumber;
/**
- * If this flag is set @p true
- * then @p MappingQ is used on
- * all cells, not only on
- * boundary cells.
+ * If this flag is set @p true then @p MappingQ is used on all cells, not
+ * only on boundary cells.
*/
const bool use_mapping_q_on_all_cells;
/**
- * An FE_Q object which is only needed in
- * 3D, since it knows how to reorder shape
- * functions/DoFs on non-standard
- * faces. This is used to reorder support
- * points in the same way. We could make
- * this a pointer to prevent construction
- * in 1D and 2D, but since memory and time
- * requirements are not particularly high
- * this seems unnecessary at the moment.
+ * An FE_Q object which is only needed in 3D, since it knows how to reorder
+ * shape functions/DoFs on non-standard faces. This is used to reorder
+ * support points in the same way. We could make this a pointer to prevent
+ * construction in 1D and 2D, but since memory and time requirements are not
+ * particularly high this seems unnecessary at the moment.
*/
const FE_Q<dim> feq;
+
+ /**
+ * Declare other MappingQ classes friends.
+ */
+ template <int,int> friend class MappingQ;
};
/*@}*/
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mapping_q1_h
#define __deal2__mapping_q1_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mapping_q1_eulerian_h
#define __deal2__mapping_q1_eulerian_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mapping_q_eulerian_h
#define __deal2__mapping_q_eulerian_h
{
public:
/**
- * Constructor. The first argument is
- * the polynomical degree of the desired
- * Qp mapping. It then takes a
- * <tt>Vector<double> &</tt> to specify the
- * transformation of the domain
- * from the reference to
- * the current configuration.
- * The organization of the
- * elements in the @p Vector
- * must follow the concept how
- * deal.II stores solutions that
- * are associated to a
- * triangulation. This is
- * automatically the case if the
- * @p Vector represents the
- * solution of the previous step
- * of a nonlinear problem.
- * Alternatively, the @p Vector
- * can be initialized by
+ * Constructor. The first argument is the polynomical degree of the desired
+ * Qp mapping. It then takes a <tt>Vector<double> &</tt> to specify the
+ * transformation of the domain from the reference to the current
+ * configuration. The organization of the elements in the @p Vector must
+ * follow the concept how deal.II stores solutions that are associated to a
+ * triangulation. This is automatically the case if the @p Vector
+ * represents the solution of the previous step of a nonlinear problem.
+ * Alternatively, the @p Vector can be initialized by
* <tt>DoFAccessor::set_dof_values()</tt>.
*/
const DoFHandler<dim,spacedim> &euler_dof_handler);
/**
- * Return a pointer to a copy of the
- * present object. The caller of this
- * copy then assumes ownership of it.
+ * Return a pointer to a copy of the present object. The caller of this copy
+ * then assumes ownership of it.
*/
virtual
Mapping<dim,spacedim> *clone () const;
/**
- * Always returns @p false because
- * MappingQ1Eulerian does not in general
- * preserve vertex locations (unless the
- * translation vector happens to provide
- * for zero displacements at vertex
- * locations).
+ * Always returns @p false because MappingQ1Eulerian does not in general
+ * preserve vertex locations (unless the translation vector happens to
+ * provide for zero displacements at vertex locations).
*/
bool preserves_vertex_locations () const;
protected:
/**
- * Implementation of the interface in
- * MappingQ. Overrides the function in
- * the base class, since we cannot use
- * any cell similarity for this class.
+ * Implementation of the interface in MappingQ. Overrides the function in
+ * the base class, since we cannot use any cell similarity for this class.
*/
virtual void
fill_fe_values (const typename Triangulation<dim,spacedim>::cell_iterator &cell,
CellSimilarity::Similarity &cell_similarity) const;
/**
- * Reference to the vector of
- * shifts.
+ * Reference to the vector of shifts.
*/
SmartPointer<const VECTOR, MappingQEulerian<dim,VECTOR,spacedim> > euler_vector;
/**
- * Pointer to the DoFHandler to
- * which the mapping vector is
- * associated.
+ * Pointer to the DoFHandler to which the mapping vector is associated.
*/
-
SmartPointer<const DoFHandler<dim,spacedim>,MappingQEulerian<dim,VECTOR,spacedim> > euler_dof_handler;
private:
/**
- * Special quadrature rule used
- * to define the support points
- * in the reference configuration.
+ * Special quadrature rule used to define the support points in the
+ * reference configuration.
*/
class SupportQuadrature : public Quadrature<dim>
{
public:
/**
- * Constructor, with an argument
- * defining the desired polynomial
- * degree.
+ * Constructor, with an argument defining the desired polynomial degree.
*/
SupportQuadrature (const unsigned int map_degree);
};
/**
- * A member variable holding the
- * quadrature points in the right
- * order.
+ * A member variable holding the quadrature points in the right order.
*/
const SupportQuadrature support_quadrature;
/**
- * FEValues object used to query the
- * the given finite element field
- * at the support points in the
- * reference configuration.
+ * FEValues object used to query the the given finite element field at the
+ * support points in the reference configuration.
*
- * The variable is marked as
- * mutable since we have to call
- * FEValues::reinit from
- * compute_mapping_support_points,
- * a function that is 'const'.
+ * The variable is marked as mutable since we have to call FEValues::reinit
+ * from compute_mapping_support_points, a function that is 'const'.
*/
mutable FEValues<dim,spacedim> fe_values;
/**
- * A variable to guard access to
- * the fe_values variable.
+ * A variable to guard access to the fe_values variable.
*/
mutable Threads::Mutex fe_values_mutex;
/**
- * Compute the positions of the
- * support points in the current
- * configuration
+ * Compute the positions of the support points in the current configuration
*/
virtual void compute_mapping_support_points(
const typename Triangulation<dim,spacedim>::cell_iterator &cell,
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1998 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+#ifndef __deal2__cell_id_h
+#define __deal2__cell_id_h
+
+#include <deal.II/base/config.h>
+#include <deal.II/base/exceptions.h>
+
+#include <vector>
+
+
+DEAL_II_NAMESPACE_OPEN
+
+
+/**
+ * A class to represent a unique ID for a cell in a Triangulation.
+ * This class stores the index of the coarse cell together with the
+ * information on how to reach the cell from that coarse cell (which
+ * child index to take on each level). The internal representation
+ * is not exposed on purpose.
+ *
+ * TODO: does it make sense to implement a more efficient representation
+ * (internally and/or as a string)? If yes, something like a 64bit int
+ * as in p4est would be a good option.
+ */
+class CellId
+{
+public:
+ /**
+ * construct CellId with a given coarse_cell_index and list of child indices
+ */
+ explicit CellId(unsigned int coarse_cell_id_, std::vector<unsigned char> id_)
+ : coarse_cell_id(coarse_cell_id_), id(id_)
+ {}
+
+ /**
+ * construct an empty CellId.
+ */
+ CellId()
+ : coarse_cell_id(-1)
+ {}
+
+ /**
+ * compare two CellIds
+ */
+ bool operator== (const CellId &other) const;
+
+ /**
+ * compare two CellIds
+ */
+ bool operator!= (const CellId &other) const;
+
+
+ friend std::istream &operator>> (std::istream &is, CellId &cid);
+ friend std::ostream &operator<< (std::ostream &os, const CellId &cid);
+private:
+ unsigned int coarse_cell_id;
+ std::vector<unsigned char> id;
+};
+
+/**
+ * output CellId into a stream
+ */
+inline std::ostream &operator<< (std::ostream &os, const CellId &cid)
+{
+ os << cid.coarse_cell_id << '_' << cid.id.size() << ':';
+ for (unsigned int i=0; i<cid.id.size(); ++i)
+ os << static_cast<int>(cid.id[i]);
+ return os;
+}
+
+/**
+ * read CellId from a stream
+ */
+inline std::istream &operator>> (std::istream &is, CellId &cid)
+{
+ unsigned int cellid;
+ is >> cellid;
+ if (is.eof())
+ return is;
+
+ cid.coarse_cell_id = cellid;
+ char dummy;
+ is >> dummy;
+ Assert(dummy=='_', ExcMessage("invalid CellId"));
+ unsigned int idsize;
+ is >> idsize;
+ is >> dummy;
+ Assert(dummy==':', ExcMessage("invalid CellId"));
+
+ char value;
+ cid.id.clear();
+ for (unsigned int i=0; i<idsize; ++i)
+ {
+ is >> value;
+ cid.id.push_back(value-'0');
+ }
+ return is;
+}
+
+inline bool
+CellId::operator== (const CellId &other) const
+{
+ if (this->coarse_cell_id != other.coarse_cell_id)
+ return false;
+ return id == other.id;
+}
+
+/**
+ *
+ */
+inline bool
+CellId::operator!= (const CellId &other) const
+{
+ return !(*this == other);
+}
+
+DEAL_II_NAMESPACE_CLOSE
+
+#endif
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2011, 2012 by the deal.II authors
+// Copyright (C) 2002 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__filtered_iterator_h
#define __deal2__filtered_iterator_h
/**
* In this namespace a number of classes is declared that may be used
- * as filters in the FilteredIterator class. The filters either
- * check for binary information (for example, the IteratorFilters::Active filter
- * class checks whether the object pointed to is active), or for
- * valued information by comparison with prescribed values (for
- * example, the LevelEqualTo filter class checks whether the
- * level of the object pointed to by the iterator under consideration
- * is equal to a value that was given to the filter upon construction.
+ * as filters in the FilteredIterator class. The filters either check
+ * for binary information (for example, the IteratorFilters::Active
+ * filter class checks whether the object pointed to is active), or
+ * for valued information by comparison with prescribed values (for
+ * example, the LevelEqualTo filter class checks whether the level of
+ * the object pointed to by the iterator under consideration is equal
+ * to a value that was given to the filter upon construction.
*
* For examples of use of these classes as well as requirements on
- * filters see the general description of the FilteredIterator
- * class.
+ * filters see the general description of the FilteredIterator class.
*
* @ingroup Iterators
* @author Wolfgang Bangerth, 2002
namespace IteratorFilters
{
/**
- * Filter that evaluates to true if
- * either the iterator points to an
- * active object or an iterator
- * past the end.
+ * Filter that evaluates to true if either the iterator points to an
+ * active object or an iterator past the end.
*
* @ingroup Iterators
*/
{
public:
/**
- * Evaluate the iterator and
- * return true if the object is
- * active or past the end.
+ * Evaluate the iterator and return true if the object is active
+ * or past the end.
*/
template <class Iterator>
bool operator () (const Iterator &i) const;
};
/**
- * Filter that evaluates to true if
- * either the iterator points to an
- * object for which the user flag
- * is set or an iterator past the
- * end. See @ref GlossUserFlags
- * for information about user flags.
+ * Filter that evaluates to true if either the iterator points to an
+ * object for which the user flag is set or an iterator past the
+ * end. See @ref GlossUserFlags for information about user flags.
*
* @ingroup Iterators
*/
{
public:
/**
- * Evaluate the iterator and
- * return true if the object
- * has a set user flag or past
- * the end.
+ * Evaluate the iterator and return true if the object has a set
+ * user flag or past the end.
*/
template <class Iterator>
bool operator () (const Iterator &i) const;
/**
- * Filter that evaluates to true if
- * either the iterator points to an
- * object for which the user flag
- * is not set or an iterator past
- * the end. Inverse filter to the
- * previous class.
+ * Filter that evaluates to true if either the iterator points to an
+ * object for which the user flag is not set or an iterator past the
+ * end. Inverse filter to the previous class.
*
* @ingroup Iterators
*/
{
public:
/**
- * Evaluate the iterator and
- * return true if the object
- * has an unset user flag or
- * past the end.
+ * Evaluate the iterator and return true if the object has an
+ * unset user flag or past the end.
*/
template <class Iterator>
bool operator () (const Iterator &i) const;
/**
- * Filter for iterators that
- * evaluates to true if either the
- * iterator is past the end or the
- * level of the object pointed to
- * is equal to a value given to the
- * constructor.
+ * Filter for iterators that evaluates to true if either the
+ * iterator is past the end or the level of the object pointed to is
+ * equal to a value given to the constructor.
*
* @ingroup Iterators
*/
{
public:
/**
- * Constructor. Store the level
- * which iterators shall have
- * to be evaluated to true.
+ * Constructor. Store the level which iterators shall have to be
+ * evaluated to true.
*/
LevelEqualTo (const unsigned int level);
/**
- * Evaluation operator. Returns
- * true if either the level of
- * the object pointed to is
- * equal to the stored value or
- * the iterator is past the
- * end.
+ * Evaluation operator. Returns true if either the level of the
+ * object pointed to is equal to the stored value or the iterator
+ * is past the end.
*/
template <class Iterator>
bool operator () (const Iterator &i) const;
protected:
/**
- * Stored value to compare the
- * level with.
+ * Stored value to compare the level with.
*/
const unsigned int level;
};
/**
- * Filter for iterators that
- * evaluates to true if either the
- * iterator is past the end or the
- * subdomain id of the object
- * pointed to is equal to a value
- * given to the constructor,
- * assuming that the iterator
- * allows querying for a subdomain
- * id).
+ * Filter for iterators that evaluates to true if either the
+ * iterator is past the end or the subdomain id of the object
+ * pointed to is equal to a value given to the constructor, assuming
+ * that the iterator allows querying for a subdomain id).
*
* @ingroup Iterators
*/
{
public:
/**
- * Constructor. Store the
- * subdomain which iterators
- * shall have to be evaluated
- * to true.
+ * Constructor. Store the subdomain which iterators shall have to
+ * be evaluated to true.
*/
SubdomainEqualTo (const types::subdomain_id subdomain_id);
/**
- * Evaluation operator. Returns
- * true if either the subdomain
- * of the object pointed to is
- * equal to the stored value or
- * the iterator is past the
- * end.
+ * Evaluation operator. Returns true if either the subdomain of
+ * the object pointed to is equal to the stored value or the
+ * iterator is past the end.
*/
template <class Iterator>
bool operator () (const Iterator &i) const;
protected:
/**
- * Stored value to compare the
- * subdomain with.
+ * Stored value to compare the subdomain with.
*/
const types::subdomain_id subdomain_id;
};
/**
- * Filter for iterators that evaluates to
- * true if a cell is owned by the current
- * processor, i.e., if it is a
- * @ref GlossLocallyOwnedCell "locally owned cell".
+ * Filter for iterators that evaluates to true if a cell is owned by
+ * the current processor, i.e., if it is a @ref
+ * GlossLocallyOwnedCell "locally owned cell".
*
- * This class is used in step-32, in
- * connection with the methods of the @ref
- * distributed module.
+ * This class is used in step-32, in connection with the methods of
+ * the @ref distributed module.
*
* @ingroup Iterators
*/
{
public:
/**
- * Evaluation operator. Returns true if
- * the cell is locally owned.
+ * Evaluation operator. Returns true if the cell is locally owned.
+ */
+ template <class Iterator>
+ bool operator () (const Iterator &i) const;
+ };
+
+
+
+ /**
+ * Filter for iterators that evaluates to true if th level subdomain
+ * id of a cell is equal to the current processor id.
+ *
+ * @ingroup Iterators
+ */
+ class LocallyOwnedLevelCell
+ {
+ public:
+ /**
+ * Evaluation operator. Returns true if the level subdomain id of
+ * the cell is equal to the current processor id.
*/
template <class Iterator>
bool operator () (const Iterator &i) const;
FilteredIterator<BaseIterator>::
FilteredIterator (const FilteredIterator &fi)
:
- BaseIterator (static_cast<BaseIterator>(fi)),
+// this construction looks strange, but without going through the
+// address of fi, GCC would not cast fi to the base class of type
+// BaseIterator but tries to go through constructing a new
+// BaseIterator with an Accessor.
+ BaseIterator (*(BaseIterator *)(&fi)),
predicate (fi.predicate->clone ())
{}
{
return (i->is_locally_owned());
}
+
+
+// ---------------- IteratorFilters::LocallyOwnedLevelCell ---------
+
+ template <class Iterator>
+ inline
+ bool
+ LocallyOwnedLevelCell::operator () (const Iterator &i) const
+ {
+ return (i->is_locally_owned_on_level());
+ }
}
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__grid_generator_h
#define __deal2__grid_generator_h
/**
- * This class provides a collection of functions for generating basic
- * triangulations. Below, we try to provide some pictures in order to
- * illustrate at least the more complex ones.
+ * This namespace provides a collection of functions for generating
+ * triangulations for some basic geometries.
*
* Some of these functions receive a flag @p colorize. If this is
- * set, parts of the boundary receive different boundary numbers,
- * allowing them to be distinguished by application programs. See the
- * documentation of the functions for details.
- *
- * Additionally this class provides a function
- * (@p laplace_transformation) that smoothly transforms a grid
- * according to given new boundary points. This can be used to
- * transform (simple-shaped) grids to a more complicated ones, like a
- * shell onto a grid of an airfoil, for example.
- *
- * No meshes for the codimension one case are provided at the moment.
+ * set, parts of the boundary receive different boundary indicators
+ * (@ref GlossBoundaryIndicator),
+ * allowing them to be distinguished for the purpose of attaching geometry
+ * objects and evaluating different boundary conditions.
*
+ * This namespace also provides a function
+ * GridGenerator::laplace_transformation that smoothly transforms a domain
+ * into another one. This can be used to
+ * transform basic geometries to more complicated ones, like a
+ * shell to a grid of an airfoil, for example.
*
* @ingroup grid
*/
-class GridGenerator
+namespace GridGenerator
{
-public:
- /**
- * Declare type for number of cell.
- */
- typedef types::global_dof_index size_type;
-
/**
* Initialize the given triangulation with a hypercube (line in 1D, square
* in 2D, etc) consisting of exactly one cell. The hypercube volume is the
* @note The triangulation needs to be void upon calling this function.
*/
template <int dim, int spacedim>
- static void hyper_cube (Triangulation<dim,spacedim> &tria,
- const double left = 0.,
- const double right= 1.);
+ void hyper_cube (Triangulation<dim,spacedim> &tria,
+ const double left = 0.,
+ const double right= 1.);
/**
* Same as hyper_cube(), but with the difference that not only one cell is
* @note The triangulation needs to be void upon calling this function.
*/
template <int dim>
- static void subdivided_hyper_cube (Triangulation<dim> &tria,
- const unsigned int repetitions,
- const double left = 0.,
- const double right= 1.);
+ void subdivided_hyper_cube (Triangulation<dim> &tria,
+ const unsigned int repetitions,
+ const double left = 0.,
+ const double right= 1.);
/**
* Create a coordinate-parallel brick from the two diagonally opposite
* @note The triangulation needs to be void upon calling this function.
*/
template <int dim, int spacedim>
- static void hyper_rectangle (Triangulation<dim,spacedim> &tria,
- const Point<spacedim> &p1,
- const Point<spacedim> &p2,
- const bool colorize = false);
+ void hyper_rectangle (Triangulation<dim,spacedim> &tria,
+ const Point<spacedim> &p1,
+ const Point<spacedim> &p2,
+ const bool colorize = false);
/**
* Create a coordinate-parallel parallelepiped from the two diagonally
* program.
*/
template <int dim>
- static
void
subdivided_hyper_rectangle (Triangulation<dim> &tria,
const std::vector<unsigned int> &repetitions,
const Point<dim> &p1,
const Point<dim> &p2,
- const bool colorize=false);
+ const bool colorize=false);
/**
* Like the previous function. However, here the second argument does not
* specified by the points @p p1 and @p p2.
*/
template <int dim>
- static
void
- subdivided_hyper_rectangle(Triangulation<dim> &tria,
- const std::vector<std::vector<double> > &step_sizes,
- const Point<dim> &p_1,
- const Point<dim> &p_2,
- const bool colorize);
+ subdivided_hyper_rectangle (Triangulation<dim> &tria,
+ const std::vector<std::vector<double> > &step_sizes,
+ const Point<dim> &p_1,
+ const Point<dim> &p_2,
+ const bool colorize);
/**
* Like the previous function, but with the following twist: the @p
* i.e. the domain will have a void there.
*/
template <int dim>
- static
void
subdivided_hyper_rectangle (Triangulation<dim> &tria,
const std::vector< std::vector<double> > &spacing,
const Point<dim> &p,
- const Table<dim,types::material_id> &material_id,
- const bool colorize=false);
+ const Table<dim,types::material_id> &material_id,
+ const bool colorize=false);
/**
* A parallelogram. The first corner point is the origin. The <tt>dim</tt>
* @note The triangulation needs to be void upon calling this function.
*/
template <int dim>
- static
void
- parallelogram(Triangulation<dim> &tria,
- const Point<dim> (&corners)[dim],
- const bool colorize=false);
+ parallelogram (Triangulation<dim> &tria,
+ const Point<dim> (&corners) [dim],
+ const bool colorize=false);
/**
* @deprecated Use the other function of same name.
*/
template <int dim>
- static
void
- parallelogram(Triangulation<dim> &tria,
- const Tensor<2,dim> &corners,
- const bool colorize=false) DEAL_II_DEPRECATED;
+ parallelogram (Triangulation<dim> &tria,
+ const Tensor<2,dim> &corners,
+ const bool colorize=false) DEAL_II_DEPRECATED;
/**
* A parallelepiped. The first corner point is the origin. The
* function.
*/
template <int dim>
- static
void
- parallelepiped (Triangulation<dim> &tria,
- const Point<dim> (&corners) [dim],
- const bool colorize = false);
+ parallelepiped (Triangulation<dim> &tria,
+ const Point<dim> (&corners) [dim],
+ const bool colorize = false);
/**
* A subdivided parallelepiped. The first corner point is the
* function.
*/
template <int dim>
- static
void
subdivided_parallelepiped (Triangulation<dim> &tria,
- const size_type n_subdivisions,
+ const unsigned int n_subdivisions,
const Point<dim> (&corners) [dim],
const bool colorize = false);
* function.
*/
template <int dim>
- static
void
subdivided_parallelepiped (Triangulation<dim> &tria,
- const size_type ( n_subdivisions) [dim],
+ const unsigned int (n_subdivisions) [dim],
const Point<dim> (&corners) [dim],
const bool colorize = false);
* @note The triangulation needs to be void upon calling this function.
*/
template <int dim>
- static void enclosed_hyper_cube (Triangulation<dim> &tria,
- const double left = 0.,
- const double right= 1.,
- const double thickness = 1.,
- const bool colorize = false);
+ void enclosed_hyper_cube (Triangulation<dim> &tria,
+ const double left = 0.,
+ const double right= 1.,
+ const double thickness = 1.,
+ const bool colorize = false);
/**
* Initialize the given triangulation with a hyperball, i.e. a circle or a
* @note The triangulation needs to be void upon calling this function.
*/
template <int dim>
- static void hyper_ball (Triangulation<dim> &tria,
- const Point<dim> ¢er = Point<dim>(),
- const double radius = 1.);
+ void hyper_ball (Triangulation<dim> &tria,
+ const Point<dim> ¢er = Point<dim>(),
+ const double radius = 1.);
/**
* This class produces a half hyper-ball around <tt>center</tt>, which
* @note The triangulation needs to be void upon calling this function.
*/
template <int dim>
- static void half_hyper_ball (Triangulation<dim> &tria,
- const Point<dim> ¢er = Point<dim>(),
- const double radius = 1.);
+ void half_hyper_ball (Triangulation<dim> &tria,
+ const Point<dim> ¢er = Point<dim>(),
+ const double radius = 1.);
/**
* Create a cylinder around the x-axis. The cylinder extends from
* @note The triangulation needs to be void upon calling this function.
*/
template <int dim>
- static void cylinder (Triangulation<dim> &tria,
- const double radius = 1.,
- const double half_length = 1.);
+ void cylinder (Triangulation<dim> &tria,
+ const double radius = 1.,
+ const double half_length = 1.);
/**
* Create a cutted cone around the x-axis. The cone extends from
* @author Markus Bürg, 2009
*/
template <int dim>
- static void
+ void
truncated_cone (Triangulation<dim> &tria,
- const double radius_0 = 1.0,
- const double radius_1 = 0.5,
- const double half_length = 1.0);
+ const double radius_0 = 1.0,
+ const double radius_1 = 0.5,
+ const double half_length = 1.0);
/**
* Initialize the given triangulation with a hyper-L consisting of exactly
* @note The triangulation needs to be void upon calling this function.
*/
template <int dim>
- static void hyper_L (Triangulation<dim> &tria,
- const double left = -1.,
- const double right= 1.);
+ void hyper_L (Triangulation<dim> &tria,
+ const double left = -1.,
+ const double right= 1.);
/**
* Initialize the given Triangulation with a hypercube with a slit. In each
* @note The triangulation needs to be void upon calling this function.
*/
template <int dim>
- static void hyper_cube_slit (Triangulation<dim> &tria,
- const double left = 0.,
- const double right= 1.,
- const bool colorize = false);
+ void hyper_cube_slit (Triangulation<dim> &tria,
+ const double left = 0.,
+ const double right = 1.,
+ const bool colorize = false);
/**
* Produce a hyper-shell, the region between two spheres around
* @note The triangulation needs to be void upon calling this function.
*/
template <int dim>
- static void hyper_shell (Triangulation<dim> &tria,
- const Point<dim> ¢er,
- const double inner_radius,
- const double outer_radius,
- const size_type n_cells = 0,
- bool colorize = false);
+ void hyper_shell (Triangulation<dim> &tria,
+ const Point<dim> ¢er,
+ const double inner_radius,
+ const double outer_radius,
+ const unsigned int n_cells = 0,
+ bool colorize = false);
/**
* Produce a half hyper-shell, i.e. the space between two circles in two
* @note The triangulation needs to be void upon calling this function.
*/
template <int dim>
- static void half_hyper_shell (Triangulation<dim> &tria,
- const Point<dim> ¢er,
- const double inner_radius,
- const double outer_radius,
- const size_type n_cells = 0,
- const bool colorize = false);
+ void half_hyper_shell (Triangulation<dim> &tria,
+ const Point<dim> ¢er,
+ const double inner_radius,
+ const double outer_radius,
+ const unsigned int n_cells = 0,
+ const bool colorize = false);
/**
* @note The triangulation needs to be void upon calling this function.
*/
template <int dim>
- static void quarter_hyper_shell (Triangulation<dim> &tria,
- const Point<dim> ¢er,
- const double inner_radius,
- const double outer_radius,
- const size_type n_cells = 0,
- const bool colorize = false);
+ void quarter_hyper_shell (Triangulation<dim> &tria,
+ const Point<dim> ¢er,
+ const double inner_radius,
+ const double outer_radius,
+ const unsigned int n_cells = 0,
+ const bool colorize = false);
/**
* Produce a domain that is the space between two cylinders in 3d, with
* @note The triangulation needs to be void upon calling this function.
*/
template <int dim>
- static void cylinder_shell (Triangulation<dim> &tria,
- const double length,
- const double inner_radius,
- const double outer_radius,
- const size_type n_radial_cells = 0,
- const size_type n_axial_cells = 0);
+ void cylinder_shell (Triangulation<dim> &tria,
+ const double length,
+ const double inner_radius,
+ const double outer_radius,
+ const unsigned int n_radial_cells = 0,
+ const unsigned int n_axial_cells = 0);
* torus.
*/
- static void torus (Triangulation<2,3> &tria,
- const double R,
- const double r);
+ void torus (Triangulation<2,3> &tria,
+ const double R,
+ const double r);
/**
* @arg @p L: extension in @p z-direction (only used in 3d)
* @arg @p repetitions: number of subdivisions
* along the @p z-direction
- * @arg @p colorize: wether to assign different
+ * @arg @p colorize: whether to assign different
* boundary indicators to different faces.
* The colors are given in lexicographic
* ordering for the flat faces (0 to 3 in 2d,
* get the number 0 and the hole gets number 1.
*/
template<int dim>
- static void hyper_cube_with_cylindrical_hole (Triangulation<dim> &triangulation,
- const double inner_radius = .25,
- const double outer_radius = .5,
- const double L = .5,
- const size_type repetition = 1,
- const bool colorize = false);
+ void hyper_cube_with_cylindrical_hole (
+ Triangulation<dim> &triangulation,
+ const double inner_radius = .25,
+ const double outer_radius = .5,
+ const double L = .5,
+ const unsigned int repetition = 1,
+ const bool colorize = false);
/**
* Produce a ring of cells in 3D that is cut open, twisted and glued
* @param R The radius of the circle, which forms the middle line of the torus containing the loop of cells. Must be greater than @p r.
* @param r The radius of the cylinder bend together as loop.
*/
- static void moebius (Triangulation<3,3> &tria,
- const size_type n_cells,
- const unsigned int n_rotations,
- const double R,
- const double r);
+ void moebius (Triangulation<3,3> &tria,
+ const unsigned int n_cells,
+ const unsigned int n_rotations,
+ const double R,
+ const double r);
/**
* Given the two triangulations specified as the first two arguments, create
* GridTools::create_union_triangulation .
*/
template <int dim, int spacedim>
- static
void
merge_triangulations (const Triangulation<dim, spacedim> &triangulation_1,
const Triangulation<dim, spacedim> &triangulation_2,
* to the corresponding side walls in z direction. The bottom and top
* get the next two free boundary indicators.
*/
- static
void
- extrude_triangulation(const Triangulation<2, 2> & input,
- const size_type n_slices,
- const double height,
- Triangulation<3,3> &result);
+ extrude_triangulation (const Triangulation<2, 2> &input,
+ const unsigned int n_slices,
+ const double height,
+ Triangulation<3,3> &result);
/**
* This function transformes the @p Triangulation @p tria smoothly to a
* @deprecated This function has been moved to GridTools::laplace_transform
*/
template <int dim>
- static
void laplace_transformation (Triangulation<dim> &tria,
- const std::map<size_type,Point<dim> > &new_points) DEAL_II_DEPRECATED;
+ const std::map<unsigned int,Point<dim> > &new_points) DEAL_II_DEPRECATED;
/**
* Exception
int,
<< "The vector of repetitions must have "
<< arg1 <<" elements.");
-
-private:
- /**
- * Perform the action specified by the @p colorize flag of the
- * hyper_rectangle() function of this class.
- */
- template <int dim, int spacedim>
- static
- void
- colorize_hyper_rectangle (Triangulation<dim,spacedim> &tria);
-
- /**
- * Perform the action specified by the @p colorize flag of the
- * subdivided_hyper_rectangle() function of this class. This function is
- * singled out because it is dimension specific.
- */
- template <int dim>
- static
- void
- colorize_subdivided_hyper_rectangle (Triangulation<dim> &tria,
- const Point<dim> &p1,
- const Point<dim> &p2,
- const double epsilon);
-
- /**
- * Assign boundary number zero to the inner shell boundary and 1 to the
- * outer.
- */
- template<int dim>
- static
- void
- colorize_hyper_shell (Triangulation<dim> &tria,
- const Point<dim> ¢er,
- const double inner_radius,
- const double outer_radius);
-
-
- /**
- * Assign boundary number zero the inner shell boundary, one to the outer
- * shell boundary, two to the face with x=0, three to the face with y=0,
- * four to the face with z=0.
- */
- template<int dim>
- static
- void
- colorize_quarter_hyper_shell(Triangulation<dim> &tria,
- const Point<dim> ¢er,
- const double inner_radius,
- const double outer_radius);
-
- /**
- * Solve the Laplace equation for @p laplace_transformation function for one
- * of the @p dim space dimensions. Externalized into a function of its own
- * in order to allow parallel execution.
- */
- static
- void
- laplace_solve (const SparseMatrix<double> &S,
- const std::map<size_type,double> &m,
- Vector<double> &u);
-};
+}
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__grid_in_h
#define __deal2__grid_in_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__grid_out_h
#define __deal2__grid_out_h
/**
* Background style.
*/
- enum Background{
- /// Use transparent value of SVG
- transparent,
- /// Use white background
- white,
- /// Use a gradient from white (top) to steelblue (bottom), and add date and time plus a deal.II logo. Automatically draws a margin.
- dealii};
+ enum Background
+ {
+ /// Use transparent value of SVG
+ transparent,
+ /// Use white background
+ white,
+ /// Use a gradient from white (top) to steelblue (bottom), and add date and time plus a deal.II logo. Automatically draws a margin.
+ dealii
+ };
Background background;
/**
* Cell coloring.
*/
- enum Coloring{
- /// No cell coloring
- none,
- /// Convert the material id into the cell color (default)
- material_id,
- /// Convert the level number into the cell color
- level_number,
- /// Convert the subdomain id into the cell color
- subdomain_id,
- /// Convert the level subdomain id into the cell color
- level_subdomain_id};
-
+ enum Coloring
+ {
+ /// No cell coloring
+ none,
+ /// Convert the material id into the cell color (default)
+ material_id,
+ /// Convert the level number into the cell color
+ level_number,
+ /// Convert the subdomain id into the cell color
+ subdomain_id,
+ /// Convert the level subdomain id into the cell color
+ level_subdomain_id
+ };
+
Coloring coloring;
/// Interpret the level number of the cells as altitude over the x-y-plane (useful in the perpspective view).
/**
* Cell labeling (fixed order).
- *
+ *
* The following booleans determine which properties of the cell
* shall be displayed as text in the middle of each cell.
*/
/**
* Write the triangulation in the SVG format.
- *
- * SVG (Scalable Vector Graphics) is
- * an XML-based vector image format
- * developed and maintained by the
- * World Wide Web Consortium (W3C).
- * This function conforms to the
- * latest specification SVG 1.1,
+ *
+ * SVG (Scalable Vector Graphics) is
+ * an XML-based vector image format
+ * developed and maintained by the
+ * World Wide Web Consortium (W3C).
+ * This function conforms to the
+ * latest specification SVG 1.1,
* released on August 16, 2011.
- *
+ *
* The cells of the triangulation are written as polygons with
* additional lines at the boundary of the triangulation. A coloring
* of the cells is further possible in order to visualize a certain
* colorbar can be drawn to encode the chosen coloring. Moreover, a
* cell label can be added, showing level index, etc.
*
- * @note Yet only implemented for
+ * @note Yet only implemented for
* two-dimensional grids in two
* space dimensions.
- *
+ *
*/
template <int dim, int spacedim>
void write_svg (const Triangulation<dim,spacedim> &tria,
*/
template <int dim>
void write_mathgl (const Triangulation<dim> &tria,
- std::ostream &out) const;
+ std::ostream &out) const;
/**
* Write grid to @p out according to the given data format. This
/**
- * This function projects a three-dimensional point (Point<3> point)
- * onto a two-dimensional image plane, specified by the position of
- * the camera viewing system (Point<3> camera_position), camera
- * direction (Point<3> camera_position), camera horizontal (Point<3>
- * camera_horizontal, necessary for the correct alignment of the
+ * This function projects a three-dimensional point (Point<3> point)
+ * onto a two-dimensional image plane, specified by the position of
+ * the camera viewing system (Point<3> camera_position), camera
+ * direction (Point<3> camera_position), camera horizontal (Point<3>
+ * camera_horizontal, necessary for the correct alignment of the
* later images), and the focus of the camera (float camera_focus).
*
* For SVG output of grids.
*/
- static Point<2> svg_project_point(Point<3> point,
- Point<3> camera_position,
- Point<3> camera_direction,
- Point<3> camera_horizontal,
+ static Point<2> svg_project_point(Point<3> point,
+ Point<3> camera_position,
+ Point<3> camera_direction,
+ Point<3> camera_horizontal,
float camera_focus);
/**
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__grid_refinement_h
#define __deal2__grid_refinement_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__grid_reordering_h
#define __deal2__grid_reordering_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2005, 2006, 2011, 2012 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__grid_reordering_internal_h
#define __deal2__grid_reordering_internal_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__grid_tools_H
#define __deal2__grid_tools_H
#include <deal.II/grid/tria_accessor.h>
#include <deal.II/grid/tria_iterator.h>
#include <deal.II/fe/mapping_q1.h>
+#include <deal.II/base/std_cxx1x/tuple.h>
#include <bitset>
#include <list>
Triangulation<2> &triangulation);
/**
- * This function transformes the @p Triangulation @p tria smoothly to a
- * domain that is described by the boundary points in the map @p
- * new_points. This map maps the point indices to the boundary points in the
- * transformed domain.
- *
- * Note, that the @p Triangulation is changed in-place, therefore you don't
- * need to keep two triangulations, but the given triangulation is changed
- * (overwritten).
- *
- * In 1d, this function is not currently implemented.
+ * Transform the given triangulation smoothly to a different domain where
+ * each of the vertices at the boundary of the triangulation is mapped to
+ * the corresponding points in the @p new_points map.
+ *
+ * The way this function works is that it solves a Laplace equation for each
+ * of the dim components of a displacement field that maps the current
+ * domain into one described by @p new_points . The @p new_points array
+ * therefore represents the boundary values of this displacement field.
+ * The function then evaluates this displacement field at each vertex in
+ * the interior and uses it to place the mapped vertex where the
+ * displacement field locates it. Because the solution of the Laplace
+ * equation is smooth, this guarantees a smooth mapping from the old
+ * domain to the new one.
+ *
+ * @param[in] new_points The locations where a subset of the existing vertices
+ * are to be placed. Typically, this would be a map from the vertex indices
+ * of all nodes on the boundary to their new locations, thus completely
+ * specifying the geometry of the mapped domain. However, it may also include
+ * interior points if necessary and it does not need to include all boundary
+ * vertices (although you then lose control over the exact shape of the mapped
+ * domain).
+ *
+ * @param[in,out] tria The Triangulation object. This object is changed in-place,
+ * i.e., the previous locations of vertices are overwritten.
+ *
+ * @note This function is not currently implemented for the 1d case.
*/
template <int dim>
void laplace_transform (const std::map<unsigned int,Point<dim> > &new_points,
* a hanging node located on a face or an
* edge of it.
*
+ * @note If the point requested does not lie in any of the cells of
+ * the mesh given, then this function throws an exception of type
+ * GridTools::ExcPointNotFound. You can catch this exception and
+ * decide what to do in that case.
+ *
* @note It isn't entirely clear at this time whether the function
* does the right thing with anisotropically refined meshes. It needs
* to be checked for this case.
/**
- * Find and return an iterator to
- * the active cell that surrounds
- * a given point @p ref. The
- * type of the first parameter
- * may be either
- * Triangulation,
- * DoFHandler, or
- * MGDoFHandler, i.e. we
- * can find the cell around a
- * point for iterators into each
- * of these classes.
- *
- * This is solely a wrapper function
- * for the @p interpolate function
- * given below,
- * providing backward compatibility.
- * A Q1 mapping is used for the
- * boundary, and the iterator to
- * the cell in which the point
- * resides is returned.
- *
- * It is recommended to use the
- * other version of this function,
- * as it simultaneously delivers the
- * local coordinate of the given point
- * without additional computational cost.
+ * Find and return an iterator to the active cell that surrounds a
+ * given point @p ref. The type of the first parameter may be either
+ * Triangulation, or one of the DoF handler classes, i.e. we can find the
+ * cell around a point for iterators into each of these classes.
+ *
+ * This is solely a wrapper function for the function of same name
+ * below. A Q1 mapping is used for the boundary, and the iterator
+ * to the cell in which the point resides is returned.
+ *
+ * It is recommended to use the other version of this function, as
+ * it simultaneously delivers the local coordinate of the given
+ * point without additional computational cost.
+ *
+ * @note If the point requested does not lie in any of the cells of
+ * the mesh given, then this function throws an exception of type
+ * GridTools::ExcPointNotFound. You can catch this exception and
+ * decide what to do in that case.
*
* @note When applied to a triangulation or DoF handler object based
* on a parallel::distributed::Triangulation object, the cell
const Point<spacedim> &p);
/**
- * Find and return an iterator to
- * the active cell that surrounds
- * a given point @p p. The
- * type of the first parameter
- * may be either
- * Triangulation,
- * DoFHandler, hp::DoFHandler, or
- * MGDoFHandler, i.e., we
- * can find the cell around a
- * point for iterators into each
- * of these classes.
- *
- * The algorithm used in this
- * function proceeds by first
- * looking for vertex located
- * closest to the given point, see
- * find_closest_vertex(). Secondly,
- * all adjacent cells to this point
- * are found in the mesh, see
- * find_cells_adjacent_to_vertex().
- * Lastly, for each of these cells,
- * it is tested whether the point is
- * inside. This check is performed
- * using arbitrary boundary mappings.
- * Still, it is possible that due
- * to roundoff errors, the point
- * cannot be located exactly inside
- * the unit cell. In this case,
- * even points at a very small
- * distance outside the unit cell
+ * Find and return an iterator to the active cell that surrounds a
+ * given point @p p. The type of the first parameter may be either
+ * Triangulation, DoFHandler, hp::DoFHandler, or MGDoFHandler, i.e.,
+ * we can find the cell around a point for iterators into each of
+ * these classes.
+ *
+ * The algorithm used in this function proceeds by first looking for
+ * vertex located closest to the given point, see
+ * find_closest_vertex(). Secondly, all adjacent cells to this point
+ * are found in the mesh, see find_cells_adjacent_to_vertex().
+ * Lastly, for each of these cells, it is tested whether the point
+ * is inside. This check is performed using arbitrary boundary
+ * mappings. Still, it is possible that due to roundoff errors, the
+ * point cannot be located exactly inside the unit cell. In this
+ * case, even points at a very small distance outside the unit cell
* are allowed.
*
- * If a point lies on the
- * boundary of two or more cells,
- * then the algorithm tries to identify
- * the cell that is of highest
+ * If a point lies on the boundary of two or more cells, then the
+ * algorithm tries to identify the cell that is of highest
* refinement level.
*
- * The function returns an
- * iterator to the cell, as well
- * as the local position of the
- * point inside the unit
- * cell. This local position
- * might be located slightly
- * outside an actual unit cell,
- * due to numerical roundoff.
- * Therefore, the point returned
- * by this function should
- * be projected onto the unit cell,
- * using GeometryInfo::project_to_unit_cell.
- * This is not automatically performed
- * by the algorithm.
+ * The function returns an iterator to the cell, as well as the
+ * local position of the point inside the unit cell. This local
+ * position might be located slightly outside an actual unit cell,
+ * due to numerical roundoff. Therefore, the point returned by this
+ * function should be projected onto the unit cell, using
+ * GeometryInfo::project_to_unit_cell. This is not automatically
+ * performed by the algorithm.
+ *
+ * @note If the point requested does not lie in any of the cells of
+ * the mesh given, then this function throws an exception of type
+ * GridTools::ExcPointNotFound. You can catch this exception and
+ * decide what to do in that case.
*
* @note When applied to a triangulation or DoF handler object based
* on a parallel::distributed::Triangulation object, the cell
const Point<spacedim> &p);
/**
- * A version of the previous function
- * where we use that mapping on a given
- * cell that corresponds to the active
- * finite element index of that
- * cell. This is obviously only useful
- * for hp problems, since the active
- * finite element index for all other DoF
- * handlers is always zero.
+ * A version of the previous function where we use that mapping on a
+ * given cell that corresponds to the active finite element index of
+ * that cell. This is obviously only useful for hp problems, since
+ * the active finite element index for all other DoF handlers is
+ * always zero.
+ *
+ * @note If the point requested does not lie in any of the cells of
+ * the mesh given, then this function throws an exception of type
+ * GridTools::ExcPointNotFound. You can catch this exception and
+ * decide what to do in that case.
*
* @note When applied to a triangulation or DoF handler object based
* on a parallel::distributed::Triangulation object, the cell
const std::set<types::boundary_id> &boundary_ids
= std::set<types::boundary_id>());
-
+ /**
+ * Data type that provides all the information that is needed
+ * to create periodicity constraints and a periodic p4est forest
+ * with respect to two periodic cell faces
+ */
+ template<typename CellIterator>
+ struct PeriodicFacePair
+ {
+ CellIterator cell[2];
+ unsigned int face_idx[2];
+ std::bitset<3> orientation;
+ };
/**
* An orthogonal equality test for faces.
/**
- * This function loops over all faces from @p begin to @p end and
- * collects a set of periodic face pairs for @p direction:
+ * This function will collect periodic face pairs on the highest (i.e.
+ * coarsest) mesh level.
*
* Define a 'first' boundary as all boundary faces having boundary_id
* @p b_id1 and a 'second' boundary consisting of all faces belonging
*
* This function tries to match all faces belonging to the first
* boundary with faces belonging to the second boundary with the help
- * of orthogonal_equality.
+ * of orthogonal_equality().
+ *
+ * The bitset that is returned inside of PeriodicFacePair encodes the
+ * _relative_ orientation of the first face with respect to the second
+ * face, see the documentation of orthogonal_equality for further details.
+ *
+ * The @p direction refers to the space direction in which periodicity
+ * is enforced.
*
* The @p offset is a vector tangential to the faces that is added to the
* location of vertices of the 'first' boundary when attempting to match
* them to the corresponding vertices of the 'second' boundary. This can
* be used to implement conditions such as $u(0,y)=u(1,y+1)$.
*
- * @author Matthias Maier, 2012
- */
- template<typename FaceIterator>
- std::map<FaceIterator, std::pair<FaceIterator, std::bitset<3> > >
- collect_periodic_face_pairs (const FaceIterator &begin,
- const typename identity<FaceIterator>::type &end,
- const types::boundary_id b_id1,
- const types::boundary_id b_id2,
- int direction,
- const dealii::Tensor<1,FaceIterator::AccessorType::space_dimension> &offset);
-
-
- /**
- * Same function as above, but accepts a Triangulation or DoFHandler
- * object @p dof_handler instead of an explicit face iterator range.
- *
- * This function will collect periodic face pairs on the highest (i.e.
- * coarsest) mesh level.
+ * @note The created std::vector can be used in
+ * DoFTools::make_periodicity_constraints and in
+ * parallel::distributed::Triangulation::add_periodicity to enforce
+ * periodicity algebraically.
*
- * @author Matthias Maier, 2012
+ * @author Daniel Arndt, 2013
*/
template<typename DH>
- std::map<typename DH::face_iterator, std::pair<typename DH::face_iterator, std::bitset<3> > >
- collect_periodic_face_pairs (const DH &dof_handler, /*TODO: Name*/
- const types::boundary_id b_id1,
- const types::boundary_id b_id2,
- int direction,
- const dealii::Tensor<1,DH::space_dimension> &offset);
-
+ std::vector<PeriodicFacePair<typename DH::cell_iterator> >
+ collect_periodic_faces
+ (const DH &dof_handler,
+ const types::boundary_id b_id1,
+ const types::boundary_id b_id2,
+ const unsigned int direction,
+ const dealii::Tensor<1,DH::space_dimension> &offset);
/**
* This compatibility version of collect_periodic_face_pairs only works
* meshes with cells not in @ref GlossFaceOrientation
* "standard orientation".
*
+ * @author Daniel Arndt, 2013
+ */
+ template<typename DH>
+ std::vector<PeriodicFacePair<typename DH::cell_iterator> >
+ collect_periodic_faces
+ (const DH &dof_handler,
+ const types::boundary_id b_id,
+ const unsigned int direction,
+ const dealii::Tensor<1,DH::space_dimension> &offset);
+
+ /**
+ * This function does the same as collect_periodic_faces but returns a
+ * different data type.
+ *
* @author Matthias Maier, 2012
+ *
+ * @note The returned data type is not compatible with
+ * DoFTools::make_periodicity_constraints
+ *
+ * @deprecated
+ */
+ template<typename DH>
+ std::map<typename DH::face_iterator, std::pair<typename DH::face_iterator, std::bitset<3> > >
+ collect_periodic_face_pairs
+ (const DH &container,
+ const types::boundary_id b_id1,
+ const types::boundary_id b_id2,
+ int direction,
+ const dealii::Tensor<1,DH::space_dimension> &offset) DEAL_II_DEPRECATED;
+
+ /**
+ * This compatibility version of collect_periodic_face_pairs only works
+ * on grids with cells in @ref GlossFaceOrientation "standard orientation".
+ *
+ * @author Matthias Maier, 2012
+ *
+ * @note The returned data type is not compatible with
+ * DoFTools::make_periodicity_constraints
+ *
+ * @deprecated
*/
template<typename DH>
std::map<typename DH::face_iterator, typename DH::face_iterator>
- collect_periodic_face_pairs (const DH &dof_handler, /*TODO: Name*/
- const types::boundary_id b_id,
- int direction,
- const dealii::Tensor<1,DH::space_dimension> &offset);
+ collect_periodic_face_pairs
+ (const DH &dof_handler, /*TODO: Name*/
+ const types::boundary_id b_id,
+ int direction,
+ const dealii::Tensor<1,DH::space_dimension> &offset) DEAL_II_DEPRECATED;
+ /**
+ * This version loops over all faces from @p begin to @p end
+ * instead of accepting a DoFHandler or a Triangulation.
+ *
+ * @author Matthias Maier, 2012
+ *
+ * @note This function cannot produce the return as the other
+ * collect_periodic_faces functions.
+ *
+ * @deprecated
+ */
+ template<typename FaceIterator>
+ std::map<FaceIterator, std::pair<FaceIterator, std::bitset<3> > >
+ collect_periodic_face_pairs
+ (const FaceIterator &begin,
+ const typename identity<FaceIterator>::type &end,
+ const types::boundary_id b_id1,
+ const types::boundary_id b_id2,
+ const int direction,
+ const dealii::Tensor<1,FaceIterator::AccessorType::space_dimension> &offset)
+ DEAL_II_DEPRECATED;
+
+ /**
+ * This function does the same as collect_periodic_faces but returns a
+ * different data type.
+ *
+ * @author Daniel Arndt, 2013
+ *
+ * @note The returned data type is not compatible with
+ * DoFTools::make_periodicity_constraints, but with a version of
+ * parallel::distributed::Triangulation::add_periodicity
+ *
+ * @note Use collect_periodic_faces instead.
+ *
+ * @deprecated
+ */
+ template<typename DH>
+ void
+ identify_periodic_face_pairs
+ (const DH &dof_handler,
+ const types::boundary_id b_id1,
+ const types::boundary_id b_id2,
+ const unsigned int direction,
+ std::vector<std_cxx1x::tuple<typename DH::cell_iterator, unsigned int,
+ typename DH::cell_iterator, unsigned int> >
+ &periodicity_vector) DEAL_II_DEPRECATED;
/**
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__intergrid_map_h
#define __deal2__intergrid_map_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__magic_numbers_h
#define __deal2__magic_numbers_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2011, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__persistent_tria_h
#define __deal2__persistent_tria_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__tria_h
#define __deal2__tria_h
* RefinementListener.
*
* @note The use of this class has been
- * superceded by the signals mechanism.
+ * superseded by the signals mechanism.
* See the general documentation of the
* Triangulation class for more information.
*
* class also has virtual functions.
*
* @note The use of this class has been
- * superceded by the signals mechanism.
+ * superseded by the signals mechanism.
* See the general documentation of the
* Triangulation class for more information.
*
* registered with the triangulation.
*
* @note The use of this class has been
- * superceded by the signals mechanism.
+ * superseded by the signals mechanism.
* See the general documentation of the
* Triangulation class for more information.
*
* registered with the triangulation.
*
* @note The use of this class has been
- * superceded by the signals mechanism.
+ * superseded by the signals mechanism.
* See the general documentation of the
* Triangulation class for more information.
*
* derived classes.
*
* @note The use of this class has been
- * superceded by the signals mechanism.
+ * superseded by the signals mechanism.
* See the general documentation of the
* Triangulation class for more information.
*
* implemented in derived classes.
*
* @note The use of this class has been
- * superceded by the signals mechanism.
+ * superseded by the signals mechanism.
* See the general documentation of the
* Triangulation class for more information.
*
virtual
void
create_notification (const Triangulation<dim, spacedim> &tria);
- } DEAL_II_DEPRECATED;
+ };
/**
* A structure that is used as an
* section on signals in the general
* documentation of this class.
*/
- void refine_global (const unsigned int times);
+ void refine_global (const unsigned int times = 1);
/**
* Execute both refinement and
* the Triangulation is refined.
*
* @note The use of this function has been
- * superceded by the signals mechanism.
+ * superseded by the signals mechanism.
* See the general documentation of the
* Triangulation class for more information.
*
* Triangulation.
*
* @note The use of this function has been
- * superceded by the signals mechanism.
+ * superseded by the signals mechanism.
* See the general documentation of the
* Triangulation class for more information.
*
cell_iterator begin (const unsigned int level = 0) const;
/**
- * Iterator to the first active
- * cell on level @p level.
+ * Iterator to the first active cell on level @p level. If the
+ * given level does not contain any active cells (i.e., all cells
+ * on this level are further refined, then this function returns
+ * <code>end_active(level)</code> so that loops of the kind
+ * @code
+ * for (cell=tria.begin_active(level); cell!=tria.end_active(level); ++cell)
+ * ...
+ * @endcode
+ * have zero iterations, as may be expected if there are no active
+ * cells on this level.
*/
active_cell_iterator begin_active(const unsigned int level = 0) const;
cell_iterator end (const unsigned int level) const;
/**
- * Return an active iterator which is the
- * first iterator not on level. If @p level
- * is the last level, then this returns
- * <tt>end()</tt>.
+ * Return an active iterator which is the first active iterator not
+ * on the given level. If @p level is the last level, then this
+ * returns <tt>end()</tt>.
*/
active_cell_iterator end_active (const unsigned int level) const;
*/
cell_iterator last () const;
- /**
- * Return an iterator pointing to the
- * last used cell on level @p level.
- */
- cell_iterator last (const unsigned int level) const;
-
/**
* Return an iterator pointing to the
* last active cell.
*/
active_cell_iterator last_active () const;
-
- /**
- * Return an iterator pointing to the
- * last active cell on level @p level.
- */
- active_cell_iterator last_active (const unsigned int level) const;
/*@}*/
/*---------------------------------------*/
*/
DeclException0 (ExcTriangulationNotEmpty);
/**
- * Trying to re-read a grid, an error occured.
+ * Trying to re-read a grid, an error occurred.
*
* @ingroup Exceptions
*/
* this contains nothing, in 2D it contains data
* concerning lines and in 3D quads and lines. All of
* these have no level and are therefore treated
- * seperately.
+ * separately.
*/
dealii::internal::Triangulation::TriaFaces<dim> *faces;
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__tria_accessor_h
#define __deal2__tria_accessor_h
#include <deal.II/base/point.h>
#include <deal.II/grid/tria_iterator_base.h>
#include <deal.II/grid/tria_iterator_selector.h>
+#include <deal.II/grid/cell_id.h>
+#include <utility>
-namespace std
-{
- template<class T1, class T2>
- struct pair;
-}
DEAL_II_NAMESPACE_OPEN
TriaAccessorBase (const Triangulation<dim,spacedim> *parent = 0,
const int level = -1,
const int index = -1,
- const AccessorData * = 0);
+ const AccessorData * = 0);
/**
* Copy constructor. Creates an
*/
TriaAccessorBase &operator = (const TriaAccessorBase &);
+ /**
+ * Ordering of accessors. If #structure_dimension is less than
+ * #dimension, we simply compare the index of such an object. If
+ * #structure_dimension equals #dimension, we compare the level()
+ * first, and the index() only if levels are equal.
+ */
+ bool operator < (const TriaAccessorBase &other) const;
+
protected:
/**
* Copy operator. This is normally
/**
* Return an iterator to the
- * parent.
+ * parent. Throws an exception if this cell has no parent, i.e. has
+ * level 0.
*/
TriaIterator<CellAccessor<dim,spacedim> >
parent () const;
*/
bool active () const;
+ /**
+ * Ordering of accessors. This function implements a total ordering
+ * of cells even on a parallel::distributed::Triangulation. This
+ * function first compares level_subdomain_id(). If these are equal,
+ * and both cells are active, it compares subdomain_id(). If this is
+ * inconclusive, TriaAccessorBase::operator < () is called.
+ */
+ bool operator < (const CellAccessor<dim, spacedim> &other) const;
+
+
/**
* Return whether this cell is owned by the current processor
* or is owned by another processor. The function always returns
*/
bool is_locally_owned () const;
+ /**
+ * Return true if either the Triangulation is not distributed or if
+ * level_subdomain_id() is equal to the id of the current processor.
+ */
+ bool is_locally_owned_on_level () const;
+
/**
* Return whether this cell
* exists in the global mesh but
void set_neighbor (const unsigned int i,
const TriaIterator<CellAccessor<dim, spacedim> > &pointer) const;
+ /**
+ * Return a unique ID for the current cell. This ID is constructed from the
+ * path in the hierarchy from the coarse father cell and works correctly
+ * in parallel computations.
+ *
+ * Note: This operation takes O(log(level)) time.
+ */
+ CellId id() const;
+
/**
* @}
*/
"the conversion is not valid in the current context."));
}
+template <int dim, int spacedim>
+CellId
+CellAccessor<dim,spacedim>::id() const
+{
+ std::vector<unsigned char> id(this->level(), -1);
+ unsigned int coarse_index;
+
+ CellAccessor<dim,spacedim> ptr = *this;
+ while (ptr.level()>0)
+ {
+ // find the 'v'st child of our parent we are
+ unsigned char v=-1;
+ for (unsigned int c=0; c<ptr.parent()->n_children(); ++c)
+ {
+ if (ptr.parent()->child_index(c)==ptr.index())
+ {
+ v = c;
+ break;
+ }
+ }
+
+ Assert(v != (unsigned char)-1, ExcInternalError());
+ id[ptr.level()-1] = v;
+
+ ptr.copy_from( *(ptr.parent()));
+ }
+
+ Assert(ptr.level()==0, ExcInternalError());
+ coarse_index = ptr.index();
+
+ return CellId(coarse_index, id);
+}
+
#ifndef DOXYGEN
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__tria_accessor_templates_h
#define __deal2__tria_accessor_templates_h
+template <int structdim, int dim, int spacedim>
+inline
+bool
+TriaAccessorBase<structdim,dim,spacedim>::operator < (const TriaAccessorBase<structdim,dim,spacedim> &other) const
+{
+ Assert (tria == other.tria, TriaAccessorExceptions::ExcCantCompareIterators());
+
+ if (present_level != other.present_level)
+ return (present_level < other.present_level);
+
+ return (present_index < other.present_index);
+
+}
+
+
+
template <int structdim, int dim, int spacedim>
inline
int
}
+template <int dim, int spacedim>
+inline
+bool
+CellAccessor<dim,spacedim>::is_locally_owned_on_level () const
+{
+#ifndef DEAL_II_WITH_P4EST
+ return true;
+#else
+ const parallel::distributed::Triangulation<dim,spacedim> *pdt
+ = dynamic_cast<const parallel::distributed::Triangulation<dim,spacedim> *>(this->tria);
+
+ if (pdt == 0)
+ return true;
+ else
+ return (this->level_subdomain_id() == pdt->locally_owned_subdomain());
+#endif
+}
+
+
template <int dim, int spacedim>
inline
bool
return neighbor_of_coarser_neighbor(neighbor).first;
}
+
+template <int dim, int spacedim>
+inline
+bool
+CellAccessor<dim,spacedim>::operator < (const CellAccessor<dim,spacedim> &other) const
+{
+ Assert (this->tria == other.tria, TriaAccessorExceptions::ExcCantCompareIterators());
+
+ if (level_subdomain_id() != other.level_subdomain_id())
+ return (level_subdomain_id() < other.level_subdomain_id());
+
+ if (active() && other.active() &&
+ (subdomain_id() != other.subdomain_id()))
+ return (subdomain_id() < other.subdomain_id());
+
+ return TriaAccessorBase<dim,dim,spacedim>::operator < (other);
+}
+
+
+
DEAL_II_NAMESPACE_CLOSE
#endif
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__tria_boundary_h
#define __deal2__tria_boundary_h
#include <deal.II/base/config.h>
#include <deal.II/base/subscriptor.h>
+#include <deal.II/base/quadrature_lib.h>
+#include <deal.II/base/thread_management.h>
#include <deal.II/base/point.h>
#include <deal.II/grid/tria.h>
public:
/**
- * Type keeping information about
- * the normals at the vertices of
- * a face of a cell. Thus, there
- * are
- * <tt>GeometryInfo<dim>::vertices_per_face</tt>
- * normal vectors, that define
- * the tangent spaces of the
- * boundary at the vertices. Note
- * that the vectors stored in
- * this object are not required
- * to be normalized, nor to
- * actually point outward, as one
- * often will only want to check
- * for orthogonality to define
- * the tangent plane; if a
- * function requires the normals
- * to be normalized, then it must
- * do so itself.
+ * Type keeping information about the normals at the vertices of a face of a
+ * cell. Thus, there are <tt>GeometryInfo<dim>::vertices_per_face</tt>
+ * normal vectors, that define the tangent spaces of the boundary at the
+ * vertices. Note that the vectors stored in this object are not required to
+ * be normalized, nor to actually point outward, as one often will only want
+ * to check for orthogonality to define the tangent plane; if a function
+ * requires the normals to be normalized, then it must do so itself.
*
- * For obvious reasons, this
- * type is not useful in 1d.
+ * For obvious reasons, this type is not useful in 1d.
*/
typedef Tensor<1,spacedim> FaceVertexNormals[GeometryInfo<dim>::vertices_per_face];
/**
- * Destructor. Does nothing here, but
- * needs to be declared to make it
+ * Destructor. Does nothing here, but needs to be declared to make it
* virtual.
*/
virtual ~Boundary ();
/**
- * Return the point which shall
- * become the new middle vertex
- * of the two children of a
- * regular line. In 2D, this line
- * is a line at the boundary,
- * while in 3d, it is bounding a
- * face at the boundary (the
- * lines therefore is also on the
- * boundary).
+ * Return the point which shall become the new middle vertex of the two
+ * children of a regular line. In 2D, this line is a line at the boundary,
+ * while in 3d, it is bounding a face at the boundary (the lines therefore
+ * is also on the boundary).
*/
virtual
Point<spacedim>
get_new_point_on_line (const typename Triangulation<dim,spacedim>::line_iterator &line) const = 0;
/**
- * Return the point which shall
- * become the common point of the
- * four children of a quad at the
- * boundary in three or more
- * spatial dimensions. This
- * function therefore is only
- * useful in at least three
- * dimensions and should not be
- * called for lower dimensions.
+ * Return the point which shall become the common point of the four children
+ * of a quad at the boundary in three or more spatial dimensions. This
+ * function therefore is only useful in at least three dimensions and should
+ * not be called for lower dimensions.
*
- * This function is called after
- * the four lines bounding the
- * given @p quad are refined, so
- * you may want to use the
- * information provided by
- * <tt>quad->line(i)->child(j)</tt>,
- * <tt>i=0...3</tt>, <tt>j=0,1</tt>.
+ * This function is called after the four lines bounding the given @p quad
+ * are refined, so you may want to use the information provided by
+ * <tt>quad->line(i)->child(j)</tt>, <tt>i=0...3</tt>, <tt>j=0,1</tt>.
*
- * Because in 2D, this function
- * is not needed, it is not made
- * pure virtual, to avoid the
- * need to overload it. The
- * default implementation throws
- * an error in any case, however.
+ * Because in 2D, this function is not needed, it is not made pure virtual,
+ * to avoid the need to overload it. The default implementation throws an
+ * error in any case, however.
*/
virtual
Point<spacedim>
get_new_point_on_quad (const typename Triangulation<dim,spacedim>::quad_iterator &quad) const;
/**
- * Depending on <tt>dim=2</tt> or
- * <tt>dim=3</tt> this function
- * calls the
- * get_new_point_on_line or the
- * get_new_point_on_quad
- * function. It throws an
- * exception for
- * <tt>dim=1</tt>. This wrapper
- * allows dimension independent
+ * Depending on <tt>dim=2</tt> or <tt>dim=3</tt> this function calls the
+ * get_new_point_on_line or the get_new_point_on_quad function. It throws an
+ * exception for <tt>dim=1</tt>. This wrapper allows dimension independent
* programming.
*/
Point<spacedim>
get_new_point_on_face (const typename Triangulation<dim,spacedim>::face_iterator &face) const;
/**
- * Return equally spaced
- * intermediate points on a line.
+ * Return intermediate points on a line spaced according to the interior
+ * support points of the 1D Gauss-Lobatto quadrature formula.
*
- * The number of points requested
- * is given by the size of the
- * vector @p points. It is the
- * task of the derived classes to
- * arrange the points in
+ * The number of points requested is given by the size of the vector @p
+ * points. It is the task of the derived classes to arrange the points in
* approximately equal distances.
*
- * This function is called by the
- * @p MappingQ class. This
- * happens on each face line of a
- * cells that has got at least
- * one boundary line.
+ * This function is called by the @p MappingQ class. This happens on each
+ * face line of a cells that has got at least one boundary line.
*
- * As this function is not needed
- * for @p MappingQ1, it is not
- * made pure virtual, to avoid
- * the need to overload it. The
- * default implementation throws
- * an error in any case, however.
+ * As this function is not needed for @p MappingQ1, it is not made pure
+ * virtual, to avoid the need to overload it. The default implementation
+ * throws an error in any case, however.
*/
virtual
void
std::vector<Point<spacedim> > &points) const;
/**
- * Return equally spaced
- * intermediate points on a
- * boundary quad.
+ * Return intermediate points on a line spaced according to the tensor
+ * product of the interior support points of the 1D Gauss-Lobatto quadrature
+ * formula.
*
- * The number of points requested
- * is given by the size of the
- * vector @p points. It is
- * required that this number is a
- * square of another integer,
- * i.e. <tt>n=points.size()=m*m</tt>. It
- * is the task of the derived
- * classes to arrange the points
- * such they split the quad into
- * <tt>(m+1)(m+1)</tt> approximately
- * equal-sized subquads.
+ * The number of points requested is given by the size of the vector @p
+ * points. It is required that this number is a square of another integer,
+ * i.e. <tt>n=points.size()=m*m</tt>. It is the task of the derived classes
+ * to arrange the points such they split the quad into <tt>(m+1)(m+1)</tt>
+ * approximately equal-sized subquads.
*
- * This function is called by the
- * <tt>MappingQ<3></tt> class. This
- * happens each face quad of
- * cells in 3d that has got at
- * least one boundary face quad.
+ * This function is called by the <tt>MappingQ<3></tt> class. This happens
+ * each face quad of cells in 3d that has got at least one boundary face
+ * quad.
*
- * As this function is not needed
- * for @p MappingQ1, it is not
- * made pure virtual, to avoid
- * the need to overload it. The
- * default implementation throws
- * an error in any case, however.
+ * As this function is not needed for @p MappingQ1, it is not made pure
+ * virtual, to avoid the need to overload it. The default implementation
+ * throws an error in any case, however.
*/
virtual
void
std::vector<Point<spacedim> > &points) const;
/**
- * Depending on <tt>dim=2</tt> or
- * <tt>dim=3</tt> this function
- * calls the
- * get_intermediate_points_on_line
- * or the
- * get_intermediate_points_on_quad
- * function. It throws an
- * exception for
- * <tt>dim=1</tt>. This wrapper
- * allows dimension independent
- * programming.
+ * Depending on <tt>dim=2</tt> or <tt>dim=3</tt> this function calls the
+ * get_intermediate_points_on_line or the get_intermediate_points_on_quad
+ * function. It throws an exception for <tt>dim=1</tt>. This wrapper allows
+ * dimension independent programming.
*/
void
get_intermediate_points_on_face (const typename Triangulation<dim,spacedim>::face_iterator &face,
std::vector<Point<spacedim> > &points) const;
/**
- * Return the normal vector to the surface
- * at the point p. If p is not in fact
- * on the surface, but only closeby,
- * try to return something reasonable,
- * for example the normal vector
- * at the surface point closest to p.
- * (The point p will in fact not normally
- * lie on the actual surface, but rather
- * be a quadrature point mapped by some
- * polynomial mapping; the mapped surface,
- * however, will not usually coincide with
- * the actual surface.)
+ * Return the normal vector to the surface at the point p. If p is not in
+ * fact on the surface, but only close-by, try to return something
+ * reasonable, for example the normal vector at the surface point closest to
+ * p. (The point p will in fact not normally lie on the actual surface, but
+ * rather be a quadrature point mapped by some polynomial mapping; the
+ * mapped surface, however, will not usually coincide with the actual
+ * surface.)
*
- * The face iterator gives an indication
- * which face this function is supposed
- * to compute the normal vector for.
- * This is useful if the boundary of
- * the domain is composed of different
- * nondifferential pieces (for example
- * when using the StraightBoundary class
- * to approximate a geometry that is
- * completely described by the coarse mesh,
- * with piecewise (bi-)linear components
- * between the vertices, but where the
- * boundary may have a kink at the vertices
- * itself).
+ * The face iterator gives an indication which face this function is
+ * supposed to compute the normal vector for. This is useful if the
+ * boundary of the domain is composed of different nondifferential pieces
+ * (for example when using the StraightBoundary class to approximate a
+ * geometry that is completely described by the coarse mesh, with piecewise
+ * (bi-)linear components between the vertices, but where the boundary may
+ * have a kink at the vertices itself).
*
- * @note Implementations of this function
- * should be able to assume that the point p
- * lies within or close to the face described by the
- * first argument. In turn, callers of this
- * function should ensure that this is
- * in fact the case.
+ * @note Implementations of this function should be able to assume that the
+ * point p lies within or close to the face described by the first
+ * argument. In turn, callers of this function should ensure that this is in
+ * fact the case.
*/
virtual
Tensor<1,spacedim>
const Point<spacedim> &p) const;
/**
- * Compute the normal vectors to
- * the boundary at each vertex of
- * the given face. It is not
- * required that the normal
- * vectors be normed
- * somehow. Neither is it
- * required that the normals
- * actually point outward.
+ * Compute the normal vectors to the boundary at each vertex of the given
+ * face. It is not required that the normal vectors be normed
+ * somehow. Neither is it required that the normals actually point outward.
*
- * This function is
- * needed to compute data for C1
- * mappings. The default
- * implementation is to throw an
- * error, so you need not
- * overload this function in case
- * you do not intend to use C1
- * mappings.
+ * This function is needed to compute data for C1 mappings. The default
+ * implementation is to throw an error, so you need not overload this
+ * function in case you do not intend to use C1 mappings.
*
- * Note that when computing
- * normal vectors at a vertex
- * where the boundary is not
- * differentiable, you have to
- * make sure that you compute the
- * one-sided limits, i.e. limit
- * with respect to points inside
- * the given face.
+ * Note that when computing normal vectors at a vertex where the boundary is
+ * not differentiable, you have to make sure that you compute the one-sided
+ * limits, i.e. limit with respect to points inside the given face.
*/
virtual
void
FaceVertexNormals &face_vertex_normals) const;
/**
- * Given a candidate point and a
- * line segment characterized by
- * the iterator, return a point
- * that lies on the surface
- * described by this object. This
- * function is used in some mesh
- * smoothing algorithms that try
- * to move around points in order
- * to improve the mesh quality
- * but need to ensure that points
- * that were on the boundary
- * remain on the boundary.
+ * Given a candidate point and a line segment characterized by the iterator,
+ * return a point that lies on the surface described by this object. This
+ * function is used in some mesh smoothing algorithms that try to move
+ * around points in order to improve the mesh quality but need to ensure
+ * that points that were on the boundary remain on the boundary.
*
- * If spacedim==1, then the line
- * represented by the line
- * iterator is the entire space
- * (i.e. it is a cell, not a part
- * of the boundary), and the
- * returned point equals the
- * given input point.
+ * If spacedim==1, then the line represented by the line iterator is the
+ * entire space (i.e. it is a cell, not a part of the boundary), and the
+ * returned point equals the given input point.
*
- * Derived classes do not need to
- * implement this function unless
- * mesh smoothing algorithms are
- * used with a particular
- * boundary object. The default
- * implementation of this
- * function throws an exception
- * of type ExcPureFunctionCalled.
+ * Derived classes do not need to implement this function unless mesh
+ * smoothing algorithms are used with a particular boundary object. The
+ * default implementation of this function throws an exception of type
+ * ExcPureFunctionCalled.
*/
virtual
Point<spacedim>
const Point<spacedim> &candidate) const;
/**
- * Same function as above but for
- * a point that is to be
- * projected onto the area
- * characterized by the given
- * quad.
+ * Same function as above but for a point that is to be projected onto the
+ * area characterized by the given quad.
*
- * If spacedim<=2, then the surface
- * represented by the quad
- * iterator is the entire space
- * (i.e. it is a cell, not a part
- * of the boundary), and the
- * returned point equals the
- * given input point.
+ * If spacedim<=2, then the surface represented by the quad iterator is the
+ * entire space (i.e. it is a cell, not a part of the boundary), and the
+ * returned point equals the given input point.
*/
virtual
Point<spacedim>
const Point<spacedim> &candidate) const;
/**
- * Same function as above but for
- * a point that is to be
- * projected onto the area
- * characterized by the given
- * quad.
+ * Same function as above but for a point that is to be projected onto the
+ * area characterized by the given quad.
*
- * If spacedim<=3, then the manifold
- * represented by the hex
- * iterator is the entire space
- * (i.e. it is a cell, not a part
- * of the boundary), and the
- * returned point equals the
- * given input point.
+ * If spacedim<=3, then the manifold represented by the hex iterator is the
+ * entire space (i.e. it is a cell, not a part of the boundary), and the
+ * returned point equals the given input point.
*/
virtual
Point<spacedim>
project_to_surface (const typename Triangulation<dim,spacedim>::hex_iterator &hex,
const Point<spacedim> &candidate) const;
+
+protected:
+ /**
+ * Returns the support points of the Gauss-Lobatto quadrature formula used
+ * for intermediate points.
+ *
+ * @note Since the boundary description is closely tied to the unit cell
+ * support points of MappingQ, new boundary descriptions need to explicitly
+ * use these Gauss-Lobatto points and not equidistant points.
+ */
+ const std::vector<Point<1> > &
+ get_line_support_points (const unsigned int n_intermediate_points) const;
+
+private:
+ /**
+ * Point generator for the intermediate points on a boundary.
+ */
+ mutable std::vector<std_cxx1x::shared_ptr<QGaussLobatto<1> > > points;
+
+ /**
+ * Mutex for protecting the points array.
+ */
+ mutable Threads::Mutex mutex;
};
{
public:
/**
- * Default constructor. Some
- * compilers require this for
- * some reasons.
+ * Default constructor. Some compilers require this for some reasons.
*/
StraightBoundary ();
/**
- * Let the new point be the
- * arithmetic mean of the two
- * vertices of the line.
+ * Let the new point be the arithmetic mean of the two vertices of the line.
*
- * Refer to the general
- * documentation of this class
- * and the documentation of the
- * base class for more
- * information.
+ * Refer to the general documentation of this class and the documentation of
+ * the base class for more information.
*/
virtual Point<spacedim>
get_new_point_on_line (const typename Triangulation<dim,spacedim>::line_iterator &line) const;
/**
- * Let the new point be the
- * arithmetic mean of the four
- * vertices of this quad and the
- * four midpoints of the lines,
- * which are already created at
- * the time of calling this
- * function.
+ * Let the new point be the arithmetic mean of the four vertices of this
+ * quad and the four midpoints of the lines, which are already created at
+ * the time of calling this function.
*
- * Refer to the general
- * documentation of this class
- * and the documentation of the
- * base class for more
- * information.
+ * Refer to the general documentation of this class and the documentation of
+ * the base class for more information.
*/
virtual
Point<spacedim>
get_new_point_on_quad (const typename Triangulation<dim,spacedim>::quad_iterator &quad) const;
/**
- * Gives <tt>n=points.size()</tt>
- * points that splits the
- * StraightBoundary line into
- * $n+1$ partitions of equal
- * lengths.
+ * Gives <tt>n=points.size()</tt> points that splits the StraightBoundary
+ * line into $n+1$ partitions of equal lengths.
*
- * Refer to the general
- * documentation of this class
- * and the documentation of the
- * base class.
+ * Refer to the general documentation of this class and the documentation of
+ * the base class.
*/
virtual
void
std::vector<Point<spacedim> > &points) const;
/**
- * Gives <tt>n=points.size()=m*m</tt>
- * points that splits the
- * StraightBoundary quad into
- * $(m+1)(m+1)$ subquads of equal
- * size.
+ * Gives <tt>n=points.size()=m*m</tt> points that splits the
+ * StraightBoundary quad into $(m+1)(m+1)$ subquads of equal size.
*
- * Refer to the general
- * documentation of this class
- * and the documentation of the
- * base class.
+ * Refer to the general documentation of this class and the documentation of
+ * the base class.
*/
virtual
void
std::vector<Point<spacedim> > &points) const;
/**
- * Implementation of the function
- * declared in the base class.
+ * Implementation of the function declared in the base class.
*
- * Refer to the general
- * documentation of this class
- * and the documentation of the
- * base class.
+ * Refer to the general documentation of this class and the documentation of
+ * the base class.
*/
virtual
Tensor<1,spacedim>
const Point<spacedim> &p) const;
/**
- * Compute the normals to the
- * boundary at the vertices of
- * the given face.
+ * Compute the normals to the boundary at the vertices of the given face.
*
- * Refer to the general
- * documentation of this class
- * and the documentation of the
- * base class.
+ * Refer to the general documentation of this class and the documentation of
+ * the base class.
*/
virtual
void
typename Boundary<dim,spacedim>::FaceVertexNormals &face_vertex_normals) const;
/**
- * Given a candidate point and a
- * line segment characterized by
- * the iterator, return a point
- * that lies on the surface
- * described by this object. This
- * function is used in some mesh
- * smoothing algorithms that try
- * to move around points in order
- * to improve the mesh quality
- * but need to ensure that points
- * that were on the boundary
- * remain on the boundary.
+ * Given a candidate point and a line segment characterized by the iterator,
+ * return a point that lies on the surface described by this object. This
+ * function is used in some mesh smoothing algorithms that try to move
+ * around points in order to improve the mesh quality but need to ensure
+ * that points that were on the boundary remain on the boundary.
*
- * The point returned is the
- * projection of the candidate
- * point onto the line through
- * the two vertices of the given
- * line iterator.
+ * The point returned is the projection of the candidate point onto the line
+ * through the two vertices of the given line iterator.
*
- * If spacedim==1, then the line
- * represented by the line
- * iterator is the entire space
- * (i.e. it is a cell, not a part
- * of the boundary), and the
- * returned point equals the
- * given input point.
+ * If spacedim==1, then the line represented by the line iterator is the
+ * entire space (i.e. it is a cell, not a part of the boundary), and the
+ * returned point equals the given input point.
*/
virtual
Point<spacedim>
const Point<spacedim> &candidate) const;
/**
- * Same function as above but for
- * a point that is to be
- * projected onto the area
- * characterized by the given
- * quad.
+ * Same function as above but for a point that is to be projected onto the
+ * area characterized by the given quad.
*
- * The point returned is the
- * projection of the candidate
- * point onto the bilinear
- * surface spanned by the four
- * vertices of the given quad
- * iterator.
+ * The point returned is the projection of the candidate point onto the
+ * bilinear surface spanned by the four vertices of the given quad iterator.
*
- * If spacedim<=2, then the surface
- * represented by the quad
- * iterator is the entire space
- * (i.e. it is a cell, not a part
- * of the boundary), and the
- * returned point equals the
- * given input point.
+ * If spacedim<=2, then the surface represented by the quad iterator is the
+ * entire space (i.e. it is a cell, not a part of the boundary), and the
+ * returned point equals the given input point.
*/
virtual
Point<spacedim>
const Point<spacedim> &candidate) const;
/**
- * Same function as above but for
- * a point that is to be
- * projected onto the area
- * characterized by the given
- * quad.
+ * Same function as above but for a point that is to be projected onto the
+ * area characterized by the given quad.
*
- * The point returned is the
- * projection of the candidate
- * point onto the trilinear
- * manifold spanned by the eight
- * vertices of the given hex
+ * The point returned is the projection of the candidate point onto the
+ * trilinear manifold spanned by the eight vertices of the given hex
* iterator.
*
- * If spacedim<=3, then the manifold
- * represented by the hex
- * iterator is the entire space
- * (i.e. it is a cell, not a part
- * of the boundary), and the
- * returned point equals the
- * given input point.
+ * If spacedim<=3, then the manifold represented by the hex iterator is the
+ * entire space (i.e. it is a cell, not a part of the boundary), and the
+ * returned point equals the given input point.
*/
virtual
Point<spacedim>
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__tria_boundary_lib_h
#define __deal2__tria_boundary_lib_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2007, 2010, 2012 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__tria_faces_h
#define __deal2__tria_faces_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__tria_iterator_h
#define __deal2__tria_iterator_h
* = accessor;
* @endcode
*/
- TriaRawIterator (const Accessor &a);
+ explicit TriaRawIterator (const Accessor &a);
/**
* Constructor. Assumes that the
* one.
*/
template <typename OtherAccessor>
- TriaRawIterator (const OtherAccessor &a);
+ explicit TriaRawIterator (const OtherAccessor &a);
/**
* Proper constructor, initialized
bool operator != (const TriaRawIterator &) const;
/**
- * Offer a weak ordering of iterators,
- * which is needed to make @p maps with
- * iterators being keys. An iterator
- * pointing to an element @p a is
- * less than another iterator pointing
- * to an element @p b if
- * level(a)<level(b) or
- * (level(a)==level(b) and index(a)<index(b)).
+ * Ordering relation for iterators.
+ *
+ * This relation attempts a total ordering of cells. For lower
+ * dimensional objects on distributed meshes, we only attempt a
+ * partial ordering.
+ *
+ * The relation is defined as follows:
+ *
+ * For objects of <tt>Accessor::structure_dimension <
+ * Accessor::dimension</tt>, we simply compare the index of such an
+ * object. This consitutes an ordering of the elements of same
+ * dimension on a mesh on a single process. For a distributed mesh,
+ * the result of the ordering relation between faces across
+ * processes is not defined, but most likely irrelevant.
*
- * Comparing iterators of which one or
- * both are invalid is an error. The
- * past-the-end iterator is always
- * ordered last. Two past-the-end
- * iterators rank the same, thus false
- * is returned in that case.
+ * For cells, there is a total ordering even in a
+ * distributed::parallel::Triangulation. The ordering is lexicographic
+ * according to the following hierarchy (in the sense, that the next
+ * test is only applied if the previous was inconclusive):
+ *
+ * <ol>
+ * <li> The past-the-end iterator is always ordered last. Two
+ * past-the-end iterators rank the same, thus false is returned in
+ * that case.</li>
+ *
+ * <li> The level subdomain id</li>
+ * <li> If both cells are active, the subdomain id.</li>
+ * <li> The level of the cell.</li>
+ * <li> The index of a cell inside the level.</li>
+ * </ol>
*/
bool operator < (const TriaRawIterator &) const;
const int index,
const typename Accessor::AccessorData *local_data = 0);
+ /**
+ * Construct from an accessor of type OtherAccessor that is convertible
+ * to the type Accessor.
+ */
+ template <typename OtherAccessor>
+ explicit TriaIterator (const OtherAccessor &a);
+
/**
* This is a conversion operator
* (constructor) which takes another
template <typename Accessor>
inline
bool
-TriaRawIterator<Accessor>::operator < (const TriaRawIterator &i) const
+TriaRawIterator<Accessor>::operator < (const TriaRawIterator<Accessor> &other) const
{
- Assert (Accessor::structure_dimension!=Accessor::dimension ||
- state() != IteratorState::invalid,
- ExcDereferenceInvalidCell(accessor));
- Assert (Accessor::structure_dimension==Accessor::dimension ||
- state() != IteratorState::invalid,
- ExcDereferenceInvalidObject(accessor));
+ Assert (state() != IteratorState::invalid, ExcDereferenceInvalidObject(accessor));
+ Assert (other.state() != IteratorState::invalid, ExcDereferenceInvalidObject(other.accessor));
- Assert (Accessor::structure_dimension!=Accessor::dimension ||
- i.state() != IteratorState::invalid,
- ExcDereferenceInvalidCell(i.accessor));
- Assert (Accessor::structure_dimension==Accessor::dimension ||
- i.state() != IteratorState::invalid,
- ExcDereferenceInvalidObject(i.accessor));
-
- Assert (&accessor.get_triangulation() == &i.accessor.get_triangulation(),
+ Assert (&accessor.get_triangulation() == &other.accessor.get_triangulation(),
ExcInvalidComparison());
- if (Accessor::structure_dimension==Accessor::dimension)
- return ((((accessor.level() < i.accessor.level()) ||
- ((accessor.level() == i.accessor.level()) &&
- (accessor.index() < i.accessor.index())) ) &&
- (state()==IteratorState::valid) &&
- (i.state()==IteratorState::valid) ) ||
- ((state()==IteratorState::valid) &&
- (i.state()==IteratorState::past_the_end)));
- else
- return ((((accessor.index() < i.accessor.index()) ) &&
- (state()==IteratorState::valid) &&
- (i.state()==IteratorState::valid) ) ||
- ((state()==IteratorState::valid) &&
- (i.state()==IteratorState::past_the_end)));
+ // Deal with iterators past end
+ if (state()==IteratorState::past_the_end)
+ return false;
+ if (other.state()==IteratorState::past_the_end)
+ return true;
+
+ return ((**this) < (*other));
}
#endif
}
-
+template <typename Accessor>
+template <typename OtherAccessor>
+TriaIterator<Accessor>::TriaIterator (const OtherAccessor &a)
+ :
+ TriaRawIterator<Accessor> (a)
+{
+#ifdef DEBUG
+ // do this like this, because:
+ // if we write
+ // "Assert (IteratorState::past_the_end || used)"
+ // used() is called anyway, even if
+ // state==IteratorState::past_the_end, and will then
+ // throw the exception!
+ if (this->state() != IteratorState::past_the_end)
+ Assert (this->accessor.used(),
+ ExcAssignmentOfUnusedObject());
+#endif
+}
template <typename Accessor>
template <typename OtherAccessor>
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2008, 2010, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__tria_iterator_templates_h
#define __deal2__tria_iterator_templates_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__tria_iterator_base_h
#define __deal2__tria_iterator_base_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2012 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__tria_iterator_selector_h
#define __deal2__tria_iterator_selector_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__tria_levels_h
#define __deal2__tria_levels_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2011, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__tria_object_h
#define __deal2__tria_object_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__tria_objects_h
#define __deal2__tria_objects_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2008, 2009, 2012 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__hp_dof_faces_h
#define __deal2__hp_dof_faces_h
#include <deal.II/base/config.h>
-#include <deal.II/dofs/dof_levels.h>
-#include <deal.II/hp/dof_objects.h>
#include <deal.II/hp/fe_collection.h>
#include <vector>
{
namespace hp
{
-
/**
+ * Store the indices of the degrees of freedom which are located on
+ * objects of dimension @p structdim < dim, i.e., for faces or edges
+ * of cells. This is opposed to the internal::hp::DoFLevels class
+ * that stores the DoF indices on cells.
+ *
+ * The things we store here is very similar to what is stored in the
+ * internal::DoFHandler::DoFObjects classes (see there for more
+ * information, in particular on the layout of the class hierarchy,
+ * and the use of file names).
+ *
+ * <h4>Offset computations</h4>
+ *
+ * For hp methods, not all cells may use the same finite element, and
+ * it is consequently more complicated to determine where the DoF
+ * indices for a given line, quad, or hex are stored. As described in
+ * the documentation of the internal::DoFHandler::DoFLevel class, we
+ * can compute the location of the first line DoF, for example, by
+ * calculating the offset as <code>line_index *
+ * dof_handler.get_fe().dofs_per_line</code>. This of course doesn't
+ * work any more if different lines may have different numbers of
+ * degrees of freedom associated with them. Consequently, rather than
+ * using this simple multiplication, the dofs array has an associated
+ * array dof_offsets. The data corresponding to a
+ * line then starts at index <code>line_dof_offsets[line_index]</code>
+ * within the <code>line_dofs</code> array.
+ *
*
- * <h4>DoFFaces</h4>
+ * <h4>Multiple data sets per object</h4>
*
+ * If two adjacent cells use different finite elements, then
+ * the face that they share needs to store DoF indices for both
+ * involved finite elements. While faces therefore have to have at
+ * most two sets of DoF indices, it is easy to see that edges and
+ * vertices can have as many sets of DoF indices associated with them
+ * as there are adjacent cells.
+ *
+ * Consequently, for objects that have a lower dimensionality than
+ * cells, we have to store a map from the finite element index to the
+ * set of DoF indices associated. Since real sets are typically very
+ * inefficient to store, and since most of the time we expect the
+ * number of individual keys to be small (frequently, adjacent cells
+ * will have the same finite element, and only a single entry will
+ * exist in the map), what we do is instead to store a linked list. In
+ * this format, the first entry starting at position
+ * <code>lines.dofs[lines.dof_offsets[line_index]]</code> will denote
+ * the finite element index of the set of DoF indices following; after
+ * this set, we will store the finite element index of the second set
+ * followed by the corresponding DoF indices; and so on. Finally, when
+ * all finite element indices adjacent to this object have been
+ * covered, we write a -1 to indicate the end of the list.
+ *
+ * Access to this kind of data, as well as the distinction between
+ * cells and objects of lower dimensionality are encoded in the
+ * accessor functions, DoFObjects::set_dof_index() and
+ * DoFLevel::get_dof_index(). They are able to traverse this
+ * list and pick out or set a DoF index given the finite element index
+ * and its location within the set of DoFs corresponding to this
+ * finite element.
+ *
+ *
+ * @ingroup hp
+ * @author Tobias Leicht, 2006
+ */
+ template <int structdim>
+ class DoFIndicesOnFacesOrEdges
+ {
+ public:
+ /**
+ * Store the start index for
+ * the degrees of freedom of each
+ * object in the @p dofs array.
+ *
+ * The type we store is then obviously the type the @p dofs array
+ * uses for indexing.
+ */
+ std::vector<unsigned int> dof_offsets;
+
+ /**
+ * Store the global indices of
+ * the degrees of freedom. See
+ * DoFLevel() for detailed
+ * information.
+ */
+ std::vector<types::global_dof_index> dofs;
+
+ /**
+ * Set the global index of
+ * the @p local_index-th
+ * degree of freedom located
+ * on the object with number @p
+ * obj_index to the value
+ * given by @p global_index. The @p
+ * dof_handler argument is
+ * used to access the finite
+ * element that is to be used
+ * to compute the location
+ * where this data is stored.
+ *
+ * The third argument, @p
+ * fe_index, denotes which of
+ * the finite elements
+ * associated with this
+ * object we shall
+ * access. Refer to the
+ * general documentation of
+ * the internal::hp::DoFLevel
+ * class template for more
+ * information.
+ */
+ template <int dim, int spacedim>
+ void
+ set_dof_index (const dealii::hp::DoFHandler<dim,spacedim> &dof_handler,
+ const unsigned int obj_index,
+ const unsigned int fe_index,
+ const unsigned int local_index,
+ const types::global_dof_index global_index,
+ const unsigned int obj_level);
+
+ /**
+ * Return the global index of
+ * the @p local_index-th
+ * degree of freedom located
+ * on the object with number @p
+ * obj_index. The @p
+ * dof_handler argument is
+ * used to access the finite
+ * element that is to be used
+ * to compute the location
+ * where this data is stored.
+ *
+ * The third argument, @p
+ * fe_index, denotes which of
+ * the finite elements
+ * associated with this
+ * object we shall
+ * access. Refer to the
+ * general documentation of
+ * the internal::hp::DoFLevel
+ * class template for more
+ * information.
+ */
+ template <int dim, int spacedim>
+ types::global_dof_index
+ get_dof_index (const dealii::hp::DoFHandler<dim,spacedim> &dof_handler,
+ const unsigned int obj_index,
+ const unsigned int fe_index,
+ const unsigned int local_index,
+ const unsigned int obj_level) const;
+
+ /**
+ * Return the number of
+ * finite elements that are
+ * active on a given
+ * object. If this is a cell,
+ * the answer is of course
+ * one. If it is a face, the
+ * answer may be one or two,
+ * depending on whether the
+ * two adjacent cells use the
+ * same finite element or
+ * not. If it is an edge in
+ * 3d, the possible return
+ * value may be one or any
+ * other value larger than
+ * that.
+ *
+ * If the object is not part
+ * of an active cell, then no
+ * degrees of freedom have
+ * been distributed and zero
+ * is returned.
+ */
+ template <int dim, int spacedim>
+ unsigned int
+ n_active_fe_indices (const dealii::hp::DoFHandler<dim,spacedim> &dof_handler,
+ const unsigned int obj_index) const;
+
+ /**
+ * Return the fe_index of the
+ * n-th active finite element
+ * on this object.
+ */
+ template <int dim, int spacedim>
+ types::global_dof_index
+ nth_active_fe_index (const dealii::hp::DoFHandler<dim,spacedim> &dof_handler,
+ const unsigned int obj_level,
+ const unsigned int obj_index,
+ const unsigned int n) const;
+
+ /**
+ * Check whether a given
+ * finite element index is
+ * used on the present
+ * object or not.
+ */
+ template <int dim, int spacedim>
+ bool
+ fe_index_is_active (const dealii::hp::DoFHandler<dim,spacedim> &dof_handler,
+ const unsigned int obj_index,
+ const unsigned int fe_index,
+ const unsigned int obj_level) const;
+
+ /**
+ * Determine an estimate for the
+ * memory consumption (in bytes)
+ * of this object.
+ */
+ std::size_t memory_consumption () const;
+ };
+
+
+
+ /**
* These classes are similar to the internal::hp::DoFLevel classes. We here store
* information that is associated with faces, rather than cells, as this information is
* independent of the hierarchical structure of cells, which are organized in levels. In 2D
* we store information on degrees of freedom located on lines whereas in 3D we store
* information on drefrees of freedom located on quads and lines. In 1D we do nothing, as
- * the faces of lines are vertices which are treated seperately.
+ * the faces of lines are vertices which are treated separately.
*
* Apart from the internal::hp::DoFObjects object containing the data to store
* (degree of freedom indices) and all the access-functionality to this data, we do not
* @ingroup dofs
* @author Tobias Leicht, 2006
*/
-
-
-
-
-
-
template<int dim>
- class DoFFaces
- {
- /**
- * Make the constrctor private to prevent the use
- * of this template, only the specializations
- * should be used
- */
- private:
- DoFFaces();
- };
+ class DoFIndicesOnFaces;
+
/**
* Store the indices of degrees of freedom on faces in 1D. As these would be vertices, which
- * are treted seperately, don't do anything.
+ * are treated separately, don't do anything.
*
* @ingroup hp
* @author Tobias Leicht, 2006
*/
template<>
- class DoFFaces<1>
+ class DoFIndicesOnFaces<1>
{
public:
/**
* @author Tobias Leicht, 2006
*/
template<>
- class DoFFaces<2>
+ class DoFIndicesOnFaces<2>
{
public:
- internal::hp::DoFObjects<1> lines;
+ /**
+ * Indices of DoFs on the lines that bound cells.
+ */
+ internal::hp::DoFIndicesOnFacesOrEdges<1> lines;
/**
* Determine an estimate for the
* @author Tobias Leicht, 2006
*/
template<>
- class DoFFaces<3>
+ class DoFIndicesOnFaces<3>
{
public:
- internal::hp::DoFObjects<1> lines;
- internal::hp::DoFObjects<2> quads;
+ /**
+ * Indices of DoFs on the lines that form the edges of cells.
+ */
+ internal::hp::DoFIndicesOnFacesOrEdges<1> lines;
+
+ /**
+ * Indices of DoFs on the quads that bound cells.
+ */
+ internal::hp::DoFIndicesOnFacesOrEdges<2> quads;
/**
* Determine an estimate for the
std::size_t memory_consumption () const;
};
+
+ // --------------------- inline and template functions ------------------
+
+ template <int structdim>
+ template <int dim, int spacedim>
+ inline
+ types::global_dof_index
+ DoFIndicesOnFacesOrEdges<structdim>::
+ get_dof_index (const dealii::hp::DoFHandler<dim,spacedim> &dof_handler,
+ const unsigned int obj_index,
+ const unsigned int fe_index,
+ const unsigned int local_index,
+ const unsigned int obj_level) const
+ {
+ Assert ((fe_index != dealii::hp::DoFHandler<dim,spacedim>::default_fe_index),
+ ExcMessage ("You need to specify a FE index when working "
+ "with hp DoFHandlers"));
+ Assert (&dof_handler != 0,
+ ExcMessage ("No DoFHandler is specified for this iterator"));
+ Assert (&dof_handler.get_fe() != 0,
+ ExcMessage ("No finite element collection is associated with "
+ "this DoFHandler"));
+ Assert (fe_index < dof_handler.get_fe().size(),
+ ExcIndexRange (fe_index, 0, dof_handler.get_fe().size()));
+ Assert (local_index <
+ dof_handler.get_fe()[fe_index].template n_dofs_per_object<structdim>(),
+ ExcIndexRange(local_index, 0,
+ dof_handler.get_fe()[fe_index]
+ .template n_dofs_per_object<structdim>()));
+ Assert (obj_index < dof_offsets.size(),
+ ExcIndexRange (obj_index, 0, dof_offsets.size()));
+
+ // make sure we are on an
+ // object for which DoFs have
+ // been allocated at all
+ Assert (dof_offsets[obj_index] != numbers::invalid_dof_index,
+ ExcMessage ("You are trying to access degree of freedom "
+ "information for an object on which no such "
+ "information is available"));
+
+ Assert (structdim<dim, ExcMessage ("This object can not be used for cells."));
+
+ // there may be multiple finite elements associated with
+ // this object. hop along the list of index sets until we
+ // find the one with the correct fe_index, and then poke
+ // into that part. trigger an exception if we can't find a
+ // set for this particular fe_index
+ const types::global_dof_index starting_offset = dof_offsets[obj_index];
+ const types::global_dof_index *pointer = &dofs[starting_offset];
+ while (true)
+ {
+ Assert (*pointer != numbers::invalid_dof_index,
+ ExcInternalError());
+ if (*pointer == fe_index)
+ return *(pointer + 1 + local_index);
+ else
+ pointer += static_cast<types::global_dof_index>(
+ dof_handler.get_fe()[*pointer]
+ .template n_dofs_per_object<structdim>() + 1);
+ }
+ }
+
+
+
+ template <int structdim>
+ template <int dim, int spacedim>
+ inline
+ void
+ DoFIndicesOnFacesOrEdges<structdim>::
+ set_dof_index (const dealii::hp::DoFHandler<dim,spacedim> &dof_handler,
+ const unsigned int obj_index,
+ const unsigned int fe_index,
+ const unsigned int local_index,
+ const types::global_dof_index global_index,
+ const unsigned int obj_level)
+ {
+ Assert ((fe_index != dealii::hp::DoFHandler<dim,spacedim>::default_fe_index),
+ ExcMessage ("You need to specify a FE index when working "
+ "with hp DoFHandlers"));
+ Assert (&dof_handler != 0,
+ ExcMessage ("No DoFHandler is specified for this iterator"));
+ Assert (&dof_handler.get_fe() != 0,
+ ExcMessage ("No finite element collection is associated with "
+ "this DoFHandler"));
+ Assert (fe_index < dof_handler.get_fe().size(),
+ ExcIndexRange (fe_index, 0, dof_handler.get_fe().size()));
+ Assert (local_index <
+ dof_handler.get_fe()[fe_index].template n_dofs_per_object<structdim>(),
+ ExcIndexRange(local_index, 0,
+ dof_handler.get_fe()[fe_index]
+ .template n_dofs_per_object<structdim>()));
+ Assert (obj_index < dof_offsets.size(),
+ ExcIndexRange (obj_index, 0, dof_offsets.size()));
+
+ // make sure we are on an
+ // object for which DoFs have
+ // been allocated at all
+ Assert (dof_offsets[obj_index] != numbers::invalid_dof_index,
+ ExcMessage ("You are trying to access degree of freedom "
+ "information for an object on which no such "
+ "information is available"));
+
+ Assert (structdim<dim, ExcMessage ("This object can not be used for cells."));
+
+ // there may be multiple finite elements associated with
+ // this object. hop along the list of index sets until we
+ // find the one with the correct fe_index, and then poke
+ // into that part. trigger an exception if we can't find a
+ // set for this particular fe_index
+ const types::global_dof_index starting_offset = dof_offsets[obj_index];
+ types::global_dof_index *pointer = &dofs[starting_offset];
+ while (true)
+ {
+ Assert (*pointer != numbers::invalid_dof_index,
+ ExcInternalError());
+ if (*pointer == fe_index)
+ {
+ *(pointer + 1 + local_index) = global_index;
+ return;
+ }
+ else
+ pointer += dof_handler.get_fe()[*pointer]
+ .template n_dofs_per_object<structdim>() + 1;
+ }
+ }
+
+
+
+ template <int structdim>
+ template <int dim, int spacedim>
+ inline
+ unsigned int
+ DoFIndicesOnFacesOrEdges<structdim>::
+ n_active_fe_indices (const dealii::hp::DoFHandler<dim,spacedim> &dof_handler,
+ const unsigned int obj_index) const
+ {
+ Assert (&dof_handler != 0,
+ ExcMessage ("No DoFHandler is specified for this iterator"));
+ Assert (&dof_handler.get_fe() != 0,
+ ExcMessage ("No finite element collection is associated with "
+ "this DoFHandler"));
+ Assert (obj_index < dof_offsets.size(),
+ ExcIndexRange (obj_index, 0, dof_offsets.size()));
+
+ // make sure we are on an
+ // object for which DoFs have
+ // been allocated at all
+ if (dof_offsets[obj_index] == numbers::invalid_unsigned_int)
+ return 0;
+
+ Assert (structdim<dim, ExcMessage ("This object can not be used for cells."));
+
+ // there may be multiple finite elements associated with this
+ // object. hop along the list of index sets until we find the
+ // one with the correct fe_index, and then poke into that
+ // part. trigger an exception if we can't find a set for this
+ // particular fe_index
+ const unsigned int starting_offset = dof_offsets[obj_index];
+ const types::global_dof_index *pointer = &dofs[starting_offset];
+ unsigned int counter = 0;
+ while (true)
+ {
+ if (*pointer == numbers::invalid_dof_index)
+ // end of list reached
+ return counter;
+ else
+ {
+ ++counter;
+ pointer += dof_handler.get_fe()[*pointer]
+ .template n_dofs_per_object<structdim>() + 1;
+ }
+ }
+ }
+
+
+
+ template <int structdim>
+ template <int dim, int spacedim>
+ inline
+ types::global_dof_index
+ DoFIndicesOnFacesOrEdges<structdim>::
+ nth_active_fe_index (const dealii::hp::DoFHandler<dim,spacedim> &dof_handler,
+ const unsigned int obj_level,
+ const unsigned int obj_index,
+ const unsigned int n) const
+ {
+ Assert (&dof_handler != 0,
+ ExcMessage ("No DoFHandler is specified for this iterator"));
+ Assert (&dof_handler.get_fe() != 0,
+ ExcMessage ("No finite element collection is associated with "
+ "this DoFHandler"));
+ Assert (obj_index < dof_offsets.size(),
+ ExcIndexRange (obj_index, 0, dof_offsets.size()));
+
+ // make sure we are on an
+ // object for which DoFs have
+ // been allocated at all
+ Assert (dof_offsets[obj_index] != numbers::invalid_dof_index,
+ ExcMessage ("You are trying to access degree of freedom "
+ "information for an object on which no such "
+ "information is available"));
+
+ Assert (structdim<dim, ExcMessage ("This object can not be used for cells."));
+
+ Assert (n < n_active_fe_indices(dof_handler, obj_index),
+ ExcIndexRange (n, 0,
+ n_active_fe_indices(dof_handler, obj_index)));
+
+ // there may be multiple finite elements associated with
+ // this object. hop along the list of index sets until we
+ // find the one with the correct fe_index, and then poke
+ // into that part. trigger an exception if we can't find a
+ // set for this particular fe_index
+ const unsigned int starting_offset = dof_offsets[obj_index];
+ const types::global_dof_index *pointer = &dofs[starting_offset];
+ unsigned int counter = 0;
+ while (true)
+ {
+ Assert (*pointer != numbers::invalid_dof_index,
+ ExcInternalError());
+
+ const unsigned int fe_index = *pointer;
+
+ Assert (fe_index < dof_handler.get_fe().size(),
+ ExcInternalError());
+
+ if (counter == n)
+ return fe_index;
+
+ ++counter;
+ pointer += dof_handler.get_fe()[fe_index]
+ .template n_dofs_per_object<structdim>() + 1;
+ }
+ }
+
+
+
+ template <int structdim>
+ template <int dim, int spacedim>
+ inline
+ bool
+ DoFIndicesOnFacesOrEdges<structdim>::
+ fe_index_is_active (const dealii::hp::DoFHandler<dim,spacedim> &dof_handler,
+ const unsigned int obj_index,
+ const unsigned int fe_index,
+ const unsigned int obj_level) const
+ {
+ Assert (&dof_handler != 0,
+ ExcMessage ("No DoFHandler is specified for this iterator"));
+ Assert (&dof_handler.get_fe() != 0,
+ ExcMessage ("No finite element collection is associated with "
+ "this DoFHandler"));
+ Assert (obj_index < dof_offsets.size(),
+ ExcIndexRange (obj_index, 0, static_cast<unsigned int>(dof_offsets.size())));
+ Assert ((fe_index != dealii::hp::DoFHandler<dim,spacedim>::default_fe_index),
+ ExcMessage ("You need to specify a FE index when working "
+ "with hp DoFHandlers"));
+ Assert (fe_index < dof_handler.get_fe().size(),
+ ExcIndexRange (fe_index, 0, dof_handler.get_fe().size()));
+
+ // make sure we are on an
+ // object for which DoFs have
+ // been allocated at all
+ Assert (dof_offsets[obj_index] != numbers::invalid_dof_index,
+ ExcMessage ("You are trying to access degree of freedom "
+ "information for an object on which no such "
+ "information is available"));
+
+ Assert (structdim<dim, ExcMessage ("This object can not be used for cells."));
+
+ // there may be multiple finite elements associated with
+ // this object. hop along the list of index sets until we
+ // find the one with the correct fe_index, and then poke
+ // into that part. trigger an exception if we can't find a
+ // set for this particular fe_index
+ const types::global_dof_index starting_offset = dof_offsets[obj_index];
+ const types::global_dof_index *pointer = &dofs[starting_offset];
+ while (true)
+ {
+ if (*pointer == numbers::invalid_dof_index)
+ // end of list reached
+ return false;
+ else if (*pointer == fe_index)
+ return true;
+ else
+ pointer += static_cast<types::global_dof_index>(
+ dof_handler.get_fe()[*pointer]
+ .template n_dofs_per_object<structdim>()+1);
+ }
+ }
+
+
} // namespace hp
} // namespace internal
-//----------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//----------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__hp_dof_handler_h
#define __deal2__hp_dof_handler_h
{
namespace hp
{
- template <int> class DoFLevel;
- template <int> class DoFFaces;
- template <int> class DoFObjects;
+ class DoFLevel;
+ template <int> class DoFIndicesOnFaces;
+ template <int> class DoFIndicesOnFacesOrEdges;
namespace DoFHandler
{
cell_iterator begin (const unsigned int level = 0) const;
/**
- * Iterator to the first active
- * cell on level @p level.
- */
+ * Iterator to the first active cell on level @p level. If the
+ * given level does not contain any active cells (i.e., all cells
+ * on this level are further refined, then this function returns
+ * <code>end_active(level)</code> so that loops of the kind
+ * @code
+ * for (cell=dof_handler.begin_active(level); cell!=dof_handler.end_active(level); ++cell)
+ * ...
+ * @endcode
+ * have zero iterations, as may be expected if there are no active
+ * cells on this level.
+ */
active_cell_iterator begin_active(const unsigned int level = 0) const;
/**
cell_iterator end (const unsigned int level) const;
/**
- * Return an active iterator
- * which is the first iterator
- * not on level. If @p level is
- * the last level, then this
- * returns <tt>end()</tt>.
- */
+ * Return an active iterator which is the first active iterator not
+ * on the given level. If @p level is the last level, then this
+ * returns <tt>end()</tt>.
+ */
active_cell_iterator end_active (const unsigned int level) const;
/*@}*/
* DoFs which are constrained by
* hanging nodes, see @ref constraints.
*/
- types::global_dof_index n_dofs () const;
+ types::global_dof_index n_dofs () const;
/**
* The number of multilevel
* the active_fe_indices in
* the
* dealii::internal::hp::DoFLevel. They
- * are initialized with the a
+ * are initialized with a
* zero indicator, meaning
* that fe[0] is going to be
* used by default. This
* cell has a valid
* active_fe_index.
*/
-
void create_active_fe_table ();
/**
* <tt>levels[]</tt> tree of
* the Triangulation objects.
*/
- std::vector<dealii::internal::hp::DoFLevel<dim>*> levels;
+ std::vector<dealii::internal::hp::DoFLevel*> levels;
+
/**
* Space to store the DoF
* numbers for the faces.
* <tt>faces</tt> pointer of
* the Triangulation objects.
*/
- dealii::internal::hp::DoFFaces<dim> *faces;
+ dealii::internal::hp::DoFIndicesOnFaces<dim> *faces;
/**
* A structure that contains all
* actual data format used to
* the present class.
*/
- std::vector<types::global_dof_index> vertex_dofs;
+ std::vector<types::global_dof_index> vertex_dofs;
/**
* For each vertex in the
/**
* Array to store the
- * information, if a cell on
+ * information if a cell on
* some level has children or
* not. It is used by the
- * refinement listeners as a
+ * signal slots as a
* persistent buffer during the
* refinement, i.e. from between
* when pre_refinement_action is
* the functions that set and
* retrieve vertex dof indices.
*/
- template <int> friend class dealii::internal::hp::DoFLevel;
- template <int> friend class dealii::internal::hp::DoFObjects;
+ template <int> friend class dealii::internal::hp::DoFIndicesOnFacesOrEdges;
friend struct dealii::internal::hp::DoFHandler::Implementation;
};
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 2003 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+#ifndef __deal2__hp_dof_level_h
+#define __deal2__hp_dof_level_h
+
+
+#include <deal.II/base/config.h>
+#include <deal.II/base/exceptions.h>
+
+#include <vector>
+
+
+DEAL_II_NAMESPACE_OPEN
+
+namespace hp
+{
+ template <int, int> class DoFHandler;
+ template <int, int> class FECollection;
+}
+
+
+namespace internal
+{
+ namespace hp
+ {
+ namespace DoFHandler
+ {
+ struct Implementation;
+ }
+ }
+ namespace DoFCellAccessor
+ {
+ struct Implementation;
+ }
+}
+
+
+namespace internal
+{
+ namespace hp
+ {
+ /**
+ * This is the class that stores the degrees of freedom on cells in a hp
+ * hierarchy. Compared to faces and edges, the task here is simple since
+ * each cell can only have a single active finite element index. Consequently,
+ * all we need is one long array with DoF indices and one array of offsets
+ * where each cell's indices start within the array of indices. This is in
+ * contrast to the DoFObjects class where each face or edge may have more than
+ * one associated finite element with corresponding degrees of freedom.
+ *
+ * The data stored here is represented by three arrays
+ * - The @p active_fe_indices array stores for each cell which
+ * finite element is used on this cell. Since some cells are not active
+ * on the current level, some entries in this array may represent an
+ * invalid value.
+ * - The @p dof_indices array stores for each active cell on the current
+ * level the dofs that associated with the <i>interior</i> of the cell,
+ * i.e., the @p dofs_per_line dofs associated with the line in 1d, and
+ * @p dofs_per_quad and @p dofs_per_hex in 2d and 3d. These numbers are
+ * in general smaller than @p dofs_per_cell.
+ * - The @p dof_offsets array stores, for each cell, the starting point
+ * of the dof indices corresponding to this cell in the @p dof_indices
+ * array. This is analogous to how we store data in compressed row storage
+ * for sparse matrices. For cells that are not active on the current level,
+ * we store an invalid value for the starting index.
+ *
+ * <h3>Compression</h3>
+ *
+ * It is common for the indices stored in @p dof_indices for one cell to be
+ * numbered consecutively. For example, using the standard numbering (without
+ * renumbering DoFs), the quad dofs on the first cell of a mesh when using a
+ * $Q_3$ element will be numbered <tt>12, 13, 14, 15</tt>. This allows for
+ * compression if we only store the first entry and have some way to mark
+ * the DoFs on this object as compressed. Here, compression means that we
+ * know that subsequent DoF indices can be obtained from the previous ones
+ * by just incrementing them by one -- in other words, we use a variant of doing
+ * run-length encoding. The way to do this is that we
+ * use positive FE indices for uncompressed sets of DoFs and if a set of indices
+ * is compressed, then we instead store the FE index in binary complement (which
+ * we can identify by looking at the sign bit when interpreting the number as a
+ * signed one). There are two functions, compress_data() and uncompress_data()
+ * that convert between the two possible representations.
+ *
+ * Note that compression is not always possible. For example, if one renumbered
+ * the example above using DoFRenumbering::downstream with $(1,0)^T$ as
+ * direction, then they would likely be numbered <tt>12, 14, 13, 15</tt>, which
+ * can not be compressed using run-length encoding.
+ */
+ class DoFLevel
+ {
+ private:
+ /**
+ * The type in which we store the offsets into the dof_indices array.
+ */
+ typedef unsigned int offset_type;
+
+ /**
+ * The type in which we store the active FE index.
+ */
+ typedef unsigned short int active_fe_index_type;
+
+ /**
+ * A signed type that matches the type in which we store the active FE
+ * index. We use this in computing binary complements.
+ */
+ typedef signed short int signed_active_fe_index_type;
+
+ /**
+ * Indices specifying the finite element of hp::FECollection to
+ * use for the different cells on the current level. The vector
+ * stores one element per cell since the active_fe_index is
+ * unique for cells.
+ *
+ * If a cell is not active on the level corresponding to the
+ * current object (i.e., it has children on higher levels) then
+ * it does not have an associated fe index and we store
+ * an invalid fe index marker instead.
+ */
+ std::vector<active_fe_index_type> active_fe_indices;
+
+ /**
+ * Store the start index for the degrees of freedom of each
+ * object in the @p dof_indices array. If the cell corresponding to
+ * a particular index in this array is not active on this level,
+ * then we do not store any DoFs for it. In that case, the offset
+ * we store here must be an invalid number and indeed we store
+ * <code>(std::vector<types::global_dof_index>::size_type)(-1)</code>
+ * for it.
+ *
+ * The type we store is then obviously the type the @p dof_indices array
+ * uses for indexing.
+ */
+ std::vector<offset_type> dof_offsets;
+
+ /**
+ * Store the global indices of the degrees of freedom.
+ * information. The dof_offsets field determines where each
+ * (active) cell's data is stored.
+ */
+ std::vector<types::global_dof_index> dof_indices;
+
+ /**
+ * The offsets for each cell of the cache that holds all DoF indices.
+ */
+ std::vector<offset_type> cell_cache_offsets;
+
+ /**
+ * Cache for the DoF indices
+ * on cells. The size of this
+ * array equals the sum over all cells of selected_fe[active_fe_index[cell]].dofs_per_cell.
+ */
+ std::vector<types::global_dof_index> cell_dof_indices_cache;
+
+ public:
+
+ /**
+ * Set the global index of
+ * the @p local_index-th
+ * degree of freedom located
+ * on the object with number @p
+ * obj_index to the value
+ * given by @p global_index. The @p
+ * dof_handler argument is
+ * used to access the finite
+ * element that is to be used
+ * to compute the location
+ * where this data is stored.
+ *
+ * The third argument, @p
+ * fe_index, denotes which of
+ * the finite elements
+ * associated with this
+ * object we shall
+ * access. Refer to the
+ * general documentation of
+ * the internal::hp::DoFLevel
+ * class template for more
+ * information.
+ */
+ void
+ set_dof_index (const unsigned int obj_index,
+ const unsigned int fe_index,
+ const unsigned int local_index,
+ const types::global_dof_index global_index);
+
+ /**
+ * Return the global index of
+ * the @p local_index-th
+ * degree of freedom located
+ * on the object with number @p
+ * obj_index. The @p
+ * dof_handler argument is
+ * used to access the finite
+ * element that is to be used
+ * to compute the location
+ * where this data is stored.
+ *
+ * The third argument, @p
+ * fe_index, denotes which of
+ * the finite elements
+ * associated with this
+ * object we shall
+ * access. Refer to the
+ * general documentation of
+ * the internal::hp::DoFLevel
+ * class template for more
+ * information.
+ */
+ types::global_dof_index
+ get_dof_index (const unsigned int obj_index,
+ const unsigned int fe_index,
+ const unsigned int local_index) const;
+
+ /**
+ * Return the fe_index of the
+ * active finite element
+ * on this object.
+ */
+ unsigned int
+ active_fe_index (const unsigned int obj_index) const;
+
+ /**
+ * Check whether a given
+ * finite element index is
+ * used on the present
+ * object or not.
+ */
+ bool
+ fe_index_is_active (const unsigned int obj_index,
+ const unsigned int fe_index) const;
+
+ /**
+ * Set the fe_index of the
+ * active finite element
+ * on this object.
+ */
+ void
+ set_active_fe_index (const unsigned int obj_index,
+ const unsigned int fe_index);
+
+ /**
+ * Return a pointer to the beginning of the DoF indices cache
+ * for a given cell.
+ *
+ * @param obj_index The number of the cell we are looking at.
+ * @param dofs_per_cell The number of DoFs per cell for this cell. This
+ * is not used for the hp case but necessary to keep the interface
+ * the same as for the non-hp case.
+ * @return A pointer to the first DoF index for the current cell. The
+ * next dofs_per_cell indices are for the current cell.
+ */
+ const types::global_dof_index *
+ get_cell_cache_start (const unsigned int obj_index,
+ const unsigned int dofs_per_cell) const;
+
+ /**
+ * Determine an estimate for the
+ * memory consumption (in bytes)
+ * of this object.
+ */
+ std::size_t memory_consumption () const;
+
+ private:
+ /**
+ * Compress the arrays that store dof indices by using a variant
+ * of run-length encoding. See the general documentation of this
+ * class for more information.
+ *
+ * @param fe_collection The object that can tell us how many
+ * degrees of freedom each of the finite elements has that we
+ * store in this object.
+ */
+ template <int dim, int spacedim>
+ void compress_data (const dealii::hp::FECollection<dim,spacedim> &fe_collection);
+
+ /**
+ * Uncompress the arrays that store dof indices by using a variant
+ * of run-length encoding. See the general documentation of this
+ * class for more information.
+ *
+ * @param fe_collection The object that can tell us how many
+ * degrees of freedom each of the finite elements has that we
+ * store in this object.
+ */
+ template <int dim, int spacedim>
+ void uncompress_data (const dealii::hp::FECollection<dim,spacedim> &fe_collection);
+
+ /**
+ * Make hp::DoFHandler and its auxiliary class a friend since it
+ * is the class that needs to create these data structures.
+ */
+ template <int, int> friend class dealii::hp::DoFHandler;
+ friend struct dealii::internal::hp::DoFHandler::Implementation;
+ friend struct dealii::internal::DoFCellAccessor::Implementation;
+ };
+
+
+ // -------------------- template functions --------------------------------
+
+ inline
+ types::global_dof_index
+ DoFLevel::
+ get_dof_index (const unsigned int obj_index,
+ const unsigned int fe_index,
+ const unsigned int local_index) const
+ {
+ Assert (obj_index < dof_offsets.size(),
+ ExcIndexRange (obj_index, 0, dof_offsets.size()));
+
+ // make sure we are on an
+ // object for which DoFs have
+ // been allocated at all
+ Assert (dof_offsets[obj_index] != (offset_type)(-1),
+ ExcMessage ("You are trying to access degree of freedom "
+ "information for an object on which no such "
+ "information is available"));
+
+ Assert (fe_index == active_fe_indices[obj_index],
+ ExcMessage ("FE index does not match that of the present cell"));
+
+ // see if the dof_indices array has been compressed for this
+ // particular cell
+ if ((signed_active_fe_index_type)active_fe_indices[obj_index]>=0)
+ return dof_indices[dof_offsets[obj_index]+local_index];
+ else
+ return dof_indices[dof_offsets[obj_index]]+local_index;
+ }
+
+
+
+ inline
+ void
+ DoFLevel::
+ set_dof_index (const unsigned int obj_index,
+ const unsigned int fe_index,
+ const unsigned int local_index,
+ const types::global_dof_index global_index)
+ {
+ Assert (obj_index < dof_offsets.size(),
+ ExcIndexRange (obj_index, 0, dof_offsets.size()));
+
+ // make sure we are on an
+ // object for which DoFs have
+ // been allocated at all
+ Assert (dof_offsets[obj_index] != (offset_type)(-1),
+ ExcMessage ("You are trying to access degree of freedom "
+ "information for an object on which no such "
+ "information is available"));
+ Assert ((signed_active_fe_index_type)active_fe_indices[obj_index]>=0,
+ ExcMessage ("This function can no longer be called after compressing the dof_indices array"));
+ Assert (fe_index == active_fe_indices[obj_index],
+ ExcMessage ("FE index does not match that of the present cell"));
+ dof_indices[dof_offsets[obj_index]+local_index] = global_index;
+ }
+
+
+
+ inline
+ unsigned int
+ DoFLevel::
+ active_fe_index (const unsigned int obj_index) const
+ {
+ Assert (obj_index < active_fe_indices.size(),
+ ExcIndexRange (obj_index, 0, active_fe_indices.size()));
+
+ if (((signed_active_fe_index_type)active_fe_indices[obj_index]) >= 0)
+ return active_fe_indices[obj_index];
+ else
+ return (active_fe_index_type)~(signed_active_fe_index_type)active_fe_indices[obj_index];
+ }
+
+
+
+ inline
+ bool
+ DoFLevel::
+ fe_index_is_active (const unsigned int obj_index,
+ const unsigned int fe_index) const
+ {
+ return (fe_index == active_fe_index(obj_index));
+ }
+
+
+ inline
+ void
+ DoFLevel::
+ set_active_fe_index (const unsigned int obj_index,
+ const unsigned int fe_index)
+ {
+ Assert (obj_index < active_fe_indices.size(),
+ ExcIndexRange (obj_index, 0, active_fe_indices.size()));
+
+ active_fe_indices[obj_index] = fe_index;
+ }
+
+
+
+ inline
+ const types::global_dof_index *
+ DoFLevel::get_cell_cache_start (const unsigned int obj_index,
+ const unsigned int dofs_per_cell) const
+ {
+ Assert (obj_index < cell_cache_offsets.size(),
+ ExcInternalError());
+ Assert (cell_cache_offsets[obj_index]+dofs_per_cell
+ <=
+ cell_dof_indices_cache.size(),
+ ExcInternalError());
+
+ return &cell_dof_indices_cache[cell_cache_offsets[obj_index]];
+ }
+ } // namespace hp
+
+} // namespace internal
+
+DEAL_II_NAMESPACE_CLOSE
+
+#endif
+++ /dev/null
-//---------------------------- hp_dof_levels.h ------------------------
-// $Id$
-//
-// Copyright (C) 2003, 2006, 2008, 2012 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.
-//
-//---------------------------- hp_dof_levels.h ------------------------
-#ifndef __deal2__hp_dof_levels_h
-#define __deal2__hp_dof_levels_h
-
-
-#include <deal.II/base/config.h>
-#include <deal.II/hp/dof_objects.h>
-
-#include <vector>
-
-DEAL_II_NAMESPACE_OPEN
-
-namespace internal
-{
- namespace hp
- {
-
- /**
- * Store the indices of the degrees of freedom which are located on
- * objects of dimension @p N. We declare this general template
- * class, but do not actually use it. Rather, only specializations of
- * this class are used.
- *
- * The things we store here is very similar to what is stored in the
- * internal::DoFHandler::DoFLevel class hierarchy (see there for more
- * information, in particular on the layout of the class hierarchy,
- * and the use of file names). There are two main
- * differences, discussed in the following subsections. In addition to
- * the data already stored by the internal::DoFHandler::DoFLevel
- * classes, we also have to store which finite element each cell
- * uses. This is done in the DoFLevel<0> class, where for each cell we
- * have an entry within the active_fe_indices field.
- *
- *
- * <h4>Offset computations</h4>
- *
- * For hp methods, not all cells may use the same finite element, and
- * it is consequently more complicated to determine where the DoF
- * indices for a given line, quad, or hex are stored. As described in
- * the documentation of the internal::DoFHandler::DoFLevel class, we
- * can compute the location of the first line DoF, for example, by
- * calculating the offset as <code>line_index *
- * dof_handler.get_fe().dofs_per_line</code>. This of course doesn't
- * work any more if different lines may have different numbers of
- * degrees of freedom associated with them. Consequently, rather than
- * using this simple multiplication, each of the lines.dofs, quads.dofs,
- * and hexes.dofs arrays has an associated array lines.dof_offsets,
- * quads.dof_offsets, and hexes.dof_offsets. The data corresponding to a
- * line then starts at index <code>line_dof_offsets[line_index]</code>
- * within the <code>line_dofs</code> array.
- *
- *
- * <h4>Multiple data sets per object</h4>
- *
- * If an object corresponds to a cell, the global dof indices of this
- * cell are stored at the location indicated above in sequential
- * order.
- *
- * However, if two adjacent cells use different finite elements, then
- * the face that they share needs to store DoF indices for both
- * involved finite elements. While faces therefore have to have at
- * most two sets of DoF indices, it is easy to see that vertices for
- * example can have as many sets of DoF indices associated with them
- * as there are adjacent cells, and the same holds for lines in 3d.
- *
- * Consequently, for objects that have a lower dimensionality than
- * cells, we have to store a map from the finite element index to the
- * set of DoF indices associated. Since real sets are typically very
- * inefficient to store, and since most of the time we expect the
- * number of individual keys to be small (frequently, adjacent cells
- * will have the same finite element, and only a single entry will
- * exist in the map), what we do is instead to store a linked list. In
- * this format, the first entry starting at position
- * <code>lines.dofs[lines.dof_offsets[line_index]]</code> will denote
- * the finite element index of the set of DoF indices following; after
- * this set, we will store the finite element index of the second set
- * followed by the corresponding DoF indices; and so on. Finally, when
- * all finite element indices adjacent to this object have been
- * covered, we write a -1 to indicate the end of the list.
- *
- * Access to this kind of data, as well as the distinction between
- * cells and objects of lower dimensionality are encoded in the
- * accessor functions, DoFObjects::set_dof_index() and
- * DoFLevel::get_dof_index() They are able to traverse this
- * list and pick out or set a DoF index given the finite element index
- * and its location within the set of DoFs corresponding to this
- * finite element.
- *
- *
- * @ingroup hp
- * @author Wolfgang Bangerth, 1998, 2006, Oliver Kayser-Herold 2003.
- */
- template <int N>
- class DoFLevel
- {
- private:
- /**
- * Make the constructor private
- * to avoid that someone uses
- * this class.
- */
- DoFLevel ();
- };
-
-
- /**
- * Storage for degrees of freedom on cells. See the documentation of
- * the DoFLevel class template for more complete information on the
- * purpose and layout of this class.
- *
- * @ingroup hp
- * @author Wolfgang Bangerth, 1998, 2006, Oliver Kayser-Herold 2003.
- */
- template <>
- class DoFLevel<0>
- {
- public:
- /**
- * Indices specifying the finite
- * element of hp::FECollection to use
- * for the different cells. The
- * meaning what a cell is, is
- * dimension specific, therefore also
- * the length of this vector depends
- * on the dimension: in one dimension,
- * the length of this vector equals
- * the length of the @p lines vector,
- * in two dimensions that of the @p
- * quads vector, etc.
- */
-
- std::vector<unsigned int> active_fe_indices;
- /**
- * Determine an estimate for the
- * memory consumption (in bytes)
- * of this object.
- */
- std::size_t memory_consumption () const;
- };
-
-
- /**
- * Store the indices of the degrees of freedom which are located on
- * the lines. See the general template DoFLevel for more information.
- *
- * @ingroup hp
- * @author Wolfgang Bangerth, 1998, 2006, Oliver Kayser-Herold 2003.
- */
- template <>
- class DoFLevel<1> : public DoFLevel<0>
- {
- public:
- /**
- * store the dof-indices and related functions of
- * lines
- */
- internal::hp::DoFObjects<1> dof_object;
-
- /**
- * Determine an estimate for the
- * memory consumption (in bytes)
- * of this object.
- */
- std::size_t memory_consumption () const;
- };
-
-
- /**
- * Store the indices of the degrees of freedom which are located on
- * quads. See the general template DoFLevel for more information.
- *
- * @ingroup hp
- * @author Wolfgang Bangerth, 1998, 2006, Oliver Kayser-Herold 2003.
- */
- template <>
- class DoFLevel<2> : public DoFLevel<0>
- {
- public:
- /**
- * store the dof-indices and related functions of
- * quads
- */
- internal::hp::DoFObjects<2> dof_object;
-
- /**
- * Determine an estimate for the
- * memory consumption (in bytes)
- * of this object.
- */
- std::size_t memory_consumption () const;
- };
-
-
-
- /**
- * Store the indices of the degrees of freedom which are located on
- * hexhedra. See the general template DoFLevel for more information.
- *
- * @ingroup hp
- * @author Wolfgang Bangerth, 1998, 2006, Oliver Kayser-Herold 2003.
- */
- template <>
- class DoFLevel<3> : public DoFLevel<0>
- {
- public:
- /**
- * store the dof-indices and related functions of
- * hexes
- */
- internal::hp::DoFObjects<3> dof_object;
-
- /**
- * Determine an estimate for the
- * memory consumption (in bytes)
- * of this object.
- */
- std::size_t memory_consumption () const;
- };
-
- } // namespace hp
-
-} // namespace internal
-
-DEAL_II_NAMESPACE_CLOSE
-
-#endif
+++ /dev/null
-//---------------------------------------------------------------------------
-// $Id$
-//
-// Copyright (C) 2006, 2008, 2012 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.
-//
-//---------------------------------------------------------------------------
-#ifndef __deal2__hp_dof_objects_h
-#define __deal2__hp_dof_objects_h
-
-#include <deal.II/base/config.h>
-#include <deal.II/hp/fe_collection.h>
-#include <deal.II/hp/dof_handler.h>
-
-#include <vector>
-
-DEAL_II_NAMESPACE_OPEN
-
-namespace internal
-{
- namespace hp
- {
-
- /**
- * Store the indices of the degrees of freedom which are located on
- * objects of dimension @p dim.
- *
- * The things we store here is very similar to what is stored in the
- * internal::DoFHandler::DoFObjects classes (see there for more
- * information, in particular on the layout of the class hierarchy,
- * and the use of file names).
- *
- * <h4>Offset computations</h4>
- *
- * For hp methods, not all cells may use the same finite element, and
- * it is consequently more complicated to determine where the DoF
- * indices for a given line, quad, or hex are stored. As described in
- * the documentation of the internal::DoFHandler::DoFLevel class, we
- * can compute the location of the first line DoF, for example, by
- * calculating the offset as <code>line_index *
- * dof_handler.get_fe().dofs_per_line</code>. This of course doesn't
- * work any more if different lines may have different numbers of
- * degrees of freedom associated with them. Consequently, rather than
- * using this simple multiplication, the dofs array has an associated
- * array dof_offsets. The data corresponding to a
- * line then starts at index <code>line_dof_offsets[line_index]</code>
- * within the <code>line_dofs</code> array.
- *
- *
- * <h4>Multiple data sets per object</h4>
- *
- * If an object corresponds to a cell, the global dof indices of this
- * cell are stored at the location indicated above in sequential
- * order.
- *
- * However, if two adjacent cells use different finite elements, then
- * the face that they share needs to store DoF indices for both
- * involved finite elements. While faces therefore have to have at
- * most two sets of DoF indices, it is easy to see that vertices for
- * example can have as many sets of DoF indices associated with them
- * as there are adjacent cells, and the same holds for lines in 3d.
- *
- * Consequently, for objects that have a lower dimensionality than
- * cells, we have to store a map from the finite element index to the
- * set of DoF indices associated. Since real sets are typically very
- * inefficient to store, and since most of the time we expect the
- * number of individual keys to be small (frequently, adjacent cells
- * will have the same finite element, and only a single entry will
- * exist in the map), what we do is instead to store a linked list. In
- * this format, the first entry starting at position
- * <code>lines.dofs[lines.dof_offsets[line_index]]</code> will denote
- * the finite element index of the set of DoF indices following; after
- * this set, we will store the finite element index of the second set
- * followed by the corresponding DoF indices; and so on. Finally, when
- * all finite element indices adjacent to this object have been
- * covered, we write a -1 to indicate the end of the list.
- *
- * Access to this kind of data, as well as the distinction between
- * cells and objects of lower dimensionality are encoded in the
- * accessor functions, DoFObjects::set_dof_index() and
- * DoFLevel::get_dof_index() They are able to traverse this
- * list and pick out or set a DoF index given the finite element index
- * and its location within the set of DoFs corresponding to this
- * finite element.
- *
- *
- * @ingroup hp
- * @author Tobias Leicht, 2006
- */
-
- template <int dim>
- class DoFObjects
- {
- public:
- /**
- * Store the start index for
- * the degrees of freedom of each
- * hex in the @p hex_dofs array.
- */
- std::vector<types::global_dof_index> dof_offsets;
-
- /**
- * Store the global indices of
- * the degrees of freedom. See
- * DoFLevel() for detailed
- * information.
- */
- std::vector<types::global_dof_index > dofs;
-
- /**
- * Set the global index of
- * the @p local_index-th
- * degree of freedom located
- * on the hex with number @p
- * hex_index to the value
- * given by the last
- * argument. The @p
- * dof_handler argument is
- * used to access the finite
- * element that is to be used
- * to compute the location
- * where this data is stored.
- *
- * The third argument, @p
- * fe_index, denotes which of
- * the finite elements
- * associated with this
- * object we shall
- * access. Refer to the
- * general documentation of
- * the internal::hp::DoFLevel
- * class template for more
- * information.
- */
- template <int dimm, int spacedim>
- void
- set_dof_index (const dealii::hp::DoFHandler<dimm,spacedim> &dof_handler,
- const unsigned int obj_index,
- const unsigned int fe_index,
- const unsigned int local_index,
- const types::global_dof_index global_index,
- const unsigned int obj_level);
-
- /**
- * Return the global index of
- * the @p local_index-th
- * degree of freedom located
- * on the hex with number @p
- * hex_index. The @p
- * dof_handler argument is
- * used to access the finite
- * element that is to be used
- * to compute the location
- * where this data is stored.
- *
- * The third argument, @p
- * fe_index, denotes which of
- * the finite elements
- * associated with this
- * object we shall
- * access. Refer to the
- * general documentation of
- * the internal::hp::DoFLevel
- * class template for more
- * information.
- */
- template <int dimm, int spacedim>
- types::global_dof_index
- get_dof_index (const dealii::hp::DoFHandler<dimm,spacedim> &dof_handler,
- const unsigned int obj_index,
- const unsigned int fe_index,
- const unsigned int local_index,
- const unsigned int obj_level) const;
-
- /**
- * Return the number of
- * finite elements that are
- * active on a given
- * object. If this is a cell,
- * the answer is of course
- * one. If it is a face, the
- * answer may be one or two,
- * depending on whether the
- * two adjacent cells use the
- * same finite element or
- * not. If it is an edge in
- * 3d, the possible return
- * value may be one or any
- * other value larger than
- * that.
- *
- * If the object is not part
- * of an active cell, then no
- * degrees of freedom have
- * been distributed and zero
- * is returned.
- */
- template <int dimm, int spacedim>
- unsigned int
- n_active_fe_indices (const dealii::hp::DoFHandler<dimm,spacedim> &dof_handler,
- const unsigned int obj_index) const;
-
- /**
- * Return the fe_index of the
- * n-th active finite element
- * on this object.
- */
- template <int dimm, int spacedim>
- types::global_dof_index
- nth_active_fe_index (const dealii::hp::DoFHandler<dimm,spacedim> &dof_handler,
- const unsigned int obj_level,
- const unsigned int obj_index,
- const unsigned int n) const;
-
- /**
- * Check whether a given
- * finite element index is
- * used on the present
- * object or not.
- */
- template <int dimm, int spacedim>
- bool
- fe_index_is_active (const dealii::hp::DoFHandler<dimm,spacedim> &dof_handler,
- const unsigned int obj_index,
- const unsigned int fe_index,
- const unsigned int obj_level) const;
-
- /**
- * Determine an estimate for the
- * memory consumption (in bytes)
- * of this object.
- */
- std::size_t memory_consumption () const;
- };
-
-
-// --------------------- inline and template functions ------------------
-
- template <int dim>
- template <int dimm, int spacedim>
- inline
- types::global_dof_index
- DoFObjects<dim>::
- get_dof_index (const dealii::hp::DoFHandler<dimm,spacedim> &dof_handler,
- const unsigned int obj_index,
- const unsigned int fe_index,
- const unsigned int local_index,
- const unsigned int obj_level) const
- {
- Assert ((fe_index != dealii::hp::DoFHandler<dimm,spacedim>::default_fe_index),
- ExcMessage ("You need to specify a FE index when working "
- "with hp DoFHandlers"));
- Assert (&dof_handler != 0,
- ExcMessage ("No DoFHandler is specified for this iterator"));
- Assert (&dof_handler.get_fe() != 0,
- ExcMessage ("No finite element collection is associated with "
- "this DoFHandler"));
- Assert (fe_index < dof_handler.get_fe().size(),
- ExcIndexRange (fe_index, 0, dof_handler.get_fe().size()));
- Assert (local_index <
- dof_handler.get_fe()[fe_index].template n_dofs_per_object<dim>(),
- ExcIndexRange(local_index, 0,
- dof_handler.get_fe()[fe_index]
- .template n_dofs_per_object<dim>()));
- Assert (obj_index < dof_offsets.size(),
- ExcIndexRange (obj_index, 0, dof_offsets.size()));
-
- // make sure we are on an
- // object for which DoFs have
- // been allocated at all
- Assert (dof_offsets[obj_index] != numbers::invalid_dof_index,
- ExcMessage ("You are trying to access degree of freedom "
- "information for an object on which no such "
- "information is available"));
-
- if (dim == dimm)
- {
- // if we are on a cell, then
- // the only set of indices we
- // store is the one for the
- // cell, which is unique. then
- // fe_index must be
- // active_fe_index
- Assert (fe_index == dof_handler.levels[obj_level]->active_fe_indices[obj_index],
- ExcMessage ("FE index does not match that of the present cell"));
- return dofs[dof_offsets[obj_index]+local_index];
- }
- else
- {
- // we are in higher space
- // dimensions, so there may
- // be multiple finite
- // elements associated with
- // this object. hop along
- // the list of index sets
- // until we find the one
- // with the correct
- // fe_index, and then poke
- // into that part. trigger
- // an exception if we can't
- // find a set for this
- // particular fe_index
- const types::global_dof_index starting_offset = dof_offsets[obj_index];
- const types::global_dof_index *pointer = &dofs[starting_offset];
- while (true)
- {
- Assert (*pointer != numbers::invalid_dof_index,
- ExcInternalError());
- if (*pointer == fe_index)
- return *(pointer + 1 + local_index);
- else
- pointer += static_cast<types::global_dof_index>(
- dof_handler.get_fe()[*pointer]
- .template n_dofs_per_object<dim>() + 1);
- }
- }
- }
-
-
-
- template <int dim>
- template <int dimm, int spacedim>
- inline
- void
- DoFObjects<dim>::
- set_dof_index (const dealii::hp::DoFHandler<dimm,spacedim> &dof_handler,
- const unsigned int obj_index,
- const unsigned int fe_index,
- const unsigned int local_index,
- const types::global_dof_index global_index,
- const unsigned int obj_level)
- {
- Assert ((fe_index != dealii::hp::DoFHandler<dimm,spacedim>::default_fe_index),
- ExcMessage ("You need to specify a FE index when working "
- "with hp DoFHandlers"));
- Assert (&dof_handler != 0,
- ExcMessage ("No DoFHandler is specified for this iterator"));
- Assert (&dof_handler.get_fe() != 0,
- ExcMessage ("No finite element collection is associated with "
- "this DoFHandler"));
- Assert (fe_index < dof_handler.get_fe().size(),
- ExcIndexRange (fe_index, 0, dof_handler.get_fe().size()));
- Assert (local_index <
- dof_handler.get_fe()[fe_index].template n_dofs_per_object<dim>(),
- ExcIndexRange(local_index, 0,
- dof_handler.get_fe()[fe_index]
- .template n_dofs_per_object<dim>()));
- Assert (obj_index < dof_offsets.size(),
- ExcIndexRange (obj_index, 0, dof_offsets.size()));
-
- // make sure we are on an
- // object for which DoFs have
- // been allocated at all
- Assert (dof_offsets[obj_index] != numbers::invalid_dof_index,
- ExcMessage ("You are trying to access degree of freedom "
- "information for an object on which no such "
- "information is available"));
-
- if (dim == dimm)
- {
- // if we are on a cell, then
- // the only set of indices we
- // store is the one for the
- // cell, which is unique. then
- // fe_index must be
- // active_fe_index
- Assert (fe_index == dof_handler.levels[obj_level]->active_fe_indices[obj_index],
- ExcMessage ("FE index does not match that of the present cell"));
- dofs[dof_offsets[obj_index]+local_index] = global_index;
- }
- else
- {
- // we are in higher space
- // dimensions, so there may
- // be multiple finite
- // elements associated with
- // this object. hop along
- // the list of index sets
- // until we find the one
- // with the correct
- // fe_index, and then poke
- // into that part. trigger
- // an exception if we can't
- // find a set for this
- // particular fe_index
- const types::global_dof_index starting_offset = dof_offsets[obj_index];
- types::global_dof_index *pointer = &dofs[starting_offset];
- while (true)
- {
- Assert (*pointer != numbers::invalid_dof_index,
- ExcInternalError());
- if (*pointer == fe_index)
- {
- *(pointer + 1 + local_index) = global_index;
- return;
- }
- else
- pointer += dof_handler.get_fe()[*pointer]
- .template n_dofs_per_object<dim>() + 1;
- }
- }
- }
-
-
-
- template <int dim>
- template <int dimm, int spacedim>
- inline
- unsigned int
- DoFObjects<dim>::
- n_active_fe_indices (const dealii::hp::DoFHandler<dimm,spacedim> &dof_handler,
- const unsigned int obj_index) const
- {
- Assert (dim <= dimm, ExcInternalError());
- Assert (&dof_handler != 0,
- ExcMessage ("No DoFHandler is specified for this iterator"));
- Assert (&dof_handler.get_fe() != 0,
- ExcMessage ("No finite element collection is associated with "
- "this DoFHandler"));
- Assert (obj_index < dof_offsets.size(),
- ExcIndexRange (obj_index, 0, dof_offsets.size()));
-
- // make sure we are on an
- // object for which DoFs have
- // been allocated at all
- if (dof_offsets[obj_index] == numbers::invalid_dof_index)
- return 0;
-
- // if we are on a cell, then the
- // only set of indices we store
- // is the one for the cell,
- // which is unique
- if (dim == dimm)
- return 1;
- else
- {
- // otherwise, there may be
- // multiple finite elements
- // associated with this
- // object. hop along the
- // list of index sets until
- // we find the one with the
- // correct fe_index, and
- // then poke into that
- // part. trigger an
- // exception if we can't
- // find a set for this
- // particular fe_index
- const unsigned int starting_offset = dof_offsets[obj_index];
- const types::global_dof_index *pointer = &dofs[starting_offset];
- unsigned int counter = 0;
- while (true)
- {
- if (*pointer == numbers::invalid_dof_index)
- // end of list reached
- return counter;
- else
- {
- ++counter;
- pointer += dof_handler.get_fe()[*pointer]
- .template n_dofs_per_object<dim>() + 1;
- }
- }
- }
- }
-
-
-
- template <int dim>
- template <int dimm, int spacedim>
- inline
- types::global_dof_index
- DoFObjects<dim>::
- nth_active_fe_index (const dealii::hp::DoFHandler<dimm,spacedim> &dof_handler,
- const unsigned int obj_level,
- const unsigned int obj_index,
- const unsigned int n) const
- {
- Assert (dim <= dimm, ExcInternalError());
- Assert (&dof_handler != 0,
- ExcMessage ("No DoFHandler is specified for this iterator"));
- Assert (&dof_handler.get_fe() != 0,
- ExcMessage ("No finite element collection is associated with "
- "this DoFHandler"));
- Assert (obj_index < dof_offsets.size(),
- ExcIndexRange (obj_index, 0, dof_offsets.size()));
-
- // make sure we are on an
- // object for which DoFs have
- // been allocated at all
- Assert (dof_offsets[obj_index] != numbers::invalid_dof_index,
- ExcMessage ("You are trying to access degree of freedom "
- "information for an object on which no such "
- "information is available"));
-
- if (dim == dimm)
- {
- // this is a cell, so there
- // is only a single
- // fe_index
- Assert (n == 0, ExcIndexRange (n, 0, 1));
-
- return dof_handler.levels[obj_level]->active_fe_indices[obj_index];
- }
- else
- {
- Assert (n < n_active_fe_indices(dof_handler, obj_index),
- ExcIndexRange (n, 0,
- n_active_fe_indices(dof_handler, obj_index)));
-
- // we are in higher space
- // dimensions, so there may
- // be multiple finite
- // elements associated with
- // this object. hop along
- // the list of index sets
- // until we find the one
- // with the correct
- // fe_index, and then poke
- // into that part. trigger
- // an exception if we can't
- // find a set for this
- // particular fe_index
- const unsigned int starting_offset = dof_offsets[obj_index];
- const types::global_dof_index *pointer = &dofs[starting_offset];
- unsigned int counter = 0;
- while (true)
- {
- Assert (*pointer != numbers::invalid_dof_index,
- ExcInternalError());
-
- const unsigned int fe_index = *pointer;
-
- Assert (fe_index < dof_handler.get_fe().size(),
- ExcInternalError());
-
- if (counter == n)
- return fe_index;
-
- ++counter;
- pointer += dof_handler.get_fe()[fe_index]
- .template n_dofs_per_object<dim>() + 1;
- }
- }
- }
-
-
-
- template <int dim>
- template <int dimm, int spacedim>
- inline
- bool
- DoFObjects<dim>::
- fe_index_is_active (const dealii::hp::DoFHandler<dimm,spacedim> &dof_handler,
- const unsigned int obj_index,
- const unsigned int fe_index,
- const unsigned int obj_level) const
- {
- Assert (&dof_handler != 0,
- ExcMessage ("No DoFHandler is specified for this iterator"));
- Assert (&dof_handler.get_fe() != 0,
- ExcMessage ("No finite element collection is associated with "
- "this DoFHandler"));
- Assert (obj_index < dof_offsets.size(),
- ExcIndexRange (obj_index, 0, static_cast<unsigned int>(dof_offsets.size())));
- Assert ((fe_index != dealii::hp::DoFHandler<dimm,spacedim>::default_fe_index),
- ExcMessage ("You need to specify a FE index when working "
- "with hp DoFHandlers"));
- Assert (fe_index < dof_handler.get_fe().size(),
- ExcIndexRange (fe_index, 0, dof_handler.get_fe().size()));
-
- // make sure we are on an
- // object for which DoFs have
- // been allocated at all
- Assert (dof_offsets[obj_index] != numbers::invalid_dof_index,
- ExcMessage ("You are trying to access degree of freedom "
- "information for an object on which no such "
- "information is available"));
-
- if (dim == dimm)
- {
- // if we are on a cell,
- // then the only set of
- // indices we store is the
- // one for the cell, which
- // is unique
- Assert (obj_index < dof_handler.levels[obj_level]->active_fe_indices.size(),
- ExcInternalError());
- return (fe_index == dof_handler.levels[obj_level]->active_fe_indices[obj_index]);
- }
- else
- {
- // we are in higher space
- // dimensions, so there may
- // be multiple finite
- // elements associated with
- // this object. hop along
- // the list of index sets
- // until we find the one
- // with the correct
- // fe_index, and then poke
- // into that part. trigger
- // an exception if we can't
- // find a set for this
- // particular fe_index
- const types::global_dof_index starting_offset = dof_offsets[obj_index];
- const types::global_dof_index *pointer = &dofs[starting_offset];
- while (true)
- {
- if (*pointer == numbers::invalid_dof_index)
- // end of list reached
- return false;
- else if (*pointer == fe_index)
- return true;
- else
- pointer += static_cast<types::global_dof_index>(
- dof_handler.get_fe()[*pointer]
- .template n_dofs_per_object<dim>()+1);
- }
- }
- }
-
- }
-}
-
-DEAL_II_NAMESPACE_CLOSE
-
-#endif
-//---------------------------- fe_collection.h ---------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2006, 2012 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------- fe_collection.h ---------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_collection_h
#define __deal2__fe_collection_h
-//---------------------------- hp_fe_values.h ---------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------- hp_fe_values.h ---------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__hp_fe_values_h
#define __deal2__hp_fe_values_h
{
public:
/**
- * Constructor. Set the fields
- * of this class to the values
- * indicated by the parameters
- * to the constructor.
+ * Constructor. Set the fields of this class to the values indicated by
+ * the parameters to the constructor.
*/
FEValuesBase (const dealii::hp::MappingCollection<dim,FEValues::space_dimension> &mapping_collection,
const dealii::hp::FECollection<dim,FEValues::space_dimension> &fe_collection,
const dealii::hp::QCollection<q_dim> &q_collection,
const UpdateFlags update_flags);
/**
- * Constructor. Set the fields
- * of this class to the values
- * indicated by the parameters
- * to the constructor, and
- * choose a @p MappingQ1
- * object for the mapping
- * object.
+ * Constructor. Set the fields of this class to the values indicated by
+ * the parameters to the constructor, and choose a @p MappingQ1 object
+ * for the mapping object.
*/
FEValuesBase (const dealii::hp::FECollection<dim,FEValues::space_dimension> &fe_collection,
const dealii::hp::QCollection<q_dim> &q_collection,
const UpdateFlags update_flags);
/**
- * Get a reference to the
- * collection of finite
- * element objects used here.
+ * Get a reference to the collection of finite element objects used
+ * here.
*/
const dealii::hp::FECollection<dim,FEValues::space_dimension> &
get_fe_collection () const;
/**
- * Return a reference to the @p
- * FEValues object selected by the
- * last call to
- * select_fe_values(). select_fe_values()
- * in turn is called when you called
- * the @p reinit function of the
- * <tt>hp::FE*Values</tt> class the
- * last time.
+ * Get a reference to the collection of mapping objects used
+ * here.
+ */
+ const dealii::hp::MappingCollection<dim,FEValues::space_dimension> &
+ get_mapping_collection () const;
+
+ /**
+ * Get a reference to the collection of quadrature objects used
+ * here.
+ */
+ const dealii::hp::QCollection<q_dim> &
+ get_quadrature_collection () const;
+
+ /**
+ * Get the underlying update flags.
+ */
+ UpdateFlags get_update_flags() const;
+
+ /**
+ * Return a reference to the @p FEValues object selected by the last
+ * call to select_fe_values(). select_fe_values() in turn is called when
+ * you called the @p reinit function of the <tt>hp::FE*Values</tt> class
+ * the last time.
*/
const FEValues &get_present_fe_values () const;
protected:
/**
- * Select a FEValues object
- * suitable for the given FE,
- * quadrature, and mapping
- * indices. If such an object
- * doesn't yet exist, create
- * one.
+ * Select a FEValues object suitable for the given FE, quadrature, and
+ * mapping indices. If such an object doesn't yet exist, create one.
*
- * The function returns a
- * writable reference so that
- * derived classes can also
- * reinit() the selected
- * FEValues object.
+ * The function returns a writable reference so that derived classes can
+ * also reinit() the selected FEValues object.
*/
FEValues &
select_fe_values (const unsigned int fe_index,
protected:
/**
- * A pointer to the
- * collection of finite
- * elements to be used.
+ * A pointer to the collection of finite elements to be used.
*/
const SmartPointer<const dealii::hp::FECollection<dim,FEValues::space_dimension>,
FEValuesBase<dim,q_dim,FEValues> > fe_collection;
/**
- * A pointer to the
- * collection of mappings to
- * be used.
+ * A pointer to the collection of mappings to be used.
*/
const SmartPointer<const dealii::hp::MappingCollection<dim, FEValues::space_dimension>,
FEValuesBase<dim,q_dim,FEValues> > mapping_collection;
/**
- * Copy of the quadrature
- * collection object
- * provided to the
- * constructor.
+ * Copy of the quadrature collection object provided to the constructor.
*/
const dealii::hp::QCollection<q_dim> q_collection;
private:
/**
- * A table in which we store
- * pointers to fe_values
- * objects for different
- * finite element, mapping,
- * and quadrature objects
- * from our collection. The
- * first index indicates the
- * index of the finite
- * element within the
- * fe_collection, the second
- * the index of the mapping
- * within the mapping
- * collection, and the last
- * one the index of the
- * quadrature formula within
- * the q_collection.
+ * A table in which we store pointers to fe_values objects for different
+ * finite element, mapping, and quadrature objects from our
+ * collection. The first index indicates the index of the finite element
+ * within the fe_collection, the second the index of the mapping within
+ * the mapping collection, and the last one the index of the quadrature
+ * formula within the q_collection.
*
- * Initially, all entries
- * have zero pointers, and we
- * will allocate them lazily
- * as needed in
- * select_fe_values().
+ * Initially, all entries have zero pointers, and we will allocate them
+ * lazily as needed in select_fe_values().
*/
Table<3,std_cxx1x::shared_ptr<FEValues> > fe_values_table;
/**
- * Set of indices pointing at
- * the fe_values object
- * selected last time the
- * select_fe_value() function
- * was called.
+ * Set of indices pointing at the fe_values object selected last time
+ * the select_fe_value() function was called.
*/
TableIndices<3> present_fe_values_index;
/**
- * Values of the update flags as
- * given to the constructor.
+ * Values of the update flags as given to the constructor.
*/
const UpdateFlags update_flags;
};
static const unsigned int space_dimension = spacedim;
/**
- * Constructor. Initialize this
- * object with the given
- * parameters.
+ * Constructor. Initialize this object with the given parameters.
*
- * The finite element
- * collection parameter is
- * actually ignored, but is in
- * the signature of this
- * function to make it
- * compatible with the
- * signature of the respective
- * constructor of the usual
- * FEValues object, with
- * the respective parameter in
- * that function also being the
- * return value of the
- * <tt>DoFHandler::get_fe()</tt>
- * function.
+ * The finite element collection parameter is actually ignored, but is in
+ * the signature of this function to make it compatible with the signature
+ * of the respective constructor of the usual FEValues object, with the
+ * respective parameter in that function also being the return value of
+ * the <tt>DoFHandler::get_fe()</tt> function.
*/
FEValues (const dealii::hp::MappingCollection<dim,spacedim> &mapping_collection,
const dealii::hp::FECollection<dim,spacedim> &fe_collection,
/**
- * Constructor. Initialize this
- * object with the given
- * parameters, and choose a
- * @p MappingQ1 object for the
- * mapping object.
+ * Constructor. Initialize this object with the given parameters, and
+ * choose a @p MappingQ1 object for the mapping object.
*
- * The finite element
- * collection parameter is
- * actually ignored, but is in
- * the signature of this
- * function to make it
- * compatible with the
- * signature of the respective
- * constructor of the usual
- * FEValues object, with
- * the respective parameter in
- * that function also being the
- * return value of the
- * <tt>DoFHandler::get_fe()</tt>
- * function.
+ * The finite element collection parameter is actually ignored, but is in
+ * the signature of this function to make it compatible with the signature
+ * of the respective constructor of the usual FEValues object, with the
+ * respective parameter in that function also being the return value of
+ * the <tt>DoFHandler::get_fe()</tt> function.
*/
FEValues (const hp::FECollection<dim,spacedim> &fe_collection,
const hp::QCollection<dim> &q_collection,
/**
- * Reinitialize the object for
- * the given cell.
+ * Reinitialize the object for the given cell.
*
- * After the call, you can get
- * an FEValues object using the
- * get_present_fe_values()
- * function that corresponds to
- * the present cell. For this
- * FEValues object, we use the
- * additional arguments
- * described below to determine
- * which finite element,
- * mapping, and quadrature
- * formula to use. They are
- * order in such a way that the
- * arguments one may want to
- * change most frequently come
- * first. The rules for these
- * arguments are as follows:
+ * After the call, you can get an FEValues object using the
+ * get_present_fe_values() function that corresponds to the present
+ * cell. For this FEValues object, we use the additional arguments
+ * described below to determine which finite element, mapping, and
+ * quadrature formula to use. They are order in such a way that the
+ * arguments one may want to change most frequently come first. The rules
+ * for these arguments are as follows:
*
- * If the @p fe_index argument
- * to this function is left at
- * its default value, then we
- * use that finite element
- * within the hp::FECollection
- * passed to the constructor of
- * this class with index given
- * by
- * <code>cell-@>active_fe_index()</code>. Consequently,
- * the hp::FECollection
- * argument given to this
- * object should really be the
- * same as that used in the
- * construction of the
- * hp::DofHandler associated
- * with the present cell. On
- * the other hand, if a value
- * is given for this argument,
- * it overrides the choice of
+ * If the @p fe_index argument to this function is left at its default
+ * value, then we use that finite element within the hp::FECollection
+ * passed to the constructor of this class with index given by
+ * <code>cell-@>active_fe_index()</code>. Consequently, the
+ * hp::FECollection argument given to this object should really be the
+ * same as that used in the construction of the hp::DofHandler associated
+ * with the present cell. On the other hand, if a value is given for this
+ * argument, it overrides the choice of
* <code>cell-@>active_fe_index()</code>.
*
- * If the @p q_index argument
- * is left at its default
- * value, then we use that
- * quadrature formula within
- * the hp::QCollection passed
- * to the constructor of this
- * class with index given by
- * <code>cell-@>active_fe_index()</code>,
- * i.e. the same index as that
- * of the finite element. In
- * this case, there should be a
- * corresponding quadrature
- * formula for each finite
- * element in the
- * hp::FECollection. As a
- * special case, if the
- * quadrature collection
- * contains only a single
- * element (a frequent case if
- * one wants to use the same
- * quadrature object for all
- * finite elements in an hp
- * discretization, even if that
- * may not be the most
- * efficient), then this single
- * quadrature is used unless a
- * different value for this
- * argument is specified. On
- * the other hand, if a value
- * is given for this argument,
- * it overrides the choice of
- * <code>cell-@>active_fe_index()</code>
- * or the choice for the single
+ * If the @p q_index argument is left at its default value, then we use
+ * that quadrature formula within the hp::QCollection passed to the
+ * constructor of this class with index given by
+ * <code>cell-@>active_fe_index()</code>, i.e. the same index as that of
+ * the finite element. In this case, there should be a corresponding
+ * quadrature formula for each finite element in the hp::FECollection. As
+ * a special case, if the quadrature collection contains only a single
+ * element (a frequent case if one wants to use the same quadrature object
+ * for all finite elements in an hp discretization, even if that may not
+ * be the most efficient), then this single quadrature is used unless a
+ * different value for this argument is specified. On the other hand, if a
+ * value is given for this argument, it overrides the choice of
+ * <code>cell-@>active_fe_index()</code> or the choice for the single
* quadrature.
*
- * If the @p mapping_index
- * argument is left at its
- * default value, then we use
- * that mapping object within
- * the hp::MappingCollection
- * passed to the constructor of
- * this class with index given
- * by
- * <code>cell-@>active_fe_index()</code>,
- * i.e. the same index as that
- * of the finite
- * element. As above, if the
- * mapping collection contains
- * only a single element (a
- * frequent case if one wants
- * to use a MappingQ1 object
- * for all finite elements in
- * an hp discretization), then
- * this single mapping is used
- * unless a different value for
- * this argument is specified.
+ * If the @p mapping_index argument is left at its default value, then we
+ * use that mapping object within the hp::MappingCollection passed to the
+ * constructor of this class with index given by
+ * <code>cell-@>active_fe_index()</code>, i.e. the same index as that of
+ * the finite element. As above, if the mapping collection contains only a
+ * single element (a frequent case if one wants to use a MappingQ1 object
+ * for all finite elements in an hp discretization), then this single
+ * mapping is used unless a different value for this argument is
+ * specified.
*/
template <class DH, bool lda>
void
const unsigned int fe_index = numbers::invalid_unsigned_int);
/**
- * Like the previous function,
- * but for non-hp
- * iterators. The reason this
- * (and the other non-hp
- * iterator) function exists is
- * so that one can use
- * hp::FEValues not only for
- * hp::DoFhandler objects, but
- * for all sorts of DoFHandler
- * objects, and triangulations
- * not associated with
- * DoFHandlers in general.
+ * Like the previous function, but for non-hp iterators. The reason this
+ * (and the other non-hp iterator) function exists is so that one can use
+ * hp::FEValues not only for hp::DoFhandler objects, but for all sorts of
+ * DoFHandler objects, and triangulations not associated with DoFHandlers
+ * in general.
*
- * Since
- * <code>cell-@>active_fe_index()</code>
- * doesn't make sense for
- * triangulation iterators,
- * this function chooses the
- * zero-th finite element,
- * mapping, and quadrature
- * object from the relevant
- * constructions passed to the
- * constructor of this
- * object. The only exception
- * is if you specify a value
- * different from the default
- * value for any of these last
+ * Since <code>cell-@>active_fe_index()</code> doesn't make sense for
+ * triangulation iterators, this function chooses the zero-th finite
+ * element, mapping, and quadrature object from the relevant constructions
+ * passed to the constructor of this object. The only exception is if you
+ * specify a value different from the default value for any of these last
* three arguments.
*/
void
{
public:
/**
- * Constructor. Initialize this
- * object with the given
- * parameters.
+ * Constructor. Initialize this object with the given parameters.
*
- * The finite element
- * collection parameter is
- * actually ignored, but is in
- * the signature of this
- * function to make it
- * compatible with the
- * signature of the respective
- * constructor of the usual
- * FEValues object, with
- * the respective parameter in
- * that function also being the
- * return value of the
- * <tt>DoFHandler::get_fe()</tt>
- * function.
+ * The finite element collection parameter is actually ignored, but is in
+ * the signature of this function to make it compatible with the signature
+ * of the respective constructor of the usual FEValues object, with the
+ * respective parameter in that function also being the return value of
+ * the <tt>DoFHandler::get_fe()</tt> function.
*/
FEFaceValues (const hp::MappingCollection<dim,spacedim> &mapping_collection,
const hp::FECollection<dim,spacedim> &fe_collection,
/**
- * Constructor. Initialize this
- * object with the given
- * parameters, and choose a
- * @p MappingQ1 object for the
- * mapping object.
+ * Constructor. Initialize this object with the given parameters, and
+ * choose a @p MappingQ1 object for the mapping object.
*
- * The finite element
- * collection parameter is
- * actually ignored, but is in
- * the signature of this
- * function to make it
- * compatible with the
- * signature of the respective
- * constructor of the usual
- * FEValues object, with
- * the respective parameter in
- * that function also being the
- * return value of the
- * <tt>DoFHandler::get_fe()</tt>
- * function.
+ * The finite element collection parameter is actually ignored, but is in
+ * the signature of this function to make it compatible with the signature
+ * of the respective constructor of the usual FEValues object, with the
+ * respective parameter in that function also being the return value of
+ * the <tt>DoFHandler::get_fe()</tt> function.
*/
FEFaceValues (const hp::FECollection<dim,spacedim> &fe_collection,
const hp::QCollection<dim-1> &q_collection,
const UpdateFlags update_flags);
/**
- * Reinitialize the object for
- * the given cell and face.
+ * Reinitialize the object for the given cell and face.
*
- * After the call, you can get
- * an FEFaceValues object using the
- * get_present_fe_values()
- * function that corresponds to
- * the present cell. For this
- * FEFaceValues object, we use the
- * additional arguments
- * described below to determine
- * which finite element,
- * mapping, and quadrature
- * formula to use. They are
- * order in such a way that the
- * arguments one may want to
- * change most frequently come
- * first. The rules for these
- * arguments are as follows:
+ * After the call, you can get an FEFaceValues object using the
+ * get_present_fe_values() function that corresponds to the present
+ * cell. For this FEFaceValues object, we use the additional arguments
+ * described below to determine which finite element, mapping, and
+ * quadrature formula to use. They are order in such a way that the
+ * arguments one may want to change most frequently come first. The rules
+ * for these arguments are as follows:
*
- * If the @p fe_index argument
- * to this function is left at
- * its default value, then we
- * use that finite element
- * within the hp::FECollection
- * passed to the constructor of
- * this class with index given
- * by
- * <code>cell-@>active_fe_index()</code>. Consequently,
- * the hp::FECollection
- * argument given to this
- * object should really be the
- * same as that used in the
- * construction of the
- * hp::DofHandler associated
- * with the present cell. On
- * the other hand, if a value
- * is given for this argument,
- * it overrides the choice of
+ * If the @p fe_index argument to this function is left at its default
+ * value, then we use that finite element within the hp::FECollection
+ * passed to the constructor of this class with index given by
+ * <code>cell-@>active_fe_index()</code>. Consequently, the
+ * hp::FECollection argument given to this object should really be the
+ * same as that used in the construction of the hp::DofHandler associated
+ * with the present cell. On the other hand, if a value is given for this
+ * argument, it overrides the choice of
* <code>cell-@>active_fe_index()</code>.
*
- * If the @p q_index argument
- * is left at its default
- * value, then we use that
- * quadrature formula within
- * the hp::QCollection passed
- * to the constructor of this
- * class with index given by
- * <code>cell-@>active_fe_index()</code>,
- * i.e. the same index as that
- * of the finite element. In
- * this case, there should be a
- * corresponding quadrature
- * formula for each finite
- * element in the
- * hp::FECollection. As a
- * special case, if the
- * quadrature collection
- * contains only a single
- * element (a frequent case if
- * one wants to use the same
- * quadrature object for all
- * finite elements in an hp
- * discretization, even if that
- * may not be the most
- * efficient), then this single
- * quadrature is used unless a
- * different value for this
- * argument is specified. On
- * the other hand, if a value
- * is given for this argument,
- * it overrides the choice of
- * <code>cell-@>active_fe_index()</code>
- * or the choice for the single
+ * If the @p q_index argument is left at its default value, then we use
+ * that quadrature formula within the hp::QCollection passed to the
+ * constructor of this class with index given by
+ * <code>cell-@>active_fe_index()</code>, i.e. the same index as that of
+ * the finite element. In this case, there should be a corresponding
+ * quadrature formula for each finite element in the hp::FECollection. As
+ * a special case, if the quadrature collection contains only a single
+ * element (a frequent case if one wants to use the same quadrature object
+ * for all finite elements in an hp discretization, even if that may not
+ * be the most efficient), then this single quadrature is used unless a
+ * different value for this argument is specified. On the other hand, if a
+ * value is given for this argument, it overrides the choice of
+ * <code>cell-@>active_fe_index()</code> or the choice for the single
* quadrature.
*
- * If the @p mapping_index
- * argument is left at its
- * default value, then we use
- * that mapping object within
- * the hp::MappingCollection
- * passed to the constructor of
- * this class with index given
- * by
- * <code>cell-@>active_fe_index()</code>,
- * i.e. the same index as that
- * of the finite
- * element. As above, if the
- * mapping collection contains
- * only a single element (a
- * frequent case if one wants
- * to use a MappingQ1 object
- * for all finite elements in
- * an hp discretization), then
- * this single mapping is used
- * unless a different value for
- * this argument is specified.
+ * If the @p mapping_index argument is left at its default value, then we
+ * use that mapping object within the hp::MappingCollection passed to the
+ * constructor of this class with index given by
+ * <code>cell-@>active_fe_index()</code>, i.e. the same index as that of
+ * the finite element. As above, if the mapping collection contains only a
+ * single element (a frequent case if one wants to use a MappingQ1 object
+ * for all finite elements in an hp discretization), then this single
+ * mapping is used unless a different value for this argument is
+ * specified.
*/
template <class DH, bool lda>
void
const unsigned int fe_index = numbers::invalid_unsigned_int);
/**
- * Like the previous function,
- * but for non-hp
- * iterators. The reason this
- * (and the other non-hp
- * iterator) function exists is
- * so that one can use
- * hp::FEValues not only for
- * hp::DoFhandler objects, but
- * for all sorts of DoFHandler
- * objects, and triangulations
- * not associated with
- * DoFHandlers in general.
+ * Like the previous function, but for non-hp iterators. The reason this
+ * (and the other non-hp iterator) function exists is so that one can use
+ * hp::FEValues not only for hp::DoFhandler objects, but for all sorts of
+ * DoFHandler objects, and triangulations not associated with DoFHandlers
+ * in general.
*
- * Since
- * <code>cell-@>active_fe_index()</code>
- * doesn't make sense for
- * triangulation iterators,
- * this function chooses the
- * zero-th finite element,
- * mapping, and quadrature
- * object from the relevant
- * constructions passed to the
- * constructor of this
- * object. The only exception
- * is if you specify a value
- * different from the default
- * value for any of these last
+ * Since <code>cell-@>active_fe_index()</code> doesn't make sense for
+ * triangulation iterators, this function chooses the zero-th finite
+ * element, mapping, and quadrature object from the relevant constructions
+ * passed to the constructor of this object. The only exception is if you
+ * specify a value different from the default value for any of these last
* three arguments.
*/
void
{
public:
/**
- * Constructor. Initialize this
- * object with the given
- * parameters.
+ * Constructor. Initialize this object with the given parameters.
*
- * The finite element
- * collection parameter is
- * actually ignored, but is in
- * the signature of this
- * function to make it
- * compatible with the
- * signature of the respective
- * constructor of the usual
- * FEValues object, with
- * the respective parameter in
- * that function also being the
- * return value of the
- * <tt>DoFHandler::get_fe()</tt>
- * function.
+ * The finite element collection parameter is actually ignored, but is in
+ * the signature of this function to make it compatible with the signature
+ * of the respective constructor of the usual FEValues object, with the
+ * respective parameter in that function also being the return value of
+ * the <tt>DoFHandler::get_fe()</tt> function.
*/
FESubfaceValues (const hp::MappingCollection<dim,spacedim> &mapping_collection,
const hp::FECollection<dim,spacedim> &fe_collection,
/**
- * Constructor. Initialize this
- * object with the given
- * parameters, and choose a
- * @p MappingQ1 object for the
- * mapping object.
+ * Constructor. Initialize this object with the given parameters, and
+ * choose a @p MappingQ1 object for the mapping object.
*
- * The finite element
- * collection parameter is
- * actually ignored, but is in
- * the signature of this
- * function to make it
- * compatible with the
- * signature of the respective
- * constructor of the usual
- * FEValues object, with
- * the respective parameter in
- * that function also being the
- * return value of the
- * <tt>DoFHandler::get_fe()</tt>
- * function.
+ * The finite element collection parameter is actually ignored, but is in
+ * the signature of this function to make it compatible with the signature
+ * of the respective constructor of the usual FEValues object, with the
+ * respective parameter in that function also being the return value of
+ * the <tt>DoFHandler::get_fe()</tt> function.
*/
FESubfaceValues (const hp::FECollection<dim,spacedim> &fe_collection,
const hp::QCollection<dim-1> &q_collection,
const UpdateFlags update_flags);
/**
- * Reinitialize the object for
- * the given cell, face, and subface.
+ * Reinitialize the object for the given cell, face, and subface.
*
- * After the call, you can get
- * an FESubfaceValues object using the
- * get_present_fe_values()
- * function that corresponds to
- * the present cell. For this
- * FESubfaceValues object, we use the
- * additional arguments
- * described below to determine
- * which finite element,
- * mapping, and quadrature
- * formula to use. They are
- * order in such a way that the
- * arguments one may want to
- * change most frequently come
- * first. The rules for these
- * arguments are as follows:
+ * After the call, you can get an FESubfaceValues object using the
+ * get_present_fe_values() function that corresponds to the present
+ * cell. For this FESubfaceValues object, we use the additional arguments
+ * described below to determine which finite element, mapping, and
+ * quadrature formula to use. They are order in such a way that the
+ * arguments one may want to change most frequently come first. The rules
+ * for these arguments are as follows:
*
- * If the @p q_index argument
- * is left at its default
- * value, then we use that
- * quadrature formula within
- * the hp::QCollection passed
- * to the constructor of this
- * class with index given by
- * <code>cell-@>active_fe_index()</code>,
- * i.e. the same index as that
- * of the finite element. In
- * this case, there should be a
- * corresponding quadrature
- * formula for each finite
- * element in the
- * hp::FECollection. As a
- * special case, if the
- * quadrature collection
- * contains only a single
- * element (a frequent case if
- * one wants to use the same
- * quadrature object for all
- * finite elements in an hp
- * discretization, even if that
- * may not be the most
- * efficient), then this single
- * quadrature is used unless a
- * different value for this
- * argument is specified. On
- * the other hand, if a value
- * is given for this argument,
- * it overrides the choice of
- * <code>cell-@>active_fe_index()</code>
- * or the choice for the single
+ * If the @p q_index argument is left at its default value, then we use
+ * that quadrature formula within the hp::QCollection passed to the
+ * constructor of this class with index given by
+ * <code>cell-@>active_fe_index()</code>, i.e. the same index as that of
+ * the finite element. In this case, there should be a corresponding
+ * quadrature formula for each finite element in the hp::FECollection. As
+ * a special case, if the quadrature collection contains only a single
+ * element (a frequent case if one wants to use the same quadrature object
+ * for all finite elements in an hp discretization, even if that may not
+ * be the most efficient), then this single quadrature is used unless a
+ * different value for this argument is specified. On the other hand, if a
+ * value is given for this argument, it overrides the choice of
+ * <code>cell-@>active_fe_index()</code> or the choice for the single
* quadrature.
*
- * If the @p mapping_index
- * argument is left at its
- * default value, then we use
- * that mapping object within
- * the hp::MappingCollection
- * passed to the constructor of
- * this class with index given
- * by
- * <code>cell-@>active_fe_index()</code>,
- * i.e. the same index as that
- * of the finite
- * element. As above, if the
- * mapping collection contains
- * only a single element (a
- * frequent case if one wants
- * to use a MappingQ1 object
- * for all finite elements in
- * an hp discretization), then
- * this single mapping is used
- * unless a different value for
- * this argument is specified.
+ * If the @p mapping_index argument is left at its default value, then we
+ * use that mapping object within the hp::MappingCollection passed to the
+ * constructor of this class with index given by
+ * <code>cell-@>active_fe_index()</code>, i.e. the same index as that of
+ * the finite element. As above, if the mapping collection contains only a
+ * single element (a frequent case if one wants to use a MappingQ1 object
+ * for all finite elements in an hp discretization), then this single
+ * mapping is used unless a different value for this argument is
+ * specified.
*/
template <class DH, bool lda>
void
const unsigned int fe_index = numbers::invalid_unsigned_int);
/**
- * Like the previous function,
- * but for non-hp
- * iterators. The reason this
- * (and the other non-hp
- * iterator) function exists is
- * so that one can use
- * hp::FEValues not only for
- * hp::DoFhandler objects, but
- * for all sorts of DoFHandler
- * objects, and triangulations
- * not associated with
- * DoFHandlers in general.
+ * Like the previous function, but for non-hp iterators. The reason this
+ * (and the other non-hp iterator) function exists is so that one can use
+ * hp::FEValues not only for hp::DoFhandler objects, but for all sorts of
+ * DoFHandler objects, and triangulations not associated with DoFHandlers
+ * in general.
*
- * Since
- * <code>cell-@>active_fe_index()</code>
- * doesn't make sense for
- * triangulation iterators,
- * this function chooses the
- * zero-th finite element,
- * mapping, and quadrature
- * object from the relevant
- * constructions passed to the
- * constructor of this
- * object. The only exception
- * is if you specify a value
- * different from the default
- * value for any of these last
+ * Since <code>cell-@>active_fe_index()</code> doesn't make sense for
+ * triangulation iterators, this function chooses the zero-th finite
+ * element, mapping, and quadrature object from the relevant constructions
+ * passed to the constructor of this object. The only exception is if you
+ * specify a value different from the default value for any of these last
* three arguments.
*/
void
{
return *fe_collection;
}
+
+
+
+ template <int dim, int q_dim, class FEValues>
+ inline
+ const dealii::hp::MappingCollection<dim,FEValues::space_dimension> &
+ FEValuesBase<dim,q_dim,FEValues>::get_mapping_collection () const
+ {
+ return *mapping_collection;
+ }
+
+
+
+ template <int dim, int q_dim, class FEValues>
+ inline
+ const dealii::hp::QCollection<q_dim> &
+ FEValuesBase<dim,q_dim,FEValues>::get_quadrature_collection () const
+ {
+ return q_collection;
+ }
+
+
+
+ template <int dim, int q_dim, class FEValues>
+ inline
+ dealii::UpdateFlags
+ FEValuesBase<dim,q_dim,FEValues>::get_update_flags () const
+ {
+ return update_flags;
+ }
}
}
-//------------------------ mapping_collection.h --------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//------------------------ mapping_collection.h --------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mapping_collection_h
#define __deal2__mapping_collection_h
-//---------------------------- q_collection.h ----------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2011, 2012 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------- q_collection.h ----------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__q_collection_h
#define __deal2__q_collection_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__integrators_advection_h
#define __deal2__integrators_advection_h
}
/**
- * Advection residual operator in weak form
+ * Advection residual operator in strong form
*
* \f[
- * r_i = \int_Z u\,(\mathbf w \cdot \nabla) v_i \, dx.
+ * r_i = \int_Z (\mathbf w \cdot \nabla)u\, v_i \, dx.
* \f]
*/
template <int dim>
const double dx = factor * fe.JxW(k);
for (unsigned i=0; i<n_dofs; ++i)
for (unsigned int d=0; d<dim; ++d)
- result(i) += dx * input[k]
- * fe.shape_grad(i,k)[d] * velocity[d][k * v_increment];
+ result(i) += dx * input[k][d]
+ * fe.shape_value(i,k) * velocity[d][k * v_increment];
}
}
/**
- * Vector-valued advection residual operator in weak form
+ * Vector-valued advection residual operator in strong form
*
*
* \f[
- * r_i = \int_Z \mathbf u\cdot\bigl((\mathbf w \cdot \nabla) \mathbf v_i\bigr) \, dx.
+ * r_i = \int_Z \bigl((\mathbf w \cdot \nabla) \mathbf u\bigr) \cdot\mathbf v_i \, dx.
* \f]
*/
template <int dim>
for (unsigned i=0; i<n_dofs; ++i)
for (unsigned int c=0; c<n_comp; ++c)
for (unsigned int d=0; d<dim; ++d)
- result(i) += dx * input[c][k]
- * fe.shape_grad_component(i,k,c)[d] * velocity[d][k * v_increment];
+ result(i) += dx * input[c][k][d]
+ * fe.shape_value_component(i,k,c) * velocity[d][k * v_increment];
}
}
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__integrators_divergence_h
#define __deal2__integrators_divergence_h
result(i) += dx * input[d][k][d] * fetest.shape_value(i,k);
}
}
+
+
/**
- * Cell matrix for gradient. The derivative is on the trial
- * function.
+ * The residual of the divergence operator in weak form.
* \f[
- * \int_Z \nabla u \cdot \mathbf v\,dx
+ * - \int_Z \nabla v \cdot \mathbf u \,dx
* \f]
- * This is the strong gradient and the trial space
- * should be at least in <i>H</i><sup>1</sup>. The test functions can
- * be discontinuous.
+ * This is the weak divergence operator and the test
+ * space should be at least <b>H</b><sup>1</sup>. The trial functions
+ * may be discontinuous.
+ *
+ * @todo Verify: The function cell_matrix() is the Frechet derivative of this function with respect
+ * to the test functions.
*
* @author Guido Kanschat
- * @date 2011
+ * @date 2013
*/
+ template <int dim, typename number>
+ void cell_residual(
+ Vector<number> &result,
+ const FEValuesBase<dim> &fetest,
+ const VectorSlice<const std::vector<std::vector<double> > > &input,
+ const double factor = 1.)
+ {
+ AssertDimension(fetest.get_fe().n_components(), 1);
+ AssertVectorVectorDimension(input, dim, fetest.n_quadrature_points);
+ const unsigned int t_dofs = fetest.dofs_per_cell;
+ Assert (result.size() == t_dofs, ExcDimensionMismatch(result.size(), t_dofs));
+
+ for (unsigned int k=0; k<fetest.n_quadrature_points; ++k)
+ {
+ const double dx = factor * fetest.JxW(k);
+
+ for (unsigned int i=0; i<t_dofs; ++i)
+ for (unsigned int d=0; d<dim; ++d)
+ result(i) -= dx * input[d][k] * fetest.shape_grad(i,k)[d];
+ }
+ }
+
+
+/**
+ * Cell matrix for gradient. The derivative is on the trial function.
+ * \f[
+ * \int_Z \nabla u \cdot \mathbf v\,dx
+ * \f]
+ *
+ * This is the strong gradient and the trial space should be at least
+ * in <i>H</i><sup>1</sup>. The test functions can be discontinuous.
+ *
+ * @author Guido Kanschat
+ * @date 2011
+ */
template <int dim>
void gradient_matrix(
FullMatrix<double> &M,
}
}
+ /**
+ * The residual of the gradient operator in weak form.
+ * \f[
+ * -\int_Z \nabla\cdot \mathbf v u \,dx
+ * \f]
+ * This is the weak gradient operator and the test
+ * space should be at least <b>H</b><sup>div</sup>. The trial functions
+ * may be discontinuous.
+ *
+ * @todo Verify: The function gradient_matrix() is the Frechet derivative of this function with respect to the test functions.
+ *
+ * @author Guido Kanschat
+ * @date 2013
+ */
+ template <int dim, typename number>
+ void gradient_residual(
+ Vector<number> &result,
+ const FEValuesBase<dim> &fetest,
+ const std::vector<double> &input,
+ const double factor = 1.)
+ {
+ AssertDimension(fetest.get_fe().n_components(), dim);
+ AssertDimension(input.size(), fetest.n_quadrature_points);
+ const unsigned int t_dofs = fetest.dofs_per_cell;
+ Assert (result.size() == t_dofs, ExcDimensionMismatch(result.size(), t_dofs));
+
+ for (unsigned int k=0; k<fetest.n_quadrature_points; ++k)
+ {
+ const double dx = factor * fetest.JxW(k);
+
+ for (unsigned int i=0; i<t_dofs; ++i)
+ for (unsigned int d=0; d<dim; ++d)
+ result(i) -= dx * input[k] * fetest.shape_grad_component(i,k,d)[d];
+ }
+ }
+
/**
* The trace of the divergence operator, namely the product of the
* normal component of the vector valued trial space and the test
}
}
+ /**
+ * The trace of the gradient
+ * operator, namely the product
+ * of the normal component of the
+ * vector valued test space and
+ * the trial space.
+ * @f[
+ * \int_F u (\mathbf v\cdot \mathbf n) \,ds
+ * @f]
+ *
+ * @author Guido Kanschat
+ * @date 2013
+ */
+ template<int dim, typename number>
+ void
+ u_times_n_residual (
+ Vector<number> &result,
+ const FEValuesBase<dim> &fetest,
+ const std::vector<double> &data,
+ double factor = 1.)
+ {
+ const unsigned int t_dofs = fetest.dofs_per_cell;
+
+ AssertDimension(fetest.get_fe().n_components(), dim);
+ AssertDimension(result.size(), t_dofs);
+ AssertDimension(data.size(), fetest.n_quadrature_points);
+
+ for (unsigned int k=0; k<fetest.n_quadrature_points; ++k)
+ {
+ const Tensor<1,dim> ndx = factor * fetest.normal_vector(k) * fetest.JxW(k);
+
+ for (unsigned int i=0; i<t_dofs; ++i)
+ for (unsigned int d=0; d<dim; ++d)
+ result(i) += ndx[d] * fetest.shape_value_component(i,k,d) * data[k];
+ }
+ }
+
/**
* The trace of the divergence
* operator, namely the product
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__integrators_elasticity_h
#define __deal2__integrators_elasticity_h
const double dx = factor * fe.JxW(k);
for (unsigned int i=0; i<n_dofs; ++i)
for (unsigned int d1=0; d1<dim; ++d1)
- for (unsigned int d2=0; d2<dim; ++d2)
- {
- result(i) += dx * .25 *
- (input[d1][k][d2] + input[d2][k][d1]) *
- (fe.shape_grad_component(i,k,d1)[d2] + fe.shape_grad_component(i,k,d2)[d1]);
- }
+ for (unsigned int d2=0; d2<dim; ++d2)
+ {
+ result(i) += dx * .25 *
+ (input[d1][k][d2] + input[d2][k][d1]) *
+ (fe.shape_grad_component(i,k,d1)[d2] + fe.shape_grad_component(i,k,d2)[d1]);
+ }
}
}
{
const double u = fe.shape_value_component(j,k,d1);
const double v = fe.shape_value_component(i,k,d1);
- M(i,j) += dx * penalty * u * v;
+ M(i,j) += dx * 2. * penalty * u * v;
for (unsigned int d2=0; d2<dim; ++d2)
{
// v . nabla u n
{
const double u= input[d1][k];
const double v= fe.shape_value_component(i,k,d1);
- const double g= data[d1][k];
- result(i) += dx + 2.*penalty * (u-g) * v;
-
- for (unsigned int d2=0; d2<dim; ++d2)
- {
- // v . nabla u n
- result(i) -= .5*dx* v * Dinput[d1][k][d2] * n(d2);
- // v . (nabla u)^T n
- result(i) -= .5*dx* v * Dinput[d2][k][d1] * n(d2);
- // u nabla v n
- result(i) -= .5*dx * (u-g) * fe.shape_grad_component(i,k,d1)[d2] * n(d2);
- // u (nabla v)^T n
- result(i) -= .5*dx * (u-g) * fe.shape_grad_component(i,k,d2)[d1] * n(d2);
- }
- }
- }
+ const double g= data[d1][k];
+ result(i) += dx * 2.*penalty * (u-g) * v;
+
+ for (unsigned int d2=0; d2<dim; ++d2)
+ {
+ // v . nabla u n
+ result(i) -= .5*dx* v * Dinput[d1][k][d2] * n(d2);
+ // v . (nabla u)^T n
+ result(i) -= .5*dx* v * Dinput[d2][k][d1] * n(d2);
+ // u nabla v n
+ result(i) -= .5*dx * (u-g) * fe.shape_grad_component(i,k,d1)[d2] * n(d2);
+ // u (nabla v)^T n
+ result(i) -= .5*dx * (u-g) * fe.shape_grad_component(i,k,d2)[d1] * n(d2);
+ }
+ }
+ }
}
-
+
+ /**
+ * Homogeneous weak boundary condition for the elasticity operator by Nitsche,
+ * namely on the face <i>F</i> the vector
+ * @f[
+ * \int_F \Bigl(\gamma u \cdot v - n^T \epsilon(u) v - u \epsilon(v) n^T\Bigr)\;ds.
+ * @f]
+ *
+ * Here, <i>u</i> is the finite element function whose values and
+ * gradient are given in the arguments <tt>input</tt> and
+ * <tt>Dinput</tt>, respectively. $n$ is the outer
+ * normal vector and $\gamma$ is the usual penalty parameter.
+ *
+ * @author Guido Kanschat
+ * @date 2013
+ */
+ template <int dim, typename number>
+ void nitsche_residual_homogeneous (
+ Vector<number> &result,
+ const FEValuesBase<dim> &fe,
+ const VectorSlice<const std::vector<std::vector<double> > > &input,
+ const VectorSlice<const std::vector<std::vector<Tensor<1,dim> > > > &Dinput,
+ double penalty,
+ double factor = 1.)
+ {
+ const unsigned int n_dofs = fe.dofs_per_cell;
+ AssertVectorVectorDimension(input, dim, fe.n_quadrature_points);
+ AssertVectorVectorDimension(Dinput, dim, fe.n_quadrature_points);
+
+ for (unsigned int k=0; k<fe.n_quadrature_points; ++k)
+ {
+ const double dx = factor * fe.JxW(k);
+ const Point<dim> &n = fe.normal_vector(k);
+ for (unsigned int i=0; i<n_dofs; ++i)
+ for (unsigned int d1=0; d1<dim; ++d1)
+ {
+ const double u= input[d1][k];
+ const double v= fe.shape_value_component(i,k,d1);
+ result(i) += dx * 2.*penalty * u * v;
+
+ for (unsigned int d2=0; d2<dim; ++d2)
+ {
+ // v . nabla u n
+ result(i) -= .5*dx* v * Dinput[d1][k][d2] * n(d2);
+ // v . (nabla u)^T n
+ result(i) -= .5*dx* v * Dinput[d2][k][d1] * n(d2);
+ // u nabla v n
+ result(i) -= .5*dx * u * fe.shape_grad_component(i,k,d1)[d2] * n(d2);
+ // u (nabla v)^T n
+ result(i) -= .5*dx * u * fe.shape_grad_component(i,k,d2)[d1] * n(d2);
+ }
+ }
+ }
+ }
+
/**
* The interior penalty flux
* for symmetric gradients.
double ext_factor = -1.)
{
const unsigned int n1 = fe1.dofs_per_cell;
-
+
AssertDimension(fe1.get_fe().n_components(), dim);
AssertDimension(fe2.get_fe().n_components(), dim);
AssertVectorVectorDimension(input1, dim, fe1.n_quadrature_points);
{
const double dx = fe1.JxW(k);
const Point<dim> &n = fe1.normal_vector(k);
-
+
for (unsigned int i=0; i<n1; ++i)
for (unsigned int d1=0; d1<dim; ++d1)
{
const double v2 = fe2.shape_value_component(i,k,d1);
const double u1 = input1[d1][k];
const double u2 = input2[d1][k];
-
+
result1(i) += dx * penalty * u1*v1;
- result1(i) -= dx * penalty * u2*v1;
- result2(i) -= dx * penalty * u1*v2;
+ result1(i) -= dx * penalty * u2*v1;
+ result2(i) -= dx * penalty * u1*v2;
result2(i) += dx * penalty * u2*v2;
-
- for (unsigned int d2=0; d2<dim; ++d2)
- {
- // v . nabla u n
- result1(i) -= .25*dx* (nu1*Dinput1[d1][k][d2]+nu2*Dinput1[d1][k][d2]) * n(d2) * v1;
- result2(i) += .25*dx* (nu1*Dinput1[d1][k][d2]+nu2*Dinput1[d1][k][d2]) * n(d2) * v1;
- // v . (nabla u)^T n
- result1(i) -= .25*dx* (nu1*Dinput1[d2][k][d1]+nu2*Dinput1[d2][k][d1]) * n(d2) * v1;
- result2(i) += .25*dx* (nu1*Dinput1[d2][k][d1]+nu2*Dinput1[d2][k][d1]) * n(d2) * v1;
- // u nabla v n
- result1(i) -= .25*dx* nu1*fe1.shape_grad_component(i,k,d1)[d2] * n(d2) * (u1-u2);
- result2(i) -= .25*dx* nu2*fe2.shape_grad_component(i,k,d1)[d2] * n(d2) * (u1-u2);
- // u (nabla v)^T n
- result1(i) -= .25*dx* nu1*fe1.shape_grad_component(i,k,d2)[d1] * n(d2) * (u1-u2);
- result2(i) -= .25*dx* nu2*fe2.shape_grad_component(i,k,d2)[d1] * n(d2) * (u1-u2);
- }
+
+ for (unsigned int d2=0; d2<dim; ++d2)
+ {
+ // v . nabla u n
+ result1(i) -= .25*dx* (nu1*Dinput1[d1][k][d2]+nu2*Dinput2[d1][k][d2]) * n(d2) * v1;
+ result2(i) += .25*dx* (nu1*Dinput1[d1][k][d2]+nu2*Dinput2[d1][k][d2]) * n(d2) * v2;
+ // v . (nabla u)^T n
+ result1(i) -= .25*dx* (nu1*Dinput1[d2][k][d1]+nu2*Dinput2[d2][k][d1]) * n(d2) * v1;
+ result2(i) += .25*dx* (nu1*Dinput1[d2][k][d1]+nu2*Dinput2[d2][k][d1]) * n(d2) * v2;
+ // u nabla v n
+ result1(i) -= .25*dx* nu1*fe1.shape_grad_component(i,k,d1)[d2] * n(d2) * (u1-u2);
+ result2(i) -= .25*dx* nu2*fe2.shape_grad_component(i,k,d1)[d2] * n(d2) * (u1-u2);
+ // u (nabla v)^T n
+ result1(i) -= .25*dx* nu1*fe1.shape_grad_component(i,k,d2)[d1] * n(d2) * (u1-u2);
+ result2(i) -= .25*dx* nu2*fe2.shape_grad_component(i,k,d2)[d1] * n(d2) * (u1-u2);
+ }
}
}
}
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__integrators_l2_h
#define __deal2__integrators_l2_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__integrators_laplace_h
#define __deal2__integrators_laplace_h
}
}
+ template <int dim>
+ void ip_tangential_matrix (
+ FullMatrix<double> &M11,
+ FullMatrix<double> &M12,
+ FullMatrix<double> &M21,
+ FullMatrix<double> &M22,
+ const FEValuesBase<dim> &fe1,
+ const FEValuesBase<dim> &fe2,
+ double penalty,
+ double factor1 = 1.,
+ double factor2 = -1.)
+ {
+ const unsigned int n_dofs = fe1.dofs_per_cell;
+ AssertDimension(fe1.get_fe().n_components(), dim);
+ AssertDimension(fe2.get_fe().n_components(), dim);
+ AssertDimension(M11.n(), n_dofs);
+ AssertDimension(M11.m(), n_dofs);
+ AssertDimension(M12.n(), n_dofs);
+ AssertDimension(M12.m(), n_dofs);
+ AssertDimension(M21.n(), n_dofs);
+ AssertDimension(M21.m(), n_dofs);
+ AssertDimension(M22.n(), n_dofs);
+ AssertDimension(M22.m(), n_dofs);
+
+ const double nui = factor1;
+ const double nue = (factor2 < 0) ? factor1 : factor2;
+ const double nu = .5*(nui+nue);
+
+ for (unsigned int k=0; k<fe1.n_quadrature_points; ++k)
+ {
+ const double dx = fe1.JxW(k);
+ const Point<dim> &n = fe1.normal_vector(k);
+ for (unsigned int i=0; i<n_dofs; ++i)
+ {
+ for (unsigned int j=0; j<n_dofs; ++j)
+ {
+ double u1dotn = 0.;
+ double v1dotn = 0.;
+ double u2dotn = 0.;
+ double v2dotn = 0.;
+
+ for (unsigned int d=0; d<dim; ++d)
+ {
+ u1dotn += n(d)*fe1.shape_value_component(j,k,d);
+ v1dotn += n(d)*fe1.shape_value_component(i,k,d);
+ u2dotn += n(d)*fe2.shape_value_component(j,k,d);
+ v2dotn += n(d)*fe2.shape_value_component(i,k,d);
+ }
+
+ for (unsigned int d=0; d<fe1.get_fe().n_components(); ++d)
+ {
+
+ // multiply by
+ const double vi = fe1.shape_value_component(i,k,d)*(1-v1dotn);
+ const double dnvi = n * fe1.shape_grad_component(i,k,d)*(1-v1dotn);
+ const double ve = fe2.shape_value_component(i,k,d)*(1-v2dotn);
+ const double dnve = n * fe2.shape_grad_component(i,k,d)*(1-v2dotn);
+ const double ui = fe1.shape_value_component(j,k,d)*(1-u1dotn);
+ const double dnui = n * fe1.shape_grad_component(j,k,d)*(1-u1dotn);
+ const double ue = fe2.shape_value_component(j,k,d)*(1-u2dotn);
+ const double dnue = n * fe2.shape_grad_component(j,k,d)*(1-u2dotn);
+ M11(i,j) += dx*(-.5*nui*dnvi*ui-.5*nui*dnui*vi+nu*penalty*ui*vi);
+ M12(i,j) += dx*( .5*nui*dnvi*ue-.5*nue*dnue*vi-nu*penalty*vi*ue);
+ M21(i,j) += dx*(-.5*nue*dnve*ui+.5*nui*dnui*ve-nu*penalty*ui*ve);
+ M22(i,j) += dx*( .5*nue*dnve*ue+.5*nue*dnue*ve+nu*penalty*ue*ve);
+ }
+ }
+ }
+ }
+ }
+
/**
* Residual term for the symmetric interior penalty method.
*
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__integrators_local_integrators_h
#define __deal2__integrators_local_integrators_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__integrators_maxwell_h
#define __deal2__integrators_maxwell_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__integrators_patches_h
#define __deal2__integrators_patches_h
-//---------------------------------------------------------------------------
-// $Id$
-// Authors: Bärbel Janssen, University of Heidelberg,
-// Agnieszka Miedler, TU Berlin, 2010
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2012, 2013 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__arpack_solver_h
#define __deal2__arpack_solver_h
AssertDimension (eigenvalues.size(), eigenvalues_im.size());
for (size_type i=0; i<eigenvalues.size(); ++i)
- eigenvalues[i] = std::complex<double> (eigenvalues_real[i],
- eigenvalues_im[i]);
+ eigenvalues[i] = std::complex<double> (eigenvalues_real[i],
+ eigenvalues_im[i]);
}
}
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__block_indices_h
#define __deal2__block_indices_h
--block;
return std::pair<size_type,size_type>(block,
- i-start_indices[block]);
+ i-start_indices[block]);
}
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__block_list_h
#define __deal2__block_list_h
inline
-BlockList::size_type
+BlockList::size_type
BlockList::size() const
{
return index_sets.size();
inline
-BlockList::size_type
+BlockList::size_type
BlockList::block_size(size_type block) const
{
return index_sets[block].size();
inline
-BlockList::size_type
+BlockList::size_type
BlockList::local_index(size_type block, size_type index) const
{
AssertIndexRange(block, index_sets.size());
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__block_matrix_h
#define __deal2__block_matrix_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__block_matrix_array_h
#define __deal2__block_matrix_array_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__block_matrix_base_h
#define __deal2__block_matrix_base_h
#include <deal.II/base/config.h>
#include <deal.II/base/table.h>
+#include <deal.II/base/thread_management.h>
#include <deal.II/base/utilities.h>
#include <deal.II/base/smartpointer.h>
#include <deal.II/base/memory_consumption.h>
*/
BlockMatrixBase ();
+ /**
+ * Destructor.
+ */
+ ~BlockMatrixBase ();
+
/**
* Copy the given matrix to this
* one. The operation throws an
/**
* Return a reference to the underlying
- * BlockIndices data of the rows.
+ * BlockIndices data of the columns.
*/
const BlockIndices &get_column_indices () const;
private:
- /**
- * Temporary vector for counting the
- * elements written into the
- * individual blocks when doing a
- * collective add or set.
- */
- std::vector<size_type> counter_within_block;
/**
- * Temporary vector for column
- * indices on each block when writing
- * local to global data on each
- * sparse matrix.
+ * A structure containing some fields used by the
+ * set() and add() functions that is used to pre-sort
+ * the input fields. Since one can reasonably expect
+ * to call set() and add() from multiple threads at once
+ * as long as the matrix indices that are touched are
+ * disjoint, these temporary data fields need to be
+ * guarded by a mutex; the structure therefore contains such
+ * a mutex as a member variable.
*/
- std::vector<std::vector<size_type> > column_indices;
+ struct TemporaryData
+ {
+ /**
+ * Temporary vector for counting the
+ * elements written into the
+ * individual blocks when doing a
+ * collective add or set.
+ */
+ std::vector<size_type> counter_within_block;
+
+ /**
+ * Temporary vector for column
+ * indices on each block when writing
+ * local to global data on each
+ * sparse matrix.
+ */
+ std::vector<std::vector<size_type> > column_indices;
+
+ /**
+ * Temporary vector for storing the
+ * local values (they need to be
+ * reordered when writing local to
+ * global).
+ */
+ std::vector<std::vector<double> > column_values;
+
+ /**
+ * A mutex variable used to guard access to the member
+ * variables of this structure;
+ */
+ Threads::Mutex mutex;
+
+ /**
+ * Copy operator. This is needed because the default copy
+ * operator of this class is deleted (since Threads::Mutex is
+ * not copyable) and hence the default copy operator of the
+ * enclosing class is also deleted.
+ *
+ * The implementation here simply does nothing -- TemporaryData
+ * objects are just scratch objects that are resized at the
+ * beginning of their use, so there is no point actually copying
+ * anything.
+ */
+ TemporaryData & operator = (const TemporaryData &)
+ {
+ return *this;
+ }
+ };
/**
- * Temporary vector for storing the
- * local values (they need to be
- * reordered when writing local to
- * global).
+ * A set of scratch arrays that can be used by the add()
+ * and set() functions that take pointers to data to
+ * pre-sort indices before use. Access from multiple threads
+ * is synchronized via the mutex variable that is part of the
+ * structure.
*/
- std::vector<std::vector<double> > column_values;
-
+ TemporaryData temporary_data;
/**
* Make the iterator class a
BlockMatrixBase<MatrixType>::BlockMatrixBase ()
{}
+template <typename MatrixType>
+inline
+BlockMatrixBase<MatrixType>::~BlockMatrixBase ()
+{
+ clear ();
+}
template <class MatrixType>
MemoryConsumption::memory_consumption(row_block_indices)+
MemoryConsumption::memory_consumption(column_block_indices)+
MemoryConsumption::memory_consumption(sub_objects)+
- MemoryConsumption::memory_consumption(counter_within_block)+
- MemoryConsumption::memory_consumption(column_indices)+
- MemoryConsumption::memory_consumption(column_values);
+ MemoryConsumption::memory_consumption(temporary_data.counter_within_block)+
+ MemoryConsumption::memory_consumption(temporary_data.column_indices)+
+ MemoryConsumption::memory_consumption(temporary_data.column_values)+
+ sizeof(temporary_data.mutex);
for (unsigned int r=0; r<n_block_rows(); ++r)
for (unsigned int c=0; c<n_block_cols(); ++c)
{
prepare_set_operation();
+ // lock access to the temporary data structure to
+ // allow multiple threads to call this function concurrently
+ Threads::Mutex::ScopedLock lock (temporary_data.mutex);
+
// Resize scratch arrays
- if (column_indices.size() < this->n_block_cols())
+ if (temporary_data.column_indices.size() < this->n_block_cols())
{
- column_indices.resize (this->n_block_cols());
- column_values.resize (this->n_block_cols());
- counter_within_block.resize (this->n_block_cols());
+ temporary_data.column_indices.resize (this->n_block_cols());
+ temporary_data.column_values.resize (this->n_block_cols());
+ temporary_data.counter_within_block.resize (this->n_block_cols());
}
// Resize sub-arrays to n_cols. This
// whether the size of one is large
// enough before actually going
// through all of them.
- if (column_indices[0].size() < n_cols)
+ if (temporary_data.column_indices[0].size() < n_cols)
{
for (unsigned int i=0; i<this->n_block_cols(); ++i)
{
- column_indices[i].resize(n_cols);
- column_values[i].resize(n_cols);
+ temporary_data.column_indices[i].resize(n_cols);
+ temporary_data.column_values[i].resize(n_cols);
}
}
// Reset the number of added elements
// in each block to zero.
for (unsigned int i=0; i<this->n_block_cols(); ++i)
- counter_within_block[i] = 0;
+ temporary_data.counter_within_block[i] = 0;
// Go through the column indices to
// find out which portions of the
const std::pair<unsigned int, size_type>
col_index = this->column_block_indices.global_to_local(col_indices[j]);
- const size_type local_index = counter_within_block[col_index.first]++;
+ const size_type local_index = temporary_data.counter_within_block[col_index.first]++;
- column_indices[col_index.first][local_index] = col_index.second;
- column_values[col_index.first][local_index] = value;
+ temporary_data.column_indices[col_index.first][local_index] = col_index.second;
+ temporary_data.column_values[col_index.first][local_index] = value;
}
#ifdef DEBUG
// the right length has been obtained.
size_type length = 0;
for (unsigned int i=0; i<this->n_block_cols(); ++i)
- length += counter_within_block[i];
+ length += temporary_data.counter_within_block[i];
Assert (length <= n_cols, ExcInternalError());
#endif
row_index = this->row_block_indices.global_to_local (row);
for (unsigned int block_col=0; block_col<n_block_cols(); ++block_col)
{
- if (counter_within_block[block_col] == 0)
+ if (temporary_data.counter_within_block[block_col] == 0)
continue;
block(row_index.first, block_col).set
(row_index.second,
- counter_within_block[block_col],
- &column_indices[block_col][0],
- &column_values[block_col][0],
+ temporary_data.counter_within_block[block_col],
+ &temporary_data.column_indices[block_col][0],
+ &temporary_data.column_values[block_col][0],
false);
}
}
return;
}
- // Resize scratch arrays
- if (column_indices.size() < this->n_block_cols())
+ // Lock scratch arrays, then resize them
+ Threads::Mutex::ScopedLock lock (temporary_data.mutex);
+
+ if (temporary_data.column_indices.size() < this->n_block_cols())
{
- column_indices.resize (this->n_block_cols());
- column_values.resize (this->n_block_cols());
- counter_within_block.resize (this->n_block_cols());
+ temporary_data.column_indices.resize (this->n_block_cols());
+ temporary_data.column_values.resize (this->n_block_cols());
+ temporary_data.counter_within_block.resize (this->n_block_cols());
}
// Resize sub-arrays to n_cols. This
// whether the size of one is large
// enough before actually going
// through all of them.
- if (column_indices[0].size() < n_cols)
+ if (temporary_data.column_indices[0].size() < n_cols)
{
for (unsigned int i=0; i<this->n_block_cols(); ++i)
{
- column_indices[i].resize(n_cols);
- column_values[i].resize(n_cols);
+ temporary_data.column_indices[i].resize(n_cols);
+ temporary_data.column_values[i].resize(n_cols);
}
}
// Reset the number of added elements
// in each block to zero.
for (unsigned int i=0; i<this->n_block_cols(); ++i)
- counter_within_block[i] = 0;
+ temporary_data.counter_within_block[i] = 0;
// Go through the column indices to
// find out which portions of the
const std::pair<unsigned int, size_type>
col_index = this->column_block_indices.global_to_local(col_indices[j]);
- const size_type local_index = counter_within_block[col_index.first]++;
+ const size_type local_index = temporary_data.counter_within_block[col_index.first]++;
- column_indices[col_index.first][local_index] = col_index.second;
- column_values[col_index.first][local_index] = value;
+ temporary_data.column_indices[col_index.first][local_index] = col_index.second;
+ temporary_data.column_values[col_index.first][local_index] = value;
}
#ifdef DEBUG
// the right length has been obtained.
size_type length = 0;
for (unsigned int i=0; i<this->n_block_cols(); ++i)
- length += counter_within_block[i];
+ length += temporary_data.counter_within_block[i];
Assert (length <= n_cols, ExcInternalError());
#endif
row_index = this->row_block_indices.global_to_local (row);
for (unsigned int block_col=0; block_col<n_block_cols(); ++block_col)
{
- if (counter_within_block[block_col] == 0)
+ if (temporary_data.counter_within_block[block_col] == 0)
continue;
block(row_index.first, block_col).add
(row_index.second,
- counter_within_block[block_col],
- &column_indices[block_col][0],
- &column_values[block_col][0],
+ temporary_data.counter_within_block[block_col],
+ &temporary_data.column_indices[block_col][0],
+ &temporary_data.column_values[block_col][0],
false,
col_indices_are_sorted);
}
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__block_sparse_matrix_h
#define __deal2__block_sparse_matrix_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2011, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__block_sparse_matrix_templates_h
#define __deal2__block_sparse_matrix_templates_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2002 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__block_sparse_matrix_ez_h
#define __deal2__block_sparse_matrix_ez_h
ExcDimensionMismatch(src.n_blocks(), n_block_rows()));
for (unsigned int row=0; row<n_block_rows(); ++row)
- for (unsigned int col=0; col<n_block_cols(); ++col)
- block(row,col).Tvmult_add (dst.block(col),
- src.block(row));
+ for (unsigned int col=0; col<n_block_cols(); ++col)
+ block(row,col).Tvmult_add (dst.block(col),
+ src.block(row));
}
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2008, 2011, 2012 by the deal.II authors
+// Copyright (C) 2002 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__block_sparse_matrix_ez_templates_h
#define __deal2__block_sparse_matrix_ez_templates_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__block_sparsity_pattern_h
#define __deal2__block_sparsity_pattern_h
* You will in general not want to use this class, but one of the
* derived classes.
*
- * @todo Handle opitmization of diagonal elements of the underlying
+ * @todo Handle optimization of diagonal elements of the underlying
* SparsityPattern correctly.
*
* @see @ref GlossBlockLA "Block (linear algebra)"
Assert(index<row_length(row), ExcIndexRange(index, 0, row_length(row)));
size_type c = 0;
+ size_type block_columns = 0; //sum of n_cols for all blocks to the left
for (unsigned int b=0; b<columns; ++b)
{
unsigned int rowlen = sub_objects[row_index.first][b]->row_length (row_index.second);
if (index<c+rowlen)
- return c+sub_objects[row_index.first][b]->column_number(row_index.second, index-c);
+ return block_columns+sub_objects[row_index.first][b]->column_number(row_index.second, index-c);
c += rowlen;
+ block_columns += sub_objects[row_index.first][b]->n_cols();
}
Assert(false, ExcInternalError());
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__block_vector_h
#define __deal2__block_vector_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__block_vector_templates_h
#define __deal2__block_vector_templates_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2007, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__block_vector_base_h
#define __deal2__block_vector_base_h
*/
reference operator[] (const size_type i);
+ /**
+ * A collective get operation: instead
+ * of getting individual elements of a
+ * vector, this function allows to get
+ * a whole set of elements at once. The
+ * indices of the elements to be read
+ * are stated in the first argument,
+ * the corresponding values are returned in the
+ * second.
+ */
+ template <typename OtherNumber>
+ void extract_subvector_to (const std::vector<size_type> &indices,
+ std::vector<OtherNumber> &values) const;
+
+ /**
+ * Just as the above, but with pointers.
+ * Useful in minimizing copying of data around.
+ */
+ template <typename ForwardIterator, typename OutputIterator>
+ void extract_subvector_to (ForwardIterator indices_begin,
+ const ForwardIterator indices_end,
+ OutputIterator values_begin) const;
+
/**
* Copy operator: fill all components of
* the vector with the given scalar
return operator()(i);
}
+
+
+template <typename VectorType>
+template <typename OtherNumber>
+inline
+void BlockVectorBase<VectorType>::extract_subvector_to (const std::vector<size_type> &indices,
+ std::vector<OtherNumber> &values) const
+{
+ for (size_type i = 0; i < indices.size(); ++i)
+ values[i] = operator()(indices[i]);
+}
+
+
+
+template <typename VectorType>
+template <typename ForwardIterator, typename OutputIterator>
+inline
+void BlockVectorBase<VectorType>::extract_subvector_to (ForwardIterator indices_begin,
+ const ForwardIterator indices_end,
+ OutputIterator values_begin) const
+{
+ while (indices_begin != indices_end) {
+ *values_begin = operator()(*indices_begin);
+ indices_begin++; values_begin++;
+ }
+}
+
#endif // DOXYGEN
DEAL_II_NAMESPACE_CLOSE
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__chunk_sparse_matrix_h
#define __deal2__chunk_sparse_matrix_h
* of the current kind.
*/
typedef
- const Accessor<number,Constness> & value_type;
+ const Accessor<number,Constness> &value_type;
/**
* Constructor. Create an iterator into the matrix @p matrix for the given
template <typename number>
inline
-typename ChunkSparseMatrix<number>::size_type
+typename ChunkSparseMatrix<number>::size_type
ChunkSparseMatrix<number>::n () const
{
Assert (cols != 0, ExcNotInitialized());
template <typename number>
inline
-typename ChunkSparseMatrix<number>::size_type
+typename ChunkSparseMatrix<number>::size_type
ChunkSparseMatrix<number>::compute_location (const size_type i,
const size_type j) const
{
const size_type chunk_size = cols->get_chunk_size();
const size_type chunk_index
- = cols->sparsity_pattern(i/chunk_size, j/chunk_size);
+ = cols->sparsity_pattern(i/chunk_size, j/chunk_size);
if (chunk_index == ChunkSparsityPattern::invalid_entry)
return ChunkSparsityPattern::invalid_entry;
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2009, 2011, 2012 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__chunk_sparse_matrix_templates_h
#define __deal2__chunk_sparse_matrix_templates_h
const size_type n_filled_last_cols = n % chunk_size;
const size_type last_regular_row = n_filled_last_rows > 0 ?
- std::min(m/chunk_size,
- static_cast<size_type>(end_row)) :
- end_row;
+ std::min(m/chunk_size,
+ static_cast<size_type>(end_row)) :
+ end_row;
const size_type irregular_col = n/chunk_size;
typename OutVector::iterator dst_ptr = dst.begin()+chunk_size*begin_row;
// chunks. this entails some padding elements
const size_type chunk_size = cols->get_chunk_size();
const size_type N = cols->sparsity_pattern.n_nonzero_elements() *
- chunk_size * chunk_size;
+ chunk_size * chunk_size;
if (N > max_len || max_len == 0)
{
if (val != 0)
template <typename number>
-typename ChunkSparseMatrix<number>::size_type
+typename ChunkSparseMatrix<number>::size_type
ChunkSparseMatrix<number>::n_nonzero_elements () const
{
Assert (cols != 0, ExcNotInitialized());
template <typename number>
-typename ChunkSparseMatrix<number>::size_type
+typename ChunkSparseMatrix<number>::size_type
ChunkSparseMatrix<number>::n_actually_nonzero_elements () const
{
Assert (cols != 0, ExcNotInitialized());
* chunk_size * chunk_size];
while (val_ptr != end_ptr)
- *val_ptr++ += factor * *matrix_ptr++;
+ *val_ptr++ += factor **matrix_ptr++;
}
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2012 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__chunk_sparsity_pattern_h
#define __deal2__chunk_sparsity_pattern_h
const ForwardIterator end,
const size_type chunk_size);
- /**
- * @deprecated This function is deprecated. Use the function
- * without the last argument
- */
+ /**
+ * @deprecated This function is deprecated. Use the function
+ * without the last argument
+ */
template <typename ForwardIterator>
void copy_from (const size_type n_rows,
const size_type n_cols,
const unsigned int row)
:
sparsity_pattern(sparsity_pattern),
- reduced_accessor(row==sparsity_pattern->n_rows() ?
+ reduced_accessor(row==sparsity_pattern->n_rows() ?
*sparsity_pattern->sparsity_pattern.end() :
*sparsity_pattern->sparsity_pattern.
begin(row/sparsity_pattern->get_chunk_size())),
Accessor::is_valid_entry () const
{
return reduced_accessor.is_valid_entry()
- &&
- sparsity_pattern->get_chunk_size()*reduced_accessor.row()+chunk_row <
- sparsity_pattern->n_rows()
- &&
- sparsity_pattern->get_chunk_size()*reduced_accessor.column()+chunk_col <
- sparsity_pattern->n_cols();
+ &&
+ sparsity_pattern->get_chunk_size()*reduced_accessor.row()+chunk_row <
+ sparsity_pattern->n_rows()
+ &&
+ sparsity_pattern->get_chunk_size()*reduced_accessor.column()+chunk_col <
+ sparsity_pattern->n_cols();
}
Assert (is_valid_entry() == true, ExcInvalidIterator());
return sparsity_pattern->get_chunk_size()*reduced_accessor.row() +
- chunk_row;
+ chunk_row;
}
Assert (is_valid_entry() == true, ExcInvalidIterator());
return sparsity_pattern->get_chunk_size()*reduced_accessor.column() +
- chunk_col;
+ chunk_col;
}
return true;
const unsigned int
- global_row = sparsity_pattern->get_chunk_size()*reduced_accessor.row()
- +chunk_row,
- other_global_row = sparsity_pattern->get_chunk_size()*
- other.reduced_accessor.row()+other.chunk_row;
+ global_row = sparsity_pattern->get_chunk_size()*reduced_accessor.row()
+ +chunk_row,
+ other_global_row = sparsity_pattern->get_chunk_size()*
+ other.reduced_accessor.row()+other.chunk_row;
if (global_row < other_global_row)
return true;
else if (global_row > other_global_row)
ChunkSparsityPattern::end (const unsigned int r) const
{
Assert (r<n_rows(), ExcIndexRange(r,0,n_rows()))
- return iterator(this, r+1);
+ return iterator(this, r+1);
}
for (inner_iterator j=i->begin(); j!=end_of_row; ++j)
{
const size_type col
- = internal::SparsityPatternTools::get_column_index_from_iterator(*j);
+ = internal::SparsityPatternTools::get_column_index_from_iterator(*j);
Assert (col < n_cols, ExcInvalidIndex(col,n_cols));
add (row, col);
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2012 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__compressed_set_sparsity_pattern_h
#define __deal2__compressed_set_sparsity_pattern_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__compressed_simple_sparsity_pattern_h
#define __deal2__compressed_simple_sparsity_pattern_h
const size_type n,
const IndexSet &rowset = IndexSet());
+ /**
+ * Create a square SparsityPattern using
+ * the index set.
+ */
+ CompressedSimpleSparsityPattern (const IndexSet &indexset);
+
/**
* Initialize a square matrix of
* dimension @p n.
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2012 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__compressed_sparsity_pattern_h
#define __deal2__compressed_sparsity_pattern_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__constraint_matrix_h
#define __deal2__constraint_matrix_h
*/
bool can_store_line (const size_type line_index) const;
+ /**
+ * Returns the index set describing locally relevant lines if any are
+ * present. Note that if no local lines were given, this represents an empty
+ * IndexSet, whereas otherwise it contains the global problem size and the
+ * local range.
+ */
+ const IndexSet & get_local_lines() const;
+
/**
* This function copies the content of @p
* constraints_in with DoFs that are
*/
bool is_identity_constrained (const size_type index) const;
+ /**
+ * Return whether the two given degrees of freedom are linked by an
+ * equality constraint that either constrains index1 to be so that
+ * <code>index1=index2</code> or constrains index2 so that
+ * <code>index2=index1</code>.
+ */
+ bool are_identity_constrained (const size_type index1,
+ const size_type index2) const;
+
/**
* Return the maximum number of other
* dofs that one dof is constrained
* @ingroup Exceptions
*/
DeclException2 (ExcIncorrectConstraint,
- int, int,
+ int, int,
<< "While distributing the constraint for DoF "
<< arg1 << ", it turns out that one of the processors "
<< "who own the " << arg2
<< "with the appropriate locally_relevant set so "
<< "that every processor who owns a DoF that constrains "
<< "another DoF also knows about this constraint?");
-
+
private:
/**
lines (),
local_lines (local_constraints),
sorted (false)
-{}
+{
+ // make sure the IndexSet is compressed. Otherwise this can lead to crashes
+ // that are hard to find (only happen in release mode).
+ // see tests/mpi/constraint_matrix_crash_01
+ local_lines.compress();
+}
+inline
+const IndexSet &
+ConstraintMatrix::get_local_lines () const
+{
+ return local_lines;
+}
+
+
+
template <class VectorType>
inline
void ConstraintMatrix::distribute_local_to_global (
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__constraint_matrix_templates_h
#define __deal2__constraint_matrix_templates_h
// which line in the constraint matrix
// handles this index
std::vector<size_type> distribute (sparsity.n_rows(),
- numbers::invalid_size_type);
+ numbers::invalid_size_type);
for (size_type c=0; c<lines.size(); ++c)
distribute[lines[c].line] = c;
// in the constraint matrix handles this
// index
std::vector<size_type> distribute (sparsity.n_rows(),
- numbers::invalid_size_type);
+ numbers::invalid_size_type);
for (size_type c=0; c<lines.size(); ++c)
distribute[lines[c].line] = c;
template<class VEC>
void set_zero_parallel(const std::vector<size_type> &cm, VEC &vec, size_type shift = 0)
{
- Assert(!vec.has_ghost_elements(), ExcInternalError());//ExcGhostsPresent());
+ Assert(!vec.has_ghost_elements(), ExcInternalError());
IndexSet locally_owned = vec.locally_owned_elements();
for (typename std::vector<size_type>::const_iterator it = cm.begin();
it != cm.end(); ++it)
- if (locally_owned.is_element(*it))
- vec(*it) = 0.;
+ {
+ // If shift>0 then we are working on a part of a BlockVector
+ // so vec(i) is actually the global entry i+shift.
+ // We first make sure the line falls into the range of vec,
+ // then check if is part of the local part of the vector, before
+ // finally setting it to 0.
+ if ((*it)<shift)
+ continue;
+ size_type idx = *it - shift;
+ if (idx<vec.size() && locally_owned.is_element(idx))
+ vec(idx) = 0.;
+ }
}
template<typename Number>
{
for (typename std::vector<size_type>::const_iterator it = cm.begin();
it != cm.end(); ++it)
- if (vec.in_local_range(*it))
- vec(*it) = 0.;
+ {
+ // If shift>0 then we are working on a part of a BlockVector
+ // so vec(i) is actually the global entry i+shift.
+ // We first make sure the line falls into the range of vec,
+ // then check if is part of the local part of the vector, before
+ // finally setting it to 0.
+ if ((*it)<shift)
+ continue;
+ size_type idx = *it - shift;
+ if (vec.in_local_range(idx))
+ vec(idx) = 0.;
+ }
vec.zero_out_ghosts();
}
{
for (typename std::vector<size_type>::const_iterator it = cm.begin();
it != cm.end(); ++it)
- vec(*it) = 0.;
+ vec(*it) = 0.;
}
template<class VEC>
typedef std::vector<ConstraintLine>::const_iterator constraint_iterator;
for (constraint_iterator it = lines.begin();
- it != lines.end(); ++it)
+ it != lines.end(); ++it)
if (vec_owned_elements.is_element(it->line))
for (unsigned int i=0; i<it->entries.size(); ++i)
- needed_elements.add_index(it->entries[i].first);
+ if (!vec_owned_elements.is_element(it->entries[i].first))
+ needed_elements.add_index(it->entries[i].first);
VectorType ghosted_vector;
internal::import_vector_with_ghost_elements (vec,
internal::bool2type<IsBlockVector<VectorType>::value>());
for (constraint_iterator it = lines.begin();
- it != lines.end(); ++it)
+ it != lines.end(); ++it)
if (vec_owned_elements.is_element(it->line))
{
typename VectorType::value_type
- new_value = it->inhomogeneity;
+ new_value = it->inhomogeneity;
for (unsigned int i=0; i<it->entries.size(); ++i)
new_value += (static_cast<typename VectorType::value_type>
(ghosted_vector(it->entries[i].first)) *
for (unsigned int i=0; i<next_constraint->entries.size(); ++i)
new_value += (static_cast<typename VectorType::value_type>
(vec(next_constraint->entries[i].first)) *
- next_constraint->entries[i].second);
+ next_constraint->entries[i].second);
Assert(numbers::is_finite(new_value), ExcNumberNotFinite());
vec(next_constraint->line) = new_value;
}
individual_size[index]++;
}
- size_type
+ size_type
get_size (const size_type index) const
{
return individual_size[index];
const size_type loc_row = global_rows.local_row(i);
typename SparseMatrix<number>::iterator
- matrix_values = sparse_matrix->begin(row);
+ matrix_values = sparse_matrix->begin(row);
const bool optimize_diagonal = sparsity.n_rows() == sparsity.n_cols();
// distinguish three cases about what can
Utilities::lower_bound(active_dofs.begin(),
active_dofs.end()-i+1,
new_index);
- if (*it != new_index)
+ if (*it != new_index)
active_dofs.insert(it, new_index);
}
}
for (size_type block_col=0; block_col<num_blocks; ++block_col)
{
const size_type start_block = block_starts[block_col],
- end_block = block_starts[block_col+1];
+ end_block = block_starts[block_col+1];
if (use_dealii_matrix == false)
{
size_type *col_ptr = &cols[0];
for (size_type block_col=0; block_col<num_blocks; ++block_col)
{
const size_type begin_block = block_starts[block_col],
- end_block = block_starts[block_col+1];
+ end_block = block_starts[block_col+1];
std::vector<size_type>::iterator col_ptr = cols.begin();
internals::resolve_matrix_row (global_rows, i, begin_block,
end_block, dof_mask, col_ptr);
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__eigen_h
#define __deal2__eigen_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__lac_exceptions_h
#define __deal2__lac_exceptions_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__filtered_matrix_h
#define __deal2__filtered_matrix_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__full_matrix_h
#define __deal2__full_matrix_h
{
const typename MATRIX::const_iterator end_row = M.end(row);
for (typename MATRIX::const_iterator entry = M.begin(row);
- entry != end_row; ++entry)
+ entry != end_row; ++entry)
this->el(row, entry->column()) = entry->value();
}
}
{
const typename MATRIX::const_iterator end_row = M.end(row);
for (typename MATRIX::const_iterator entry = M.begin(row);
- entry != end_row; ++entry)
+ entry != end_row; ++entry)
this->el(entry->column(), row) = entry->value();
}
}
for (size_type i=0; i<this->m(); ++i)
{
for (size_type j=0; j<this->n(); ++j)
- {
- s.width(w);
- s.precision(p);
- s << this->el(i,j);
- }
+ {
+ s.width(w);
+ s.precision(p);
+ s << this->el(i,j);
+ }
s << std::endl;
}
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__full_matrix_templates_h
#define __deal2__full_matrix_templates_h
// Compute maximal size of copied block
const size_type rows = std::min (m() - dst_offset_i,
- src.m() - src_offset_i);
+ src.m() - src_offset_i);
const size_type cols = std::min (n() - dst_offset_j,
- src.n() - src_offset_j);
+ src.n() - src_offset_j);
for (size_type i=0; i<rows ; ++i)
for (size_type j=0; j<cols ; ++j)
// Compute maximal size of copied block
const size_type rows = std::min (m() - dst_offset_i, src.n() - src_offset_j);
const size_type cols = std::min (n() - dst_offset_j,
- src.m() - src_offset_i);
+ src.m() - src_offset_i);
for (size_type i=0; i<rows ; ++i)
const somenumber *src_ptr = src.begin();
for (size_type i=0; i<n; ++i, ++dst_ptr, ++src_ptr)
- *dst_ptr = somenumber(om) * *src_ptr / somenumber((*this)(i,i));
+ *dst_ptr = somenumber(om) **src_ptr / somenumber((*this)(i,i));
}
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 2008 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+#ifndef __deal2__generic_linear_algebra_h
+#define __deal2__generic_linear_algebra_h
+
+#include <deal.II/base/config.h>
+
+
+#include <deal.II/lac/vector.h>
+#include <deal.II/lac/block_vector.h>
+#include <deal.II/lac/sparse_matrix.h>
+#include <deal.II/lac/precondition.h>
+DEAL_II_NAMESPACE_OPEN
+
+
+namespace LinearAlgebraDealII
+{
+ typedef Vector<double> Vector;
+ typedef BlockVector<double> BlockVector;
+
+ typedef SparseMatrix<double> SparseMatrix;
+
+ typedef PreconditionSSOR<SparseMatrix > PreconditionSSOR;
+
+}
+
+
+DEAL_II_NAMESPACE_CLOSE
+
+
+#ifdef DEAL_II_USE_PETSC
+
+#include <deal.II/lac/block_sparsity_pattern.h>
+#include <deal.II/lac/petsc_vector.h>
+#include <deal.II/lac/petsc_block_vector.h>
+#include <deal.II/lac/petsc_parallel_sparse_matrix.h>
+#include <deal.II/lac/petsc_sparse_matrix.h>
+#include <deal.II/lac/petsc_parallel_block_sparse_matrix.h>
+#include <deal.II/lac/petsc_precondition.h>
+#include <deal.II/lac/petsc_solver.h>
+
+DEAL_II_NAMESPACE_OPEN
+
+namespace LinearAlgebraPETSc
+{
+ using namespace dealii;
+
+ typedef PETScWrappers::Vector Vector;
+ typedef PETScWrappers::BlockVector BlockVector;
+
+ typedef PETScWrappers::SparseMatrix SparseMatrix;
+
+ typedef PETScWrappers::SolverCG SolverCG;
+
+
+ namespace MPI
+ {
+
+ /**
+ * Typedef for the vector type used.
+ */
+ typedef PETScWrappers::MPI::Vector Vector;
+
+ /**
+ * Typedef for the type used to describe vectors that
+ * consist of multiple blocks.
+ */
+ typedef PETScWrappers::MPI::BlockVector BlockVector;
+
+ /**
+ * Typedef for the sparse matrix type used.
+ */
+ typedef PETScWrappers::MPI::SparseMatrix SparseMatrix;
+
+ /**
+ * Typedef for the type used to describe sparse matrices that
+ * consist of multiple blocks.
+ */
+ typedef PETScWrappers::MPI::BlockSparseMatrix BlockSparseMatrix;
+
+ typedef dealii::BlockCompressedSimpleSparsityPattern CompressedBlockSparsityPattern;
+
+ /**
+ * Typedef for the AMG preconditioner type.
+ */
+ typedef PETScWrappers::PreconditionBoomerAMG PreconditionAMG;
+
+ /**
+ * Typedef for the Incomplete Cholesky preconditioner.
+ */
+ typedef PETScWrappers::PreconditionICC PreconditionIC;
+
+ /**
+ * Typedef for the Incomplete LU decomposition preconditioner.
+ */
+ typedef PETScWrappers::PreconditionILU PreconditionILU;
+
+ /**
+ * Typedef for the Incomplete Jacobi decomposition preconditioner.
+ */
+ typedef PETScWrappers::PreconditionJacobi PreconditionJacobi;
+
+ /**
+ * Typedef for the SSOR preconditioner.
+ */
+ typedef PETScWrappers::PreconditionSSOR PreconditionSSOR;
+
+ }
+
+}
+DEAL_II_NAMESPACE_CLOSE
+
+
+#endif // DEAL_II_USE_PETSC
+
+#ifdef DEAL_II_USE_TRILINOS
+
+#include <deal.II/lac/trilinos_vector.h>
+#include <deal.II/lac/trilinos_block_vector.h>
+#include <deal.II/lac/trilinos_block_sparse_matrix.h>
+#include <deal.II/lac/trilinos_sparse_matrix.h>
+#include <deal.II/lac/trilinos_precondition.h>
+#include <deal.II/lac/block_sparsity_pattern.h>
+#include <deal.II/lac/trilinos_solver.h>
+
+DEAL_II_NAMESPACE_OPEN
+
+namespace LinearAlgebraTrilinos
+{
+ using namespace dealii;
+
+ typedef TrilinosWrappers::Vector Vector;
+
+ typedef TrilinosWrappers::SolverCG SolverCG;
+
+ namespace MPI
+ {
+
+ /**
+ * Typedef for the vector type used.
+ */
+ typedef TrilinosWrappers::MPI::Vector Vector;
+
+ /**
+ * Typedef for the type used to describe vectors that
+ * consist of multiple blocks.
+ */
+ typedef TrilinosWrappers::MPI::BlockVector BlockVector;
+
+ /**
+ * Typedef for the sparse matrix type used.
+ */
+ typedef TrilinosWrappers::SparseMatrix SparseMatrix;
+
+ /**
+ * Typedef for the type used to describe sparse matrices that
+ * consist of multiple blocks.
+ */
+ typedef TrilinosWrappers::BlockSparseMatrix BlockSparseMatrix;
+
+ typedef TrilinosWrappers::BlockSparsityPattern CompressedBlockSparsityPattern;
+
+ /**
+ * Typedef for the AMG preconditioner type.
+ */
+ typedef TrilinosWrappers::PreconditionAMG PreconditionAMG;
+
+ /**
+ * Typedef for the Incomplete Cholesky preconditioner.
+ */
+ typedef TrilinosWrappers::PreconditionIC PreconditionIC;
+
+ /**
+ * Typedef for the Incomplete LU decomposition preconditioner.
+ */
+ typedef TrilinosWrappers::PreconditionILU PreconditionILU;
+
+ /**
+ * Typedef for the Incomplete Jacobi decomposition preconditioner.
+ */
+ typedef TrilinosWrappers::PreconditionJacobi PreconditionJacobi;
+
+ /**
+ * Typedef for the SSOR preconditioner
+ */
+ typedef TrilinosWrappers::PreconditionSSOR PreconditionSSOR;
+
+
+ }
+
+}
+
+DEAL_II_NAMESPACE_CLOSE
+
+
+#endif // DEAL_II_USE_TRILINOS
+
+
+
+#endif
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2007, 2008, 2010, 2012 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__householder_h
#define __deal2__householder_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2012 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__identity_matrix_h
#define __deal2__identity_matrix_h
inline
-IdentityMatrix::size_type
+IdentityMatrix::size_type
IdentityMatrix::m () const
{
return size;
inline
-IdentityMatrix::size_type
+IdentityMatrix::size_type
IdentityMatrix::n () const
{
return size;
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__iterative_inverse_h
#define __deal2__iterative_inverse_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2008, 2009, 2010, 2012, 2013 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__lapack_full_matrix_h
#define __deal2__lapack_full_matrix_h
{
const typename MATRIX::const_iterator end_row = M.end(row);
for (typename MATRIX::const_iterator entry = M.begin(row);
- entry != end_row; ++entry)
+ entry != end_row; ++entry)
this->el(row, entry->column()) = entry->value();
}
{
const typename MATRIX::const_iterator end_row = M.end(row);
for (typename MATRIX::const_iterator entry = M.begin(row);
- entry != end_row; ++entry)
+ entry != end_row; ++entry)
{
const size_type i = transpose ? entry->column() : row;
const size_type j = transpose ? row : entry->column();
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2008, 2010, 2012 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__lapack_support_h
#define __deal2__lapack_support_h
-//---------------------------------------------------------------------------
+// ---------------------------------------------------------------------
+// $Id$
//
-// This file was automatically generated from lapack_templates.h.in
-// See blastemplates in the deal.II contrib directory
+// Copyright (C) 2005 - 2013 by the deal.II authors
//
-// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 by the deal authors
+// This file is part of the deal.II library.
//
-// 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.
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
//
-//---------------------------------------------------------------------------
+// ---------------------------------------------------------------------
+
#ifndef __LAPACK_TEMPLATES_H
#define __LAPACK_TEMPLATES_H
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2007 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__matrix_block_h
#define __deal2__matrix_block_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__matrix_iterator_h
#define __deal2__matrix_iterator_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2012, 2013 by the deal.II authors
+// Copyright (C) 2002 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__matrix_lib_h
#define __deal2__matrix_lib_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2002, 2003, 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 2002 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__matrix_lib_templates_h
#define __deal2__matrix_lib_templates_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__matrix_out_h
#define __deal2__matrix_out_h
const std::string &name,
const Options options)
{
- size_type
+ size_type
gridpoints_x = (matrix.n() / options.block_size
+
(matrix.n() % options.block_size != 0 ? 1 : 0)),
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__parallel_block_vector_h
#define __deal2__parallel_block_vector_h
*/
BlockVector (const std::vector<size_type> &block_sizes);
+ /**
+ * Construct a block vector with an IndexSet for the local range
+ * and ghost entries for each block.
+ */
+ BlockVector (const std::vector<IndexSet> &local_ranges,
+ const std::vector<IndexSet> &ghost_indices,
+ const MPI_Comm communicator);
+
+ /**
+ * Same as above but the ghost indicies are assumed to be empty.
+ */
+ BlockVector (const std::vector<IndexSet> &local_ranges,
+ const MPI_Comm communicator);
+
/**
* Destructor. Clears memory.
*/
}
+ template <typename Number>
+ inline
+ BlockVector<Number>::BlockVector (const std::vector<IndexSet> &local_ranges,
+ const std::vector<IndexSet> &ghost_indices,
+ const MPI_Comm communicator)
+ {
+ std::vector<size_type> sizes(local_ranges.size());
+ for (unsigned int i=0; i<local_ranges.size(); ++i)
+ sizes[i] = local_ranges[i].size();
+
+ this->block_indices.reinit(sizes);
+ this->components.resize(this->n_blocks());
+
+ for (unsigned int i=0; i<this->n_blocks(); ++i)
+ this->block(i).reinit(local_ranges[i], ghost_indices[i], communicator);
+ }
+
+
+ template <typename Number>
+ inline
+ BlockVector<Number>::BlockVector (const std::vector<IndexSet> &local_ranges,
+ const MPI_Comm communicator)
+ {
+ std::vector<size_type> sizes(local_ranges.size());
+ for (unsigned int i=0; i<local_ranges.size(); ++i)
+ sizes[i] = local_ranges[i].size();
+
+ this->block_indices.reinit(sizes);
+ this->components.resize(this->n_blocks());
+
+ for (unsigned int i=0; i<this->n_blocks(); ++i)
+ this->block(i).reinit(local_ranges[i], communicator);
+ }
+
+
template <typename Number>
inline
BlockVector<Number> &
BlockVector<Number>::operator = (const BlockVector &v)
{
- reinit (v, true);
- BaseClass::operator = (v);
+ // we only allow assignment to vectors with the same number of blocks
+ // or to an empty BlockVector
+ Assert (this->n_blocks() == 0 || this->n_blocks() == v.n_blocks(),
+ ExcDimensionMismatch(this->n_blocks(), v.n_blocks()));
+
+ if (this->n_blocks() != v.n_blocks())
+ reinit(v.n_blocks(), true);
+
+ for (size_type i=0; i<this->n_blocks(); ++i)
+ this->components[i] = v.block(i);
+
+ this->collect_sizes();
return *this;
}
if (this->block(0).partitioner->n_mpi_processes() > 1)
return Utilities::MPI::sum (local_result,
this->block(0).partitioner->get_communicator())/
- (real_type)this->size();
+ (real_type)this->size();
else
return local_result/(real_type)this->size();
}
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2011, 2012, 2013 by deal.II authors
+// Copyright (C) 2011 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__parallel_vector_h
#define __deal2__parallel_vector_h
const IndexSet &ghost_indices,
const MPI_Comm communicator);
+ /**
+ * Same constructor as above but without any ghost indices.
+ */
+ Vector (const IndexSet &local_range,
+ const MPI_Comm communicator);
+
/**
* Create the vector based on the parallel partitioning described in @p
* partitioner. The input argument is a shared pointer, which store the
const IndexSet &ghost_indices,
const MPI_Comm communicator);
+ /**
+ * Same as above, but without ghost entries.
+ */
+ void reinit (const IndexSet &local_range,
+ const MPI_Comm communicator);
+
/**
* Initialize the vector given to the parallel partitioning described in
* @p partitioner. The input argument is a shared pointer, which store
* not owned by the current processor but can be written into or read
* from locally (ghost elements).
*/
- const IndexSet& ghost_elements() const;
+ const IndexSet &ghost_elements() const;
/**
* Returns whether the given global index is a ghost index on the
*/
Number &operator [] (const size_type global_index);
+ /**
+ * A collective get operation: instead
+ * of getting individual elements of a
+ * vector, this function allows to get
+ * a whole set of elements at once. The
+ * indices of the elements to be read
+ * are stated in the first argument,
+ * the corresponding values are returned in the
+ * second.
+ */
+ template <typename OtherNumber>
+ void extract_subvector_to (const std::vector<size_type> &indices,
+ std::vector<OtherNumber> &values) const;
+
+ /**
+ * Just as the above, but with pointers.
+ * Useful in minimizing copying of data around.
+ */
+ template <typename ForwardIterator, typename OutputIterator>
+ void extract_subvector_to (ForwardIterator indices_begin,
+ const ForwardIterator indices_end,
+ OutputIterator values_begin) const;
+
/**
* Read access to the data field specified by @p local_index. Locally
* owned indices can be accessed with indices
* vector.
*/
const MPI_Comm &get_mpi_communicator () const;
-
+
/**
* Checks whether the given partitioner is compatible with the
* partitioner used for this vector. Two partitioners are compatible if
+ template <typename Number>
+ inline
+ Vector<Number>::Vector (const IndexSet &local_range,
+ const MPI_Comm communicator)
+ :
+ allocated_size (0),
+ val (0),
+ import_data (0),
+ vector_view (0, static_cast<Number *>(0))
+ {
+ IndexSet ghost_indices(local_range.size());
+ reinit (local_range, ghost_indices, communicator);
+ }
+
+
+
template <typename Number>
inline
Vector<Number>::Vector (const size_type size)
else if (partitioner.get() != c.partitioner.get())
{
size_type local_ranges_different_loc = (local_range() !=
- c.local_range());
+ c.local_range());
if ((partitioner->n_mpi_processes() > 1 &&
Utilities::MPI::max(local_ranges_different_loc,
partitioner->get_communicator()) != 0)
reinit (c, true);
}
vector_view = c.vector_view;
+ update_ghost_values();
return *this;
}
else if (partitioner.get() != c.partitioner.get())
{
size_type local_ranges_different_loc = (local_range() !=
- c.local_range());
+ c.local_range());
if ((partitioner->n_mpi_processes() > 1 &&
Utilities::MPI::max(local_ranges_different_loc,
partitioner->get_communicator()) != 0)
Vector<Number>::vectors_equal_local (const Vector<Number2> &v) const
{
return partitioner->local_size()>0 ?
- vector_view.template operator == <Number2>(v.vector_view)
- : true;
+ vector_view.template operator == <Number2>(v.vector_view)
+ : true;
}
return Utilities::MPI::sum (local_result *
(real_type)partitioner->local_size(),
partitioner->get_communicator())
- /(real_type)partitioner->size();
+ /(real_type)partitioner->size();
else
return local_result;
}
template <typename Number>
inline
std::pair<typename Vector<Number>::size_type,
- typename Vector<Number>::size_type>
- Vector<Number>::local_range () const
+ typename Vector<Number>::size_type>
+ Vector<Number>::local_range () const
{
return partitioner->local_range();
}
template <typename Number>
inline
- typename Vector<Number>::size_type
+ typename Vector<Number>::size_type
Vector<Number>::n_ghost_entries () const
{
return partitioner->n_ghost_indices();
template <typename Number>
inline
- const IndexSet&
+ const IndexSet &
Vector<Number>::ghost_elements() const
{
return partitioner->ghost_indices();
+ template <typename Number>
+ template <typename OtherNumber>
+ inline
+ void Vector<Number>::extract_subvector_to (const std::vector<size_type> &indices,
+ std::vector<OtherNumber> &values) const
+ {
+ for (size_type i = 0; i < indices.size(); ++i)
+ values[i] = operator()(indices[i]);
+ }
+
+
+
+ template <typename Number>
+ template <typename ForwardIterator, typename OutputIterator>
+ inline
+ void Vector<Number>::extract_subvector_to (ForwardIterator indices_begin,
+ const ForwardIterator indices_end,
+ OutputIterator values_begin) const
+ {
+ while (indices_begin != indices_end) {
+ *values_begin = operator()(*indices_begin);
+ indices_begin++; values_begin++;
+ }
+ }
+
+
+
template <typename Number>
inline
Number
template <typename Number>
inline
- const MPI_Comm&
+ const MPI_Comm &
Vector<Number>::get_mpi_communicator() const
{
return partitioner->get_communicator();
-//----------%-----------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2011 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__parallel_vector_templates_h
#define __deal2__parallel_vector_templates_h
const IndexSet &ghost_indices,
const MPI_Comm communicator)
{
- // set up parallel partitioner with index sets
- // and communicator
+ // set up parallel partitioner with index sets and communicator
+ std_cxx1x::shared_ptr<const Utilities::MPI::Partitioner> new_partitioner
+ (new Utilities::MPI::Partitioner (locally_owned_indices,
+ ghost_indices, communicator));
+ reinit (new_partitioner);
+ }
+
+
+
+ template <typename Number>
+ void
+ Vector<Number>::reinit (const IndexSet &locally_owned_indices,
+ const MPI_Comm communicator)
+ {
+ // set up parallel partitioner with index sets and communicator
+ IndexSet ghost_indices(locally_owned_indices.size());
std_cxx1x::shared_ptr<const Utilities::MPI::Partitioner> new_partitioner
(new Utilities::MPI::Partitioner (locally_owned_indices,
ghost_indices, communicator));
// nothing to do for insert (only need to zero ghost entries in
// compress_finish(). in debug mode we still want to check consistency
// of the inserted data, therefore the communication is still
- // initialized
+ // initialized. Having different code in debug and optimized mode is
+ // somewhat dangerous, but it really saves communication so it seems
+ // still worthwhile.
#ifndef DEBUG
if (operation == VectorOperation::insert)
return;
{
#ifdef DEAL_II_WITH_MPI
+ // in optimized mode, no communication was started, so leave the
+ // function directly (and only clear ghosts)
+#ifndef DEBUG
+ if (operation == VectorOperation::insert)
+ {
+ zero_out_ghosts();
+ return;
+ }
+#endif
+
const Utilities::MPI::Partitioner &part = *partitioner;
// nothing to do when we neither have import
j++, read_position++)
Assert(*read_position == 0. ||
std::abs(local_element(j) - *read_position) <
- std::abs(local_element(j)) * 100. *
+ std::abs(local_element(j)) * 1000. *
std::numeric_limits<Number>::epsilon(),
ExcMessage("Inserted elements do not match."));
AssertDimension(read_position-import_data,part.n_import_indices());
#endif
out << "Process #" << partitioner->this_mpi_process() << std::endl
- << "Local range: [" << partitioner->local_range().first << "/"
- << partitioner->local_range().second << "], global size: "
+ << "Local range: [" << partitioner->local_range().first << ", "
+ << partitioner->local_range().second << "), global size: "
<< partitioner->size() << std::endl
<< "Vector data:" << std::endl;
if (across)
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2007, 2010, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__petsc_block_sparse_matrix_h
#define __deal2__petsc_block_sparse_matrix_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2007, 2010, 2012, 2013 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__petsc_block_vector_h
#define __deal2__petsc_block_vector_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2007, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__petsc_full_matrix_h
#define __deal2__petsc_full_matrix_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__petsc_matrix_base_h
#define __deal2__petsc_matrix_base_h
class Accessor
{
public:
- /**
- * Declare type for container size.
- */
- typedef types::global_dof_index size_type;
-
+ /**
+ * Declare type for container size.
+ */
+ typedef types::global_dof_index size_type;
+
/**
* Constructor. Since we use
* accessors only for read
const size_type row,
const size_type index);
+ /**
+ * Copy constructor.
+ */
+ Accessor (const Accessor &a);
+
/**
* Row number of the element
* represented by this
* Declare type for container size.
*/
typedef types::global_dof_index size_type;
-
+
/**
* Constructor. Create an iterator
* into the matrix @p matrix for the
* class.
*/
typedef MatrixIterators::const_iterator const_iterator;
-
- /**
- * Declare type for container size.
- */
- typedef types::global_dof_index size_type;
+
+ /**
+ * Declare type for container size.
+ */
+ typedef types::global_dof_index size_type;
/**
* Declare a typedef in analogy to all
* Add the matrix @p other scaled by the factor @p factor to the current
* matrix.
*/
- MatrixBase & add (const MatrixBase &other,
- const PetscScalar factor);
+ MatrixBase &add (const MatrixBase &other,
+ const PetscScalar factor);
/**
* Matrix-vector multiplication:
*/
void write_ascii (const PetscViewerFormat format = PETSC_VIEWER_DEFAULT);
+ /**
+ * print command, similar to write_ascii, but the same format as
+ * produced by Trilinos
+ */
+ void print (std::ostream &out,
+ const bool alternative_output = false) const;
+
/**
* Returns the number bytes consumed
* by this matrix on this CPU.
private:
+
+ /**
+ * purposefully not implemented
+ */
+ MatrixBase(const MatrixBase &);
+ /**
+ * purposefully not implemented
+ */
+ MatrixBase &operator=(const MatrixBase &);
+
/**
* An internal array of integer
* values that is used to store the
inline
- const_iterator::Accessor::size_type
+ const_iterator::Accessor::
+ Accessor (const Accessor &a)
+ :
+ matrix(a.matrix),
+ a_row(a.a_row),
+ a_index(a.a_index),
+ colnum_cache (a.colnum_cache),
+ value_cache (a.value_cache)
+ {}
+
+
+ inline
+ const_iterator::Accessor::size_type
const_iterator::Accessor::row() const
{
Assert (a_row < matrix->m(), ExcBeyondEndOfMatrix());
inline
- const_iterator::Accessor::size_type
+ const_iterator::Accessor::size_type
const_iterator::Accessor::column() const
{
Assert (a_row < matrix->m(), ExcBeyondEndOfMatrix());
inline
- const_iterator::Accessor::size_type
+ const_iterator::Accessor::size_type
const_iterator::Accessor::index() const
{
Assert (a_row < matrix->m(), ExcBeyondEndOfMatrix());
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2012 by the deal.II authors
+// Copyright (C) 2012 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#ifndef __deal2__petsc_matrix_free_h
#define __deal2__petsc_matrix_free_h
* Implementation of a parallel matrix class based on PETSc <tt>MatShell</tt> matrix-type.
* This base class implements only the interface to the PETSc matrix object,
* while all the functionality is contained in the matrix-vector
- * multiplication which must be reimplmented in derived classes.
+ * multiplication which must be reimplemented in derived classes.
*
* This interface is an addition to the dealii::MatrixFree class to realize
* user-defined matrix-classes together with PETSc solvers and functionalities.
* See also the documentation of dealii::MatrixFree class and step-37 and step-48.
*
* Similar to other matrix classes in namespaces PETScWrappers and PETScWrappers::MPI,
- * the MatrxiFree class provides the usual matrix-vector multiplication
+ * the MatrixFree class provides the usual matrix-vector multiplication
* <tt>vmult(VectorBase &dst, const VectorBase &src)</tt>
* which is pure virtual and must be reimplemented in derived classes.
* Besides the usual interface, this class has a matrix-vector multiplication
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2007, 2010, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__petsc_parallel_block_sparse_matrix_h
#define __deal2__petsc_parallel_block_sparse_matrix_h
# include <deal.II/base/table.h>
# include <deal.II/lac/block_matrix_base.h>
+# include <deal.II/lac/block_sparsity_pattern.h>
# include <deal.II/lac/petsc_parallel_sparse_matrix.h>
# include <deal.II/lac/petsc_parallel_block_vector.h>
# include <deal.II/lac/exceptions.h>
void reinit (const size_type n_block_rows,
const size_type n_block_columns);
+
+ /**
+ * Efficiently reinit the block matrix for a parallel computation.
+ * Only the BlockSparsityPattern of the Simple type can efficiently
+ * store large sparsity patterns in parallel, so this is the only
+ * supported argument.
+ * The IndexSets describe the locally owned range of DoFs for each block.
+ * Note that each IndexSet needs to be contiguous. For a symmetric structure
+ * hand in the same vector for the first two arguments.
+ */
+ void reinit(const std::vector<IndexSet> &rows,
+ const std::vector<IndexSet> &cols,
+ const BlockCompressedSimpleSparsityPattern &bcsp,
+ const MPI_Comm &com);
+
+
+ /**
+ * Same as above but for a symmetric structure only.
+ */
+ void reinit(const std::vector<IndexSet> &sizes,
+ const BlockCompressedSimpleSparsityPattern &bcsp,
+ const MPI_Comm &com);
+
+
+
/**
* Matrix-vector multiplication:
* let $dst = M*src$ with $M$
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2012, 2013 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__petsc_parallel_block_vector_h
#define __deal2__petsc_parallel_block_vector_h
explicit BlockVector (const std::vector<IndexSet> ¶llel_partitioning,
const MPI_Comm &communicator = MPI_COMM_WORLD);
+ /**
+ * Same as above, but include ghost elements
+ */
+ BlockVector (const std::vector<IndexSet> ¶llel_partitioning,
+ const std::vector<IndexSet> &ghost_indices,
+ const MPI_Comm &communicator);
+
+
+
/**
* Destructor. Clears memory
*/
void reinit (const std::vector<IndexSet> ¶llel_partitioning,
const MPI_Comm &communicator);
+ /**
+ * Same as above but include ghost entries.
+ */
+ void reinit (const std::vector<IndexSet> ¶llel_partitioning,
+ const std::vector<IndexSet> &ghost_entries,
+ const MPI_Comm &communicator);
+
/**
* Change the number of blocks to
* <tt>num_blocks</tt>. The individual
*/
void reinit (const unsigned int num_blocks);
+ /**
+ * Returns if this vector is a ghosted vector (and thus read-only).
+ */
+ bool has_ghost_elements() const;
+
/**
* Return a reference to the MPI
* communicator object in use with
inline
BlockVector::BlockVector (const std::vector<IndexSet> ¶llel_partitioning,
- const MPI_Comm &communicator)
+ const MPI_Comm &communicator)
{
reinit(parallel_partitioning, communicator);
}
+ inline
+ BlockVector::BlockVector (const std::vector<IndexSet> ¶llel_partitioning,
+ const std::vector<IndexSet> &ghost_indices,
+ const MPI_Comm &communicator)
+ {
+ reinit(parallel_partitioning, ghost_indices, communicator);
+ }
inline
BlockVector &
return *this;
}
-
-
inline
BlockVector &
BlockVector::operator = (const BlockVector &v)
{
- BaseClass::operator = (v);
- return *this;
- }
+ // we only allow assignment to vectors with the same number of blocks
+ // or to an empty BlockVector
+ Assert (n_blocks() == 0 || n_blocks() == v.n_blocks(),
+ ExcDimensionMismatch(n_blocks(), v.n_blocks()));
+
+ if (this->n_blocks() != v.n_blocks())
+ reinit(v.n_blocks());
+ for (size_type i=0; i<this->n_blocks(); ++i)
+ this->components[i] = v.block(i);
+ collect_sizes();
+
+ return *this;
+ }
inline
BlockVector::~BlockVector ()
inline
void
BlockVector::reinit (const std::vector<IndexSet> ¶llel_partitioning,
- const MPI_Comm &communicator)
+ const MPI_Comm &communicator)
{
std::vector<size_type> sizes(parallel_partitioning.size());
for (unsigned int i=0; i<parallel_partitioning.size(); ++i)
this->components.resize(this->n_blocks());
for (unsigned int i=0; i<this->n_blocks(); ++i)
- block(i).reinit(communicator, parallel_partitioning[i]);
+ block(i).reinit(parallel_partitioning[i], communicator);
}
+ inline
+ void
+ BlockVector::reinit (const std::vector<IndexSet> ¶llel_partitioning,
+ const std::vector<IndexSet> &ghost_entries,
+ const MPI_Comm &communicator)
+ {
+ std::vector<types::global_dof_index> sizes(parallel_partitioning.size());
+ for (unsigned int i=0; i<parallel_partitioning.size(); ++i)
+ sizes[i] = parallel_partitioning[i].size();
+
+ this->block_indices.reinit(sizes);
+ if (this->components.size() != this->n_blocks())
+ this->components.resize(this->n_blocks());
+
+ for (unsigned int i=0; i<this->n_blocks(); ++i)
+ block(i).reinit(parallel_partitioning[i], ghost_entries[i], communicator);
+ }
+
+
inline
const MPI_Comm &
return block(0).get_mpi_communicator();
}
+ inline
+ bool
+ BlockVector::has_ghost_elements() const
+ {
+ bool ghosted=block(0).has_ghost_elements();
+#ifdef DEBUG
+ for (unsigned int i=0; i<this->n_blocks(); ++i)
+ Assert(block(i).has_ghost_elements()==ghosted, ExcInternalError());
+#endif
+ return ghosted;
+ }
inline
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2007, 2009, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__petsc_parallel_sparse_matrix_h
#define __deal2__petsc_parallel_sparse_matrix_h
*/
SparseMatrix ();
+ /**
+ * Destructor to free the PETSc object.
+ */
+ ~SparseMatrix ();
+
/**
* Create a sparse matrix of
* dimensions @p m times @p n, with
*/
SparseMatrix &operator = (const value_type d);
+
+ /**
+ * Make a copy of the PETSc matrix @p other. It is assumed that both matrices have
+ * the same SparsityPattern.
+ */
+ void copy_from(const SparseMatrix &other);
+
/**
* Throw away the present matrix and
* generate one that has the same
const unsigned int this_process,
const bool preset_nonzero_locations = true);
+ /**
+ * Create a matrix where the size() of the IndexSets determine the global
+ * number of rows and columns and the entries of the IndexSet give
+ * the rows and columns for the calling processor.
+ * Note that only contiguous IndexSets are supported.
+ */
+ template <typename SparsityType>
+ void reinit (const IndexSet &local_rows,
+ const IndexSet &local_columns,
+ const SparsityType &sparsity_pattern,
+ const MPI_Comm &communicator);
+
/**
* Return a reference to the MPI
* communicator object in use with
const unsigned int this_process,
const bool preset_nonzero_locations);
+ /**
+ * Same as previous functions.
+ */
+ template <typename SparsityType>
+ void do_reinit (const IndexSet &local_rows,
+ const IndexSet &local_columns,
+ const SparsityType &sparsity_pattern);
+
/**
* To allow calling protected
* prepare_add() and
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2012, 2013 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__petsc_parallel_vector_h
#define __deal2__petsc_parallel_vector_h
*/
static const bool supports_distributed_data = true;
- /**
- * Default constructor. Initialize the
- * vector as empty.
- */
+ /**
+ * Default constructor. Initialize the
+ * vector as empty.
+ */
Vector ();
/**
*/
explicit Vector (const MPI_Comm &communicator,
const IndexSet &local,
- const IndexSet &ghost);
+ const IndexSet &ghost) DEAL_II_DEPRECATED;
+
+ /**
+ * Constructs a new parallel ghosted PETSc
+ * vector from an Indexset. Note that
+ * @p local must be contiguous and
+ * the global size of the vector is
+ * determined by local.size(). The
+ * global indices in @p ghost are
+ * supplied as ghost indices that can
+ * also be read locally.
+ *
+ * Note that the @p ghost IndexSet
+ * may be empty and that any indices
+ * already contained in @p local are
+ * ignored during construction. That
+ * way, the ghost parameter can equal
+ * the set of locally relevant
+ * degrees of freedom, see step-32.
+ *
+ * @note This operation always creates a ghosted
+ * vector.
+ */
+ Vector (const IndexSet &local,
+ const IndexSet &ghost,
+ const MPI_Comm &communicator);
/**
* Constructs a new parallel PETSc
* vector from an Indexset. This creates a non
* ghosted vector.
*/
- explicit Vector (const MPI_Comm &communicator,
- const IndexSet &local);
+ explicit Vector (const MPI_Comm &communicator,
+ const IndexSet &local) DEAL_II_DEPRECATED;
+ /**
+ * Constructs a new parallel PETSc
+ * vector from an Indexset. This creates a non
+ * ghosted vector.
+ */
+ explicit Vector (const IndexSet &local,
+ const MPI_Comm &communicator);
/**
* Copy the given vector. Resize the
*/
void reinit (const MPI_Comm &communicator,
const IndexSet &local,
- const IndexSet &ghost);
+ const IndexSet &ghost) DEAL_II_DEPRECATED;
+ /**
+ * Reinit as a vector without ghost elements. See
+ * constructor with same signature
+ * for more detais.
+ */
+ void reinit (const IndexSet &local,
+ const IndexSet &ghost,
+ const MPI_Comm &communicator);
/**
* Reinit as a vector without ghost elements. See
* for more detais.
*/
void reinit (const MPI_Comm &communicator,
- const IndexSet &local);
+ const IndexSet &local) DEAL_II_DEPRECATED;
+ /**
+ * Reinit as a vector without ghost elements. See
+ * constructor with same signature
+ * for more detais.
+ */
+ void reinit (const IndexSet &local,
+ const MPI_Comm &communicator);
/**
* Return a reference to the MPI
Vector &
Vector::operator = (const Vector &v)
{
+ if (v.size()==0)
+ {
+ // this happens if v has not been initialized to something useful:
+ // Vector x,v;x=v;
+ // we skip the code below and create a simple serial vector of
+ // length 0
+
+ int ierr;
+#if DEAL_II_PETSC_VERSION_LT(3,2,0)
+ ierr = VecDestroy (vector);
+#else
+ ierr = VecDestroy (&vector);
+#endif
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+ const int n = 0;
+ ierr = VecCreateSeq (PETSC_COMM_SELF, n, &vector);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+ ghosted = false;
+ ghost_indices.clear();
+ return *this;
+ }
+
// if the vectors have different sizes,
// then first resize the present one
if (size() != v.size())
- reinit (v.communicator, v.size(), v.local_size(), true);
+ {
+ if (v.has_ghost_elements())
+ reinit( v.locally_owned_elements(), v.ghost_indices, v.communicator);
+ else
+ reinit (v.communicator, v.size(), v.local_size(), true);
+ }
const int ierr = VecCopy (v.vector, vector);
AssertThrow (ierr == 0, ExcPETScError(ierr));
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2007, 2010, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__petsc_precondition_h
#define __deal2__petsc_precondition_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__petsc_solver_h
#define __deal2__petsc_solver_h
* convergence has been reached.
*/
static
- PetscErrorCode convergence_test (KSP ksp,
- const PetscInt iteration,
- const PetscReal residual_norm,
- KSPConvergedReason *reason,
- void *solver_control);
+ PetscErrorCode convergence_test (KSP ksp,
+ const PetscInt iteration,
+ const PetscReal residual_norm,
+ KSPConvergedReason *reason,
+ void *solver_control);
/**
* A structure that contains the PETSc
* to see if convergence has been reached.
*/
static
- PetscErrorCode convergence_test (KSP ksp,
- const PetscInt iteration,
- const PetscReal residual_norm,
- KSPConvergedReason *reason,
- void *solver_control);
+ PetscErrorCode convergence_test (KSP ksp,
+ const PetscInt iteration,
+ const PetscReal residual_norm,
+ KSPConvergedReason *reason,
+ void *solver_control);
/**
* A structure that contains the
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2007, 2009, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__petsc_sparse_matrix_h
#define __deal2__petsc_sparse_matrix_h
* the start.
*/
template <typename SparsityType>
- SparseMatrix (const SparsityType &sparsity_pattern,
- const bool preset_nonzero_locations = true);
+ explicit SparseMatrix (const SparsityType &sparsity_pattern,
+ const bool preset_nonzero_locations = true);
/**
* This operator assigns a scalar to
* the constructor of this class with
* the same argument list as the
* present function.
- */
+ */
void reinit (const size_type m,
const size_type n,
const std::vector<size_type> &row_lengths,
private:
+ /**
+ * Purposefully not implemented
+ */
+ SparseMatrix(const SparseMatrix &);
+ /**
+ * Purposefully not implemented
+ */
+ SparseMatrix &operator= (const SparseMatrix &);
+
/**
* Do the actual work for the
* respective reinit() function and the
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2007, 2009, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__petsc_vector_h
#define __deal2__petsc_vector_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__petsc_vector_base_h
#define __deal2__petsc_vector_base_h
*/
typedef types::global_dof_index size_type;
- private:
+ private:
/**
* Constructor. It is made private so
* as to only allow the actual vector
const size_type index);
- public:
-
+ public:
+
/**
* This looks like a copy operator,
* but does something different than
void set (const std::vector<size_type> &indices,
const std::vector<PetscScalar> &values);
+ /**
+ * A collective get operation: instead
+ * of getting individual elements of a
+ * vector, this function allows to get
+ * a whole set of elements at once. The
+ * indices of the elements to be read
+ * are stated in the first argument,
+ * the corresponding values are returned in the
+ * second.
+ */
+ void extract_subvector_to (const std::vector<size_type> &indices,
+ std::vector<PetscScalar> &values) const;
+
+ /**
+ * Just as the above, but with pointers.
+ * Useful in minimizing copying of data around.
+ */
+ template <typename ForwardIterator, typename OutputIterator>
+ void extract_subvector_to (const ForwardIterator indices_begin,
+ const ForwardIterator indices_end,
+ OutputIterator values_begin) const;
+
/**
* A collective add operation: This
* function adds a whole set of values
return comm;
}
+ inline
+ void VectorBase::extract_subvector_to (const std::vector<size_type> &indices,
+ std::vector<PetscScalar> &values) const
+ {
+ extract_subvector_to(&(indices[0]), &(indices[0]) + indices.size(), &(values[0]));
+ }
+
+ template <typename ForwardIterator, typename OutputIterator>
+ inline
+ void VectorBase::extract_subvector_to (const ForwardIterator indices_begin,
+ const ForwardIterator indices_end,
+ OutputIterator values_begin) const
+ {
+ const PetscInt n_idx = static_cast<PetscInt>(indices_end - indices_begin);
+ if (n_idx == 0)
+ return;
+
+ // if we are dealing
+ // with a parallel vector
+ if (ghosted )
+ {
+
+ int ierr;
+
+ // there is the possibility
+ // that the vector has
+ // ghost elements. in that
+ // case, we first need to
+ // figure out which
+ // elements we own locally,
+ // then get a pointer to
+ // the elements that are
+ // stored here (both the
+ // ones we own as well as
+ // the ghost elements). in
+ // this array, the locally
+ // owned elements come
+ // first followed by the
+ // ghost elements whose
+ // position we can get from
+ // an index set
+ PetscInt begin, end, i;
+ ierr = VecGetOwnershipRange (vector, &begin, &end);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+ Vec locally_stored_elements = PETSC_NULL;
+ ierr = VecGhostGetLocalForm(vector, &locally_stored_elements);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+ PetscInt lsize;
+ ierr = VecGetSize(locally_stored_elements, &lsize);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+ PetscScalar *ptr;
+ ierr = VecGetArray(locally_stored_elements, &ptr);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+ for (i = 0; i < n_idx; i++) {
+ const unsigned int index = *(indices_begin+i);
+ if ( index>=static_cast<unsigned int>(begin)
+ && index<static_cast<unsigned int>(end) )
+ {
+ //local entry
+ *(values_begin+i) = *(ptr+index-begin);
+ }
+ else
+ {
+ //ghost entry
+ const unsigned int ghostidx
+ = ghost_indices.index_within_set(index);
+
+ Assert(ghostidx+end-begin<(unsigned int)lsize, ExcInternalError());
+ *(values_begin+i) = *(ptr+ghostidx+end-begin);
+ }
+ }
+
+ ierr = VecRestoreArray(locally_stored_elements, &ptr);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+ ierr = VecGhostRestoreLocalForm(vector, &locally_stored_elements);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+ }
+ // if the vector is local or the
+ // caller, then simply access the
+ // element we are interested in
+ else
+ {
+ int ierr;
+
+ PetscInt begin, end;
+ ierr = VecGetOwnershipRange (vector, &begin, &end);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+ PetscScalar *ptr;
+ ierr = VecGetArray(vector, &ptr);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+ for (PetscInt i = 0; i < n_idx; i++) {
+ const unsigned int index = *(indices_begin+i);
+
+ Assert(index>=static_cast<unsigned int>(begin)
+ && index<static_cast<unsigned int>(end), ExcInternalError());
+
+ *(values_begin+i) = *(ptr+index-begin);
+ }
+
+ ierr = VecRestoreArray(vector, &ptr);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+ }
+ }
+
#endif // DOXYGEN
}
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2002 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__pointer_matrix_h
#define __deal2__pointer_matrix_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__precondition_h
#define __deal2__precondition_h
// only. note: the first entry in each line denotes the diagonal
// element, which we need not check.
typename SparseMatrix<typename MATRIX::value_type>::const_iterator
- it = mat->begin(row)+1;
+ it = mat->begin(row)+1;
for ( ; it < mat->end(row); ++it)
if (it->column() > row)
break;
// attach stream to SolverCG, run it with log report for eigenvalues
std::ostream *old_stream = deallog.has_file() ? &deallog.get_file_stream() :
- static_cast<std::ostream *>(0);
+ static_cast<std::ostream *>(0);
if (old_stream)
deallog.detach();
cg_data.compute_eigenvalues = true;
SolverCG<VECTOR> solver (control, memory, cg_data);
internal::PreconditionChebyshev::DiagonalPreconditioner<VECTOR>
- preconditioner(data.matrix_diagonal_inverse);
+ preconditioner(data.matrix_diagonal_inverse);
try
{
solver.solve(matrix, *dummy, *rhs, preconditioner);
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__precondition_block_h
#define __deal2__precondition_block_h
template<class MATRIX, typename inverse_type>
inline
-typename PreconditionBlockJacobi<MATRIX, inverse_type>::size_type
+typename PreconditionBlockJacobi<MATRIX, inverse_type>::size_type
PreconditionBlockJacobi<MATRIX, inverse_type>::const_iterator::Accessor::row() const
{
Assert (a_block < matrix->size(),
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__precondition_block_templates_h
#define __deal2__precondition_block_templates_h
{
const size_type column = entry->column();
const size_type inverse_permuted_column = permuted
- ? this->inverse_permutation[column]
- : column;
+ ? this->inverse_permutation[column]
+ : column;
if (inverse_permuted_column >= block_end)
b_cell_row -= entry->value() * dst(column);
else if (!this->inverses_ready() && column >= block_start)
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__precondition_block_base_h
#define __deal2__precondition_block_base_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__precondition_selector_h
#define __deal2__precondition_selector_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__relaxation_block_h
#define __deal2__relaxation_block_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__relaxation_block_templates_h
#define __deal2__relaxation_block_templates_h
// Apply inverse diagonal
this->inverse_vmult(block, x_cell, b_cell);
#ifdef DEBUG
- for (unsigned int i=0;i<x_cell.size();++i)
- {
- Assert(numbers::is_finite(x_cell(i)), ExcNumberNotFinite());
- }
+ for (unsigned int i=0; i<x_cell.size(); ++i)
+ {
+ Assert(numbers::is_finite(x_cell(i)), ExcNumberNotFinite());
+ }
#endif
// Store in result vector
row=additional_data->block_list.begin(block);
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__schur_matrix_h
#define __deal2__schur_matrix_h
const MDt &Dt,
const MC &C,
VectorMemory<BlockVector<double> > &mem,
- const std::vector<types::global_dof_index> &signature)
+ const std::vector<unsigned int> &signature)
: Ainv(&Ainv), B(&B), Dt(&Dt), C(&C),
mem(mem),
signature(signature),
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2012 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__shifted_matrix_h
#define __deal2__shifted_matrix_h
-//---------------------------------------------------------------------------
-// $Id$
-// Author: Toby D. Young, Polish Academy of Sciences, 2008-2013
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009-2013 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__slepc_solver_h
#define __deal2__slepc_solver_h
class SolverBase
{
public:
- /**
- * Declare type for container size.
- */
- typedef types::global_dof_index size_type;
-
/**
* Constructor. Takes the MPI communicator over which parallel
* computations are to happen.
solve (const PETScWrappers::MatrixBase &A,
std::vector<double> &eigenvalues,
std::vector<OutputVector> &eigenvectors,
- const size_type n_eigenpairs = 1);
+ const unsigned int n_eigenpairs = 1);
/**
* Same as above, but here a composite method for solving the
const PETScWrappers::MatrixBase &B,
std::vector<double> &eigenvalues,
std::vector<OutputVector> &eigenvectors,
- const size_type n_eigenpairs = 1);
+ const unsigned int n_eigenpairs = 1);
/**
* Same as above, but here a composite method for solving the
* deal.II's own SolverControl objects to see if convergence has
* been reached.
*/
- void
+ void
get_solver_state (const SolverControl::State state);
/**
EPS *get_eps ();
/**
- * Solve the linear system for </code>n_eigenpairs</code>
+ * Solve the linear system for <code>n_eigenpairs</code>
* eigenstates. Parameter <code>n_converged</code> contains the
- * actual number of eigenstates that have . converged; this can
+ * actual number of eigenstates that have converged; this can
* be both fewer or more than n_eigenpairs, depending on the
* SLEPc eigensolver used.
*/
void
- solve (const unsigned int n_eigenpairs, unsigned int *n_converged);
+ solve (const unsigned int n_eigenpairs,
+ unsigned int *n_converged);
/**
* Access the real parts of solutions for a solved eigenvector
* change that.
*/
SolverLAPACK (SolverControl &cn,
- const MPI_Comm &mpi_communicator = PETSC_COMM_SELF,
- const AdditionalData &data = AdditionalData());
+ const MPI_Comm &mpi_communicator = PETSC_COMM_SELF,
+ const AdditionalData &data = AdditionalData());
protected:
// todo: The logic of these functions can be simplified without breaking backward compatibility...
template <typename OutputVector>
- void
- SolverBase::solve (const PETScWrappers::MatrixBase &A,
- std::vector<double> &eigenvalues,
- std::vector<OutputVector> &eigenvectors,
- const size_type n_eigenpairs)
- {
- // Panic if the number of eigenpairs wanted is out of bounds.
- AssertThrow ((n_eigenpairs > 0) && (n_eigenpairs <= A.m ()),
- ExcSLEPcWrappersUsageError());
-
- // Set the matrices of the problem
- set_matrices (A);
-
- // and solve
- size_type n_converged = 0;
- solve (n_eigenpairs, &n_converged);
-
- if (n_converged > n_eigenpairs)
- n_converged = n_eigenpairs;
- AssertThrow (n_converged == n_eigenpairs,
- ExcSLEPcEigenvectorConvergenceMismatchError(n_converged, n_eigenpairs));
-
- AssertThrow (eigenvectors.size() != 0, ExcSLEPcWrappersUsageError());
- eigenvectors.resize (n_converged, eigenvectors.front());
- eigenvalues.resize (n_converged);
-
- for (size_type index=0; index<n_converged; ++index)
- get_eigenpair (index, eigenvalues[index], eigenvectors[index]);
- }
-
+ void
+ SolverBase::solve (const PETScWrappers::MatrixBase &A,
+ std::vector<double> &eigenvalues,
+ std::vector<OutputVector> &eigenvectors,
+ const unsigned int n_eigenpairs)
+ {
+ // Panic if the number of eigenpairs wanted is out of bounds.
+ AssertThrow ((n_eigenpairs > 0) && (n_eigenpairs <= A.m ()),
+ ExcSLEPcWrappersUsageError());
+
+ // Set the matrices of the problem
+ set_matrices (A);
+
+ // and solve
+ unsigned int n_converged = 0;
+ solve (n_eigenpairs, &n_converged);
+
+ if (n_converged > n_eigenpairs)
+ n_converged = n_eigenpairs;
+ AssertThrow (n_converged == n_eigenpairs,
+ ExcSLEPcEigenvectorConvergenceMismatchError(n_converged, n_eigenpairs));
+
+ AssertThrow (eigenvectors.size() != 0, ExcSLEPcWrappersUsageError());
+ eigenvectors.resize (n_converged, eigenvectors.front());
+ eigenvalues.resize (n_converged);
+
+ for (unsigned int index=0; index<n_converged; ++index)
+ get_eigenpair (index, eigenvalues[index], eigenvectors[index]);
+ }
+
template <typename OutputVector>
- void
- SolverBase::solve (const PETScWrappers::MatrixBase &A,
- const PETScWrappers::MatrixBase &B,
- std::vector<double> &eigenvalues,
- std::vector<OutputVector> &eigenvectors,
- const size_type n_eigenpairs)
- {
- // Guard against incompatible matrix sizes:
- AssertThrow (A.m() == B.m (), ExcDimensionMismatch(A.m(), B.m()));
- AssertThrow (A.n() == B.n (), ExcDimensionMismatch(A.n(), B.n()));
-
- // Panic if the number of eigenpairs wanted is out of bounds.
- AssertThrow ((n_eigenpairs>0) && (n_eigenpairs<=A.m ()),
- ExcSLEPcWrappersUsageError());
-
- // Set the matrices of the problem
- set_matrices (A, B);
-
- // and solve
- size_type n_converged = 0;
- solve (n_eigenpairs, &n_converged);
-
- if (n_converged>=n_eigenpairs)
- n_converged = n_eigenpairs;
-
- AssertThrow (n_converged==n_eigenpairs,
- ExcSLEPcEigenvectorConvergenceMismatchError(n_converged, n_eigenpairs));
- AssertThrow (eigenvectors.size() != 0, ExcSLEPcWrappersUsageError());
-
- eigenvectors.resize (n_converged, eigenvectors.front());
- eigenvalues.resize (n_converged);
-
- for (size_type index=0; index<n_converged; ++index)
- get_eigenpair (index, eigenvalues[index], eigenvectors[index]);
- }
+ void
+ SolverBase::solve (const PETScWrappers::MatrixBase &A,
+ const PETScWrappers::MatrixBase &B,
+ std::vector<double> &eigenvalues,
+ std::vector<OutputVector> &eigenvectors,
+ const unsigned int n_eigenpairs)
+ {
+ // Guard against incompatible matrix sizes:
+ AssertThrow (A.m() == B.m (), ExcDimensionMismatch(A.m(), B.m()));
+ AssertThrow (A.n() == B.n (), ExcDimensionMismatch(A.n(), B.n()));
+
+ // Panic if the number of eigenpairs wanted is out of bounds.
+ AssertThrow ((n_eigenpairs>0) && (n_eigenpairs<=A.m ()),
+ ExcSLEPcWrappersUsageError());
+
+ // Set the matrices of the problem
+ set_matrices (A, B);
+
+ // and solve
+ unsigned int n_converged = 0;
+ solve (n_eigenpairs, &n_converged);
+
+ if (n_converged>=n_eigenpairs)
+ n_converged = n_eigenpairs;
+
+ AssertThrow (n_converged==n_eigenpairs,
+ ExcSLEPcEigenvectorConvergenceMismatchError(n_converged, n_eigenpairs));
+ AssertThrow (eigenvectors.size() != 0, ExcSLEPcWrappersUsageError());
+
+ eigenvectors.resize (n_converged, eigenvectors.front());
+ eigenvalues.resize (n_converged);
+
+ for (unsigned int index=0; index<n_converged; ++index)
+ get_eigenpair (index, eigenvalues[index], eigenvectors[index]);
+ }
template <typename OutputVector>
- void
- SolverBase::solve (const PETScWrappers::MatrixBase &A,
- const PETScWrappers::MatrixBase &B,
- std::vector<double> &real_eigenvalues,
- std::vector<double> &imag_eigenvalues,
- std::vector<OutputVector> &real_eigenvectors,
- std::vector<OutputVector> &imag_eigenvectors,
- const size_type n_eigenpairs)
- {
- // Guard against incompatible matrix sizes:
- AssertThrow (A.m() == B.m (), ExcDimensionMismatch(A.m(), B.m()));
- AssertThrow (A.n() == B.n (), ExcDimensionMismatch(A.n(), B.n()));
-
- // and incompatible eigenvalue/eigenvector sizes
- AssertThrow (real_eigenvalues.size() == imag_eigenvalues.size(),
- ExcDimensionMismatch(real_eigenvalues.size(), imag_eigenvalues.size()));
- AssertThrow (real_eigenvectors.size() == imag_eigenvectors.n (),
- ExcDimensionMismatch(real_eigenvectors.size(), imag_eigenvectors.size()));
-
- // Panic if the number of eigenpairs wanted is out of bounds.
- AssertThrow ((n_eigenpairs>0) && (n_eigenpairs<=A.m ()),
- ExcSLEPcWrappersUsageError());
-
- // Set the matrices of the problem
- set_matrices (A, B);
-
- // and solve
- size_type n_converged = 0;
- solve (n_eigenpairs, &n_converged);
-
- if (n_converged>=n_eigenpairs)
- n_converged = n_eigenpairs;
-
- AssertThrow (n_converged==n_eigenpairs,
- ExcSLEPcEigenvectorConvergenceMismatchError(n_converged, n_eigenpairs));
- AssertThrow ((real_eigenvectors.size()!=0) && (imag_eigenvectors.size()!=0),
- ExcSLEPcWrappersUsageError());
-
- real_eigenvectors.resize (n_converged, real_eigenvectors.front());
- imag_eigenvectors.resize (n_converged, imag_eigenvectors.front());
- real_eigenvalues.resize (n_converged);
- imag_eigenvalues.resize (n_converged);
-
- for (size_type index=0; index<n_converged; ++index)
- get_eigenpair (index,
- real_eigenvalues[index], imag_eigenvalues[index],
- real_eigenvectors[index], imag_eigenvectors[index]);
- }
+ void
+ SolverBase::solve (const PETScWrappers::MatrixBase &A,
+ const PETScWrappers::MatrixBase &B,
+ std::vector<double> &real_eigenvalues,
+ std::vector<double> &imag_eigenvalues,
+ std::vector<OutputVector> &real_eigenvectors,
+ std::vector<OutputVector> &imag_eigenvectors,
+ const unsigned int n_eigenpairs)
+ {
+ // Guard against incompatible matrix sizes:
+ AssertThrow (A.m() == B.m (), ExcDimensionMismatch(A.m(), B.m()));
+ AssertThrow (A.n() == B.n (), ExcDimensionMismatch(A.n(), B.n()));
+
+ // and incompatible eigenvalue/eigenvector sizes
+ AssertThrow (real_eigenvalues.size() == imag_eigenvalues.size(),
+ ExcDimensionMismatch(real_eigenvalues.size(), imag_eigenvalues.size()));
+ AssertThrow (real_eigenvectors.size() == imag_eigenvectors.n (),
+ ExcDimensionMismatch(real_eigenvectors.size(), imag_eigenvectors.size()));
+
+ // Panic if the number of eigenpairs wanted is out of bounds.
+ AssertThrow ((n_eigenpairs>0) && (n_eigenpairs<=A.m ()),
+ ExcSLEPcWrappersUsageError());
+
+ // Set the matrices of the problem
+ set_matrices (A, B);
+
+ // and solve
+ unsigned int n_converged = 0;
+ solve (n_eigenpairs, &n_converged);
+
+ if (n_converged>=n_eigenpairs)
+ n_converged = n_eigenpairs;
+
+ AssertThrow (n_converged==n_eigenpairs,
+ ExcSLEPcEigenvectorConvergenceMismatchError(n_converged, n_eigenpairs));
+ AssertThrow ((real_eigenvectors.size()!=0) && (imag_eigenvectors.size()!=0),
+ ExcSLEPcWrappersUsageError());
+
+ real_eigenvectors.resize (n_converged, real_eigenvectors.front());
+ imag_eigenvectors.resize (n_converged, imag_eigenvectors.front());
+ real_eigenvalues.resize (n_converged);
+ imag_eigenvalues.resize (n_converged);
+
+ for (unsigned int index=0; index<n_converged; ++index)
+ get_eigenpair (index,
+ real_eigenvalues[index], imag_eigenvalues[index],
+ real_eigenvectors[index], imag_eigenvectors[index]);
+ }
}
-//---------------------------------------------------------------------------
-// $Id$
-// Author: Toby D. Young, Polish Academy of Sciences, 2009
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2012 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__slepc_spectral_transformation_h
#define __deal2__slepc_spectral_transformation_h
* <code>eigensolver</code>:
* @code
* // Set a transformation, this one shifts the eigenspectrum by 3.142..
- * SLEPcWrappers::TransformationShift::AdditionalData additional_data (3.142);
+ * SLEPcWrappers::TransformationShift::AdditionalData additional_data (3.142);
* SLEPcWrappers::TransformationShift shift (additional_data);
* eigensolver.set_transformation (shift);
* @endcode
* SolverArnoldi system (solver_control, mpi_communicator);
* eigensolver.solve (A, B, lambda, x, size_of_spectrum);
* @endcode
- *
+ *
* @note These options can also be set at the commandline.
*
* @ingroup SLEPcWrappers
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__solver_h
#define __deal2__solver_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2012, 2013 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__solver_bicgstab_h
#define __deal2__solver_bicgstab_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2010, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__solver_cg_h
#define __deal2__solver_cg_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2010, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__solver_control_h
#define __deal2__solver_control_h
-//---------------------------- solver_gmres.h ---------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------- solver_gmres.h ---------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__solver_gmres_h
#define __deal2__solver_gmres_h
precondition.vmult(vv,p);
}
else
- {
+ {
precondition.vmult(p, tmp_vectors[inner_iteration]);
A.vmult(vv,p);
};
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__solver_minres_h
#define __deal2__solver_minres_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__solver_qmrs_h
#define __deal2__solver_qmrs_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__solver_relaxation_h
#define __deal2__solver_relaxation_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2010, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__solver_richardson_h
#define __deal2__solver_richardson_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__solver_selector_h
#define __deal2__solver_selector_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2008, 2012 by the deal.II authors
-// by the deal.II authors and Stephen "Cheffo" Kolaroff
+// Copyright (C) 2002 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__sparse_decomposition_h
#define __deal2__sparse_decomposition_h
-//---------------------------------------------------------------------------
-// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2009, 2011, 2012, 2013 by the deal.II authors
-// by the deal.II authors and Stephen "Cheffo" Kolaroff
+// ---------------------------------------------------------------------
+// $Id$
//
-// 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.
+// Copyright (C) 2002 - 2013 by the deal.II authors
//
-//---------------------------------------------------------------------------
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__sparse_decomposition_templates_h
#define __deal2__sparse_decomposition_templates_h
SparseLUDecomposition<number>::prebuild_lower_bound()
{
const size_type *const
- column_numbers = this->get_sparsity_pattern().colnums;
+ column_numbers = this->get_sparsity_pattern().colnums;
const std::size_t *const
- rowstart_indices = this->get_sparsity_pattern().rowstart;
+ rowstart_indices = this->get_sparsity_pattern().rowstart;
const size_type N = this->m();
-
- prebuilt_lower_bound.resize (N);
-
- for (size_type row=0; row<N; row++)
- {
- prebuilt_lower_bound[row]
- = Utilities::lower_bound (&column_numbers[rowstart_indices[row]+1],
- &column_numbers[rowstart_indices[row+1]],
- row);
+
+ prebuilt_lower_bound.resize (N);
+
+ for (size_type row=0; row<N; row++)
+ {
+ prebuilt_lower_bound[row]
+ = Utilities::lower_bound (&column_numbers[rowstart_indices[row]+1],
+ &column_numbers[rowstart_indices[row+1]],
+ row);
}
}
{
typename SparseMatrix<number>::iterator index = this->begin(row);
typename SparseMatrix<somenumber>::const_iterator
- in_index = matrix.begin(row);
+ in_index = matrix.begin(row);
index->value() = in_index->value();
++index, ++in_index;
while (index < this->end(row) && in_index < matrix.end(row))
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__sparse_direct_h
#define __deal2__sparse_direct_h
/**
* @{
*/
-
+
/**
* This function does nothing. It is only here to provide a interface
* consistent with other sparse direct solvers.
/**
* @{
*/
-
+
/**
* Preconditioner interface function. Usually, given the source vector,
- * this method returns an approximated solution of <i>Ax = b</i>. As this
+ * this method returns an approximate solution of <i>Ax = b</i>. As this
* class provides a wrapper to a direct solver, here it is actually the
* exact solution (exact within the range of numerical accuracy of
* course).
* inverse of the matrix, $A^{-1}$.
*/
void vmult (Vector<double> &dst,
- const Vector<double> &src) const;
+ const Vector<double> &src) const;
/**
* Same as before, but for block vectors.
*/
void vmult (BlockVector<double> &dst,
- const BlockVector<double> &src) const;
+ const BlockVector<double> &src) const;
/**
- * Not implemented but necessary for compiling certain other classes.
+ * Same as before, but uses the transpose of the matrix, i.e. this
+ * function multiplies with $A^{-T}$.
*/
void Tvmult (Vector<double> &dst,
- const Vector<double> &src) const;
+ const Vector<double> &src) const;
+
+ /**
+ * Same as before, but for block vectors
+ */
+ void Tvmult (BlockVector<double> &dst,
+ const BlockVector<double> &src) const;
/**
* Same as vmult(), but adding to the previous solution. Not implemented
* yet but necessary for compiling certain other classes.
*/
void vmult_add (Vector<double> &dst,
- const Vector<double> &src) const;
+ const Vector<double> &src) const;
/**
- * Not implemented but necessary for compiling certain other classes.
+ * Same as before, but uses the transpose of the matrix, i.e. this
+ * function multiplies with $A^{-T}$.
*/
void Tvmult_add (Vector<double> &dst,
- const Vector<double> &src) const;
-
+ const Vector<double> &src) const;
+
/**
* @}
*/
* happen. Note that we can't actually call the factorize() function from
* here if it has not yet been called, since we have no access to the
* actual matrix.
+ *
+ * If @p transpose is set to true this function solves for the transpose
+ * of the matrix, i.e. $x=A^{-T}b$.
*/
- void solve (Vector<double> &rhs_and_solution) const;
+ void solve (Vector<double> &rhs_and_solution, bool transpose = false) const;
/**
* Same as before, but for block vectors.
*/
- void solve (BlockVector<double> &rhs_and_solution) const;
-
+ void solve (BlockVector<double> &rhs_and_solution, bool transpose = false) const;
+
/**
* Call the two functions factorize() and solve() in that order, i.e. perform
* the whole solution process for the given right hand side vector.
*/
template <class Matrix>
void solve (const Matrix &matrix,
- Vector<double> &rhs_and_solution);
+ Vector<double> &rhs_and_solution,
+ bool transpose = false);
/**
* Same as before, but for block vectors.
*/
template <class Matrix>
void solve (const Matrix &matrix,
- BlockVector<double> &rhs_and_solution);
+ BlockVector<double> &rhs_and_solution,
+ bool transpose = false);
/**
* @}
*/
-
+
/**
* One of the UMFPack routines threw an error. The error code is included
* in the output and can be looked up in the UMFPack user manual. The
DeclException2 (ExcUMFPACKError, char *, int,
<< "UMFPACK routine " << arg1
<< " returned error status " << arg2
- << ". See the file <contrib/umfpack/UMFPACK/Include/umfpack.h>"
- << " for a description of error codes.");
+ << ". See the file <bundled/umfpack/UMFPACK/Include/umfpack.h>"
+ << " for a description of 'status codes'.");
private:
/**
-//---------------------------------------------------------------------------
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2012 by the deal.II authors
-// by the deal.II authors and Stephen "Cheffo" Kolaroff
+// ---------------------------------------------------------------------
+// $Id$
//
-// 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.
+// Copyright (C) 1999 - 2013 by the deal.II authors
//
-//---------------------------------------------------------------------------
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__sparse_ilu_h
#define __deal2__sparse_ilu_h
-//---------------------------------------------------------------------------
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2011, 2012 by the deal.II authors
-// by the deal.II authors and Stephen "Cheffo" Kolaroff
+// ---------------------------------------------------------------------
+// $Id$
//
-// 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.
+// Copyright (C) 1999 - 2013 by the deal.II authors
//
-//---------------------------------------------------------------------------
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__sparse_ilu_templates_h
#define __deal2__sparse_ilu_templates_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__sparse_matrix_h
#define __deal2__sparse_matrix_h
* object. See MemoryConsumption.
*/
std::size_t memory_consumption () const;
-
+
/**
* Dummy function for compatibility with distributed, parallel matrices.
*/
SparseMatrix<number> &
copy_from (const TrilinosWrappers::SparseMatrix &matrix);
#endif
-
+
/**
* Add <tt>matrix</tt> scaled by <tt>factor</tt> to this matrix, i.e. the
* matrix <tt>factor*matrix</tt> is added to <tt>this</tt>. This function
//@{
/**
- * Print the matrix to the given stream, using the format <tt>(row,column)
- * value</tt>, i.e. one nonzero entry of the matrix per line. If @p across
- * is true, print all entries on a single line, using the format
- * row,column:value
+ * Print the matrix to the given stream, using the format
+ * <tt>(row,column) value</tt>, i.e. one nonzero entry of the matrix
+ * per line. If <tt>across</tt> is true, print all entries on a
+ * single line, using the format row,column:value.
+ *
+ * If the argument <tt>diagonal_first</tt> is true, diagonal
+ * elements of quadratic matrices are printed first in their row,
+ * corresponding to the internal storage scheme. If it is false, the
+ * elements in a row are written in ascending column order.
*/
template <class STREAM>
- void print (STREAM &out, bool across=false) const;
+ void print (STREAM &out, bool across=false, bool diagonal_first=true) const;
/**
* Print the matrix in the usual format, i.e. as a matrix and not as a list
template <typename number>
template <class STREAM>
inline
-void SparseMatrix<number>::print (STREAM &out, bool across) const
+void SparseMatrix<number>::print (STREAM &out, bool across, bool diagonal_first) const
{
Assert (cols != 0, ExcNotInitialized());
Assert (val != 0, ExcNotInitialized());
- if (across)
+ bool hanging_diagonal = false;
+ number diagonal;
+
+ for (size_type i=0; i<cols->rows; ++i)
{
- for (size_type i=0; i<cols->rows; ++i)
- for (size_type j=cols->rowstart[i]; j<cols->rowstart[i+1]; ++j)
- out << ' ' << i << ',' << cols->colnums[j] << ':' << val[j];
- out << std::endl;
- }
- else
- for (size_type i=0; i<cols->rows; ++i)
for (size_type j=cols->rowstart[i]; j<cols->rowstart[i+1]; ++j)
- out << "(" << i << "," << cols->colnums[j] << ") " << val[j] << std::endl;
+ {
+ if (!diagonal_first && i == cols->colnums[j])
+ {
+ diagonal = val[j];
+ hanging_diagonal = true;
+ }
+ else
+ {
+ if (hanging_diagonal && cols->colnums[j]>i)
+ {
+ if (across)
+ out << ' ' << i << ',' << i << ':' << diagonal;
+ else
+ out << '(' << i << ',' << i << ") " << diagonal << std::endl;
+ hanging_diagonal = false;
+ }
+ if (across)
+ out << ' ' << i << ',' << cols->colnums[j] << ':' << val[j];
+ else
+ out << "(" << i << "," << cols->colnums[j] << ") " << val[j] << std::endl;
+ }
+ }
+ if (hanging_diagonal)
+ {
+ if (across)
+ out << ' ' << i << ',' << i << ':' << diagonal;
+ else
+ out << '(' << i << ',' << i << ") " << diagonal << std::endl;
+ hanging_diagonal = false;
+ }
+ }
+ if (across)
+ out << std::endl;
}
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__sparse_matrix_templates_h
#define __deal2__sparse_matrix_templates_h
template <typename number>
-typename SparseMatrix<number>::size_type
+typename SparseMatrix<number>::size_type
SparseMatrix<number>::get_row_length (const size_type row) const
{
Assert (cols != 0, ExcNotInitialized());
template <typename number>
-typename SparseMatrix<number>::size_type
+typename SparseMatrix<number>::size_type
SparseMatrix<number>::n_nonzero_elements () const
{
Assert (cols != 0, ExcNotInitialized());
template <typename number>
-typename SparseMatrix<number>::size_type
+typename SparseMatrix<number>::size_type
SparseMatrix<number>::n_actually_nonzero_elements (const double threshold) const
{
Assert (cols != 0, ExcNotInitialized());
{
Assert (m() == matrix.m(), ExcDimensionMismatch(m(), matrix.m()));
Assert (n() == matrix.n(), ExcDimensionMismatch(n(), matrix.n()));
-
+
// first delete previous content
*this = 0;
// length of the row
int ncols;
int ierr
- = matrix.trilinos_matrix().ExtractGlobalRowCopy
- (row, matrix.row_length(row), ncols,
- &(value_cache[0]),
- reinterpret_cast<TrilinosWrappers::types::int_type*>(&(colnum_cache[0])));
+ = matrix.trilinos_matrix().ExtractGlobalRowCopy
+ (row, matrix.row_length(row), ncols,
+ &(value_cache[0]),
+ reinterpret_cast<TrilinosWrappers::types::int_type *>(&(colnum_cache[0])));
Assert (ierr==0, ExcTrilinosError(ierr));
// resize arrays to the size actually used
// then copy everything in one swoop
this->set(row,
- colnum_cache,
- value_cache);
+ colnum_cache,
+ value_cache);
}
return *this;
const number *const end_ptr = &val[cols->n_nonzero_elements()];
while (val_ptr != end_ptr)
- *val_ptr++ += factor * *matrix_ptr++;
+ *val_ptr++ += factor **matrix_ptr++;
}
{
const size_type col = *rows;
size_type *new_cols = const_cast<size_type *>
- (&sp_B.colnums[sp_B.rowstart[col]]);
+ (&sp_B.colnums[sp_B.rowstart[col]]);
size_type *end_new_cols = const_cast<size_type *>
- (&sp_B.colnums[sp_B.rowstart[col+1]]);
+ (&sp_B.colnums[sp_B.rowstart[col+1]]);
// if B has a diagonal, need to add that manually. this way,
// we maintain sortedness.
&B.val[new_cols-&sp_B.colnums[sp_B.rowstart[0]]];
const numberB *const end_cols = &B.val[sp_B.rowstart[col+1]];
for (; B_val_ptr != end_cols; ++B_val_ptr)
- *new_ptr++ = A_val * *B_val_ptr * (use_vector ? V(col) : 1);
+ *new_ptr++ = A_val **B_val_ptr * (use_vector ? V(col) : 1);
C.add (i, new_ptr-&new_entries[0], new_cols, &new_entries[0],
false, true);
const size_type *const end_rows =
&sp_A.colnums[sp_A.rowstart[i+1]];
// cast away constness to conform with csp.add_entries interface
- size_type *new_cols = const_cast<size_type*>
- (&sp_B.colnums[sp_B.rowstart[i]]);
- size_type *end_new_cols = const_cast<size_type*>
- (&sp_B.colnums[sp_B.rowstart[i+1]]);
+ size_type *new_cols = const_cast<size_type *>
+ (&sp_B.colnums[sp_B.rowstart[i]]);
+ size_type *end_new_cols = const_cast<size_type *>
+ (&sp_B.colnums[sp_B.rowstart[i+1]]);
if (sp_B.n_rows() == sp_B.n_cols())
++new_cols;
const numberB *B_val_ptr =
&B.val[new_cols-&sp_B.colnums[sp_B.rowstart[0]]];
for (; B_val_ptr != end_cols; ++B_val_ptr)
- *new_ptr++ = A_val * *B_val_ptr * (use_vector ? V(i) : 1);
+ *new_ptr++ = A_val **B_val_ptr * (use_vector ? V(i) : 1);
C.add (row, new_ptr-&new_entries[0], new_cols, &new_entries[0],
false, true);
// square matrix by above assertion
if (om != 1.)
for (size_type i=0; i<n; ++i, ++dst_ptr, ++src_ptr, ++rowstart_ptr)
- *dst_ptr = om * *src_ptr / val[*rowstart_ptr];
+ *dst_ptr = om **src_ptr / val[*rowstart_ptr];
else
for (size_type i=0; i<n; ++i, ++dst_ptr, ++src_ptr, ++rowstart_ptr)
*dst_ptr = *src_ptr / val[*rowstart_ptr];
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2012, 2013 by the deal.II authors
+// Copyright (C) 2002 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__sparse_matrix_ez_h
#define __deal2__sparse_matrix_ez_h
template <typename number>
inline
-typename SparseMatrixEZ<number>::size_type
+typename SparseMatrixEZ<number>::size_type
SparseMatrixEZ<number>::const_iterator::Accessor::row() const
{
return a_row;
template <typename number>
inline
-typename SparseMatrixEZ<number>::size_type
+typename SparseMatrixEZ<number>::size_type
SparseMatrixEZ<number>::const_iterator::Accessor::column() const
{
return matrix->data[matrix->row_info[a_row].start+a_index].column;
{
const typename MATRIX::const_iterator end_row = M.end(row);
for (typename MATRIX::const_iterator entry = M.begin(row);
- entry != end_row; ++entry)
+ entry != end_row; ++entry)
if (entry->value() != 0)
set(row, entry->column(), entry->value());
}
{
const typename MATRIX::const_iterator end_row = M.end(row);
for (typename MATRIX::const_iterator entry = M.begin(row);
- entry != end_row; ++entry)
+ entry != end_row; ++entry)
if (entry->value() != 0)
add(row, entry->column(), factor * entry->value());
}
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2002 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__sparse_matrix_ez_templates_h
#define __deal2__sparse_matrix_ez_templates_h
for (; ri != end; ++dst_ptr, ++src_ptr, ++ri)
{
Assert (ri->diagonal != RowInfo::invalid_diagonal, ExcNoDiagonal());
- *dst_ptr = om * *src_ptr / data[ri->start + ri->diagonal].value;
+ *dst_ptr = om **src_ptr / data[ri->start + ri->diagonal].value;
}
}
template <typename number>
-typename SparseMatrixEZ<number>::size_type
+typename SparseMatrixEZ<number>::size_type
SparseMatrixEZ<number>::get_row_length (const size_type row) const
{
return row_info[row].length;
template <typename number>
-typename SparseMatrixEZ<number>::size_type
+typename SparseMatrixEZ<number>::size_type
SparseMatrixEZ<number>::n_nonzero_elements() const
{
typename std::vector<RowInfo>::const_iterator row = row_info.begin();
-//---------------------------------------------------------------------------
-// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2012 by the deal.II authors
-// by the deal.II authors and Stephen "Cheffo" Kolaroff
+// ---------------------------------------------------------------------
+// $Id$
//
-// 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.
+// Copyright (C) 2002 - 2013 by the deal.II authors
//
-//---------------------------------------------------------------------------
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__sparse_mic_h
#define __deal2__sparse_mic_h
-//---------------------------------------------------------------------------
-// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2011, 2012, 2013 by the deal.II authors
-// by the deal.II authors and Stephen "Cheffo" Kolaroff
+// ---------------------------------------------------------------------
+// $Id$
//
-// 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.
+// Copyright (C) 2002 - 2013 by the deal.II authors
//
-//---------------------------------------------------------------------------
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__sparse_mic_templates_h
#define __deal2__sparse_mic_templates_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__sparse_vanka_h
#define __deal2__sparse_vanka_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__sparse_vanka_templates_h
#define __deal2__sparse_vanka_templates_h
#else
const size_type n_inverses = std::count (selected.begin(),
selected.end(),
- true);
+ true);
- const size_type n_inverses_per_thread = std::max(n_inverses / n_threads,
- static_cast<size_type> (1U));
+ const size_type n_inverses_per_thread = std::max(n_inverses / n_threads,
+ static_cast<size_type> (1U));
// set up start and end index
// for each of the
// number of DoFs coupling to
// irow (including irow itself)
for (typename SparseMatrix<number>::const_iterator p=matrix->begin(row);
- p != matrix->end(row); ++p)
+ p != matrix->end(row); ++p)
{
// find out whether this DoF
// (that couples with @p irow,
selected.end(),
true);
- const size_type n_inverses_per_block = std::max(n_inverses / n_blocks,
- static_cast<size_type> (1U));
+ const size_type n_inverses_per_block = std::max(n_inverses / n_blocks,
+ static_cast<size_type> (1U));
// precompute the splitting points
std::vector<std::pair<size_type, size_type> > intervals (n_blocks);
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__sparsity_pattern_h
#define __deal2__sparsity_pattern_h
* the copy_from() function, if the inner iterator type points to plain
* unsigned integers.
*/
- size_type
+ size_type
get_column_index_from_iterator (const size_type i);
/**
* unsigned integers and some other value.
*/
template <typename value>
- size_type
+ size_type
get_column_index_from_iterator (const std::pair<size_type, value> &i);
/**
* <tt>std::map</tt>).
*/
template <typename value>
- size_type
+ size_type
get_column_index_from_iterator (const std::pair<const size_type, value> &i);
}
/**
* Write the data of this object en bloc to a file. This is done in a binary
* mode, so the output is neither readable by humans nor (probably) by other
- * computers using a different operating system of number format.
+ * computers using a different operating system or number format.
*
* The purpose of this function is that you can swap out matrices and
* sparsity pattern if you are short of memory, want to communicate between
* <i>r</i> are stored within the index range
* #rowstart[<i>r</i>]...#rowstart[<i>r+1</i>]. Therefore to find out
* whether a given element (<i>r,c</i>) exists, we have to check whether the
- * column number <i>c</i> exists in the abovementioned range within this
+ * column number <i>c</i> exists in the above-mentioned range within this
* array. If it exists, say at position <i>p</i> within this array, the
* value of the respective element in the sparse matrix will also be at
* position <i>p</i> of the values array of that class.
inline
- size_type
+ size_type
Accessor::row() const
{
Assert (is_valid_entry() == true, ExcInvalidIterator());
- const std::size_t * insert_point =
+ const std::size_t *insert_point =
std::upper_bound(sparsity_pattern->rowstart,
sparsity_pattern->rowstart + sparsity_pattern->rows + 1,
index_within_sparsity);
inline
- size_type
+ size_type
Accessor::column() const
{
Assert (is_valid_entry() == true, ExcInvalidIterator());
inline
- size_type
+ size_type
Accessor::index() const
{
Assert (is_valid_entry() == true, ExcInvalidIterator());
inline
-SparsityPattern::size_type
+SparsityPattern::size_type
SparsityPattern::n_rows () const
{
return rows;
inline
-SparsityPattern::size_type
+SparsityPattern::size_type
SparsityPattern::n_cols () const
{
return cols;
inline
-SparsityPattern::size_type
+SparsityPattern::size_type
SparsityPattern::column_number (const size_type row,
const unsigned int index) const
{
namespace internal
{
namespace SparsityPatternTools
- {
+ {
/**
* Declare type for container size.
*/
- typedef types::global_dof_index size_type;
-
+ typedef types::global_dof_index size_type;
+
inline
- size_type
+ size_type
get_column_index_from_iterator (const size_type i)
{
return i;
template <typename value>
inline
- size_type
+ size_type
get_column_index_from_iterator (const std::pair<size_type, value> &i)
{
return i.first;
template <typename value>
inline
- size_type
+ size_type
get_column_index_from_iterator (const std::pair<const size_type, value> &i)
{
return i.first;
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__sparsity_tools_h
#define __deal2__sparsity_tools_h
* range of elements stored locally
* and should be the one used in
* the constructor of the
- * CompressedSimpleSparsityPattern. Only
+ * CompressedSimpleSparsityPattern.
+ * This should be the locally relevant set.
+ * Only
* rows contained in myrange are
* checked in csp for transfer.
* This function needs to be used
const std::vector<size_type> &rows_per_cpu,
const MPI_Comm &mpi_comm,
const IndexSet &myrange);
+
+ /**
+ * similar to the function above, but includes support for
+ * BlockCompressedSimpleSparsityPattern.
+ * @p owned_set_per_cpu is typically DoFHandler::locally_owned_dofs_per_processor
+ * and @p myrange are locally_relevant_dofs.
+ */
+ template <class CSP_t>
+ void distribute_sparsity_pattern(CSP_t &csp,
+ const std::vector<IndexSet> &owned_set_per_cpu,
+ const MPI_Comm &mpi_comm,
+ const IndexSet &myrange);
+
#endif
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__swappable_vector_h
#define __deal2__swappable_vector_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2011, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__swappable_vector_templates_h
#define __deal2__swappable_vector_templates_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2009, 2012 by the deal.II authors
+// Copyright (C) 2002 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__transpose_matrix_h
#define __deal2__transpose_matrix_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2007, 2009, 2011, 2012 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__tridiagonal_matrix_h
#define __deal2__tridiagonal_matrix_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2010, 2012 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__trilinos_block_sparse_matrix_h
#define __deal2__trilinos_block_sparse_matrix_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__trilinos_block_vector_h
#define __deal2__trilinos_block_vector_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__trilinos_parallel_block_vector_h
#define __deal2__trilinos_parallel_block_vector_h
* processes.
*/
explicit BlockVector (const std::vector<IndexSet> ¶llel_partitioning,
- const MPI_Comm &communicator = MPI_COMM_WORLD);
+ const MPI_Comm &communicator = MPI_COMM_WORLD);
+
+ /**
+ * Creates a BlockVector with ghost elements. @p ghost_values
+ * may contain any elements in @p parallel_partitioning, they will
+ * be ignored.
+ */
+ BlockVector (const std::vector<IndexSet> ¶llel_partitioning,
+ const std::vector<IndexSet> &ghost_values,
+ const MPI_Comm &communicator);
+
/**
* Copy-Constructor. Set all the
void reinit (const std::vector<IndexSet> ¶llel_partitioning,
const MPI_Comm &communicator = MPI_COMM_WORLD,
const bool fast = false);
+ /**
+ * like above, but with a second set of indices for
+ * ghost entries.
+ */
+ void reinit (const std::vector<IndexSet> &partitioning,
+ const std::vector<IndexSet> &ghost_values,
+ const MPI_Comm &communicator = MPI_COMM_WORLD);
+
/**
* Change the dimension to that
*/
bool is_compressed () const;
+ /**
+ * Returns if this Vector contains ghost elements.
+ */
+ bool has_ghost_elements() const;
+
/**
* Swap the contents of this
* vector and the other vector
}
+ inline
+ BlockVector::BlockVector (const std::vector<IndexSet> ¶llel_partitioning,
+ const std::vector<IndexSet> &ghost_values,
+ const MPI_Comm &communicator)
+ {
+ reinit(parallel_partitioning, ghost_values, communicator);
+ }
+
inline
BlockVector::BlockVector (const size_type num_blocks)
}
+ inline
+ bool
+ BlockVector::has_ghost_elements() const
+ {
+ bool ghosted=block(0).has_ghost_elements();
+#ifdef DEBUG
+ for (unsigned int i=0; i<this->n_blocks(); ++i)
+ Assert(block(i).has_ghost_elements()==ghosted, ExcInternalError());
+#endif
+ return ghosted;
+ }
+
inline
void
BlockVector::swap (BlockVector &v)
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2010, 2012, 2013 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__trilinos_precondition_h
#define __deal2__trilinos_precondition_h
/**
* Apply the preconditioner.
*/
- void vmult (VectorBase &dst,
- const VectorBase &src) const;
+ virtual void vmult (VectorBase &dst,
+ const VectorBase &src) const;
/**
* Apply the transpose preconditioner.
*/
- void Tvmult (VectorBase &dst,
+ virtual void Tvmult (VectorBase &dst,
const VectorBase &src) const;
/**
* in the Trilinos wrapper
* class.
*/
- void vmult (dealii::Vector<double> &dst,
- const dealii::Vector<double> &src) const;
+ virtual void vmult (dealii::Vector<double> &dst,
+ const dealii::Vector<double> &src) const;
/**
* Apply the transpose preconditioner on
* in the Trilinos wrapper
* class.
*/
- void Tvmult (dealii::Vector<double> &dst,
- const dealii::Vector<double> &src) const;
+ virtual void Tvmult (dealii::Vector<double> &dst,
+ const dealii::Vector<double> &src) const;
/**
* Apply the preconditioner on deal.II
* the ones provided in the Trilinos
* wrapper class.
*/
- void vmult (dealii::parallel::distributed::Vector<double> &dst,
- const dealii::parallel::distributed::Vector<double> &src) const;
+ virtual void vmult (dealii::parallel::distributed::Vector<double> &dst,
+ const dealii::parallel::distributed::Vector<double> &src) const;
/**
* Apply the transpose preconditioner on deal.II
* the ones provided in the Trilinos
* wrapper class.
*/
- void Tvmult (dealii::parallel::distributed::Vector<double> &dst,
- const dealii::parallel::distributed::Vector<double> &src) const;
+ virtual void Tvmult (dealii::parallel::distributed::Vector<double> &dst,
+ const dealii::parallel::distributed::Vector<double> &src) const;
/**
* Exception.
+ /**
+ * A wrapper class for an identity preconditioner for Trilinos matrices.
+ *
+ * @ingroup TrilinosWrappers
+ * @ingroup Preconditioners
+ * @author Bruno Turcksin, 2013
+ */
+ class PreconditionIdentity : public PreconditionBase
+ {
+ public:
+
+ /**
+ * Apply the preconditioner, i.e., dst = src.
+ */
+ void vmult (VectorBase &dst,
+ const VectorBase &src) const;
+
+ /**
+ * Apply the transport conditioner, i.e., dst = src.
+ */
+ void Tvmult (VectorBase &dst,
+ const VectorBase &src) const;
+
+ /**
+ * Apply the preconditioner on deal.II data structures
+ * instead of the ones provided in the Trilinos wrapper class,
+ * i.e., dst = src.
+ */
+ void vmult (dealii::Vector<double> &dst,
+ const dealii::Vector<double> &src) const;
+
+ /**
+ * Apply the transpose preconditioner on deal.II data structures
+ * instead of the ones provided in the Trilinos wrapper class,
+ * i.e. dst = src.
+ */
+ void Tvmult (dealii::Vector<double> &dst,
+ const dealii::Vector<double> &src) const;
+
+ /**
+ * Apply the preconditioner on deal.II parallel data structures
+ * instead of the ones provided in the Trilinos wrapper class,
+ * i.e., dst = src.
+ */
+ void vmult (parallel::distributed::Vector<double> &dst,
+ const dealii::parallel::distributed::Vector<double> &src) const;
+
+ /**
+ * Apply the transpose preconditioner on deal.II parallel data structures
+ * instead of the ones provided in the Trilinos wrapper class,
+ * i.e., dst = src.
+ */
+ void Tvmult (parallel::distributed::Vector<double> &dst,
+ const dealii::parallel::distributed::Vector<double> &src) const;
+ };
+
+
+
// -------------------------- inline and template functions ----------------------
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2009, 2012 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__trilinos_solver_h
#define __deal2__trilinos_solver_h
const VectorBase &b,
const PreconditionBase &preconditioner);
+ /**
+ * Solve the linear system
+ * <tt>Ax=b</tt> where <tt>A</tt>
+ * is an operator. This function
+ * can be used for matrix free
+ * computation. Depending on
+ * the information provided by
+ * derived classes and the
+ * object passed as a
+ * preconditioner, one of the
+ * linear solvers and
+ * preconditioners of Trilinos
+ * is chosen.
+ */
+ void
+ solve (Epetra_Operator &A,
+ VectorBase &x,
+ const VectorBase &b,
+ const PreconditionBase &preconditioner);
+
/**
* Solve the linear system
* <tt>Ax=b</tt>. Depending on the
const dealii::Vector<double> &b,
const PreconditionBase &preconditioner);
+ /**
+ * Solve the linear system
+ * <tt>Ax=b</tt> where <tt>A</tt>
+ * is an operator. This function can
+ * be used for matric free. Depending on the
+ * information provided by derived
+ * classes and the object passed as a
+ * preconditioner, one of the linear
+ * solvers and preconditioners of
+ * Trilinos is chosen. This class
+ * works with matrices according to
+ * the TrilinosWrappers format, but
+ * can take deal.II vectors as
+ * argument. Since deal.II are serial
+ * vectors (not distributed), this
+ * function does only what you expect
+ * in case the matrix is locally
+ * owned. Otherwise, an exception
+ * will be thrown.
+ */
+ void
+ solve (Epetra_Operator &A,
+ dealii::Vector<double> &x,
+ const dealii::Vector<double> &b,
+ const PreconditionBase &preconditioner);
+
/**
* Access to object that controls
* convergence.
private:
+ /**
+ * The solve function is used to set properly the Epetra_LinearProblem,
+ * once it is done this function solves the linear problem.
+ */
+ void execute_solve(const PreconditionBase &preconditioner);
+
/**
* A structure that collects
* the Trilinos sparse matrix,
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__trilinos_sparse_matrix_h
#define __deal2__trilinos_sparse_matrix_h
Epetra_CombineMode mode = last_action;
if (last_action == Zero)
- {
- if ((operation==::dealii::VectorOperation::add) ||
- (operation==::dealii::VectorOperation::unknown))
- mode = Add;
- else if (operation==::dealii::VectorOperation::insert)
- mode = Insert;
- }
+ {
+ if ((operation==::dealii::VectorOperation::add) ||
+ (operation==::dealii::VectorOperation::unknown))
+ mode = Add;
+ else if (operation==::dealii::VectorOperation::insert)
+ mode = Insert;
+ }
else
- {
- Assert(
+ {
+ Assert(
((last_action == Add) && (operation!=::dealii::VectorOperation::insert))
||
((last_action == Insert) && (operation!=::dealii::VectorOperation::add)),
ExcMessage("operation and argument to compress() do not match"));
- }
+ }
// flush buffers
int ierr;
ierr = matrix->GlobalAssemble (*column_space_map, matrix->RowMap(),
- true, mode);
+ true, mode);
AssertThrow (ierr == 0, ExcTrilinosError(ierr));
if (elide_zero_values == false)
{
col_index_ptr = (TrilinosWrappers::types::int_type *)col_indices;
- col_value_ptr = const_cast<TrilinosScalar*>(values);
+ col_value_ptr = const_cast<TrilinosScalar *>(values);
n_columns = n_cols;
}
else
if (matrix->Filled() == false)
{
ierr = matrix->Epetra_CrsMatrix::InsertGlobalValues(
- static_cast<TrilinosWrappers::types::int_type>(row),
- static_cast<int>(n_columns),const_cast<double *>(col_value_ptr),
- col_index_ptr);
+ static_cast<TrilinosWrappers::types::int_type>(row),
+ static_cast<int>(n_columns),const_cast<double *>(col_value_ptr),
+ col_index_ptr);
// When inserting elements, we do not want to create exceptions in
// the case when inserting non-local data (since that's what we
if (elide_zero_values == false)
{
col_index_ptr = (TrilinosWrappers::types::int_type *)col_indices;
- col_value_ptr = const_cast<TrilinosScalar*>(values);
+ col_value_ptr = const_cast<TrilinosScalar *>(values);
n_columns = n_cols;
#ifdef DEBUG
for (size_type j=0; j<n_cols; ++j)
indices);
for (TrilinosWrappers::types::int_type i=0; i<n_indices; ++i)
std::cout << indices[i] << " ";
- std::cout << endl << std::endl;
+ std::cout << std::endl << std::endl;
Assert (ierr <= 0,
ExcAccessToNonPresentElement(row, col_index_ptr[0]));
}
ExcMessage ("Column map of matrix does not fit with vector map!"));
Assert (out.vector_partitioner().SameAs(m.RangeMap()) == true,
ExcMessage ("Row map of matrix does not fit with vector map!"));
+ (void)m;
+ (void)in;
+ (void)out;
}
}
}
{
Assert (&src != &dst, ExcSourceEqualsDestination());
Assert (matrix->Filled(), ExcMatrixNotCompressed());
+ (void)src;
+ (void)dst;
internal::SparseMatrix::check_vector_map_equality(*matrix, src, dst);
const size_type dst_local_size = dst.end() - dst.begin();
AssertDimension (dst_local_size, static_cast<size_type>(matrix->RangeMap().NumMyElements()));
+ (void)dst_local_size;
const size_type src_local_size = src.end() - src.begin();
AssertDimension (src_local_size, static_cast<size_type>(matrix->DomainMap().NumMyElements()));
+ (void)src_local_size;
Epetra_MultiVector tril_dst (View, matrix->RangeMap(), dst.begin(),
matrix->DomainMap().NumMyPoints(), 1);
}
-
+
template <typename VectorType>
inline
void
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__trilinos_sparsity_pattern_h
#define __deal2__trilinos_sparsity_pattern_h
const size_type row,
const size_type index);
+ /**
+ * Copy constructor.
+ */
+ Accessor (const Accessor &a);
+
/**
* Row number of the element
* represented by this object.
const size_type row,
const size_type index);
+ /**
+ * Copy constructor.
+ */
+ Iterator (const Iterator &i);
+
/**
* Prefix increment.
*/
}
+ inline
+ Accessor::Accessor (const Accessor &a)
+ :
+ sparsity_pattern(a.sparsity_pattern),
+ a_row(a.a_row),
+ a_index(a.a_index),
+ colnum_cache (a.colnum_cache)
+ {}
+
+
inline
Accessor::size_type
Accessor::row() const
{}
+ inline
+ Iterator::Iterator(const Iterator &i)
+ :
+ accessor(i.accessor)
+ {}
+
+
inline
Iterator &
// from it which we can by evaluating an expression such as when
// multiplying the value produced by 2
Assert (sizeof(TrilinosWrappers::types::int_type) ==
- sizeof((*begin)*2),
- ExcNotImplemented());
+ sizeof((*begin)*2),
+ ExcNotImplemented());
TrilinosWrappers::types::int_type *col_index_ptr =
(TrilinosWrappers::types::int_type *)(&*begin);
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2009, 2010, 2012, 2013 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__trilinos_vector_h
#define __deal2__trilinos_vector_h
namespace
{
#ifndef DEAL_II_USE_LARGE_INDEX_TYPE
- // define a helper function that queries the global ID of local ID of
- // an Epetra_BlockMap object by calling either the 32- or 64-bit
+ // define a helper function that queries the global ID of local ID of
+ // an Epetra_BlockMap object by calling either the 32- or 64-bit
// function necessary.
int gid(const Epetra_BlockMap &map, int i)
{
return map.GID(i);
}
#else
- // define a helper function that queries the global ID of local ID of
- // an Epetra_BlockMap object by calling either the 32- or 64-bit
+ // define a helper function that queries the global ID of local ID of
+ // an Epetra_BlockMap object by calling either the 32- or 64-bit
// function necessary.
long long int gid(const Epetra_BlockMap &map, int i)
{
void reinit (const BlockVector &v,
const bool import_data = false);
+ /**
+ * Reinit function. Creates a vector
+ * using the IndexSet local as our
+ * own unknowns, add optional ghost
+ * values ghost.
+ */
+ void reinit (const IndexSet &local,
+ const IndexSet &ghost,
+ const MPI_Comm &communicator = MPI_COMM_WORLD);
+
/**
* Set all components of the
* vector to the given number @p
* this is all we need to
* generate a parallel vector.
*/
- Vector (const Epetra_Map ¶llel_partitioning);
+ explicit Vector (const Epetra_Map ¶llel_partitioning);
/**
* Copy constructor from the
* that sets the partitioning
* details.
*/
- explicit Vector (const Epetra_Map ¶llel_partitioning,
- const VectorBase &v);
+ Vector (const Epetra_Map ¶llel_partitioning,
+ const VectorBase &v);
/**
* Reinitialize from a deal.II
* elements.
*/
template <typename Number>
- explicit Vector (const Epetra_Map ¶llel_partitioning,
- const dealii::Vector<Number> &v);
+ Vector (const Epetra_Map ¶llel_partitioning,
+ const dealii::Vector<Number> &v);
//@}
/**
* @name Initialization with an IndexSet
* need to generate a %parallel
* vector.
*/
- Vector (const IndexSet ¶llel_partitioning,
+ explicit Vector (const IndexSet ¶llel_partitioning,
+ const MPI_Comm &communicator = MPI_COMM_WORLD);
+
+ /**
+ * Creates a ghosted parallel vector.
+ */
+ Vector (const IndexSet &local,
+ const IndexSet &ghost,
const MPI_Comm &communicator = MPI_COMM_WORLD);
/**
* communicator that set the
* partitioning details.
*/
- explicit Vector (const IndexSet ¶llel_partitioning,
- const VectorBase &v,
- const MPI_Comm &communicator = MPI_COMM_WORLD);
+ Vector (const IndexSet ¶llel_partitioning,
+ const VectorBase &v,
+ const MPI_Comm &communicator = MPI_COMM_WORLD);
/**
* Copy-constructor from deal.II
* copies all the elements.
*/
template <typename Number>
- explicit Vector (const IndexSet ¶llel_partitioning,
- const dealii::Vector<Number> &v,
- const MPI_Comm &communicator = MPI_COMM_WORLD);
+ Vector (const IndexSet ¶llel_partitioning,
+ const dealii::Vector<Number> &v,
+ const MPI_Comm &communicator = MPI_COMM_WORLD);
/**
* Reinit functionality. This function
* input the number of elements
* in the vector.
*/
- Vector (const size_type n);
+ explicit Vector (const size_type n);
/**
* This constructor takes as
* map will be generated
* internally.
*/
- Vector (const Epetra_Map &partitioning);
+ explicit Vector (const Epetra_Map &partitioning);
/**
* This constructor takes as input
* taken and a localized version will
* be generated internally.
*/
- Vector (const IndexSet &partitioning,
- const MPI_Comm &communicator = MPI_COMM_WORLD);
+ explicit Vector (const IndexSet &partitioning,
+ const MPI_Comm &communicator = MPI_COMM_WORLD);
/**
* This constructor takes a
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__trilinos_vector_base_h
#define __deal2__trilinos_vector_base_h
TrilinosScalar
operator [] (const size_type index) const;
+ /**
+ * A collective get operation: instead
+ * of getting individual elements of a
+ * vector, this function allows to get
+ * a whole set of elements at once. The
+ * indices of the elements to be read
+ * are stated in the first argument,
+ * the corresponding values are returned in the
+ * second.
+ */
+ void extract_subvector_to (const std::vector<size_type> &indices,
+ std::vector<TrilinosScalar> &values) const;
+
+ /**
+ * Just as the above, but with pointers.
+ * Useful in minimizing copying of data around.
+ */
+ template <typename ForwardIterator, typename OutputIterator>
+ void extract_subvector_to (ForwardIterator indices_begin,
+ const ForwardIterator indices_end,
+ OutputIterator values_begin) const;
+
/**
* Return the value of the vector
* entry <i>i</i>. Note that this
/**
* Make the Vector class a bit like the <tt>vector<></tt> class of
* the C++ standard library by returning iterators to the start and end
- * of the locally owned elements of this vector. The ordering of local elements corresponds to the one given
+ * of the locally owned elements of this vector. The ordering of local elements corresponds to the one given
*
* It holds that end() - begin() == local_size().
*/
{
const size_type n_indices = vector->Map().NumMyElements();
#ifndef DEAL_II_USE_LARGE_INDEX_TYPE
- unsigned int * vector_indices = (unsigned int*)vector->Map().MyGlobalElements();
+ unsigned int *vector_indices = (unsigned int *)vector->Map().MyGlobalElements();
#else
- size_type * vector_indices = (size_type*)vector->Map().MyGlobalElements64();
+ size_type *vector_indices = (size_type *)vector->Map().MyGlobalElements64();
#endif
is.add_indices(vector_indices, vector_indices+n_indices);
is.compress();
+ inline
+ void VectorBase::extract_subvector_to (const std::vector<size_type> &indices,
+ std::vector<TrilinosScalar> &values) const
+ {
+ for (size_type i = 0; i < indices.size(); ++i)
+ values[i] = operator()(indices[i]);
+ }
+
+
+
+ template <typename ForwardIterator, typename OutputIterator>
+ inline
+ void VectorBase::extract_subvector_to (ForwardIterator indices_begin,
+ const ForwardIterator indices_end,
+ OutputIterator values_begin) const
+ {
+ while (indices_begin != indices_end) {
+ *values_begin = operator()(*indices_begin);
+ indices_begin++; values_begin++;
+ }
+ }
+
+
+
inline
VectorBase::iterator
VectorBase::begin()
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__vector_h
#define __deal2__vector_h
* Exactly the same as operator().
*/
Number &operator[] (const size_type i);
+
+ /**
+ * A collective get operation: instead
+ * of getting individual elements of a
+ * vector, this function allows to get
+ * a whole set of elements at once. The
+ * indices of the elements to be read
+ * are stated in the first argument,
+ * the corresponding values are returned in the
+ * second.
+ */
+ template <typename OtherNumber>
+ void extract_subvector_to (const std::vector<size_type> &indices,
+ std::vector<OtherNumber> &values) const;
+
+ /**
+ * Just as the above, but with pointers.
+ * Useful in minimizing copying of data around.
+ */
+ template <typename ForwardIterator, typename OutputIterator>
+ void extract_subvector_to (ForwardIterator indices_begin,
+ const ForwardIterator indices_end,
+ OutputIterator values_begin) const;
//@}
+template <typename Number>
+template <typename OtherNumber>
+inline
+void Vector<Number>::extract_subvector_to (const std::vector<size_type> &indices,
+ std::vector<OtherNumber> &values) const
+{
+ for (size_type i = 0; i < indices.size(); ++i)
+ values[i] = operator()(indices[i]);
+}
+
+
+
+template <typename Number>
+template <typename ForwardIterator, typename OutputIterator>
+inline
+void Vector<Number>::extract_subvector_to (ForwardIterator indices_begin,
+ const ForwardIterator indices_end,
+ OutputIterator values_begin) const
+{
+ while (indices_begin != indices_end) {
+ *values_begin = operator()(*indices_begin);
+ indices_begin++; values_begin++;
+ }
+}
+
+
+
template <typename Number>
inline
Vector<Number> &
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__vector_templates_h
#define __deal2__vector_templates_h
{
namespace Vector
{
- typedef types::global_dof_index size_type;
-
- template<typename T>
+ template <typename T>
void set_subrange (const T s,
- const size_type begin,
- const size_type end,
+ const typename dealii::Vector<T>::size_type begin,
+ const typename dealii::Vector<T>::size_type end,
dealii::Vector<T> &dst)
{
if (s == T())
std::fill (&*(dst.begin()+begin), &*(dst.begin()+end), s);
}
- template<typename T>
- void copy_subrange (const size_type begin,
- const size_type end,
+
+ template <typename T>
+ void copy_subrange (const typename dealii::Vector<T>::size_type begin,
+ const typename dealii::Vector<T>::size_type end,
const dealii::Vector<T> &src,
dealii::Vector<T> &dst)
{
(end-begin)*sizeof(T));
}
- template<typename T, typename U>
- void copy_subrange (const size_type begin,
- const size_type end,
+
+ template <typename T, typename U>
+ void copy_subrange (const typename dealii::Vector<T>::size_type begin,
+ const typename dealii::Vector<T>::size_type end,
const dealii::Vector<T> &src,
dealii::Vector<U> &dst)
{
*p = *q;
}
+
template<typename T, typename U>
- void copy_subrange_wrap (const size_type begin,
- const size_type end,
+ void copy_subrange_wrap (const typename dealii::Vector<T>::size_type begin,
+ const typename dealii::Vector<T>::size_type end,
const dealii::Vector<T> &src,
dealii::Vector<U> &dst)
{
copy_subrange (begin, end, src, dst);
}
+
template <typename T, typename U>
void copy_vector (const dealii::Vector<T> &src,
dealii::Vector<U> &dst)
if (PointerComparison::equal(&src, &dst))
return;
- const size_type vec_size = src.size();
- const size_type dst_size = dst.size();
+ const typename dealii::Vector<T>::size_type vec_size = src.size();
+ const typename dealii::Vector<U>::size_type dst_size = dst.size();
if (dst_size != vec_size)
dst.reinit (vec_size, true);
if (vec_size>internal::Vector::minimum_parallel_grain_size)
// The code returns the result as the last argument in order to make
// spawning tasks simpler and use automatic template deduction.
template <typename Operation, typename Number, typename Number2,
- typename ResultType>
+ typename ResultType, typename size_type>
void accumulate (const Operation &op,
const Number *X,
const Number2 *Y,
ResultType r0, r1, r2, r3;
Threads::TaskGroup<> task_group;
task_group += Threads::new_task(&accumulate<Operation,Number,Number2,
- ResultType>,
+ ResultType,size_type>,
op, X, Y, power, new_size, r0);
task_group += Threads::new_task(&accumulate<Operation,Number,Number2,
- ResultType>,
+ ResultType,size_type>,
op, X+new_size, Y+new_size, power,
new_size, r1);
task_group += Threads::new_task(&accumulate<Operation,Number,Number2,
- ResultType>,
+ ResultType,size_type>,
op, X+2*new_size, Y+2*new_size, power,
new_size, r2);
task_group += Threads::new_task(&accumulate<Operation,Number,Number2,
- ResultType>,
+ ResultType,size_type>,
op, X+3*new_size, Y+3*new_size, power,
vec_size-3*new_size, r3);
task_group.join_all();
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__vector_memory_h
#define __deal2__vector_memory_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2012 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __dealii__vector_view_h
#define __dealii__vector_view_h
* view_of_long_vector(i), with i>0 might
* cause an attempt to access invalid
* areas of memory, or might function
- * properly, depending on wether or not
+ * properly, depending on whether or not
* the system was able to allocate some
* memory consecutively after the
* original allocation.
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2011-2013 by the deal.II authors
+// Copyright (C) 2011 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__matrix_free_dof_info_h
#define __deal2__matrix_free_dof_info_h
#include <deal.II/dofs/dof_handler.h>
#include <deal.II/matrix_free/helper_functions.h>
+#include <deal.II/base/std_cxx1x/array.h>
+
#include <memory>
*/
struct DoFInfo
{
-
- /**
- * size_type of the dof_indicies object.
- */
-
- typedef std::vector<types::global_dof_index>::size_type size_dof;
-
- /**
- * size_type of the constraint_indicators object.
- */
-
- typedef std::vector<std::pair<unsigned short, unsigned short> >::size_type size_constraint;
-
/**
* Default empty constructor.
*/
* Clears all data fields in this class.
*/
void clear ();
-
+
/**
* Returns a pointer to the first index in the DoF row @p row.
*/
- const types::global_dof_index *begin_indices (const unsigned int row) const;
+ const unsigned int *begin_indices (const unsigned int row) const;
/**
* Returns a pointer to the one past the last DoF index in the row @p
* row.
*/
- const types::global_dof_index *end_indices (const unsigned int row) const;
+ const unsigned int *end_indices (const unsigned int row) const;
/**
* Returns the number of entries in the indices field for the given row.
* Returns a pointer to the first index in the DoF row @p row for plain
* indices (i.e., the entries where constraints are not embedded).
*/
- const types::global_dof_index *begin_indices_plain (const unsigned int row) const;
+ const unsigned int *begin_indices_plain (const unsigned int row) const;
/**
* Returns a pointer to the one past the last DoF index in the row @p
* row (i.e., the entries where constraints are not embedded).
*/
- const types::global_dof_index *end_indices_plain (const unsigned int row) const;
+ const unsigned int *end_indices_plain (const unsigned int row) const;
/**
* Returns the FE index for a given finite element degree. If not in hp
*/
void compute_renumber_serial (const std::vector<unsigned int> &boundary_cells,
const SizeInfo &size_info,
- std::vector<types::global_dof_index> &renumbering);
+ std::vector<unsigned int> &renumbering);
/**
* Reorganizes cells in the hp case without parallelism such that all
* DoFHandlers.
*/
void compute_renumber_hp_serial (SizeInfo &size_info,
- std::vector<types::global_dof_index> &renumbering,
+ std::vector<unsigned int> &renumbering,
std::vector<unsigned int> &irregular_cells);
/**
*/
void compute_renumber_parallel (const std::vector<unsigned int> &boundary_cells,
SizeInfo &size_info,
- std::vector<types::global_dof_index> &renumbering);
+ std::vector<unsigned int> &renumbering);
/**
* This method reorders the way cells are gone through based on a given
* vectorization.
*/
void reorder_cells (const SizeInfo &size_info,
- const std::vector<types::global_dof_index> &renumbering,
+ const std::vector<unsigned int> &renumbering,
const std::vector<unsigned int> &constraint_pool_row_index,
const std::vector<unsigned int> &irregular_cells,
const unsigned int vectorization_length);
void
make_thread_graph_partition_color (SizeInfo &size_info,
TaskInfo &task_info,
- std::vector<types::global_dof_index> &renumbering,
+ std::vector<unsigned int> &renumbering,
std::vector<unsigned int> &irregular_cells,
const bool hp_bool);
void
make_thread_graph_partition_partition (SizeInfo &size_info,
TaskInfo &task_info,
- std::vector<types::global_dof_index> &renumbering,
+ std::vector<unsigned int> &renumbering,
std::vector<unsigned int> &irregular_cells,
const bool hp_bool);
void
make_connectivity_graph (const SizeInfo &size_info,
const TaskInfo &task_info,
- const std::vector<types::global_dof_index> &renumbering,
+ const std::vector<unsigned int> &renumbering,
const std::vector<unsigned int> &irregular_cells,
const bool do_blocking,
CompressedSimpleSparsityPattern &connectivity) const;
* certain structure in the indices, like indices for vector-valued
* problems or for cells where not all vector components are filled.
*/
- std::vector<std_cxx1x::tuple<size_dof,
- size_constraint,
- unsigned int> > row_starts;
+ std::vector<std_cxx1x::array<unsigned int, 3> > row_starts;
/**
- * Stores the (global) indices of the degrees of freedom for each cell. This
- * array also includes the indirect contributions from constraints,
+ * Stores the indices of the degrees of freedom for each cell. These
+ * indices are computed in MPI-local index space, i.e., each processor
+ * stores the locally owned indices as numbers between <tt>0</tt> and
+ * <tt>n_locally_owned_dofs-1</tt> and ghost indices in the range
+ * <tt>n_locally_owned_dofs</tt> to
+ * <tt>n_locally_owned_dofs+n_ghost_dofs</tt>. The translation between
+ * this MPI-local index space and the global numbering of degrees of
+ * freedom is stored in the @p vector_partitioner data structure.
+
+ * This array also includes the indirect contributions from constraints,
* which are described by the @p constraint_indicator field. Because of
* variable lengths of rows, this would be a vector of a
* vector. However, we use one contiguous memory region and store the
* rowstart in the variable @p row_starts.
*/
- std::vector<types::global_dof_index> dof_indices;
+ std::vector<unsigned int> dof_indices;
/**
* This variable describes the position of constraints in terms of the
* This stores a (sorted) list of all locally owned degrees of freedom
* that are constrained.
*/
- std::vector<types::global_dof_index> constrained_dofs;
+ std::vector<unsigned int> constrained_dofs;
/**
* Stores the rowstart indices of the compressed row storage in the @p
* plain_dof_indices fields.
*/
- std::vector<types::global_dof_index> row_starts_plain_indices;
+ std::vector<unsigned int> row_starts_plain_indices;
/**
* Stores the indices of the degrees of freedom for each cell. This
* contiguous memory region and store the rowstart in the variable @p
* row_starts_plain_indices.
*/
- std::vector<types::global_dof_index> plain_dof_indices;
+ std::vector<unsigned int> plain_dof_indices;
/**
* Stores the dimension of the underlying DoFHandler. Since the indices
#ifndef DOXYGEN
inline
- const types::global_dof_index *
+ const unsigned int *
DoFInfo::begin_indices (const unsigned int row) const
{
AssertIndexRange (row, row_starts.size()-1);
- const unsigned int index = std_cxx1x::get<0>(row_starts[row]);
+ const unsigned int index = row_starts[row][0];
AssertIndexRange(index, dof_indices.size()+1);
return dof_indices.empty() ? 0 : &dof_indices[0] + index;
}
inline
- const types::global_dof_index *
+ const unsigned int *
DoFInfo::end_indices (const unsigned int row) const
{
AssertIndexRange (row, row_starts.size()-1);
- const unsigned int index = std_cxx1x::get<0>(row_starts[row+1]);
+ const unsigned int index = row_starts[row+1][0];
AssertIndexRange(index, dof_indices.size()+1);
return dof_indices.empty() ? 0 : &dof_indices[0] + index;
}
DoFInfo::row_length_indices (const unsigned int row) const
{
AssertIndexRange (row, row_starts.size()-1);
- return (std_cxx1x::get<0>(row_starts[row+1]) -
- std_cxx1x::get<0>(row_starts[row]));
+ return (row_starts[row+1][0] - row_starts[row][0]);
}
DoFInfo::begin_indicators (const unsigned int row) const
{
AssertIndexRange (row, row_starts.size()-1);
- const unsigned int index = std_cxx1x::get<1>(row_starts[row]);
+ const unsigned int index = row_starts[row][1];
AssertIndexRange (index, constraint_indicator.size()+1);
return constraint_indicator.empty() ? 0 : &constraint_indicator[0] + index;
}
DoFInfo::end_indicators (const unsigned int row) const
{
AssertIndexRange (row, row_starts.size()-1);
- const unsigned int index = std_cxx1x::get<1>(row_starts[row+1]);
+ const unsigned int index = row_starts[row+1][1];
AssertIndexRange (index, constraint_indicator.size()+1);
return constraint_indicator.empty() ? 0 : &constraint_indicator[0] + index;
}
DoFInfo::row_length_indicators (const unsigned int row) const
{
AssertIndexRange (row, row_starts.size()-1);
- return (std_cxx1x::get<1>(row_starts[row+1]) -
- std_cxx1x::get<1>(row_starts[row]));
+ return (row_starts[row+1][1] - row_starts[row][1]);
}
inline
- const types::global_dof_index *
+ const unsigned int *
DoFInfo::begin_indices_plain (const unsigned int row) const
{
// if we have no constraints, should take the data from dof_indices
if (row_length_indicators(row) == 0)
{
- Assert (row_starts_plain_indices[row] == numbers::invalid_dof_index,
+ Assert (row_starts_plain_indices[row]==numbers::invalid_unsigned_int,
ExcInternalError());
return begin_indices(row);
}
inline
- const types::global_dof_index *
+ const unsigned int *
DoFInfo::end_indices_plain (const unsigned int row) const
{
return begin_indices_plain(row) +
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2011 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/memory_consumption.h>
#include <deal.II/base/multithread_info.h>
template <typename Number>
unsigned short
ConstraintValues<Number>::
- insert_entries (const std::vector<std::pair<types::global_dof_index,double> > &entries)
+ insert_entries (const std::vector<std::pair<types::global_dof_index,double> > &entries)
{
next_constraint.first.resize(entries.size());
if (entries.size() > 0)
void
- DoFInfo::read_dof_indices (const std::vector<types::global_dof_index> &local_indices,
+ DoFInfo::read_dof_indices (const std::vector<types::global_dof_index> &local_indices,
const std::vector<unsigned int> &lexicographic_inv,
const ConstraintMatrix &constraints,
const unsigned int cell_number,
const unsigned int n_mpi_procs = vector_partitioner->n_mpi_processes();
const types::global_dof_index first_owned = vector_partitioner->local_range().first;
const types::global_dof_index last_owned = vector_partitioner->local_range().second;
- const types::global_dof_index n_owned = last_owned - first_owned;
+ Assert (last_owned-first_owned < std::numeric_limits<unsigned int>::max(),
+ ExcMessage("The size local range of owned indices must not "
+ "exceed the size of unsigned int"));
+ const unsigned int n_owned = last_owned - first_owned;
std::pair<unsigned short,unsigned short> constraint_iterator (0,0);
unsigned int dofs_this_cell = (cell_active_fe_index.empty()) ?
dofs_per_cell[0] : dofs_per_cell[cell_active_fe_index[cell_number]];
for (unsigned int i=0; i<dofs_this_cell; i++)
{
- types::global_dof_index current_dof =
+ types::global_dof_index current_dof =
local_indices[lexicographic_inv[i]];
const std::vector<std::pair<types::global_dof_index,double> >
*entries_ptr =
(constraint_indices[j] < first_owned ||
constraint_indices[j] >= last_owned))
{
- dof_indices.push_back
- (n_owned + ghost_dofs.size());
+ dof_indices.push_back (n_owned + ghost_dofs.size());
// collect ghosts so that we can later construct an
// IndexSet for them. also store whether the current
// not ghost, so transform to the local index space
// directly
dof_indices.push_back
- (constraint_indices[j] - first_owned);
+ (static_cast<unsigned int>(constraint_indices[j] -
+ first_owned));
}
}
}
else
current_dof -= first_owned;
- dof_indices.push_back (current_dof);
+ dof_indices.push_back (static_cast<unsigned int>(current_dof));
// make sure constraint_iterator.first is always within the
// bounds of unsigned short
constraint_iterator.first++;
}
}
- row_starts[cell_number+1] = std_cxx1x::tuple<size_dof,
- size_constraint,
- unsigned int>
- (dof_indices.size(), constraint_indicator.size(), 0);
+ row_starts[cell_number+1][0] = dof_indices.size();
+ row_starts[cell_number+1][1] = constraint_indicator.size();
+ row_starts[cell_number+1][2] = 0;
// now to the plain indices: in case we have constraints on this cell,
// store the indices without the constraints resolve once again
if (cell_number == 0)
row_starts_plain_indices.resize (row_starts.size());
row_starts_plain_indices[cell_number] = plain_dof_indices.size();
- bool cell_has_constraints =
- std_cxx1x::get<1>(row_starts[cell_number+1]) >
- std_cxx1x::get<1>(row_starts[cell_number]);
+ bool cell_has_constraints = (row_starts[cell_number+1][1] >
+ row_starts[cell_number][1]);
if (cell_has_constraints == true)
{
for (unsigned int i=0; i<dofs_this_cell; ++i)
{
- types::global_dof_index current_dof =
+ types::global_dof_index current_dof =
local_indices[lexicographic_inv[i]];
if (n_mpi_procs > 1 &&
(current_dof < first_owned ||
}
else
current_dof -= first_owned;
- plain_dof_indices.push_back (current_dof);
+ plain_dof_indices.push_back (static_cast<unsigned int>
+ (current_dof));
}
}
}
Assert (boundary_cells.size() < row_starts.size(), ExcInternalError());
// sort ghost dofs and compress out duplicates
- const types::global_dof_index n_owned = (vector_partitioner->local_range().second-
+ const unsigned int n_owned = (vector_partitioner->local_range().second-
vector_partitioner->local_range().first);
- const size_dof n_ghosts = ghost_dofs.size();
- unsigned int n_unique_ghosts= 0;
+ const std::size_t n_ghosts = ghost_dofs.size();
+ unsigned int n_unique_ghosts= 0;
#ifdef DEBUG
- for (std::vector<types::global_dof_index>::iterator dof = dof_indices.begin();
+ for (std::vector<unsigned int>::iterator dof = dof_indices.begin();
dof!=dof_indices.end(); ++dof)
AssertIndexRange (*dof, n_owned+n_ghosts);
#endif
// replace the temporary numbering of ghosts by the real number in
// the index set, we need to store these values
std::vector<std::pair<types::global_dof_index,unsigned int> > ghost_origin(n_ghosts);
- for (size_dof i=0; i<n_ghosts; ++i)
+ for (std::size_t i=0; i<n_ghosts; ++i)
{
ghost_origin[i].first = ghost_dofs[i];
ghost_origin[i].second = i;
}
std::sort (ghost_origin.begin(), ghost_origin.end());
- types::global_dof_index last_contiguous_start = ghost_origin[0].first;
+ types::global_dof_index last_contiguous_start = ghost_origin[0].first;
ghost_numbering[ghost_origin[0].second] = 0;
- for (size_dof i=1; i<n_ghosts; i++)
+ for (std::size_t i=1; i<n_ghosts; i++)
{
- if (ghost_origin[i].first>ghost_origin[i-1].first+1)
+ if (ghost_origin[i].first > ghost_origin[i-1].first+1)
{
ghost_indices.add_range (last_contiguous_start,
ghost_origin[i-1].first+1);
// dofs. the ghost index set should store the same number
{
AssertDimension (n_unique_ghosts, ghost_indices.n_elements());
- for (size_dof i=0; i<n_ghosts; ++i)
+ for (std::size_t i=0; i<n_ghosts; ++i)
Assert (ghost_numbering[i] ==
ghost_indices.index_within_set(ghost_dofs[i]),
ExcInternalError());
const unsigned int n_boundary_cells = boundary_cells.size();
for (unsigned int i=0; i<n_boundary_cells; ++i)
{
- types::global_dof_index *data_ptr = const_cast<types::global_dof_index *>
- (begin_indices(boundary_cells[i]));
+ unsigned int *data_ptr = const_cast<unsigned int *> (begin_indices(boundary_cells[i]));
- const types::global_dof_index *row_end = end_indices(boundary_cells[i]);
+ const unsigned int *row_end = end_indices(boundary_cells[i]);
for ( ; data_ptr != row_end; ++data_ptr)
*data_ptr = ((*data_ptr < n_owned)
?
{
if (row_length_indicators(boundary_cells[i]) > 0)
{
- types::global_dof_index *data_ptr = const_cast<types::global_dof_index *>
- (begin_indices_plain(boundary_cells[i]));
- const types::global_dof_index *row_end =
- (end_indices_plain(boundary_cells[i]));
+ unsigned int *data_ptr = const_cast<unsigned int *> (begin_indices_plain(boundary_cells[i]));
+ const unsigned int *row_end = end_indices_plain(boundary_cells[i]);
for ( ; data_ptr != row_end; ++data_ptr)
*data_ptr = ((*data_ptr < n_owned)
?
}
}
- std::vector<types::global_dof_index> new_ghosts;
- ghost_dofs.swap(new_ghosts);
+ std::vector<types::global_dof_index> empty;
+ ghost_dofs.swap(empty);
// set the ghost indices now. need to cast away constness here, but that
// is uncritical since we reset the Partitioner in the same initialize
void
DoFInfo::compute_renumber_serial (const std::vector<unsigned int> &boundary_cells,
const SizeInfo &size_info,
- std::vector<types::global_dof_index> &renumbering)
+ std::vector<unsigned int> &renumbering)
{
- std::vector<types::global_dof_index> reverse_numbering (size_info.n_active_cells,
+ std::vector<unsigned int> reverse_numbering (size_info.n_active_cells,
numbers::invalid_unsigned_int);
const unsigned int n_boundary_cells = boundary_cells.size();
for (unsigned int j=0; j<n_boundary_cells; ++j)
void
DoFInfo::compute_renumber_hp_serial (SizeInfo &size_info,
- std::vector<types::global_dof_index> &renumbering,
+ std::vector<unsigned int> &renumbering,
std::vector<unsigned int> &irregular_cells)
{
if (max_fe_index < 2)
void
DoFInfo::compute_renumber_parallel (const std::vector<unsigned int> &boundary_cells,
SizeInfo &size_info,
- std::vector<types::global_dof_index> &renumbering)
+ std::vector<unsigned int> &renumbering)
{
- std::vector<types::global_dof_index> reverse_numbering (size_info.n_active_cells,
+ std::vector<unsigned int> reverse_numbering (size_info.n_active_cells,
numbers::invalid_unsigned_int);
const unsigned int n_boundary_cells = boundary_cells.size();
for (unsigned int j=0; j<n_boundary_cells; ++j)
void
DoFInfo::reorder_cells (const SizeInfo &size_info,
- const std::vector<types::global_dof_index> &renumbering,
+ const std::vector<unsigned int> &renumbering,
const std::vector<unsigned int> &constraint_pool_row_index,
const std::vector<unsigned int> &irregular_cells,
const unsigned int vectorization_length)
std::swap (new_active_fe_index, cell_active_fe_index);
}
- std::vector<std_cxx1x::tuple<size_dof, size_constraint,
- unsigned int> > new_row_starts;
- std::vector<types::global_dof_index> new_dof_indices;
+ std::vector<std_cxx1x::array<unsigned int, 3> > new_row_starts;
+ std::vector<unsigned int> new_dof_indices;
std::vector<std::pair<unsigned short,unsigned short> >
new_constraint_indicator;
- std::vector<types::global_dof_index> new_plain_indices, new_rowstart_plain;
+ std::vector<unsigned int> new_plain_indices, new_rowstart_plain;
unsigned int position_cell = 0;
new_row_starts.resize (size_info.n_macro_cells + 1);
new_dof_indices.reserve (dof_indices.size());
if (store_plain_indices == true)
{
new_rowstart_plain.resize (size_info.n_macro_cells + 1,
- numbers::invalid_dof_index);
+ numbers::invalid_unsigned_int);
new_plain_indices.reserve (plain_dof_indices.size());
}
// vectors are adjacent, i.e., first dof index 0 for all vectors, then
// dof index 1 for all vectors, and so on. This involves some extra
// resorting.
- std::vector<const types::global_dof_index *> glob_indices (vectorization_length);
- std::vector<const types::global_dof_index *> plain_glob_indices (vectorization_length);
+ std::vector<const unsigned int *> glob_indices (vectorization_length);
+ std::vector<const unsigned int *> plain_glob_indices (vectorization_length);
std::vector<const std::pair<unsigned short,unsigned short>*>
constr_ind(vectorization_length), constr_end(vectorization_length);
std::vector<unsigned int> index(vectorization_length);
const unsigned int dofs_mcell =
dofs_per_cell[cell_active_fe_index.size() == 0 ? 0 :
cell_active_fe_index[i]] * vectorization_length;
- new_row_starts[i] =
- std_cxx1x::tuple<size_dof, size_constraint, unsigned int>
- (new_dof_indices.size(), new_constraint_indicator.size(),
- irregular_cells[i]);
+ new_row_starts[i][0] = new_dof_indices.size();
+ new_row_starts[i][1] = new_constraint_indicator.size();
+ new_row_starts[i][2] = irregular_cells[i];
const unsigned int n_comp = (irregular_cells[i]>0 ?
irregular_cells[i] : vectorization_length);
}
AssertDimension (position_cell+1, row_starts.size());
- new_row_starts[size_info.n_macro_cells] =
- std_cxx1x::tuple<size_dof, size_constraint, unsigned int>
- (new_dof_indices.size(), new_constraint_indicator.size(), 0);
+ new_row_starts[size_info.n_macro_cells][0] = new_dof_indices.size();
+ new_row_starts[size_info.n_macro_cells][1] = new_constraint_indicator.size();
+ new_row_starts[size_info.n_macro_cells][2] = 0;
AssertDimension(dof_indices.size(), new_dof_indices.size());
AssertDimension(constraint_indicator.size(),
#ifdef DEBUG
// sanity check 1: all indices should be smaller than the number of dofs
// locally owned plus the number of ghosts
- const types::global_dof_index index_range = (vector_partitioner->local_range().second-
+ const unsigned int index_range = (vector_partitioner->local_range().second-
vector_partitioner->local_range().first)
- + vector_partitioner->ghost_indices().n_elements();
- for (size_dof i=0; i<dof_indices.size(); ++i)
+ + vector_partitioner->ghost_indices().n_elements();
+ for (std::size_t i=0; i<dof_indices.size(); ++i)
AssertIndexRange (dof_indices[i], index_range);
// sanity check 2: for the constraint indicators, the first index should
// sanity check 3: all non-boundary cells should have indices that only
// refer to the locally owned range
- const types::global_dof_index local_size = (vector_partitioner->local_range().second-
+ const unsigned int local_size = (vector_partitioner->local_range().second-
vector_partitioner->local_range().first);
for (unsigned int row=0; row<size_info.boundary_cells_start; ++row)
{
- const types::global_dof_index *ptr = begin_indices(row);
- const types::global_dof_index *end_ptr = end_indices (row);
+ const unsigned int *ptr = begin_indices(row);
+ const unsigned int *end_ptr = end_indices (row);
for ( ; ptr != end_ptr; ++ptr)
AssertIndexRange (*ptr, local_size);
}
for (unsigned int row=size_info.boundary_cells_end;
row<size_info.n_macro_cells; ++row)
{
- const types::global_dof_index *ptr = begin_indices(row);
- const types::global_dof_index *end_ptr = end_indices (row);
+ const unsigned int *ptr = begin_indices(row);
+ const unsigned int *end_ptr = end_indices (row);
for ( ; ptr != end_ptr; ++ptr)
AssertIndexRange (*ptr, local_size);
}
void DoFInfo::make_thread_graph_partition_color
- (SizeInfo &size_info,
- TaskInfo &task_info,
- std::vector<types::global_dof_index> &renumbering,
- std::vector<unsigned int> &irregular_cells,
- const bool hp_bool)
+ (SizeInfo &size_info,
+ TaskInfo &task_info,
+ std::vector<unsigned int> &renumbering,
+ std::vector<unsigned int> &irregular_cells,
+ const bool hp_bool)
{
if (size_info.n_macro_cells == 0)
return;
// yet assigned a partition.
std::vector<unsigned int> cell_partition(task_info.n_blocks,
size_info.n_macro_cells);
- std::vector<types::global_dof_index> neighbor_list;
- std::vector<types::global_dof_index> neighbor_neighbor_list;
+ std::vector<unsigned int> neighbor_list;
+ std::vector<unsigned int> neighbor_neighbor_list;
// In element j of this variable, one puts the old number of the block
// that should be the jth block in the new numeration.
- std::vector<types::global_dof_index> partition_list (task_info.n_blocks,0);
+ std::vector<unsigned int> partition_list (task_info.n_blocks,0);
std::vector<unsigned int> partition_color_list(task_info.n_blocks,0);
// This vector points to the start of each partition.
k++)
{
unsigned int cell = partition_list[k];
- unsigned int no_neighbors = connectivity.row_length(cell);
+ unsigned int n_neighbors = connectivity.row_length(cell);
// In the worst case, each neighbor has a different color. So we
- // find at least one available color between 0 and no_neighbors.
- color_finder.resize(no_neighbors+1);
- for (unsigned int j=0; j<=no_neighbors; ++j)
+ // find at least one available color between 0 and n_neighbors.
+ color_finder.resize(n_neighbors+1);
+ for (unsigned int j=0; j<=n_neighbors; ++j)
color_finder[j]=true;
CompressedSimpleSparsityPattern::row_iterator
neighbor = connectivity.row_begin(cell),
// Mark the color that a neighbor within the partition has
// as taken
if (cell_partition[*neighbor] == part &&
- cell_color[*neighbor] <= no_neighbors)
+ cell_color[*neighbor] <= n_neighbors)
color_finder[cell_color[*neighbor]] = false;
}
// Choose the smallest color that is not taken for the block
// check that the renumbering is one-to-one
#ifdef DEBUG
{
- std::vector<types::global_dof_index> sorted_renumbering (renumbering);
+ std::vector<unsigned int> sorted_renumbering (renumbering);
std::sort(sorted_renumbering.begin(), sorted_renumbering.end());
for (unsigned int i=0; i<sorted_renumbering.size(); ++i)
Assert(sorted_renumbering[i] == i, ExcInternalError());
void
DoFInfo::make_thread_graph_partition_partition
- (SizeInfo &size_info,
- TaskInfo &task_info,
- std::vector<types::global_dof_index> &renumbering,
- std::vector<unsigned int> &irregular_cells,
- const bool hp_bool)
+ (SizeInfo &size_info,
+ TaskInfo &task_info,
+ std::vector<unsigned int> &renumbering,
+ std::vector<unsigned int> &irregular_cells,
+ const bool hp_bool)
{
if (size_info.n_macro_cells == 0)
return;
// In element j of this variable, one puts the old number of the block
// that should be the jth block in the new numeration.
std::vector<unsigned int> partition_list(size_info.n_active_cells,0);
- std::vector<types::global_dof_index> partition_partition_list(size_info.n_active_cells,0);
+ std::vector<unsigned int> partition_partition_list(size_info.n_active_cells,0);
// This vector points to the start of each partition.
std::vector<unsigned int> partition_size(2,0);
missing_macros = 0;
std::vector<unsigned int> remaining_per_macro_cell
(max_fe_index);
- std::vector<std::vector<types::global_dof_index> >
+ std::vector<std::vector<unsigned int> >
renumbering_fe_index;
unsigned int cell;
bool filled = true;
reserve (2000);
}
- void reserve (const types::global_dof_index size)
+ void reserve (const std::size_t size)
{
if (size > 0)
this->std::vector<types::global_dof_index>::reserve (size);
// insert a given entry. dat is a pointer within this vector (the user
// needs to make sure that it really stays there)
- void insert (const types::global_dof_index entry,
+ void insert (const unsigned int entry,
std::vector<types::global_dof_index>::iterator &dat)
{
- AssertIndexRange (static_cast<types::global_dof_index>(dat - begin()), size()+1);
- AssertIndexRange (static_cast<types::global_dof_index>(end() - dat), size()+1);
+ AssertIndexRange (static_cast<std::size_t>(dat - begin()), size()+1);
+ AssertIndexRange (static_cast<std::size_t>(end() - dat), size()+1);
AssertIndexRange (size(), capacity());
while (dat != end() && *dat < entry)
++dat;
DoFInfo::make_connectivity_graph
(const SizeInfo &size_info,
const TaskInfo &task_info,
- const std::vector<types::global_dof_index> &renumbering,
+ const std::vector<unsigned int> &renumbering,
const std::vector<unsigned int> &irregular_cells,
const bool do_blocking,
CompressedSimpleSparsityPattern &connectivity) const
{
AssertDimension (row_starts.size()-1, size_info.n_active_cells);
- const types::global_dof_index n_rows =
- (vector_partitioner->local_range().second-
- vector_partitioner->local_range().first)
- + vector_partitioner->ghost_indices().n_elements();
- const types::global_dof_index n_blocks = (do_blocking == true) ?
+ const unsigned int n_rows =
+ (vector_partitioner->local_range().second-
+ vector_partitioner->local_range().first)
+ + vector_partitioner->ghost_indices().n_elements();
+ const unsigned int n_blocks = (do_blocking == true) ?
task_info.n_blocks : size_info.n_active_cells;
// first determine row lengths
std::vector<unsigned int> row_lengths(n_rows);
unsigned int cell_start = 0, mcell_start = 0;
- std::vector<types::global_dof_index> scratch;
+ std::vector<unsigned int> scratch;
for (unsigned int block = 0; block < n_blocks; ++block)
{
// if we have the blocking variant (used in the coloring scheme), we
scratch.insert(scratch.end(),
begin_indices(block), end_indices(block));
std::sort(scratch.begin(), scratch.end());
- const types::global_dof_index n_unique =
+ const unsigned int n_unique =
std::unique(scratch.begin(), scratch.end())-scratch.begin();
- for (types::global_dof_index i=0; i<n_unique; ++i)
+ for (unsigned int i=0; i<n_unique; ++i)
row_lengths[scratch[i]]++;
}
}
// disregard dofs that only sit on one cell
- for (types::global_dof_index row=0; row<n_rows; ++row)
+ for (unsigned int row=0; row<n_rows; ++row)
if (row_lengths[row] == 1)
row_lengths[row] = 0;
for (unsigned int cell = cell_start; cell < cell_start+n_comp;
++cell)
{
- const types::global_dof_index
+ const unsigned int
*it = begin_indices (renumbering[cell]),
*end_cell = end_indices (renumbering[cell]);
for ( ; it != end_cell; ++it)
}
else
{
- const types::global_dof_index
+ const unsigned int
*it = begin_indices (block),
*end_cell = end_indices (block);
for ( ; it != end_cell; ++it)
++cell)
{
// apply renumbering when we do blocking
- const types::global_dof_index
+ const unsigned int
*it = begin_indices (renumbering[cell]),
*end_cell = end_indices (renumbering[cell]);
for ( ; it != end_cell; ++it)
}
else
{
- const types::global_dof_index *it = begin_indices (block),
- * end_cell = end_indices (block);
+ const unsigned int *it = begin_indices (block),
+ * end_cell = end_indices (block);
for ( ; it != end_cell; ++it)
if (row_lengths[*it] > 0)
{
renumbering.resize (local_size, numbers::invalid_dof_index);
types::global_dof_index counter = 0;
- std::vector<types::global_dof_index>::iterator dof_ind = dof_indices.begin(),
+ std::vector<unsigned int>::iterator dof_ind = dof_indices.begin(),
end_ind = dof_indices.end();
for ( ; dof_ind != end_ind; ++dof_ind)
{
}
AssertIndexRange (counter, local_size+1);
- for (size_dof i=0; i<renumbering.size(); ++i)
+ for (std::size_t i=0; i<renumbering.size(); ++i)
if (renumbering[i] == numbers::invalid_dof_index)
renumbering[i] = counter++;
// adjust the constrained DoFs
- std::vector<types::global_dof_index> new_constrained_dofs (constrained_dofs.size());
- for (size_dof i=0; i<constrained_dofs.size(); ++i)
+ std::vector<unsigned int> new_constrained_dofs (constrained_dofs.size());
+ for (std::size_t i=0; i<constrained_dofs.size(); ++i)
new_constrained_dofs[i] = renumbering[constrained_dofs[i]];
// the new constrained DoFs should be sorted already as they are not
// contained in dof_indices and then get contiguous numbers
#ifdef DEBUG
- for (size_dof i=1; i<new_constrained_dofs.size(); ++i)
+ for (std::size_t i=1; i<new_constrained_dofs.size(); ++i)
Assert (new_constrained_dofs[i] > new_constrained_dofs[i-1], ExcInternalError());
#endif
std::swap (constrained_dofs, new_constrained_dofs);
+ // transform indices to global index space
+ for (std::size_t i=0; i<renumbering.size(); ++i)
+ renumbering[i] = vector_partitioner->local_to_global(renumbering[i]);
+
AssertDimension (counter, renumbering.size());
}
DoFInfo::memory_consumption () const
{
std::size_t memory = sizeof(*this);
- memory += (row_starts.capacity()*sizeof(std_cxx1x::tuple<size_dof,
- size_constraint, unsigned int>));
+ memory += (row_starts.capacity()*sizeof(std_cxx1x::array<unsigned int,3>));
memory += MemoryConsumption::memory_consumption (dof_indices);
memory += MemoryConsumption::memory_consumption (row_starts_plain_indices);
memory += MemoryConsumption::memory_consumption (plain_dof_indices);
{
out << " Memory row starts indices: ";
size_info.print_memory_statistics
- (out, (row_starts.capacity()*sizeof(std_cxx1x::tuple<size_dof, size_constraint, unsigned int>)));
+ (out, (row_starts.capacity()*sizeof(std_cxx1x::array<unsigned int, 3>)));
out << " Memory dof indices: ";
size_info.print_memory_statistics
(out, MemoryConsumption::memory_consumption (dof_indices));
for (unsigned int row=0 ; row<n_rows ; ++row)
{
out << "Entries row " << row << ": ";
- const types::global_dof_index
- *glob_indices = begin_indices(row),
- *end_row = end_indices(row);
+ const unsigned int *glob_indices = begin_indices(row),
+ *end_row = end_indices(row);
unsigned int index = 0;
const std::pair<unsigned short,unsigned short>
*con_it = begin_indicators(row),
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2011, 2012 by the deal.II authors
+// Copyright (C) 2011 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__matrix_free_fe_evaluation_h
#define __deal2__matrix_free_fe_evaluation_h
{
typedef typename VectorType::BlockType BaseVectorType;
- static BaseVectorType* get_vector_component (VectorType &vec,
+ static BaseVectorType *get_vector_component (VectorType &vec,
const unsigned int component)
{
AssertIndexRange (component, vec.n_blocks());
{
typedef VectorType BaseVectorType;
- static BaseVectorType* get_vector_component (VectorType &vec,
+ static BaseVectorType *get_vector_component (VectorType &vec,
const unsigned int)
{
return &vec;
// loop over all local dofs. ind_local holds local number on cell, index
// iterates over the elements of index_local_to_global and dof_indices
// points to the global indices stored in index_local_to_global
- const types::global_dof_index *dof_indices = dof_info.begin_indices(cell);
+ const unsigned int *dof_indices = dof_info.begin_indices(cell);
const std::pair<unsigned short,unsigned short> *indicators =
dof_info.begin_indicators(cell);
const std::pair<unsigned short,unsigned short> *indicators_end =
dof_info.end_indicators(cell);
unsigned int ind_local = 0;
- const unsigned int n_irreg_components_filled =
- std_cxx1x::get<2>(dof_info.row_starts[cell]);
+ const unsigned int n_irreg_components_filled = dof_info.row_starts[cell][2];
const bool at_irregular_cell = n_irreg_components_filled > 0;
// scalar case (or case when all components have the same degrees of freedom
// select between block vectors and non-block vectors. Note that the number
// of components is checked in the internal data
typename internal::BlockVectorSelector<VectorType,
- IsBlockVector<VectorType>::value>::BaseVectorType *src_data[n_components];
+ IsBlockVector<VectorType>::value>::BaseVectorType *src_data[n_components];
for (unsigned int d=0; d<n_components; ++d)
src_data[d] = internal::BlockVectorSelector<VectorType, IsBlockVector<VectorType>::value>::get_vector_component(const_cast<VectorType &>(src), d);
// select between block vectors and non-block vectors. Note that the number
// of components is checked in the internal data
const typename internal::BlockVectorSelector<VectorType,
- IsBlockVector<VectorType>::value>::BaseVectorType *src_data[n_components];
+ IsBlockVector<VectorType>::value>::BaseVectorType *src_data[n_components];
for (unsigned int d=0; d<n_components; ++d)
src_data[d] = internal::BlockVectorSelector<VectorType, IsBlockVector<VectorType>::value>::get_vector_component(const_cast<VectorType &>(src), d);
// select between block vectors and non-block vectors. Note that the number
// of components is checked in the internal data
typename internal::BlockVectorSelector<VectorType,
- IsBlockVector<VectorType>::value>::BaseVectorType *dst_data[n_components];
+ IsBlockVector<VectorType>::value>::BaseVectorType *dst_data[n_components];
for (unsigned int d=0; d<n_components; ++d)
dst_data[d] = internal::BlockVectorSelector<VectorType, IsBlockVector<VectorType>::value>::get_vector_component(dst, d);
// select between block vectors and non-block vectors. Note that the number
// of components is checked in the internal data
typename internal::BlockVectorSelector<VectorType,
- IsBlockVector<VectorType>::value>::BaseVectorType *dst_data[n_components];
+ IsBlockVector<VectorType>::value>::BaseVectorType *dst_data[n_components];
for (unsigned int d=0; d<n_components; ++d)
dst_data[d] = internal::BlockVectorSelector<VectorType, IsBlockVector<VectorType>::value>::get_vector_component(dst, d);
// loop over all local dofs. ind_local holds local number on cell, index
// iterates over the elements of index_local_to_global and dof_indices
// points to the global indices stored in index_local_to_global
- const types::global_dof_index *dof_indices = dof_info.begin_indices_plain(cell);
+ const unsigned int *dof_indices = dof_info.begin_indices_plain(cell);
- const unsigned int n_irreg_components_filled =
- std_cxx1x::get<2>(dof_info.row_starts[cell]);
+ const unsigned int n_irreg_components_filled = dof_info.row_starts[cell][2];
const bool at_irregular_cell = n_irreg_components_filled > 0;
// scalar case (or case when all components have the same degrees of freedom
inline
void
apply_tensor_product_values (const VectorizedArray<Number> *shape_values,
- const VectorizedArray<Number> in [],
- VectorizedArray<Number> out [])
+ const VectorizedArray<Number> in [],
+ VectorizedArray<Number> out [])
{
AssertIndexRange (direction, dim);
const int mm = dof_to_quad ? (fe_degree+1) : n_q_points_1d,
- nn = dof_to_quad ? n_q_points_1d : (fe_degree+1);
+ nn = dof_to_quad ? n_q_points_1d : (fe_degree+1);
const int n_cols = nn / 2;
const int mid = mm / 2;
{
for (int col=0; col<n_cols; ++col)
{
- VectorizedArray<Number> val0, val1, in0, in1, res0, res1;
- if (dof_to_quad == true)
- {
- val0 = shape_values[col];
- val1 = shape_values[nn-1-col];
- }
- else
- {
- val0 = shape_values[col*n_q_points_1d];
- val1 = shape_values[(col+1)*n_q_points_1d-1];
- }
- if (mid > 0)
- {
- in0 = in[0];
- in1 = in[stride*(mm-1)];
- res0 = val0 * in0;
- res1 = val1 * in0;
- res0 += val1 * in1;
- res1 += val0 * in1;
- for (int ind=1; ind<mid; ++ind)
- {
- if (dof_to_quad == true)
- {
- val0 = shape_values[ind*n_q_points_1d+col];
- val1 = shape_values[ind*n_q_points_1d+nn-1-col];
- }
- else
- {
- val0 = shape_values[col*n_q_points_1d+ind];
- val1 = shape_values[(col+1)*n_q_points_1d-1-ind];
- }
- in0 = in[stride*ind];
- in1 = in[stride*(mm-1-ind)];
- res0 += val0 * in0;
- res1 += val1 * in0;
- res0 += val1 * in1;
- res1 += val0 * in1;
- }
- }
- else
- res0 = res1 = VectorizedArray<Number>();
- if (dof_to_quad == true)
- {
- if (mm % 2 == 1)
- {
- val0 = shape_values[mid*n_q_points_1d+col];
- val1 = val0 * in[stride*mid];
- res0 += val1;
- res1 += val1;
- }
- }
- else
- {
- if (mm % 2 == 1 && nn % 2 == 0)
- {
- val0 = shape_values[col*n_q_points_1d+mid];
- val1 = val0 * in[stride*mid];
- res0 += val1;
- res1 += val1;
- }
- }
- if (add == false)
- {
- out[stride*col] = res0;
- out[stride*(nn-1-col)] = res1;
- }
- else
- {
- out[stride*col] += res0;
- out[stride*(nn-1-col)] += res1;
- }
+ VectorizedArray<Number> val0, val1, in0, in1, res0, res1;
+ if (dof_to_quad == true)
+ {
+ val0 = shape_values[col];
+ val1 = shape_values[nn-1-col];
+ }
+ else
+ {
+ val0 = shape_values[col*n_q_points_1d];
+ val1 = shape_values[(col+1)*n_q_points_1d-1];
+ }
+ if (mid > 0)
+ {
+ in0 = in[0];
+ in1 = in[stride*(mm-1)];
+ res0 = val0 * in0;
+ res1 = val1 * in0;
+ res0 += val1 * in1;
+ res1 += val0 * in1;
+ for (int ind=1; ind<mid; ++ind)
+ {
+ if (dof_to_quad == true)
+ {
+ val0 = shape_values[ind*n_q_points_1d+col];
+ val1 = shape_values[ind*n_q_points_1d+nn-1-col];
+ }
+ else
+ {
+ val0 = shape_values[col*n_q_points_1d+ind];
+ val1 = shape_values[(col+1)*n_q_points_1d-1-ind];
+ }
+ in0 = in[stride*ind];
+ in1 = in[stride*(mm-1-ind)];
+ res0 += val0 * in0;
+ res1 += val1 * in0;
+ res0 += val1 * in1;
+ res1 += val0 * in1;
+ }
+ }
+ else
+ res0 = res1 = VectorizedArray<Number>();
+ if (dof_to_quad == true)
+ {
+ if (mm % 2 == 1)
+ {
+ val0 = shape_values[mid*n_q_points_1d+col];
+ val1 = val0 * in[stride*mid];
+ res0 += val1;
+ res1 += val1;
+ }
+ }
+ else
+ {
+ if (mm % 2 == 1 && nn % 2 == 0)
+ {
+ val0 = shape_values[col*n_q_points_1d+mid];
+ val1 = val0 * in[stride*mid];
+ res0 += val1;
+ res1 += val1;
+ }
+ }
+ if (add == false)
+ {
+ out[stride*col] = res0;
+ out[stride*(nn-1-col)] = res1;
+ }
+ else
+ {
+ out[stride*col] += res0;
+ out[stride*(nn-1-col)] += res1;
+ }
}
if ( dof_to_quad == true && nn%2==1 && mm%2==1 )
{
- if (add==false)
- out[stride*n_cols] = in[stride*mid];
- else
- out[stride*n_cols] += in[stride*mid];
+ if (add==false)
+ out[stride*n_cols] = in[stride*mid];
+ else
+ out[stride*n_cols] += in[stride*mid];
}
else if (dof_to_quad == true && nn%2==1)
{
- VectorizedArray<Number> res0;
- VectorizedArray<Number> val0 = shape_values[n_cols];
- if (mid > 0)
- {
- res0 = in[0] + in[stride*(mm-1)];
- res0 *= val0;
- for (int ind=1; ind<mid; ++ind)
- {
- val0 = shape_values[ind*n_q_points_1d+n_cols];
- VectorizedArray<Number> val1 = in[stride*ind] + in[stride*(mm-1-ind)];
- val1 *= val0;
- res0 += val1;
- }
- }
- else
- res0 = VectorizedArray<Number>();
- if (add == false)
- out[stride*n_cols] = res0;
- else
- out[stride*n_cols] += res0;
+ VectorizedArray<Number> res0;
+ VectorizedArray<Number> val0 = shape_values[n_cols];
+ if (mid > 0)
+ {
+ res0 = in[0] + in[stride*(mm-1)];
+ res0 *= val0;
+ for (int ind=1; ind<mid; ++ind)
+ {
+ val0 = shape_values[ind*n_q_points_1d+n_cols];
+ VectorizedArray<Number> val1 = in[stride*ind] + in[stride*(mm-1-ind)];
+ val1 *= val0;
+ res0 += val1;
+ }
+ }
+ else
+ res0 = VectorizedArray<Number>();
+ if (add == false)
+ out[stride*n_cols] = res0;
+ else
+ out[stride*n_cols] += res0;
}
else if (dof_to_quad == false && nn%2 == 1)
{
- VectorizedArray<Number> res0;
- if (mid > 0)
- {
- VectorizedArray<Number> val0 = shape_values[n_cols*n_q_points_1d];
- res0 = in[0] + in[stride*(mm-1)];
- res0 *= val0;
- for (int ind=1; ind<mid; ++ind)
- {
- val0 = shape_values[n_cols*n_q_points_1d+ind];
- VectorizedArray<Number> val1 = in[stride*ind] + in[stride*(mm-1-ind)];
- val1 *= val0;
- res0 += val1;
- }
- if (mm % 2)
- res0 += in[stride*mid];
- }
- else
- res0 = in[0];
- if (add == false)
- out[stride*n_cols] = res0;
- else
- out[stride*n_cols] += res0;
+ VectorizedArray<Number> res0;
+ if (mid > 0)
+ {
+ VectorizedArray<Number> val0 = shape_values[n_cols*n_q_points_1d];
+ res0 = in[0] + in[stride*(mm-1)];
+ res0 *= val0;
+ for (int ind=1; ind<mid; ++ind)
+ {
+ val0 = shape_values[n_cols*n_q_points_1d+ind];
+ VectorizedArray<Number> val1 = in[stride*ind] + in[stride*(mm-1-ind)];
+ val1 *= val0;
+ res0 += val1;
+ }
+ if (mm % 2)
+ res0 += in[stride*mid];
+ }
+ else
+ res0 = in[0];
+ if (add == false)
+ out[stride*n_cols] = res0;
+ else
+ out[stride*n_cols] += res0;
}
// increment: in regular case, just go to the next point in
switch (direction)
{
case 0:
- in += mm;
- out += nn;
- break;
+ in += mm;
+ out += nn;
+ break;
case 1:
case 2:
- ++in;
- ++out;
- break;
+ ++in;
+ ++out;
+ break;
default:
- Assert (false, ExcNotImplemented());
+ Assert (false, ExcNotImplemented());
}
}
if (direction == 1)
inline
void
apply_tensor_product_gradients (const VectorizedArray<Number> *shape_gradients,
- const VectorizedArray<Number> in [],
- VectorizedArray<Number> out [])
+ const VectorizedArray<Number> in [],
+ VectorizedArray<Number> out [])
{
AssertIndexRange (direction, dim);
const int mm = dof_to_quad ? (fe_degree+1) : n_q_points_1d,
- nn = dof_to_quad ? n_q_points_1d : (fe_degree+1);
+ nn = dof_to_quad ? n_q_points_1d : (fe_degree+1);
const int n_cols = nn / 2;
const int mid = mm / 2;
inline
void
apply_tensor_product_hessians (const VectorizedArray<Number> *shape_hessians,
- const VectorizedArray<Number> in [],
- VectorizedArray<Number> out [])
+ const VectorizedArray<Number> in [],
+ VectorizedArray<Number> out [])
{
AssertIndexRange (direction, dim);
const int mm = dof_to_quad ? (fe_degree+1) : n_q_points_1d,
- nn = dof_to_quad ? n_q_points_1d : (fe_degree+1);
+ nn = dof_to_quad ? n_q_points_1d : (fe_degree+1);
const int n_cols = nn / 2;
const int mid = mm / 2;
inline
void
apply_tensor_product_gradients_gl (const VectorizedArray<Number> *shape_gradients,
- const VectorizedArray<Number> in [],
- VectorizedArray<Number> out [])
+ const VectorizedArray<Number> in [],
+ VectorizedArray<Number> out [])
{
AssertIndexRange (direction, dim);
const int mm = fe_degree+1;
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2011 by the deal.II authors
+// Copyright (C) 2011 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__matrix_free_helper_functions_h
#define __deal2__matrix_free_helper_functions_h
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2011-2012 by the deal.II authors
+// Copyright (C) 2011 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__matrix_free_mapping_info_h
#define __deal2__matrix_free_mapping_info_h
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2011-2012 by the deal.II authors
+// Copyright (C) 2011 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/utilities.h>
#include <deal.II/base/memory_consumption.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2011, 2012 by the deal.II authors
+// Copyright (C) 2011 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__matrix_free_h
#define __deal2__matrix_free_h
/**
* Returns a list of all degrees of freedom that are constrained. The list
- * is returned in local index space for the locally owned range of the
- * vector, not in global numbers. In addition, it only returns the indices
- * for degrees of freedom that are owned locally, not for ghosts.
- */
- const std::vector<types::global_dof_index> &
+ * is returned in MPI-local index space for the locally owned range of the
+ * vector, not in global MPI index space that spans all MPI processors. To
+ * get numbers in global index space, call
+ * <tt>get_vector_partitioner()->local_to_global</tt> on an entry of the
+ * vector. In addition, it only returns the indices for degrees of freedom
+ * that are owned locally, not for ghosts.
+ */
+ const std::vector<unsigned int> &
get_constrained_dofs (const unsigned int fe_component = 0) const;
/**
- * Calls renumber_dofs function in dof info which renumbers the degrees
+ * Calls renumber_dofs function in dof_info which renumbers the degrees
* of freedom according to the ordering for parallelization.
*/
void renumber_dofs (std::vector<types::global_dof_index> &renumbering,
template <int dim, typename Number>
inline
-const std::vector<types::global_dof_index> &
+const std::vector<unsigned int> &
MatrixFree<dim,Number>::get_constrained_dofs (const unsigned int comp) const
{
AssertIndexRange (comp, n_components());
AssertIndexRange (dof_index, dof_handlers.n_dof_handlers);
AssertIndexRange (macro_cell_number, size_info.n_macro_cells);
AssertIndexRange (vector_number, vectorization_length);
- const unsigned int irreg_filled =
- std_cxx1x::get<2>(dof_info[dof_index].row_starts[macro_cell_number]);
+ const unsigned int irreg_filled = dof_info[dof_index].row_starts[macro_cell_number][2];
if (irreg_filled > 0)
AssertIndexRange (vector_number, irreg_filled);
#endif
AssertIndexRange (dof_index, dof_handlers.n_dof_handlers);
AssertIndexRange (macro_cell_number, size_info.n_macro_cells);
AssertIndexRange (vector_number, vectorization_length);
- const unsigned int irreg_filled =
- std_cxx1x::get<2>(dof_info[dof_index].row_starts[macro_cell_number]);
+ const unsigned int irreg_filled = dof_info[dof_index].row_starts[macro_cell_number][2];
if (irreg_filled > 0)
AssertIndexRange (vector_number, irreg_filled);
#endif
MatrixFree<dim,Number>::at_irregular_cell (const unsigned int macro_cell) const
{
AssertIndexRange (macro_cell, size_info.n_macro_cells);
- return std_cxx1x::get<2>(dof_info[0].row_starts[macro_cell]) > 0;
+ return dof_info[0].row_starts[macro_cell][2] > 0;
}
MatrixFree<dim,Number>::n_components_filled (const unsigned int macro_cell) const
{
AssertIndexRange (macro_cell, size_info.n_macro_cells);
- const unsigned int n_filled =
- std_cxx1x::get<2>(dof_info[0].row_starts[macro_cell]);
+ const unsigned int n_filled = dof_info[0].row_starts[macro_cell][2];
if (n_filled == 0)
return VectorizedArray<Number>::n_array_elements;
else
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2011, 2012 by the deal.II authors
+// Copyright (C) 2011 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/utilities.h>
#include <deal.II/base/memory_consumption.h>
dof_info[i].n_components = dof_handler[i]->get_fe().element_multiplicity(0);
dof_info[i].dofs_per_cell.push_back(dof_handler[i]->get_fe().dofs_per_cell);
dof_info[i].row_starts.resize(size_info.n_macro_cells+1);
- std_cxx1x::get<2>(dof_info[i].row_starts.back()) =
+ dof_info[i].row_starts.back()[2] =
cell_level_index.size() % VectorizedArray<Number>::n_array_elements;
// if indices are not initialized, the cell_level_index might not be
dof_info[i].n_components = dof_handler[i]->get_fe()[0].element_multiplicity(0);
dof_info[i].dofs_per_cell.push_back(dof_handler[i]->get_fe()[0].dofs_per_cell);
dof_info[i].row_starts.resize(size_info.n_macro_cells+1);
- std_cxx1x::get<2>(dof_info[i].row_starts.back()) =
+ dof_info[i].row_starts.back()[2] =
cell_level_index.size() % VectorizedArray<Number>::n_array_elements;
// if indices are not initialized, the cell_level_index might not be
{
const unsigned int n_fe = dof_handlers.n_dof_handlers;
const unsigned int n_active_cells = cell_level_index.size();
- const unsigned int n_mpi_procs = size_info.n_procs;
AssertDimension (n_active_cells, cell_level_index.size());
AssertDimension (n_fe, locally_owned_set.size());
AssertDimension (n_fe, constraint.size());
std::vector<types::global_dof_index> local_dof_indices;
- std::vector<std::vector<types::global_dof_index> > ghost_dofs(n_fe);
std::vector<std::vector<std::vector<unsigned int> > > lexicographic_inv(n_fe);
internal::MatrixFreeFunctions::ConstraintValues<double> constraint_values;
dynamic_cast<const FE_Poly<TensorProductPolynomials<dim>,dim,dim>*>
(&fe.base_element(0));
const FE_Poly<TensorProductPolynomials<dim,Polynomials::
- PiecewisePolynomial<double> >,dim,dim> *fe_poly_piece =
+ PiecewisePolynomial<double> >,dim,dim> *fe_poly_piece =
dynamic_cast<const FE_Poly<TensorProductPolynomials<dim,
Polynomials::PiecewisePolynomial<double> >,dim,dim>*>
(&fe.base_element(0));
// initialize the arrays for indices
dof_info[no].row_starts.resize (n_active_cells+1);
- dof_info[no].row_starts[0] = std_cxx1x::tuple<unsigned int,unsigned int,
- unsigned int> (0,0,0);
+ dof_info[no].row_starts[0][0] = 0;
+ dof_info[no].row_starts[0][1] = 0;
+ dof_info[no].row_starts[0][2] = 0;
dof_info[no].dof_indices.reserve
((n_active_cells*dof_info[no].dofs_per_cell[0]*3)/2);
end_index = dof_info[no].vector_partitioner->local_range().second;
for (types::global_dof_index i=start_index; i<end_index; ++i)
if (constraint[no]->is_constrained(i)==true)
- dof_info[no].constrained_dofs.push_back(i-start_index);
+ dof_info[no].constrained_dofs.
+ push_back(static_cast<unsigned int>(i-start_index));
}
-
- if (n_mpi_procs > 1)
- ghost_dofs[no].reserve (locally_owned_set[no].n_elements()/10+1);
}
// extract all the global indices associated with the computation, and form
// reorganize the indices in order to overlap communication in MPI with
// computations: Place all cells with ghost indices into one chunk. Also
// reorder cells so that we can parallelize by threads
- std::vector<types::global_dof_index> renumbering;
+ std::vector<unsigned int> renumbering;
if (task_info.use_multithreading == true)
{
dof_info[0].compute_renumber_parallel (boundary_cells, size_info,
// operations will then be done simultaneously).
#ifdef DEBUG
{
- std::vector<types::global_dof_index> sorted_renumbering (renumbering);
+ std::vector<unsigned int> sorted_renumbering (renumbering);
std::sort (sorted_renumbering.begin(), sorted_renumbering.end());
for (unsigned int i=0; i<sorted_renumbering.size(); ++i)
Assert (sorted_renumbering[i] == i, ExcInternalError());
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2011 by the deal.II authors
+// Copyright (C) 2011 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__matrix_free_shape_info_h
#define __deal2__matrix_free_shape_info_h
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2011, 2013 by the deal.II authors
+// Copyright (C) 2011 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/utilities.h>
#include <deal.II/base/memory_consumption.h>
const FE_Poly<TensorProductPolynomials<dim>,dim,dim> *fe_poly =
dynamic_cast<const FE_Poly<TensorProductPolynomials<dim>,dim,dim>*>(&fe);
const FE_Poly<TensorProductPolynomials<dim,Polynomials::
- PiecewisePolynomial<double> >,dim,dim> *fe_poly_piece =
+ PiecewisePolynomial<double> >,dim,dim> *fe_poly_piece =
dynamic_cast<const FE_Poly<TensorProductPolynomials<dim,
Polynomials::PiecewisePolynomial<double> >,dim,dim>*> (&fe);
Assert (fe_poly != 0 || fe_poly_piece, ExcNotImplemented());
lexicographic = fe_poly != 0 ?
- fe_poly->get_poly_space_numbering_inverse() :
- fe_poly_piece->get_poly_space_numbering_inverse();
+ fe_poly->get_poly_space_numbering_inverse() :
+ fe_poly_piece->get_poly_space_numbering_inverse();
// to evaluate 1D polynomials, evaluate along the line where y=z=0,
// assuming that shape_value(0,Point<dim>()) == 1. otherwise, need
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mesh_worker_assembler_h
#define __deal2__mesh_worker_assembler_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mesh_worker_dof_info_h
#define __deal2__mesh_worker_dof_info_h
* pointer empty, but setting
* the #aux_local_indices.
*/
- DoFInfo (const DoFHandler<dim, spacedim>& dof_handler);
+ DoFInfo (const DoFHandler<dim, spacedim> &dof_handler);
/**
* Set the current cell and
template <class DHFaceIterator>
void set_face (const DHFaceIterator &f,
const unsigned int face_no);
-
+
/**
* Switch to a new subface of the same cell. Does not change @p
* indices and does not reset data in LocalResults.
get_indices(c);
level_cell = c->is_level_cell();
- cell = static_cast<typename Triangulation<dim,spacedim>::cell_iterator> (c);
+ cell = typename Triangulation<dim,spacedim>::cell_iterator(*c);
face_number = deal_II_numbers::invalid_unsigned_int;
sub_number = deal_II_numbers::invalid_unsigned_int;
if (block_info)
const unsigned int face_no)
{
if ((cell.state() != IteratorState::valid)
- || cell != static_cast<typename Triangulation<dim>::cell_iterator> (c))
+ || cell != typename Triangulation<dim>::cell_iterator(*c))
get_indices(c);
level_cell = c->is_level_cell();
- cell = static_cast<typename Triangulation<dim>::cell_iterator> (c);
+ cell = typename Triangulation<dim>::cell_iterator(*c);
set_face(f,face_no);
if (block_info)
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/meshworker/dof_info.h>
#include <deal.II/base/quadrature_lib.h>
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mesh_worker_functional_h
#define __deal2__mesh_worker_functional_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mesh_worker_integration_info_h
#define __deal2__mesh_worker_integration_info_h
IntegrationInfo();
/**
- * Copy constructor, creating a
- * clone to be used by
+ * Copy constructor, creating a clone to be used by
* WorksTream::run().
*/
IntegrationInfo(const IntegrationInfo<dim, spacedim> &other);
/**
- * Build all internal
- * structures, in particular
- * the FEValuesBase objects
- * and allocate space for
- * data vectors.
+ * Build all internal structures, in particular the FEValuesBase
+ * objects and allocate space for data vectors.
*
- * @param el is the finite
- * element of the DoFHandler.
+ * @param el is the finite element of the DoFHandler.
*
- * @param mapping is the Mapping
- * object used to map the
- * mesh cells.
+ * @param mapping is the Mapping object used to map the mesh
+ * cells.
*
- * @param quadrature is a
- * Quadrature formula used in
- * the constructor of the
- * FEVALUES objects.
+ * @param quadrature is a Quadrature formula used in the
+ * constructor of the FEVALUES objects.
*
- * @param flags are the
- * UpdateFlags used in
- * the constructor of the
+ * @param flags are the UpdateFlags used in the constructor of the
* FEVALUES objects.
*
- * @param local_block_info is
- * an optional parameter for
- * systems of PDE. If it is
- * provided with reasonable
- * data, then the degrees of
- * freedom on the cells will be
- * re-ordered to reflect the
- * block structure of the system.
+ * @param local_block_info is an optional parameter for systems of
+ * PDE. If it is provided with reasonable data, then the degrees
+ * of freedom on the cells will be re-ordered to reflect the block
+ * structure of the system.
*/
template <class FEVALUES>
void initialize(const FiniteElement<dim,spacedim> &el,
const BlockInfo *local_block_info = 0);
/**
- * Initialize the data
- * vector and cache the
- * selector.
+ * Initialize the data vector and cache the selector.
*/
void initialize_data(const std_cxx1x::shared_ptr<VectorDataBase<dim,spacedim> > &data);
bool multigrid;
/// Access to finite element
/**
- * This is the access
- * function being used, if
- * the constructor for a
- * single element was
- * used. It throws an
- * exception, if applied to a
- * vector of elements.
+ * This is the access function being used, if the constructor for
+ * a single element was used. It throws an exception, if applied
+ * to a vector of elements.
*/
const FEValuesBase<dim, spacedim> &fe_values () const;
/// Access to finite elements
/**
- * This access function must
- * be used if the constructor
- * for a group of elements
- * was used.
+ * This access function must be used if the constructor for a
+ * group of elements was used.
*
* @see DGBlockSplitApplication
*/
const FEValuesBase<dim, spacedim> &fe_values (const unsigned int i) const;
/**
- * The vector containing the
- * values of finite element
- * functions in the quadrature
- * points.
+ * The vector containing the values of finite element functions in
+ * the quadrature points.
*
- * There is one vector per
- * selected finite element
- * function, containing one
- * vector for each component,
- * containing vectors with
- * values for each quadrature
- * point.
+ * There is one vector per selected finite element function,
+ * containing one vector for each component, containing vectors
+ * with values for each quadrature point.
*/
std::vector<std::vector<std::vector<double> > > values;
/**
- * The vector containing the
- * derivatives of finite
- * element functions in the
- * quadrature points.
+ * The vector containing the derivatives of finite element
+ * functions in the quadrature points.
*
- * There is one vector per
- * selected finite element
- * function, containing one
- * vector for each component,
- * containing vectors with
- * values for each quadrature
- * point.
+ * There is one vector per selected finite element function,
+ * containing one vector for each component, containing vectors
+ * with values for each quadrature point.
*/
std::vector<std::vector<std::vector<Tensor<1,dim> > > > gradients;
/**
- * The vector containing the
- * second derivatives of finite
- * element functions in the
- * quadrature points.
+ * The vector containing the second derivatives of finite element
+ * functions in the quadrature points.
*
- * There is one vector per
- * selected finite element
- * function, containing one
- * vector for each component,
- * containing vectors with
- * values for each quadrature
- * point.
+ * There is one vector per selected finite element function,
+ * containing one vector for each component, containing vectors
+ * with values for each quadrature point.
*/
std::vector<std::vector<std::vector<Tensor<2,dim> > > > hessians;
/**
- * Reinitialize internal data
- * structures for use on a cell.
+ * Reinitialize internal data structures for use on a cell.
*/
template <typename number>
void reinit(const DoFInfo<dim, spacedim, number> &i);
/**
- * Use the finite element
- * functions in #global_data
- * and fill the vectors
- * #values, #gradients and
- * #hessians.
+ * Use the finite element functions in #global_data and fill the
+ * vectors #values, #gradients and #hessians.
*/
template<typename number>
void fill_local_data(const DoFInfo<dim, spacedim, number> &info, bool split_fevalues);
/**
- * The global data vector
- * used to compute function
- * values in quadrature
- * points.
+ * The global data vector used to compute function values in
+ * quadrature points.
*/
std_cxx1x::shared_ptr<VectorDataBase<dim, spacedim> > global_data;
private:
/**
- * Use the finite element
- * functions in #global_data
- * and fill the vectors
- * #values, #gradients and
- * #hessians with values
- * according to the
- * selector.
+ * Use the finite element functions in #global_data and fill the
+ * vectors #values, #gradients and #hessians with values according
+ * to the selector.
*/
template <typename TYPE>
void fill_local_data(
VectorSelector &selector,
bool split_fevalues) const;
/**
- * Cache the number of
- * components of the system element.
+ * Cache the number of components of the system element.
*/
unsigned int n_components;
};
IntegrationInfoBox ();
/**
- * Initialize the
- * IntegrationInfo objects
- * contained.
+ * Initialize the IntegrationInfo objects contained.
*
- * Before doing so, add update
- * flags necessary to produce
- * the data needed and also
- * set uninitialized quadrature
- * rules to Gauss formulas,
- * which integrate polynomial
- * bilinear forms exactly.
+ * Before doing so, add update flags necessary to produce the data
+ * needed and also set uninitialized quadrature rules to Gauss
+ * formulas, which integrate polynomial bilinear forms exactly.
*/
void initialize(const FiniteElement<dim, spacedim> &el,
const Mapping<dim, spacedim> &mapping,
const BlockInfo *block_info = 0);
/**
- * Initialize the
- * IntegrationInfo objects
- * contained.
+ * Initialize the IntegrationInfo objects contained.
*
- * Before doing so, add update
- * flags necessary to produce
- * the data needed and also
- * set uninitialized quadrature
- * rules to Gauss formulas,
- * which integrate polynomial
- * bilinear forms exactly.
+ * Before doing so, add update flags necessary to produce the data
+ * needed and also set uninitialized quadrature rules to Gauss
+ * formulas, which integrate polynomial bilinear forms exactly.
*/
template <typename VECTOR>
void initialize(const FiniteElement<dim, spacedim> &el,
const BlockInfo *block_info = 0);
/**
- * Initialize the
- * IntegrationInfo objects
- * contained.
+ * Initialize the IntegrationInfo objects contained.
*
- * Before doing so, add update
- * flags necessary to produce
- * the data needed and also
- * set uninitialized quadrature
- * rules to Gauss formulas,
- * which integrate polynomial
- * bilinear forms exactly.
+ * Before doing so, add update flags necessary to produce the data
+ * needed and also set uninitialized quadrature rules to Gauss
+ * formulas, which integrate polynomial bilinear forms exactly.
*/
template <typename VECTOR>
void initialize(const FiniteElement<dim, spacedim> &el,
/* @{ */
/**
- * Call this function before
- * initialize() in order to
- * guess the update flags
- * needed, based on the data
- * selected.
+ * Call this function before initialize() in order to guess the
+ * update flags needed, based on the data selected.
*
- * When computing face fluxes,
- * we normally can use the
- * geometry (integration
- * weights and normal vectors)
- * from the original cell and
- * thus can avoid updating
- * these values on the
- * neighboring cell. Set
- * <tt>neighbor_geometry</tt>
- * to true in order to
- * initialize these values as
- * well.
+ * When computing face fluxes, we normally can use the geometry
+ * (integration weights and normal vectors) from the original cell
+ * and thus can avoid updating these values on the neighboring
+ * cell. Set <tt>neighbor_geometry</tt> to true in order to
+ * initialize these values as well.
*/
void initialize_update_flags(bool neighbor_geometry = false);
/**
- * Add FEValues UpdateFlags for
- * integration on all objects
- * (cells, boundary faces and
- * all interior faces).
+ * Add FEValues UpdateFlags for integration on all objects (cells,
+ * boundary faces and all interior faces).
*/
void add_update_flags_all (const UpdateFlags flags);
/**
- * Add FEValues UpdateFlags for
- * integration on cells.
+ * Add FEValues UpdateFlags for integration on cells.
*/
void add_update_flags_cell(const UpdateFlags flags);
/**
- * Add FEValues UpdateFlags for
- * integration on boundary faces.
+ * Add FEValues UpdateFlags for integration on boundary faces.
*/
void add_update_flags_boundary(const UpdateFlags flags);
/**
- * Add FEValues UpdateFlags for
- * integration on interior faces.
+ * Add FEValues UpdateFlags for integration on interior faces.
*/
void add_update_flags_face(const UpdateFlags flags);
/**
- * Add additional update flags
- * to the ones already set in
- * this program. The four
- * boolean flags indicate
- * whether the additional flags
- * should be set for cell,
- * boundary, interelement face
- * for the cell itself
- * or neighbor cell, or
- * any combination thereof.
+ * Add additional update flags to the ones already set in this
+ * program. The four boolean flags indicate whether the additional
+ * flags should be set for cell, boundary, interelement face for
+ * the cell itself or neighbor cell, or any combination thereof.
*/
void add_update_flags(const UpdateFlags flags,
const bool cell = true,
const bool neighbor = true);
/**
- * Assign n-point Gauss
- * quadratures to each of the
- * quadrature rules. Here, a
- * size of zero points means
- * that no loop over these grid
- * entities should be
- * performed.
+ * Assign n-point Gauss quadratures to each of the quadrature
+ * rules. Here, a size of zero points means that no loop over
+ * these grid entities should be performed.
*
- * If the parameter
- * <tt>force</tt> is true, then
- * all quadrature sets are
- * filled with new quadrature
- * ruels. If it is false, then
+ * If the parameter <tt>force</tt> is true, then all quadrature
+ * sets are filled with new quadrature ruels. If it is false, then
* only empty rules are changed.
*/
void initialize_gauss_quadrature(unsigned int n_cell_points,
std::size_t memory_consumption () const;
/**
- * The set of update flags
- * for boundary cell integration.
+ * The set of update flags for boundary cell integration.
*
- * Defaults to
- * #update_JxW_values.
+ * Defaults to #update_JxW_values.
*/
UpdateFlags cell_flags;
/**
- * The set of update flags
- * for boundary face integration.
+ * The set of update flags for boundary face integration.
*
- * Defaults to
- * #update_JxW_values and
- * #update_normal_vectors.
+ * Defaults to #update_JxW_values and #update_normal_vectors.
*/
UpdateFlags boundary_flags;
/**
- * The set of update flags
- * for interior face integration.
+ * The set of update flags for interior face integration.
*
- * Defaults to
- * #update_JxW_values and
- * #update_normal_vectors.
+ * Defaults to #update_JxW_values and #update_normal_vectors.
*/
UpdateFlags face_flags;
/**
- * The set of update flags
- * for interior face integration.
+ * The set of update flags for interior face integration.
*
- * Defaults to
- * #update_default, since
- * quadrature weights are
- * taken from the other cell.
+ * Defaults to #update_default, since quadrature weights are taken
+ * from the other cell.
*/
UpdateFlags neighbor_flags;
/**
- * The quadrature rule used
- * on cells.
+ * The quadrature rule used on cells.
*/
Quadrature<dim> cell_quadrature;
/**
- * The quadrature rule used
- * on boundary faces.
+ * The quadrature rule used on boundary faces.
*/
Quadrature<dim-1> boundary_quadrature;
/**
- * The quadrature rule used
- * on interior faces.
+ * The quadrature rule used on interior faces.
*/
Quadrature<dim-1> face_quadrature;
/* @} */
/* @{ */
/**
- * Initialize the
- * VectorSelector objects
- * #cell_selector,
- * #boundary_selector and
- * #face_selector in order to
- * save computational
- * effort. If no selectors
- * are used, then values for
- * all named vectors in
- * DoFInfo::global_data will be
- * computed in all quadrature
- * points.
+ * Initialize the VectorSelector objects #cell_selector,
+ * #boundary_selector and #face_selector in order to save
+ * computational effort. If no selectors are used, then values for
+ * all named vectors in DoFInfo::global_data will be computed in
+ * all quadrature points.
*
- * This function will also
- * add UpdateFlags to the
- * flags stored in this class.
+ * This function will also add UpdateFlags to the flags stored in
+ * this class.
*/
/**
- * Select the vectors from
- * DoFInfo::global_data
- * that should be computed in
- * the quadrature points on cells.
+ * Select the vectors from DoFInfo::global_data that should be
+ * computed in the quadrature points on cells.
*/
MeshWorker::VectorSelector cell_selector;
/**
- * Select the vectors from
- * DoFInfo::global_data
- * that should be computed in
- * the quadrature points on
- * boundary faces.
+ * Select the vectors from DoFInfo::global_data that should be
+ * computed in the quadrature points on boundary faces.
*/
MeshWorker::VectorSelector boundary_selector;
/**
- * Select the vectors from
- * DoFInfo::global_data
- * that should be computed in
- * the quadrature points on
- * interior faces.
+ * Select the vectors from DoFInfo::global_data that should be
+ * computed in the quadrature points on interior faces.
*/
MeshWorker::VectorSelector face_selector;
*/
/* @{ */
/**
- * A callback function which is
- * called in the loop over all
- * cells, after the action on a
- * cell has been performed and
- * before the faces are dealt
- * with.
+ * A callback function which is called in the loop over all cells,
+ * after the action on a cell has been performed and before the
+ * faces are dealt with.
*
- * In order for this function
- * to have this effect,
- * at least either of the
- * arguments
- * <tt>boundary_worker</tt> or
- * <tt>face_worker</tt>
- * arguments of loop() should
- * be nonzero. Additionally,
- * <tt>cells_first</tt> should
- * be true. If
- * <tt>cells_first</tt> is
- * false, this function is
- * called before any action on
- * a cell is taken.
+ * In order for this function to have this effect, at least either
+ * of the arguments <tt>boundary_worker</tt> or
+ * <tt>face_worker</tt> arguments of loop() should be
+ * nonzero. Additionally, <tt>cells_first</tt> should be true. If
+ * <tt>cells_first</tt> is false, this function is called before
+ * any action on a cell is taken.
*
- * And empty function in this
- * class, but can be replaced
- * in other classes given to
- * loop() instead.
+ * And empty function in this class, but can be replaced in other
+ * classes given to loop() instead.
*
- * See loop() and cell_action()
- * for more details of how this
+ * See loop() and cell_action() for more details of how this
* function can be used.
*/
template <class DOFINFO>
void post_cell(const DoFInfoBox<dim, DOFINFO> &);
/**
- * A callback function which is
- * called in the loop over all
- * cells, after the action on
- * the faces of a cell has been
- * performed and before the
- * cell itself is dealt with
- * (assumes
+ * A callback function which is called in the loop over all cells,
+ * after the action on the faces of a cell has been performed and
+ * before the cell itself is dealt with (assumes
* <tt>cells_first</tt> is false).
*
- * In order for this function
- * to have a reasonable effect,
- * at least either of the
- * arguments
- * <tt>boundary_worker</tt> or
- * <tt>face_worker</tt>
- * arguments of loop() should
- * be nonzero. Additionally,
- * <tt>cells_first</tt> should
- * be false.
+ * In order for this function to have a reasonable effect, at
+ * least either of the arguments <tt>boundary_worker</tt> or
+ * <tt>face_worker</tt> arguments of loop() should be
+ * nonzero. Additionally, <tt>cells_first</tt> should be false.
*
- * And empty function in this
- * class, but can be replaced
- * in other classes given to
- * loop() instead.
+ * And empty function in this class, but can be replaced in other
+ * classes given to loop() instead.
*
- * See loop() and cell_action()
- * for more details of how this
+ * See loop() and cell_action() for more details of how this
* function can be used.
*/
template <class DOFINFO>
*/
CellInfo cell;
/**
- * The info object for a
- * boundary face.
+ * The info object for a boundary face.
*/
CellInfo boundary;
/**
- * The info object for a
- * regular interior face, seen
- * from the first cell.
+ * The info object for a regular interior face, seen from the
+ * first cell.
*/
CellInfo face;
/**
- * The info object for the
- * refined side of an interior
- * face seen from the first
- * cell.
+ * The info object for the refined side of an interior face seen
+ * from the first cell.
*/
CellInfo subface;
/**
- * The info object for an
- * interior face, seen from the
- * other cell.
+ * The info object for an interior face, seen from the other cell.
*/
CellInfo neighbor;
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/meshworker/dof_info.h>
#include <deal.II/meshworker/integration_info.h>
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mesh_worker_local_integrator_h
#define __deal2__mesh_worker_local_integrator_h
* integrate on boundary and interior faces. Thes flags are true by
* default, but can be modified by applications to speed up the loop.
*
+ * If a function is not overloaded in a derived class, but its usage
+ * flag is true, the function will cause an exception
+ * ExcPureFunction.
+ *
* @ingroup MeshWorker
* @author Guido Kanschat
* @date 2012
{
public:
/**
- * The constructor setting
- * default values.
+ * The constructor setting default values, namely all integration flags to true.
*/
LocalIntegrator();
+ /**
+ * The constructor setting integration flags to specified values.
+ */
+ LocalIntegrator(bool use_cell, bool use_boundary, bool use_face);
+
/**
* The empty virtual destructor.
*/
~LocalIntegrator();
/**
- * Virtual function for
- * integrating on cells.
+ * Virtual function for integrating on cells. Throws exception
+ * PureFunctionCalled if not overloaded by a derived class.
*/
virtual void cell(DoFInfo<dim, spacedim, number> &dinfo,
- IntegrationInfo<dim, spacedim> &info) const = 0;
+ IntegrationInfo<dim, spacedim> &info) const;
/**
- * Virtual function for
- * integrating on boundary faces.
+ * Virtual function for integrating on boundary faces. Throws exception
+ * PureFunctionCalled if not overloaded by a derived class.
*/
virtual void boundary(DoFInfo<dim, spacedim, number> &dinfo,
- IntegrationInfo<dim, spacedim> &info) const = 0;
+ IntegrationInfo<dim, spacedim> &info) const;
/**
- * Virtual function for
- * integrating on interior faces.
+ * Virtual function for integrating on interior faces. Throws exception
+ * PureFunctionCalled if not overloaded by a derived class.
*/
virtual void face(DoFInfo<dim, spacedim, number> &dinfo1,
DoFInfo<dim, spacedim, number> &dinfo2,
IntegrationInfo<dim, spacedim> &info1,
- IntegrationInfo<dim, spacedim> &info2) const = 0;
+ IntegrationInfo<dim, spacedim> &info2) const;
/**
- * The flag indicating whether
- * the cell integrator cell()
- * is to be used in the
- * loop. Defaults to
- * <tt>true</tt>.
+ * The flag indicating whether the cell integrator cell() is to be
+ * used in the loop. Defaults to <tt>true</tt>.
*/
bool use_cell;
/**
- * The flag indicating whether
- * the boundary integrator
- * boundary() is to be
- * used in the loop. Defaults
- * to <tt>true</tt>.
+ * The flag indicating whether the boundary integrator boundary()
+ * is to be used in the loop. Defaults to <tt>true</tt>.
*/
bool use_boundary;
/**
- * The flag indicating whether
- * the interior face integrator
- * face() is to be used in the
- * loop. Defaults to
- * <tt>true</tt>.
+ * The flag indicating whether the interior face integrator face()
+ * is to be used in the loop. Defaults to <tt>true</tt>.
*/
bool use_face;
+ /**
+ * This error is thrown if one of the virtual functions cell(),
+ * boundary(), or face() is called without being overloaded in a
+ * derived class. Consider setting #use_cell, #use_boundary, and
+ * #use_face to false, respectively.
+ *
+ * @ingroup Exceptions
+ */
+ DeclException0(ExcPureFunction);
};
}
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mesh_worker_local_results_h
#define __deal2__mesh_worker_local_results_h
* @note This function is usually only called by the assembler.
*/
void initialize_numbers(const unsigned int n);
-
+
/**
* Initialize the vector with vector values.
*
* @note This function is usually only called by the assembler.
*/
void initialize_vectors(const unsigned int n);
-
+
/**
* Allocate @p n local matrices. Additionally, set their block row
* and column coordinates to zero. The matrices themselves are
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mesh_worker_loop_h
#define __deal2__mesh_worker_loop_h
DEAL_II_NAMESPACE_OPEN
template <typename> class TriaActiveIterator;
+template <typename> class FilteredIterator;
namespace internal
{
return true;
}
+ template <class ACCESSOR>
+ inline bool is_active_iterator(const FilteredIterator<TriaActiveIterator<ACCESSOR> > &)
+ {
+ return true;
+ }
+
template<int dim, class DOFINFO, class A>
void assemble(const MeshWorker::DoFInfoBox<dim, DOFINFO> &dinfo, A *assembler)
{
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mesh_worker_output_h
#define __deal2__mesh_worker_output_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mesh_worker_simple_h
#define __deal2__mesh_worker_simple_h
*/
SmartPointer<const ConstraintMatrix,ResidualSimple<VECTOR> > constraints;
};
-
-
+
+
/**
* Assemble local matrices into a single global matrix. If this global
* matrix has a block structure, this structure is not used, but
{
public:
/**
- * Constructor, initializing
- * the #threshold, which
- * limits how small numbers
- * may be to be entered into
- * the matrix.
+ * Constructor, initializing the #threshold, which limits how
+ * small numbers may be to be entered into the matrix.
*/
MGMatrixSimple(double threshold = 1.e-12);
/**
- * Store the result matrix
- * for later assembling.
+ * Store the result matrix for later assembling.
*/
void initialize(MGLevelObject<MATRIX> &m);
/**
- * Initialize the multilevel
- * constraints.
+ * Initialize the multilevel constraints.
*/
void initialize(const MGConstrainedDoFs &mg_constrained_dofs);
/**
- * @deprecated This function is of no effect. Only the block info
- * structure in DoFInfo is being used.
+ * @deprecated This function is of no effect. Only the block
+ * info structure in DoFInfo is being used.
*
* Store information on the local block structure. If the
* assembler is inititialized with this function,
*/
void initialize(MATRIX &m, VECTOR &rhs);
+ /**
+ * Initialize the constraints. After this function has been
+ * called with a valid ConstraintMatrix, the function
+ * ConstraintMatrix::distribute_local_to_global() will be used
+ * by assemble() to distribute the cell and face matrices into a
+ * global sparse matrix.
+ */
+ void initialize(const ConstraintMatrix &constraints);
+
/**
* Initialize the local data
* in the
inline void
ResidualSimple<MATRIX>::initialize_local_blocks(const BlockIndices &)
{}
-
-
+
+
template <class VECTOR>
template <class DOFINFO>
inline void
}
else
{
- if (info.indices_by_block.size() == 0)
- constraints->distribute_local_to_global(info.vector(k).block(0), info.indices, (*residuals(k)));
- else
- for (unsigned int i=0;i != info.vector(k).n_blocks();++i)
- constraints->distribute_local_to_global(info.vector(k).block(i), info.indices_by_block[i], (*residuals(k)));
- }
- }
+ if (info.indices_by_block.size() == 0)
+ constraints->distribute_local_to_global(info.vector(k).block(0), info.indices, (*residuals(k)));
+ else
+ for (unsigned int i=0; i != info.vector(k).n_blocks(); ++i)
+ constraints->distribute_local_to_global(info.vector(k).block(i), info.indices_by_block[i], (*residuals(k)));
+ }
+ }
}
template <class VECTOR>
}
else
{
- if (info1.indices_by_block.size() == 0 && info2.indices_by_block.size() == 0)
- {
- constraints->distribute_local_to_global
- (info1.vector(k).block(0), info1.indices, (*residuals(k)));
- constraints->distribute_local_to_global
- (info2.vector(k).block(0), info2.indices, (*residuals(k)));
- }
- else if (info1.indices_by_block.size() != 0 && info2.indices_by_block.size() != 0)
- {
- for (unsigned int i=0;i<info1.vector(k).n_blocks();++i)
- {
- constraints->distribute_local_to_global
- (info1.vector(k).block(i), info1.indices_by_block[i], (*residuals(k)));
- constraints->distribute_local_to_global
- (info2.vector(k).block(i), info2.indices_by_block[i], (*residuals(k)));
- }
- }
- else
- {
- Assert(false, ExcNotImplemented());
- }
+ if (info1.indices_by_block.size() == 0 && info2.indices_by_block.size() == 0)
+ {
+ constraints->distribute_local_to_global
+ (info1.vector(k).block(0), info1.indices, (*residuals(k)));
+ constraints->distribute_local_to_global
+ (info2.vector(k).block(0), info2.indices, (*residuals(k)));
+ }
+ else if (info1.indices_by_block.size() != 0 && info2.indices_by_block.size() != 0)
+ {
+ for (unsigned int i=0; i<info1.vector(k).n_blocks(); ++i)
+ {
+ constraints->distribute_local_to_global
+ (info1.vector(k).block(i), info1.indices_by_block[i], (*residuals(k)));
+ constraints->distribute_local_to_global
+ (info2.vector(k).block(i), info2.indices_by_block[i], (*residuals(k)));
+ }
+ }
+ else
+ {
+ Assert(false, ExcNotImplemented());
+ }
}
}
}
info2.indices_by_block[row], info1.indices_by_block[column]);
}
else
- {
- Assert(false, ExcNotImplemented());
- }
+ {
+ Assert(false, ExcNotImplemented());
+ }
}
{
if (mg_constrained_dofs->set_boundary_values())
{
- // At the
- // boundary,
- // only enter
- // the term
- // on the
- // diagonal,
- // but not
- // the
- // coupling terms
+ // At the boundary, only enter the term on the
+ // diagonal, but not the coupling terms
if ((!mg_constrained_dofs->is_boundary_index(level, i1[j]) &&
!mg_constrained_dofs->is_boundary_index(level, i2[k]))
||
for (unsigned int j=0; j<i1.size(); ++j)
for (unsigned int k=0; k<i2.size(); ++k)
if (std::fabs(M(k,j)) >= threshold)
- if (mg_constrained_dofs->at_refinement_edge(level, i1[j]) &&
- !mg_constrained_dofs->at_refinement_edge(level, i2[k]))
+ if (!mg_constrained_dofs->at_refinement_edge(level, i2[k]))
G.add(i1[j], i2[k], M(k,j));
}
}
for (unsigned int j=0; j<i1.size(); ++j)
for (unsigned int k=0; k<i2.size(); ++k)
if (std::fabs(M(j,k)) >= threshold)
- if (mg_constrained_dofs->at_refinement_edge(level, i1[j]) &&
- !mg_constrained_dofs->at_refinement_edge(level, i2[k]))
+ if (!mg_constrained_dofs->at_refinement_edge(level, i2[k]))
G.add(i1[j], i2[k], M(j,k));
}
}
{
AssertDimension(M.m(), i1.size());
AssertDimension(M.n(), i2.size());
-
- if (mg_constrained_dofs == 0)
- {
- for (unsigned int j=0; j<i1.size(); ++j)
- for (unsigned int k=0; k<i2.size(); ++k)
- if (std::fabs(M(j,k)) >= threshold)
- G.add(i1[j], i2[k], M(j,k));
- }
- else
- {
- for (unsigned int j=0; j<i1.size(); ++j)
- for (unsigned int k=0; k<i2.size(); ++k)
- if (std::fabs(M(j,k)) >= threshold)
- if (mg_constrained_dofs->at_refinement_edge(level, i1[j]) &&
- !mg_constrained_dofs->at_refinement_edge(level, i2[k]))
- {
- if (mg_constrained_dofs->set_boundary_values())
- {
- if ((!mg_constrained_dofs->at_refinement_edge_boundary(level, i1[j]) &&
- !mg_constrained_dofs->at_refinement_edge_boundary(level, i2[k]))
- ||
- (mg_constrained_dofs->at_refinement_edge_boundary(level, i1[j]) &&
- mg_constrained_dofs->at_refinement_edge_boundary(level, i2[k]) &&
- i1[j] == i2[k]))
- G.add(i1[j], i2[k], M(j,k));
- }
- else
- G.add(i1[j], i2[k], M(j,k));
- }
- }
+ Assert(mg_constrained_dofs != 0, ExcInternalError());
+
+ for (unsigned int j=0; j<i1.size(); ++j)
+ for (unsigned int k=0; k<i2.size(); ++k)
+ if (std::fabs(M(j,k)) >= threshold)
+ // Enter values into matrix only if j corresponds to a
+ // degree of freedom on the refinemenent edge, k does
+ // not, and both are not on the boundary. This is part
+ // the difference between the complete matrix with no
+ // boundary condition at the refinement edge and and
+ // the matrix assembled above by assemble().
+
+ // Thus the logic is: enter the row if it is
+ // constrained by hanging node constraints (actually,
+ // the whole refinement edge), but not if it is
+ // constrained by a boundary constraint.
+ if (mg_constrained_dofs->at_refinement_edge(level, i1[j]) &&
+ !mg_constrained_dofs->at_refinement_edge(level, i2[k]))
+ {
+ if (mg_constrained_dofs->set_boundary_values())
+ {
+ if ((!mg_constrained_dofs->at_refinement_edge_boundary(level, i1[j]) &&
+ !mg_constrained_dofs->at_refinement_edge_boundary(level, i2[k]))
+ ||
+ (mg_constrained_dofs->at_refinement_edge_boundary(level, i1[j]) &&
+ mg_constrained_dofs->at_refinement_edge_boundary(level, i2[k]) &&
+ i1[j] == i2[k]))
+ G.add(i1[j], i2[k], M(j,k));
+ }
+ else
+ G.add(i1[j], i2[k], M(j,k));
+ }
}
-
+
+
template <class MATRIX>
inline void
MGMatrixSimple<MATRIX>::assemble_out(
{
AssertDimension(M.n(), i1.size());
AssertDimension(M.m(), i2.size());
-
- if (mg_constrained_dofs == 0)
- {
- for (unsigned int j=0; j<i1.size(); ++j)
- for (unsigned int k=0; k<i2.size(); ++k)
- if (std::fabs(M(k,j)) >= threshold)
- G.add(i1[j], i2[k], M(k,j));
- }
- else
- {
- for (unsigned int j=0; j<i1.size(); ++j)
- for (unsigned int k=0; k<i2.size(); ++k)
- if (std::fabs(M(k,j)) >= threshold)
- if (mg_constrained_dofs->at_refinement_edge(level, i1[j]) &&
- !mg_constrained_dofs->at_refinement_edge(level, i2[k]))
- {
- if (mg_constrained_dofs->set_boundary_values())
- {
- if ((!mg_constrained_dofs->at_refinement_edge_boundary(level, i1[j]) &&
- !mg_constrained_dofs->at_refinement_edge_boundary(level, i2[k]))
- ||
- (mg_constrained_dofs->at_refinement_edge_boundary(level, i1[j]) &&
- mg_constrained_dofs->at_refinement_edge_boundary(level, i2[k]) &&
- i1[j] == i2[k]))
- G.add(i1[j], i2[k], M(k,j));
- }
- else
- G.add(i1[j], i2[k], M(k,j));
- }
- }
+ Assert(mg_constrained_dofs != 0, ExcInternalError());
+
+ for (unsigned int j=0; j<i1.size(); ++j)
+ for (unsigned int k=0; k<i2.size(); ++k)
+ if (std::fabs(M(k,j)) >= threshold)
+ if (mg_constrained_dofs->at_refinement_edge(level, i1[j]) &&
+ !mg_constrained_dofs->at_refinement_edge(level, i2[k]))
+ {
+ if (mg_constrained_dofs->set_boundary_values())
+ {
+ if ((!mg_constrained_dofs->at_refinement_edge_boundary(level, i1[j]) &&
+ !mg_constrained_dofs->at_refinement_edge_boundary(level, i2[k]))
+ ||
+ (mg_constrained_dofs->at_refinement_edge_boundary(level, i1[j]) &&
+ mg_constrained_dofs->at_refinement_edge_boundary(level, i2[k]) &&
+ i1[j] == i2[k]))
+ G.add(i1[j], i2[k], M(k,j));
+ }
+ else
+ G.add(i1[j], i2[k], M(k,j));
+ }
}
-
+
template <class MATRIX>
template <class DOFINFO>
ResidualSimple<VECTOR>::initialize(data);
}
+ template <class MATRIX, class VECTOR>
+ inline void
+ SystemSimple<MATRIX,VECTOR>::initialize(const ConstraintMatrix &c)
+ {
+ MatrixSimple<MATRIX>::initialize(c);
+ ResidualSimple<VECTOR>::initialize(c);
+ }
+
template <class MATRIX, class VECTOR>
template <class DOFINFO>
inline void
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mesh_worker_vector_selector_h
#define __deal2__mesh_worker_vector_selector_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/meshworker/vector_selector.h>
#include <deal.II/base/vector_slice.h>
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2010, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mg_base_h
#define __deal2__mg_base_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2010, 2012, 2013 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mg_block_smoother_h
#define __deal2__mg_block_smoother_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2002 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mg_coarse_h
#define __deal2__mg_coarse_h
template<typename number, class VECTOR>
void
MGCoarseGridHouseholder<number, VECTOR>::operator() (
- const unsigned int /*level*/,
- VECTOR &dst,
- const VECTOR &src) const
+ const unsigned int /*level*/,
+ VECTOR &dst,
+ const VECTOR &src) const
{
householder.least_squares(dst, src);
}
template<typename number, class VECTOR>
void
MGCoarseGridSVD<number, VECTOR>::operator() (
- const unsigned int /*level*/,
- VECTOR &dst,
- const VECTOR &src) const
+ const unsigned int /*level*/,
+ VECTOR &dst,
+ const VECTOR &src) const
{
matrix.vmult(dst, src);
}
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mg_constraints_h
#define __deal2__mg_constraints_h
class MGConstrainedDoFs : public Subscriptor
{
public:
-
+
typedef std::vector<std::set<types::global_dof_index> >::size_type size_dof;
/**
* Fill the internal data
void clear();
/**
- * Determine whether a dof index
- * is subject to a boundary
+ * Determine whether a dof index is subject to a boundary
* constraint.
*/
bool is_boundary_index (const unsigned int level,
const types::global_dof_index index) const;
/**
- * Determine whether a dof index
- * is at an edge that is not
- * a refinement edge.
+ * Determine whether a dof index is at an edge that is not a
+ * refinement edge.
*/
bool non_refinement_edge_index (const unsigned int level,
const types::global_dof_index index) const;
/**
- * Determine whether a dof index
- * is at the refinement edge.
+ * Determine whether a dof index is at the refinement edge.
*/
bool at_refinement_edge (const unsigned int level,
const types::global_dof_index index) const;
/**
- * Determine whether a dof index
- * is at the refinement edge and
- * subject to a boundary
- * constraint .
+ * Determine whether a dof index is at the refinement edge and
+ * subject to a boundary constraint .
*/
bool at_refinement_edge_boundary (const unsigned int level,
const types::global_dof_index index) const;
/**
- * Return the indices of dofs for each
- * level that lie on the boundary of the
- * domain.
+ * Return the indices of dofs for each level that lie on the
+ * boundary of the domain.
*/
const std::vector<std::set<types::global_dof_index> > &
get_boundary_indices () const;
/**
- * Return the indices of dofs for each
- * level that lie on the boundary of the
- * domain.
+ * Return the indices of dofs for each level that lie on the
+ * boundary of the domain.
*/
const std::vector<std::set<types::global_dof_index> > &
get_non_refinement_edge_indices () const;
/**
- * Return the indices of dofs for each
- * level that lie on the refinement edge
- * (i.e. are on faces between cells of
- * this level and cells on the level
- * below).
+ * Return the indices of dofs for each level that lie on the
+ * refinement edge (i.e. are on faces between cells of this level
+ * and cells on the level below).
*/
const std::vector<std::vector<bool> > &
get_refinement_edge_indices () const;
/**
- * Return the indices of dofs for each
- * level that are in the intersection of
- * the sets returned by
- * get_boundary_indices() and
+ * Return the indices of dofs for each level that are in the
+ * intersection of the sets returned by get_boundary_indices() and
* get_refinement_edge_indices().
*/
const std::vector<std::vector<bool> > &
get_refinement_edge_boundary_indices () const;
/**
- * Return if boundary_indices need to
- * be set or not.
+ * Return if boundary_indices need to be set or not.
*/
bool set_boundary_values () const;
/**
- * Return if the finite element requires
- * continuity across refinement edges.
+ * Return if the finite element requires continuity across
+ * refinement edges.
*/
bool continuity_across_refinement_edges () const;
private:
/**
- * The indices of boundary dofs
- * for each level.
+ * The indices of boundary dofs for each level.
*/
std::vector<std::set<types::global_dof_index> > boundary_indices;
/**
- * The degrees of freedom on egdges
- * that are not a
- * refinement edge between a
- * level and coarser cells.
+ * The degrees of freedom on egdges that are not a refinement edge
+ * between a level and coarser cells.
*/
std::vector<std::set<types::global_dof_index> > non_refinement_edge_indices;
/**
- * The degrees of freedom on the
- * refinement edge between a
- * level and coarser cells.
+ * The degrees of freedom on the refinement edge between a level and
+ * coarser cells.
*/
std::vector<std::vector<bool> > refinement_edge_indices;
/**
- * The degrees of freedom on the
- * refinement edge between a
- * level and coarser cells, which
- * are also on the boundary.
+ * The degrees of freedom on the refinement edge between a level and
+ * coarser cells, which are also on the boundary.
*
- * This is a subset of
- * #refinement_edge_indices.
+ * This is a subset of #refinement_edge_indices.
*/
std::vector<std::vector<bool> > refinement_edge_boundary_indices;
};
void
MGConstrainedDoFs::initialize(const DoFHandler<dim,spacedim> &dof)
{
- const unsigned int nlevels = dof.get_tria().n_levels();
+ const unsigned int nlevels = dof.get_tria().n_global_levels();
refinement_edge_indices.resize(nlevels);
refinement_edge_boundary_indices.resize(nlevels);
non_refinement_edge_indices.resize(nlevels);
const typename FunctionMap<dim>::type &function_map,
const ComponentMask &component_mask)
{
- const unsigned int nlevels = dof.get_tria().n_levels();
+ const unsigned int nlevels = dof.get_tria().n_global_levels();
boundary_indices.resize(nlevels);
refinement_edge_indices.resize(nlevels);
refinement_edge_boundary_indices.resize(nlevels);
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mg_dof_accessor_h
#define __deal2__mg_dof_accessor_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mg_dof_handler_h
#define __deal2__mg_dof_handler_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2010, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mg_dof_iterator_selector_h
#define __deal2__mg_dof_iterator_selector_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2005, 2006, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mg_matrix_h
#define __deal2__mg_matrix_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mg_smoother_h
#define __deal2__mg_smoother_h
{
if (this->debug > 0)
deallog << 'T';
- matrices[level].Tvmult(*r,u);
- r->sadd(-1.,1.,rhs);
+ if (i == 0 && u.all_zero())
+ *r = rhs;
+ else
+ {
+ matrices[level].Tvmult(*r,u);
+ r->sadd(-1.,1.,rhs);
+ }
if (this->debug > 2)
deallog << ' ' << r->l2_norm() << ' ';
smoothers[level].Tvmult(*d, *r);
{
if (this->debug > 0)
deallog << 'N';
- matrices[level].vmult(*r,u);
- r->sadd(-1.,rhs);
+ if (i == 0 && u.all_zero())
+ *r = rhs;
+ else
+ {
+ matrices[level].vmult(*r,u);
+ r->sadd(-1.,rhs);
+ }
if (this->debug > 2)
deallog << ' ' << r->l2_norm() << ' ';
smoothers[level].vmult(*d, *r);
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2007, 2008, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mg_tools_h
#define __deal2__mg_tools_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2012, 2013 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mg_transfer_h
#define __deal2__mg_transfer_h
{
typedef ::dealii::SparsityPattern Sparsity;
typedef ::dealii::SparseMatrix<typename VECTOR::value_type> Matrix;
-
+
template <class CSP, class DH>
- static void reinit(Matrix& matrix, Sparsity& sparsity, int level, const CSP& csp, const DH&)
+ static void reinit(Matrix &matrix, Sparsity &sparsity, int level, const CSP &csp, const DH &)
{
sparsity.copy_from (csp);
matrix.reinit (sparsity);
{
typedef ::dealii::TrilinosWrappers::SparsityPattern Sparsity;
typedef ::dealii::TrilinosWrappers::SparseMatrix Matrix;
-
+
template <class CSP, class DH>
- static void reinit(Matrix& matrix, Sparsity& sparsity, int level, const CSP& csp, DH& dh)
+ static void reinit(Matrix &matrix, Sparsity &sparsity, int level, const CSP &csp, DH &dh)
{
matrix.reinit(dh.locally_owned_mg_dofs(level+1),
- dh.locally_owned_mg_dofs(level),
- csp, MPI_COMM_WORLD, true);
+ dh.locally_owned_mg_dofs(level),
+ csp, MPI_COMM_WORLD, true);
}
-
+
};
template <>
{
typedef ::dealii::TrilinosWrappers::SparsityPattern Sparsity;
typedef ::dealii::TrilinosWrappers::SparseMatrix Matrix;
-
+
template <class CSP, class DH>
- static void reinit(Matrix& matrix, Sparsity& sparsity, int level, const CSP& csp, DH& dh)
+ static void reinit(Matrix &matrix, Sparsity &sparsity, int level, const CSP &csp, DH &dh)
{
}
};
* Memory used by this object.
*/
std::size_t memory_consumption () const;
-
+
/**
* Print all the matrices for debugging purposes.
*/
- void print_matrices(std::ostream& os) const;
+ void print_matrices(std::ostream &os) const;
/**
* Print the copy index fields for debugging purposes.
*/
- void print_indices(std::ostream& os) const;
-
+ void print_indices(std::ostream &os) const;
+
private:
/**
/**
* Mapping for the copy_to_mg() and copy_from_mg() functions. Here only
* index pairs locally owned
- *
+ *
* The data is organized as follows: one vector per level. Each
* element of these vectors contains first the global index, then
* the level index.
*/
std::vector<std::vector<std::pair<types::global_dof_index, unsigned int> > >
copy_indices_from_me;
-
+
/**
* The vector that stores what
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mg_transfer_templates_h
#define __deal2__mg_transfer_templates_h
// First copy all indices local to this process
if (constraints==0)
- for (IT i= copy_indices[level].begin();
- i != copy_indices[level].end(); ++i)
- dst(i->first) = src[level](i->second);
+ for (IT i= copy_indices[level].begin();
+ i != copy_indices[level].end(); ++i)
+ dst(i->first) = src[level](i->second);
else
- for (IT i= copy_indices[level].begin();
- i != copy_indices[level].end(); ++i)
- constraints->distribute_local_to_global(i->first, src[level](i->second), dst);
-
+ for (IT i= copy_indices[level].begin();
+ i != copy_indices[level].end(); ++i)
+ constraints->distribute_local_to_global(i->first, src[level](i->second), dst);
+
// Do the same for the indices where the level index is local,
// but the global index is not
if (constraints==0)
- for (IT i= copy_indices_from_me[level].begin();
- i != copy_indices_from_me[level].end(); ++i)
- dst(i->first) = src[level](i->second);
+ for (IT i= copy_indices_from_me[level].begin();
+ i != copy_indices_from_me[level].end(); ++i)
+ dst(i->first) = src[level](i->second);
else
- for (IT i= copy_indices_from_me[level].begin();
- i != copy_indices_from_me[level].end(); ++i)
- constraints->distribute_local_to_global(i->first, src[level](i->second), dst);
+ for (IT i= copy_indices_from_me[level].begin();
+ i != copy_indices_from_me[level].end(); ++i)
+ constraints->distribute_local_to_global(i->first, src[level](i->second), dst);
}
}
{
typedef std::vector<std::pair<types::global_dof_index, unsigned int> >::const_iterator IT;
if (constraints==0)
- for (IT i= copy_indices[level].begin();
- i != copy_indices[level].end(); ++i)
- dst(i->first) += src[level](i->second);
+ for (IT i= copy_indices[level].begin();
+ i != copy_indices[level].end(); ++i)
+ dst(i->first) += src[level](i->second);
else
- for (IT i= copy_indices[level].begin();
- i != copy_indices[level].end(); ++i)
- constraints->distribute_local_to_global(i->first, src[level](i->second), dst);
-
+ for (IT i= copy_indices[level].begin();
+ i != copy_indices[level].end(); ++i)
+ constraints->distribute_local_to_global(i->first, src[level](i->second), dst);
+
// Do the same for the indices where the level index is local,
// but the global index is not
if (constraints==0)
- for (IT i= copy_indices_from_me[level].begin();
- i != copy_indices_from_me[level].end(); ++i)
- dst(i->first) += src[level](i->second);
+ for (IT i= copy_indices_from_me[level].begin();
+ i != copy_indices_from_me[level].end(); ++i)
+ dst(i->first) += src[level](i->second);
else
- for (IT i= copy_indices_from_me[level].begin();
- i != copy_indices_from_me[level].end(); ++i)
- constraints->distribute_local_to_global(i->first, src[level](i->second), dst);
+ for (IT i= copy_indices_from_me[level].begin();
+ i != copy_indices_from_me[level].end(); ++i)
+ constraints->distribute_local_to_global(i->first, src[level](i->second), dst);
}
}
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mg_transfer_block_h
#define __deal2__mg_transfer_block_h
-//---------------------------------------------------------------------------
-// mg_transfer.templates.h,v 1.22 2006/01/29 15:03:55 guido Exp
-// Version:
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mg_transfer_block_templates_h
#define __deal2__mg_transfer_block_templates_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2010, 2012, 2013 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mg_transfer_component_h
#define __deal2__mg_transfer_component_h
#include <deal.II/base/config.h>
+#include <deal.II/base/std_cxx1x/shared_ptr.h>
#include <deal.II/lac/block_vector.h>
#include <deal.II/lac/constraint_matrix.h>
#include <deal.II/lac/sparsity_pattern.h>
#include <deal.II/lac/block_sparsity_pattern.h>
#include <deal.II/lac/vector_memory.h>
-#include <deal.II/multigrid/mg_base.h>
-#include <deal.II/fe/component_mask.h>
#include <deal.II/base/mg_level_object.h>
-
-
-
#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/fe/component_mask.h>
+#include <deal.II/multigrid/mg_base.h>
-#include <deal.II/base/std_cxx1x/shared_ptr.h>
DEAL_II_NAMESPACE_OPEN
-//---------------------------------------------------------------------------
-// mg_transfer.templates.h,v 1.22 2006/01/29 15:03:55 guido Exp
-// Version:
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__mg_transfer_component_templates_h
#define __deal2__mg_transfer_component_templates_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__multigrid_h
#define __deal2__multigrid_h
#include <deal.II/base/subscriptor.h>
#include <deal.II/base/smartpointer.h>
#include <deal.II/dofs/dof_handler.h>
-#include <deal.II/numerics/data_out.h>
#include <deal.II/lac/sparse_matrix.h>
#include <deal.II/lac/vector.h>
#include <deal.II/multigrid/mg_base.h>
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__multigrid_templates_h
#define __deal2__multigrid_templates_h
#include <deal.II/multigrid/multigrid.h>
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id: mg_matrix.h 30036 2013-07-18 16:55:32Z maier $
+//
+// Copyright (C) 2003 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+#ifndef __deal2__mg_sparse_matrix_collection_h
+#define __deal2__mg_sparse_matrix_collection_h
+
+#include <deal.II/lac/vector.h>
+#include <deal.II/lac/pointer_matrix.h>
+#include <deal.II/lac/sparse_matrix.h>
+#include <deal.II/lac/compressed_sparsity_pattern.h>
+#include <deal.II/multigrid/mg_base.h>
+#include <deal.II/multigrid/mg_tools.h>
+#include <deal.II/base/mg_level_object.h>
+#include <deal.II/base/std_cxx1x/shared_ptr.h>
+
+DEAL_II_NAMESPACE_OPEN
+
+namespace mg
+{
+/**
+ * Handler and storage for all five SparseMatrix object involved in
+ * using multigrid with local refinement.
+ *
+ * @author Baerbel Janssen, Guido Kanschat
+ * @date 2013
+ */
+ template <typename number>
+ class SparseMatrixCollection : public Subscriptor
+ {
+ public:
+ void resize(const unsigned int minlevel, const unsigned int maxlevel);
+
+ template <class DH>
+ void reinit(const DH& dof_handler);
+
+ void set_zero();
+
+ MGLevelObject<SparsityPattern> sparsity;
+ MGLevelObject<SparsityPattern> sparsity_edge;
+
+ MGLevelObject<SparseMatrix<number> > matrix;
+ MGLevelObject<SparseMatrix<number> > matrix_down;
+ MGLevelObject<SparseMatrix<number> > matrix_up;
+ MGLevelObject<SparseMatrix<number> > matrix_in;
+ MGLevelObject<SparseMatrix<number> > matrix_out;
+ };
+
+
+ template <typename number>
+ void
+ SparseMatrixCollection<number>::resize(const unsigned int minlevel, const unsigned int maxlevel)
+ {
+ matrix.resize(minlevel, maxlevel);
+ matrix.clear();
+ matrix_up.resize(minlevel+1, maxlevel);
+ matrix_up.clear();
+ matrix_down.resize(minlevel+1, maxlevel);
+ matrix_down.clear();
+ matrix_in.resize(minlevel, maxlevel);
+ matrix_in.clear();
+ matrix_out.resize(minlevel, maxlevel);
+ matrix_out.clear();
+ sparsity.resize(minlevel, maxlevel);
+ sparsity_edge.resize(minlevel, maxlevel);
+ }
+
+
+ template <typename number>
+ template <class DH>
+ void
+ SparseMatrixCollection<number>::reinit(const DH& dof_handler)
+ {
+ AssertIndexRange(sparsity.max_level(), dof_handler.get_tria().n_levels());
+
+ for (unsigned int level=sparsity.min_level();
+ level<=sparsity.max_level();++level)
+ {
+ CompressedSparsityPattern c_sparsity(dof_handler.n_dofs(level));
+ MGTools::make_flux_sparsity_pattern(dof_handler, c_sparsity, level);
+ sparsity[level].copy_from(c_sparsity);
+ matrix[level].reinit(sparsity[level]);
+ matrix_in[level].reinit(sparsity[level]);
+ matrix_out[level].reinit(sparsity[level]);
+ if (level>0)
+ {
+ CompressedSparsityPattern ci_sparsity;
+ ci_sparsity.reinit(dof_handler.n_dofs(level-1), dof_handler.n_dofs(level));
+ MGTools::make_flux_sparsity_pattern_edge(dof_handler, ci_sparsity, level);
+ sparsity_edge[level].copy_from(ci_sparsity);
+ matrix_up[level].reinit(sparsity_edge[level]);
+ matrix_down[level].reinit(sparsity_edge[level]);
+ }
+ }
+ }
+
+ template <typename number>
+ void
+ SparseMatrixCollection<number>::set_zero()
+ {
+ matrix = 0.;
+ matrix_in = 0.;
+ matrix_out = 0.;
+ matrix_up = 0.;
+ matrix_down = 0.;
+ }
+
+}
+
+DEAL_II_NAMESPACE_CLOSE
+
+#endif
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2007, 2008, 2012 by the deal.II authors
+// Copyright (C) 2007 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__data_component_interpretation_h
#define __deal2__data_component_interpretation_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__data_out_h
#define __deal2__data_out_h
#include <deal.II/base/config.h>
-#include <deal.II/base/smartpointer.h>
-#include <deal.II/base/data_out_base.h>
-#include <deal.II/dofs/dof_handler.h>
-#include <deal.II/fe/mapping.h>
-#include <deal.II/hp/q_collection.h>
-#include <deal.II/hp/fe_collection.h>
-#include <deal.II/hp/mapping_collection.h>
-#include <deal.II/hp/fe_values.h>
-#include <deal.II/numerics/data_postprocessor.h>
-#include <deal.II/numerics/data_component_interpretation.h>
+#include <deal.II/numerics/data_out_dof_data.h>
#include <deal.II/base/std_cxx1x/shared_ptr.h>
namespace DataOut
{
/**
- * For each vector that has been added
- * through the add_data_vector()
- * functions, we need to keep track of a
- * pointer to it, and allow data
- * extraction from it when we generate
- * patches. Unfortunately, we need to do
- * this for a number of different vector
- * types. Fortunately, they all have the
- * same interface. So the way we go is to
- * have a base class that provides the
- * functions to access the vector's
- * information, and to have a derived
- * template class that can be
- * instantiated for each vector
- * type. Since the vectors all have the
- * same interface, this is no big
- * problem, as they can all use the same
- * general templatized code.
- *
- * @author Wolfgang Bangerth, 2004
- */
- template <class DH>
- class DataEntryBase
- {
- public:
- /**
- * Constructor. Give a list of names
- * for the individual components of
- * the vector and their
- * interpretation as scalar or vector
- * data. This constructor assumes
- * that no postprocessor is going to
- * be used.
- */
- DataEntryBase (const std::vector<std::string> &names,
- const std::vector<DataComponentInterpretation::DataComponentInterpretation> &data_component_interpretation);
-
- /**
- * Constructor when a data
- * postprocessor is going to be
- * used. In that case, the names and
- * vector declarations are going to
- * be acquired from the postprocessor.
- */
- DataEntryBase (const DataPostprocessor<DH::space_dimension> *data_postprocessor);
-
- /**
- * Destructor made virtual.
- */
- virtual ~DataEntryBase ();
-
- /**
- * Assuming that the stored vector is
- * a cell vector, extract the given
- * element from it.
- */
- virtual
- double
- get_cell_data_value (const unsigned int cell_number) const = 0;
-
- /**
- * Given a FEValuesBase object,
- * extract the values on the present
- * cell from the vector we actually
- * store.
- */
- virtual
- void
- get_function_values (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
- std::vector<double> &patch_values) const = 0;
-
- /**
- * Given a FEValuesBase object,
- * extract the values on the present
- * cell from the vector we actually
- * store. This function does the same
- * as the one above but for
- * vector-valued finite elements.
- */
- virtual
- void
- get_function_values (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
- std::vector<dealii::Vector<double> > &patch_values_system) const = 0;
-
- /**
- * Given a FEValuesBase object,
- * extract the gradients on the present
- * cell from the vector we actually
- * store.
- */
- virtual
- void
- get_function_gradients (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
- std::vector<Tensor<1,DH::space_dimension> > &patch_gradients) const = 0;
-
- /**
- * Given a FEValuesBase object,
- * extract the gradients on the present
- * cell from the vector we actually
- * store. This function does the same
- * as the one above but for
- * vector-valued finite elements.
- */
- virtual
- void
- get_function_gradients (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
- std::vector<std::vector<Tensor<1,DH::space_dimension> > > &patch_gradients_system) const = 0;
-
- /**
- * Given a FEValuesBase object, extract
- * the second derivatives on the
- * present cell from the vector we
- * actually store.
- */
- virtual
- void
- get_function_hessians (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
- std::vector<Tensor<2,DH::space_dimension> > &patch_hessians) const = 0;
-
- /**
- * Given a FEValuesBase object, extract
- * the second derivatives on the
- * present cell from the vector we
- * actually store. This function does
- * the same as the one above but for
- * vector-valued finite elements.
- */
- virtual
- void
- get_function_hessians (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
- std::vector<std::vector< Tensor<2,DH::space_dimension> > > &patch_hessians_system) const = 0;
-
- /**
- * Clear all references to the
- * vectors.
- */
- virtual void clear () = 0;
-
- /**
- * Determine an estimate for
- * the memory consumption (in
- * bytes) of this object.
- */
- virtual std::size_t memory_consumption () const = 0;
-
- /**
- * Names of the components of this
- * data vector.
- */
- const std::vector<std::string> names;
-
- /**
- * A vector that for each of the
- * n_output_variables variables of
- * the current data set indicates
- * whether they are scalar fields,
- * parts of a vector-field, or any of
- * the other supported kinds of data.
- */
- const std::vector<DataComponentInterpretation::DataComponentInterpretation>
- data_component_interpretation;
-
- /**
- * Pointer to a DataPostprocessing
- * object which shall be applied to
- * this data vector.
- */
- SmartPointer<const dealii::DataPostprocessor<DH::space_dimension> > postprocessor;
-
- /**
- * Number of output variables this
- * dataset provides (either number of
- * components in vector valued function
- * / data vector or number of computed
- * quantities, if DataPostprocessor is
- * applied). This variable is
- * determined via and thus equivalent
- * to <tt>names.size()</tt>.
- */
- unsigned int n_output_variables;
- };
-
-
- /**
- * A data structure that holds
- * all data needed in one thread
- * when building patches in
- * parallel. These data
- * structures are created
- * globally rather than on each
- * cell to avoid allocation of
- * memory in the threads. This is
- * a base class for the
- * AdditionalData kind of data
- * structure discussed in the
- * documentation of the
- * WorkStream class.
- *
- * The
- * <code>cell_to_patch_index_map</code>
- * is an array that stores for index
- * <tt>[i][j]</tt> the number of the
- * patch that associated with the cell
- * with index @p j on level @p i. This
- * information is set up prior to
- * generation of the patches, and is
- * needed to generate neighborship
- * information.
- *
- * This structure is used by
- * several of the DataOut*
- * classes, which derived their
- * own ParallelData classes from
- * it for additional fields.
- */
- template <int dim, int spacedim>
- struct ParallelDataBase
- {
- template <class FE>
- ParallelDataBase (const unsigned int n_components,
- const unsigned int n_datasets,
- const unsigned int n_subdivisions,
- const unsigned int n_q_points,
- const std::vector<unsigned int> &n_postprocessor_outputs,
- const FE &finite_elements);
-
- const unsigned int n_components;
- const unsigned int n_datasets;
- const unsigned int n_subdivisions;
-
- std::vector<double> patch_values;
- std::vector<dealii::Vector<double> > patch_values_system;
- std::vector<Tensor<1,spacedim> > patch_gradients;
- std::vector<std::vector<Tensor<1,spacedim> > > patch_gradients_system;
- std::vector<Tensor<2,spacedim> > patch_hessians;
- std::vector<std::vector<Tensor<2,spacedim> > > patch_hessians_system;
- std::vector<std::vector<dealii::Vector<double> > > postprocessed_values;
-
- const dealii::hp::FECollection<dim,spacedim> fe_collection;
- };
-
-
- /**
- * A derived class for use in the
- * DataOut class. This is
- * a class for the
- * AdditionalData kind of data
- * structure discussed in the
- * documentation of the
- * WorkStream context.
+ * A derived class for use in the DataOut class. This is a class for the
+ * AdditionalData kind of data structure discussed in the documentation of
+ * the WorkStream context.
*/
template <int dim, int spacedim>
struct ParallelData : public ParallelDataBase<dim,spacedim>
{
- template <class FE>
- ParallelData (const Quadrature<dim> &quadrature,
- const unsigned int n_components,
- const unsigned int n_datasets,
+ ParallelData (const unsigned int n_datasets,
const unsigned int n_subdivisions,
const std::vector<unsigned int> &n_postprocessor_outputs,
const Mapping<dim,spacedim> &mapping,
- const std::vector<std::vector<unsigned int> > &cell_to_patch_index_map,
- const FE &finite_elements,
- const UpdateFlags update_flags);
-
- const dealii::hp::QCollection<dim> q_collection;
- const dealii::hp::MappingCollection<dim,spacedim> mapping_collection;
- dealii::hp::FEValues<dim,spacedim> x_fe_values;
+ const std::vector<std_cxx1x::shared_ptr<dealii::hp::FECollection<dim,spacedim> > > &finite_elements,
+ const UpdateFlags update_flags,
+ const std::vector<std::vector<unsigned int> > &cell_to_patch_index_map);
std::vector<Point<spacedim> > patch_evaluation_points;
}
-//TODO: Most of the documentation of DataOut_DoFData applies to DataOut.
/**
- * This is an abstract class which provides the functionality to
- * generate patches for output by base classes from data vectors on a
- * grid. It allows to store a pointer to a DoFHandler object and one
- * or more pointers to node and cell data denoting functions on the
- * grid which shall later be written in any of the implemented data
- * formats.
- *
- *
- * <h3>User visible interface</h3>
- *
- * The user visible interface of this class consists of functions which allow
- * a user to make a DoFHandler object known to this class and to add data
- * vectors which will later be written to a file in some format. Instead of
- * pondering about the different functions, an example is probably the best
- * way:
- * @code
- * ...
- * ... // compute solution, which contains nodal values
- * ...
- * ... // compute error_estimator, which contains one value per cell
- *
- * std::vector<std::string> solution_names;
- * solution_names.push_back ("x-displacement");
- * solution_names.push_back ("y-displacement");
- *
- * DataOut<dim> data_out;
- * data_out.attach_dof_handler (dof_handler);
- * data_out.add_data_vector (solution, solution_names);
- * data_out.add_data_vector (error_estimator, "estimated_error");
- *
- * data_out.build_patches ();
- *
- * ofstream output_file ("output");
- * data_out.write_xxx (output_file);
- *
- * data_out.clear();
- * @endcode
- *
- * attach_dof_handler() tells this class that all future operations
- * are to take place with the DoFHandler object and the triangulation
- * it lives on. We then add the solution vector and the error
- * estimator; note that they have different dimensions, because the
- * solution is a nodal vector, here consisting of two components
- * ("x-displacement" and "y-displacement") while the error estimator
- * probably is a vector holding cell data. When attaching a data
- * vector, you have to give a name to each component of the vector,
- * which is done through an object of type <tt>vector<string></tt> as
- * second argument; if only one component is in the vector, for
- * example if we are adding cell data as in the second case, or if the
- * finite element used by the DoFHandler has only one component, then
- * you can use the second add_data_vector() function which takes a @p
- * string instead of the <tt>vector<string></tt>.
- *
- * The add_data_vector() functions have additional arguments (with default
- * values) that can be used to specify certain transformations. In particular,
- * it allows to attach DataPostprocessor arguments to compute derived
- * information from a data vector at each point at which the field will
- * be evaluated so that it can be written to a file (for example, the
- * Mach number in hypersonic flow can be computed from density and velocities;
- * step-29 also shows an example); another piece of information
- * specified through arguments with default values is how certain output
- * components should be interpreted, i.e. whether each component of the data
- * is logically an independent scalar field, or whether some of them together
- * form logically a vector-field (see the
- * DataComponentInterpretation::DataComponentInterpretation enum, and the @ref
- * step_22 "step-22" tutorial program).
- *
- * It should be noted that this class does not copy the vector given to it through
- * the add_data_vector() functions, for memory consumption reasons. It only
- * stores a reference to it, so it is in your responsibility to make sure that
- * the data vectors exist long enough.
- *
- * After adding all data vectors, you need to call a function which generates
- * the patches for output from the stored data. Derived classes name this
- * function build_patches(). Finally, you write() the data in one format or other,
- * to a file.
- *
- * Please note, that in the example above, an object of type DataOut was
- * used, i.e. an object of a derived class. This is necessary since this
- * class does not provide means to actually generate the patches, only aids to
- * store and access data.
- *
- * Note that the base class of this class, DataOutInterface offers
- * several functions to ease programming with run-time determinable
- * output formats (i.e. you need not use a fixed format by calling
- * DataOutInterface::write_xxx in the above example, but you can
- * select it by a run-time parameter without having to write the
- * <tt>if () ... else ...</tt> clauses yourself), and also functions
- * and classes offering ways to control the appearance of the output
- * by setting flags for each output format.
- *
- *
- * <h3>Information for derived classes</h3>
- *
- * What is actually missing this class is a way to produce the patches
- * for output itself, from the stored data and degree of freedom
- * information. Since this task is often application dependent it is
- * left to derived classes. For example, in many applications, it
- * might be wanted to limit the depth of output to a certain number of
- * refinement levels and write data from finer cells only in a way
- * interpolated to coarser cells, to reduce the amount of
- * output. Also, it might be wanted to use different numbers of
- * subdivisions on different cells when forming a patch, for example
- * to accomplish for different polynomial degrees of the trial space
- * on different cells. Also, the output need not necessarily consist
- * of a patch for each cell, but might be made up of patches for
- * faces, of other things. Take a look at derived classes to what is
- * possible in this respect.
- *
- * For this reason, it is left to a derived class to provide a
- * function, named usually build_patches() or the like, which fills
- * the #patches array of this class.
- *
- * Regarding the templates of this class, it needs three values: first
- * the space dimension in which the triangulation and the DoF handler
- * operate, second the dimension of the objects which the patches
- * represent. Although in most cases they are equal, there are also
- * classes for which this does not hold, for example if one outputs
- * the result of a computation exploiting rotational symmetry in the
- * original domain (in which the space dimension of the output would
- * be one higher than that of the DoF handler, see the
- * DataOut_Rotation() class), or one might conceive that one could
- * write a class that only outputs the solution on a cut through the
- * domain, in which case the space dimension of the output is less
- * than that of the DoF handler. The last template argument denotes
- * the dimension of the space into which the patches are embedded;
- * usually, this dimension is the same as the dimensio of the patches
- * themselves (which is also the default value of the template
- * parameter), but there might be cases where this is not so. For
- * example, in the DataOut_Faces() class, patches are generated
- * from faces of the triangulation. Thus, the dimension of the patch
- * is one less than the dimension of the embedding space, which is, in
- * this case, equal to the dimension of the triangulation and DoF
- * handler. However, for the cut through the domain mentioned above,
- * if the cut is a straight one, then the cut can be embedded into a
- * space of one dimension lower than the dimension of the
- * triangulation, so that the last template parameter has the same
- * value as the second one.
+ * This class is the main class to provide output of data described by finite
+ * element fields defined on a collection of cells.
*
- * @ingroup output
- * @author Wolfgang Bangerth, 1999
- */
-template <class DH, int patch_dim, int patch_space_dim=patch_dim>
-class DataOut_DoFData : public DataOutInterface<patch_dim,patch_space_dim>
-{
-public:
-
- /**
- * Typedef to the iterator type
- * of the dof handler class under
- * consideration.
- */
- typedef typename DH::cell_iterator cell_iterator;
- typedef typename DH::active_cell_iterator active_cell_iterator;
-
-public:
-
- /**
- * Type describing what the
- * vector given to
- * add_data_vector() is: a
- * vector that has one entry per
- * degree of freedom in a
- * DoFHandler object (such
- * as solution vectors), or one
- * entry per cell in the
- * triangulation underlying the
- * DoFHandler object (such
- * as error per cell data). The
- * value #type_automatic tells
- * add_data_vector() to find
- * out itself (see the
- * documentation of
- * add_data_vector() for the
- * method used).
- */
- enum DataVectorType
- {
- /**
- * Data vector entries are
- * associated to degrees of freedom
- */
- type_dof_data,
-
- /**
- * Data vector entries are one per
- * grid cell
- */
- type_cell_data,
-
- /**
- * Find out automatically
- */
- type_automatic
- };
-
- /**
- * Constructor
- */
- DataOut_DoFData ();
-
- /**
- * Destructor.
- */
- virtual ~DataOut_DoFData ();
-
- /**
- * Designate a dof handler to be
- * used to extract geometry data
- * and the mapping between nodes
- * and node values.
- */
- void attach_dof_handler (const DH &);
-
- /**
- * Add a data vector together
- * with its name.
- *
- * A pointer to the vector is
- * stored, so you have to make
- * sure the vector exists at that
- * address at least as long as
- * you call the <tt>write_*</tt>
- * functions.
- *
- * It is assumed that the vector
- * has the same number of
- * components as there are
- * degrees of freedom in the dof
- * handler, in which case it is
- * assumed to be a vector storing
- * nodal data; or the size may be
- * the number of active cells on
- * the present grid, in which
- * case it is assumed to be a
- * cell data vector. As the
- * number of degrees of freedom
- * and of cells is usually not
- * equal, the function can
- * determine itself which type of
- * vector it is given. However,
- * there are corner cases where
- * this automatic determination
- * does not work. One example is
- * if you compute with piecewise
- * constant elements and have a
- * scalar solution, then there
- * are as many cells as there are
- * degrees of freedom (though
- * they may be numbered
- * differently). Another
- * possibility is if you have a
- * 1d mesh embedded in 2d space
- * and the mesh consists of a
- * closed curve of cells; in this
- * case, there are as many nodes
- * as there are cells, and when
- * using a Q1 element you will
- * have as many degrees of
- * freedom as there are cells.
- * In these cases, you can change
- * the last argument of the
- * function from its default
- * value #type_automatic to
- * either #type_dof_data or
- * #type_cell_data, depending on
- * what the vector
- * represents. Apart from such
- * corner cases, you can leave
- * the argument at its default
- * value and let the function
- * determine the type of the
- * vector itself.
- *
- * If it is a vector holding DoF
- * data, the names given shall be
- * one for each component of the
- * underlying finite element. If
- * it is a finite element
- * composed of only one
- * subelement, then there is
- * another function following
- * which takes a single name
- * instead of a vector of names.
- *
- * The data_component_interpretation
- * argument contains information about
- * how the individual components of
- * output files that consist of more than
- * one data set are to be interpreted.
- *
- * For example, if one has a finite
- * element for the Stokes equations in
- * 2d, representing components (u,v,p),
- * one would like to indicate that the
- * first two, u and v, represent a
- * logical vector so that later on when
- * we generate graphical output we can
- * hand them off to a visualization
- * program that will automatically know
- * to render them as a vector field,
- * rather than as two separate and
- * independent scalar fields.
- *
- * The default value of this argument
- * (i.e. an empty vector) corresponds is
- * equivalent to a vector of values
- * DataComponentInterpretation::component_is_scalar,
- * indicating that all output components
- * are independent scalar
- * fields. However, if the given data
- * vector represents logical vectors, you
- * may pass a vector that contains values
- * DataComponentInterpretation::component_is_part_of_vector. In
- * the example above, one would pass in a
- * vector with components
- * (DataComponentInterpretation::component_is_part_of_vector,
- * DataComponentInterpretation::component_is_part_of_vector,
- * DataComponentInterpretation::component_is_scalar)
- * for (u,v,p).
- *
- * The names of a data vector
- * shall only contain characters
- * which are letters, underscore
- * and a few other ones. Refer to
- * the ExcInvalidCharacter
- * exception declared in this
- * class to see which characters
- * are valid and which are not.
- *
- * @note The actual type for the
- * vector argument may be any
- * vector type from which
- * FEValues can extract values on
- * a cell using the
- * FEValuesBase::get_function_values()
- * function. In particular, this
- * includes all of the usual
- * vector types, but also
- * IndexSet (see step-41 for a
- * use of this).
- */
- template <class VECTOR>
- void add_data_vector (const VECTOR &data,
- const std::vector<std::string> &names,
- const DataVectorType type = type_automatic,
- const std::vector<DataComponentInterpretation::DataComponentInterpretation> &data_component_interpretation
- = std::vector<DataComponentInterpretation::DataComponentInterpretation>());
-
- /**
- * This function is an abbreviation to
- * the above one (see there for a
- * discussion of the various arguments),
- * intended for use with finite elements
- * that are not composed of
- * subelements. In this case, only one
- * name per data vector needs to be
- * given, which is what this function
- * takes. It simply relays its arguments
- * after a conversion of the @p name to a
- * vector of strings, to the other
- * add_data_vector() function above.
- *
- * If @p data is a vector with
- * multiple components this
- * function will generate
- * distinct names for all
- * components by appending an
- * underscore and the number of
- * each component to @p name
- *
- * The actual type for the template
- * argument may be any vector type from
- * which FEValues can extract values
- * on a cell using the
- * FEValuesBase::get_function_values() function.
- */
- template <class VECTOR>
- void add_data_vector (const VECTOR &data,
- const std::string &name,
- const DataVectorType type = type_automatic,
- const std::vector<DataComponentInterpretation::DataComponentInterpretation> &data_component_interpretation
- = std::vector<DataComponentInterpretation::DataComponentInterpretation>());
-
- /**
- * This function is an alternative to the
- * above ones, allowing the output of
- * derived quantities instead of the given
- * data. This converison has to be done in
- * a class derived from DataPostprocessor.
- *
- * The names for these derived quantities
- * are provided by the @p
- * data_postprocessor argument. Likewise,
- * the data_component_interpretation
- * argument of the other
- * add_data_vector() functions is
- * provided by the data_postprocessor
- * argument. As only data of type @p
- * type_dof_data can be transformed, this
- * type is also known implicitly and does
- * not have to be given.
- *
- * @note The actual type for the
- * vector argument may be any
- * vector type from which
- * FEValues can extract values on
- * a cell using the
- * FEValuesBase::get_function_values()
- * function. In particular, this
- * includes all of the usual
- * vector types, but also
- * IndexSet (see step-41 for a
- * use of this).
- */
- template <class VECTOR>
- void add_data_vector (const VECTOR &data,
- const DataPostprocessor<DH::space_dimension> &data_postprocessor);
-
- /**
- * Release the pointers to the
- * data vectors. This allows
- * output of a new set of vectors
- * without supplying the DoF
- * handler again. Therefore, the
- * DataOut object can be used
- * in an algebraic context. Note
- * that besides the data vectors
- * also the patches already
- * computed are deleted.
- */
- void clear_data_vectors ();
-
- /**
- * Release pointers to all input
- * data elements, i.e. pointers
- * to data vectors and to the DoF
- * handler object. This function
- * may be useful when you have
- * called the @p build_patches
- * function of derived class,
- * since then the patches are
- * built and the input data is no
- * more needed, nor is there a
- * need to reference it. You can
- * then output the patches
- * detached from the main thread
- * and need not make sure anymore
- * that the DoF handler object
- * and vectors must not be
- * deleted before the output
- * thread is finished.
- */
- void clear_input_data_references ();
-
- /**
- * This function can be used to
- * merge the patches that were
- * created using the
- * @p build_patches function of
- * the object given as argument
- * into the list of patches
- * created by this object. This
- * is sometimes handy if one has,
- * for example, a domain
- * decomposition algorithm where
- * each block is represented by a
- * DoFHandler of its own,
- * but one wants to output the
- * solution on all the blocks at
- * the same time.
- *
- * For this to work, the given
- * argument and this object need
- * to have the same number of
- * output vectors, and they need
- * to use the same number of
- * subdivisions per patch. The
- * output will probably look
- * rather funny if patches in
- * both objects overlap in space.
- *
- * If you call
- * build_patches() for this
- * object after merging in
- * patches, the previous state is
- * overwritten, and the merged-in
- * patches are lost.
- *
- * The second parameter allows to
- * shift each node of the patches
- * in the object passed in in the
- * first parameter by a certain
- * amount. This is sometimes
- * useful to generate "exploded"
- * views of a collection of
- * blocks.
- *
- * This function will fail if
- * either this or the other
- * object did not yet set up any
- * patches.
- */
- template <class DH2>
- void merge_patches (const DataOut_DoFData<DH2,patch_dim,patch_space_dim> &source,
- const Point<patch_space_dim> &shift = Point<patch_space_dim>());
-
- /**
- * Release the pointers to the
- * data vectors and the DoF
- * handler. You have to set all
- * data entries again using the
- * add_data_vector()
- * function. The pointer to the
- * dof handler is cleared as
- * well, along with all other
- * data. In effect, this function
- * resets everything to a virgin
- * state.
- */
- virtual void clear ();
-
- /**
- * Determine an estimate for the
- * memory consumption (in bytes)
- * of this object.
- */
- std::size_t memory_consumption () const;
-
- /**
- * Exception
- */
- DeclException0 (ExcNoDoFHandlerSelected);
- /**
- * Exception
- */
- DeclException0 (ExcDataPostprocessingIsNotPossibleForCellData);
- /**
- * Exception
- */
- DeclException3 (ExcInvalidVectorSize,
- int, int, int,
- << "The vector has size " << arg1
- << " but the DoFHandler objects says there are " << arg2
- << " degrees of freedom and there are " << arg3
- << " active cells.");
- /**
- * Exception
- */
- DeclException2 (ExcInvalidCharacter,
- std::string, size_t,
- << "Please use only the characters [a-zA-Z0-9_<>()] for" << std::endl
- << "description strings since some graphics formats will only accept these."
- << std::endl
- << "The string you gave was <" << arg1
- << ">, the invalid character is <" << arg1[arg2]
- << ">." << std::endl);
- /**
- * Exception
- */
- DeclException0 (ExcOldDataStillPresent);
- /**
- * Exception
- */
- DeclException2 (ExcInvalidNumberOfNames,
- int, int,
- << "You have to give one name per component in your "
- << "data vector. The number you gave was " << arg1
- << ", but the number of components is " << arg2);
- /**
- * Exception
- */
- DeclException0 (ExcNoPatches);
- /**
- * Exception
- */
- DeclException0 (ExcIncompatibleDatasetNames);
- /**
- * Exception
- */
- DeclException0 (ExcIncompatiblePatchLists);
-
- DeclException2 (ExcInvalidVectorDeclaration,
- int, std::string,
- << "When declaring that a number of components in a data\n"
- << "set to be output logically form a vector instead of\n"
- << "simply a set of scalar fields, you need to specify\n"
- << "this for all relevant components. Furthermore,\n"
- << "vectors must always consist of exactly <dim>\n"
- << "components. However, the vector component at\n"
- << "position " << arg1 << " with name <" << arg2
- << "> does not satisfy these conditions.");
-
-protected:
- /**
- * Abbreviate the somewhat lengthy
- * name for the Patch class.
- */
- typedef dealii::DataOutBase::Patch<patch_dim,patch_space_dim> Patch;
-
- /**
- * Pointer to the dof handler object.
- */
- SmartPointer<const DH, DataOut_DoFData<DH,patch_dim,patch_space_dim> > dofs;
-
- /**
- * List of data elements with vectors of
- * values for each degree of freedom.
- */
- std::vector<std_cxx1x::shared_ptr<internal::DataOut::DataEntryBase<DH> > > dof_data;
-
- /**
- * List of data elements with vectors of
- * values for each cell.
- */
- std::vector<std_cxx1x::shared_ptr<internal::DataOut::DataEntryBase<DH> > > cell_data;
-
- /**
- * This is a list of patches that is
- * created each time build_patches()
- * is called. These patches are used
- * in the output routines of the base
- * classes.
- */
- std::vector<Patch> patches;
-
- /**
- * Function by which the base
- * class's functions get to know
- * what patches they shall write
- * to a file.
- */
- virtual
- const std::vector<Patch> &get_patches () const;
-
- /**
- * Virtual function through
- * which the names of data sets are
- * obtained by the output functions
- * of the base class.
- */
- virtual
- std::vector<std::string> get_dataset_names () const;
-
- /**
- * Overload of the respective
- * DataOutInterface::get_vector_data_ranges()
- * function. See there for a more
- * extensive documentation.
- */
- virtual
- std::vector<std_cxx1x::tuple<unsigned int, unsigned int, std::string> >
- get_vector_data_ranges () const;
-
- /**
- * Make all template siblings
- * friends. Needed for the
- * merge_patches() function.
- */
- template <class, int, int>
- friend class DataOut_DoFData;
-};
-
-
-
-/**
* This class is an actual implementation of the functionality proposed by
* the DataOut_DoFData class. It offers a function build_patches() that
* generates the patches to be written in some graphics format from the data
{
public:
/**
- * Typedef to the iterator type
- * of the dof handler class under
+ * Typedef to the iterator type of the dof handler class under
* consideration.
*/
typedef typename DataOut_DoFData<DH,DH::dimension,DH::space_dimension>::cell_iterator cell_iterator;
typedef typename DataOut_DoFData<DH,DH::dimension,DH::space_dimension>::active_cell_iterator active_cell_iterator;
/**
- * Enumeration describing the region of the
- * domain in which curved cells shall be
- * created.
+ * Enumeration describing the region of the domain in which curved cells
+ * shall be created.
*/
enum CurvedCellRegion
{
};
/**
- * This is the central function
- * of this class since it builds
- * the list of patches to be
- * written by the low-level
- * functions of the base
- * class. See the general
- * documentation of this class
- * for further information.
+ * This is the central function of this class since it builds the list of
+ * patches to be written by the low-level functions of the base class. See
+ * the general documentation of this class for further information.
*
- * The default value <tt>0</tt>
- * of <tt>n_subdivisions</tt>
- * indicates that the value
- * stored in
- * DataOutInterface::default_subdivisions
- * is to be used.
+ * The default value <tt>0</tt> of <tt>n_subdivisions</tt> indicates that
+ * the value stored in DataOutInterface::default_subdivisions is to be used.
*/
virtual void build_patches (const unsigned int n_subdivisions = 0);
/**
- * Same as above, except that the
- * additional first parameter
- * defines a mapping that is to
- * be used in the generation of
- * output. If
- * <tt>n_subdivisions>1</tt>, the
- * points interior of subdivided
- * patches which originate from
- * cells at the boundary of the
- * domain can be computed using the
- * mapping, i.e. a higher order
- * mapping leads to a
- * representation of a curved
- * boundary by using more
- * subdivisions. Some mappings like
- * MappingQEulerian result in curved cells
- * in the interior of the domain. However,
- * there is nor easy way to get this
- * information from the Mapping. Thus the
- * last argument @p curved_region take one
- * of three values resulting in no curved
- * cells at all, curved cells at the
- * boundary (default) or curved cells in
- * the whole domain.
+ * Same as above, except that the additional first parameter defines a
+ * mapping that is to be used in the generation of output. If
+ * <tt>n_subdivisions>1</tt>, the points interior of subdivided patches
+ * which originate from cells at the boundary of the domain can be computed
+ * using the mapping, i.e. a higher order mapping leads to a representation
+ * of a curved boundary by using more subdivisions. Some mappings like
+ * MappingQEulerian result in curved cells in the interior of the
+ * domain. However, there is nor easy way to get this information from the
+ * Mapping. Thus the last argument @p curved_region take one of three values
+ * resulting in no curved cells at all, curved cells at the boundary
+ * (default) or curved cells in the whole domain.
*
- * Even for non-curved cells the
- * mapping argument can be used
- * for the Eulerian mappings (see
- * class MappingQ1Eulerian) where
- * a mapping is used not only to
- * determine the position of
- * points interior to a cell, but
- * also of the vertices. It
- * offers an opportunity to watch
- * the solution on a deformed
- * triangulation on which the
- * computation was actually
- * carried out, even if the mesh
- * is internally stored in its
- * undeformed configuration and
- * the deformation is only
- * tracked by an additional
- * vector that holds the
+ * Even for non-curved cells the mapping argument can be used for the
+ * Eulerian mappings (see class MappingQ1Eulerian) where a mapping is used
+ * not only to determine the position of points interior to a cell, but also
+ * of the vertices. It offers an opportunity to watch the solution on a
+ * deformed triangulation on which the computation was actually carried out,
+ * even if the mesh is internally stored in its undeformed configuration and
+ * the deformation is only tracked by an additional vector that holds the
* deformation of each vertex.
*
- * @todo The @p mapping argument should be
- * replaced by a hp::MappingCollection in
- * case of a hp::DoFHandler.
+ * @todo The @p mapping argument should be replaced by a
+ * hp::MappingCollection in case of a hp::DoFHandler.
*/
virtual void build_patches (const Mapping<DH::dimension,DH::space_dimension> &mapping,
const unsigned int n_subdivisions = 0,
const CurvedCellRegion curved_region = curved_boundary);
/**
- * Return the first cell which we
- * want output for. The default
- * implementation returns the
- * first active cell, but you
- * might want to return other
- * cells in a derived class.
+ * Return the first cell which we want output for. The default
+ * implementation returns the first active cell, but you might want to
+ * return other cells in a derived class.
*/
virtual cell_iterator first_cell ();
/**
- * Return the next cell after
- * @p cell which we want output
- * for. If there are no more
- * cells, <tt>#dofs->end()</tt> shall
- * be returned.
+ * Return the next cell after @p cell which we want output for. If there
+ * are no more cells, <tt>#dofs->end()</tt> shall be returned.
*
- * The default implementation
- * returns the next active cell,
- * but you might want to return
- * other cells in a derived
- * class. Note that the default
- * implementation assumes that
- * the given @p cell is active,
- * which is guaranteed as long as
- * first_cell() is also used
- * from the default
- * implementation. Overloading
- * only one of the two functions
- * might not be a good idea.
+ * The default implementation returns the next active cell, but you might
+ * want to return other cells in a derived class. Note that the default
+ * implementation assumes that the given @p cell is active, which is
+ * guaranteed as long as first_cell() is also used from the default
+ * implementation. Overloading only one of the two functions might not be a
+ * good idea.
*/
virtual cell_iterator next_cell (const cell_iterator &cell);
private:
/**
- * Return the first cell produced
- * by the
- * first_cell()/next_cell()
- * function pair that is locally
- * owned. If this object operates
- * on a non-distributed
- * triangulation, the result
- * equals what first_cell()
- * returns.
+ * Return the first cell produced by the first_cell()/next_cell() function
+ * pair that is locally owned. If this object operates on a non-distributed
+ * triangulation, the result equals what first_cell() returns.
*/
cell_iterator first_locally_owned_cell ();
/**
- * Return the next cell produced
- * by the next_cell() function
- * that is locally owned. If this
- * object operates on a
- * non-distributed triangulation,
- * the result equals what
- * first_cell() returns.
+ * Return the next cell produced by the next_cell() function that is locally
+ * owned. If this object operates on a non-distributed triangulation, the
+ * result equals what first_cell() returns.
*/
cell_iterator next_locally_owned_cell (const cell_iterator &cell);
/**
- * Build one patch. This function
- * is called in a WorkStream
- * context.
+ * Build one patch. This function is called in a WorkStream context.
*
- * The result is written into the patch
- * variable.
+ * The result is written into the patch variable.
*/
void build_one_patch (const std::pair<cell_iterator, unsigned int> *cell_and_index,
internal::DataOut::ParallelData<DH::dimension, DH::space_dimension> &data,
-// -------------------- template and inline functions ------------------------
-
-
-namespace internal
-{
- namespace DataOut
- {
- template <int dim, int spacedim>
- template <class FE>
- ParallelDataBase<dim,spacedim>::
- ParallelDataBase (const unsigned int n_components,
- const unsigned int n_datasets,
- const unsigned int n_subdivisions,
- const unsigned int n_q_points,
- const std::vector<unsigned int> &n_postprocessor_outputs,
- const FE &finite_elements)
- :
- n_components (n_components),
- n_datasets (n_datasets),
- n_subdivisions (n_subdivisions),
- patch_values (n_q_points),
- patch_values_system (n_q_points),
- patch_gradients (n_q_points),
- patch_gradients_system (n_q_points),
- patch_hessians (n_q_points),
- patch_hessians_system (n_q_points),
- postprocessed_values (n_postprocessor_outputs.size()),
- fe_collection (finite_elements)
- {
- for (unsigned int k=0; k<n_q_points; ++k)
- {
- patch_values_system[k].reinit(n_components);
- patch_gradients_system[k].resize(n_components);
- patch_hessians_system[k].resize(n_components);
- }
-
- for (unsigned int dataset=0; dataset<n_postprocessor_outputs.size(); ++dataset)
- if (n_postprocessor_outputs[dataset] != 0)
- postprocessed_values[dataset]
- .resize(n_q_points,
- dealii::Vector<double>(n_postprocessor_outputs[dataset]));
- }
- }
-}
-
-
-template <class DH, int patch_dim, int patch_space_dim>
-template <class DH2>
-void
-DataOut_DoFData<DH,patch_dim,patch_space_dim>::
-merge_patches (const DataOut_DoFData<DH2,patch_dim,patch_space_dim> &source,
- const Point<patch_space_dim> &shift)
-{
- const std::vector<Patch> source_patches = source.get_patches ();
- Assert (patches.size () != 0, ExcNoPatches ());
- Assert (source_patches.size () != 0, ExcNoPatches ());
- // check equality of component
- // names
- Assert (get_dataset_names() == source.get_dataset_names(),
- ExcIncompatibleDatasetNames());
- // make sure patches are compatible. we'll
- // assume that if the first respective
- // patches are ok that all the other ones
- // are ok as well
- Assert (patches[0].n_subdivisions == source_patches[0].n_subdivisions,
- ExcIncompatiblePatchLists());
- Assert (patches[0].data.n_rows() == source_patches[0].data.n_rows(),
- ExcIncompatiblePatchLists());
- Assert (patches[0].data.n_cols() == source_patches[0].data.n_cols(),
- ExcIncompatiblePatchLists());
-
- // check equality of the vector data
- // specifications
- Assert (get_vector_data_ranges().size() ==
- source.get_vector_data_ranges().size(),
- ExcMessage ("Both sources need to declare the same components "
- "as vectors."));
- for (unsigned int i=0; i<get_vector_data_ranges().size(); ++i)
- {
- Assert (std_cxx1x::get<0>(get_vector_data_ranges()[i]) ==
- std_cxx1x::get<0>(source.get_vector_data_ranges()[i]),
- ExcMessage ("Both sources need to declare the same components "
- "as vectors."));
- Assert (std_cxx1x::get<1>(get_vector_data_ranges()[i]) ==
- std_cxx1x::get<1>(source.get_vector_data_ranges()[i]),
- ExcMessage ("Both sources need to declare the same components "
- "as vectors."));
- Assert (std_cxx1x::get<2>(get_vector_data_ranges()[i]) ==
- std_cxx1x::get<2>(source.get_vector_data_ranges()[i]),
- ExcMessage ("Both sources need to declare the same components "
- "as vectors."));
- }
-
- // merge patches. store old number
- // of elements, since we need to
- // adjust patch numbers, etc
- // afterwards
- const unsigned int old_n_patches = patches.size();
- patches.insert (patches.end(),
- source_patches.begin(),
- source_patches.end());
-
- // perform shift, if so desired
- if (shift != Point<patch_space_dim>())
- for (unsigned int i=old_n_patches; i<patches.size(); ++i)
- for (unsigned int v=0; v<GeometryInfo<patch_dim>::vertices_per_cell; ++v)
- patches[i].vertices[v] += shift;
-
- // adjust patch numbers
- for (unsigned int i=old_n_patches; i<patches.size(); ++i)
- patches[i].patch_index += old_n_patches;
-
- // adjust patch neighbors
- for (unsigned int i=old_n_patches; i<patches.size(); ++i)
- for (unsigned int n=0; n<GeometryInfo<patch_dim>::faces_per_cell; ++n)
- if (patches[i].neighbors[n] != Patch::no_neighbor)
- patches[i].neighbors[n] += old_n_patches;
-}
-
-
DEAL_II_NAMESPACE_CLOSE
#endif
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1999 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+#ifndef __deal2__data_out_dof_data_h
+#define __deal2__data_out_dof_data_h
+
+
+
+#include <deal.II/base/config.h>
+#include <deal.II/base/smartpointer.h>
+#include <deal.II/base/data_out_base.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/fe/mapping.h>
+#include <deal.II/hp/q_collection.h>
+#include <deal.II/hp/fe_collection.h>
+#include <deal.II/hp/mapping_collection.h>
+#include <deal.II/hp/fe_values.h>
+#include <deal.II/numerics/data_postprocessor.h>
+#include <deal.II/numerics/data_component_interpretation.h>
+
+#include <deal.II/base/std_cxx1x/shared_ptr.h>
+
+DEAL_II_NAMESPACE_OPEN
+
+template <int, int> class FEValuesBase;
+
+namespace internal
+{
+ namespace DataOut
+ {
+ /**
+ * For each vector that has been added through the add_data_vector()
+ * functions, we need to keep track of a pointer to it, and allow data
+ * extraction from it when we generate patches. Unfortunately, we need to
+ * do this for a number of different vector types. Fortunately, they all
+ * have the same interface. So the way we go is to have a base class that
+ * provides the functions to access the vector's information, and to have
+ * a derived template class that can be instantiated for each vector
+ * type. Since the vectors all have the same interface, this is no big
+ * problem, as they can all use the same general templatized code.
+ *
+ * @author Wolfgang Bangerth, 2004
+ */
+ template <class DH>
+ class DataEntryBase
+ {
+ public:
+ /**
+ * Constructor. Give a list of names for the individual components of
+ * the vector and their interpretation as scalar or vector data. This
+ * constructor assumes that no postprocessor is going to be used.
+ */
+ DataEntryBase (const DH *dofs,
+ const std::vector<std::string> &names,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &data_component_interpretation);
+
+ /**
+ * Constructor when a data postprocessor is going to be used. In that
+ * case, the names and vector declarations are going to be acquired from
+ * the postprocessor.
+ */
+ DataEntryBase (const DH *dofs,
+ const DataPostprocessor<DH::space_dimension> *data_postprocessor);
+
+ /**
+ * Destructor made virtual.
+ */
+ virtual ~DataEntryBase ();
+
+ /**
+ * Assuming that the stored vector is a cell vector, extract the given
+ * element from it.
+ */
+ virtual
+ double
+ get_cell_data_value (const unsigned int cell_number) const = 0;
+
+ /**
+ * Given a FEValuesBase object, extract the values on the present cell
+ * from the vector we actually store.
+ */
+ virtual
+ void
+ get_function_values (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
+ std::vector<double> &patch_values) const = 0;
+
+ /**
+ * Given a FEValuesBase object, extract the values on the present cell
+ * from the vector we actually store. This function does the same as the
+ * one above but for vector-valued finite elements.
+ */
+ virtual
+ void
+ get_function_values (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
+ std::vector<dealii::Vector<double> > &patch_values_system) const = 0;
+
+ /**
+ * Given a FEValuesBase object, extract the gradients on the present
+ * cell from the vector we actually store.
+ */
+ virtual
+ void
+ get_function_gradients (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
+ std::vector<Tensor<1,DH::space_dimension> > &patch_gradients) const = 0;
+
+ /**
+ * Given a FEValuesBase object, extract the gradients on the present
+ * cell from the vector we actually store. This function does the same
+ * as the one above but for vector-valued finite elements.
+ */
+ virtual
+ void
+ get_function_gradients (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
+ std::vector<std::vector<Tensor<1,DH::space_dimension> > > &patch_gradients_system) const = 0;
+
+ /**
+ * Given a FEValuesBase object, extract the second derivatives on the
+ * present cell from the vector we actually store.
+ */
+ virtual
+ void
+ get_function_hessians (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
+ std::vector<Tensor<2,DH::space_dimension> > &patch_hessians) const = 0;
+
+ /**
+ * Given a FEValuesBase object, extract the second derivatives on the
+ * present cell from the vector we actually store. This function does
+ * the same as the one above but for vector-valued finite elements.
+ */
+ virtual
+ void
+ get_function_hessians (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
+ std::vector<std::vector< Tensor<2,DH::space_dimension> > > &patch_hessians_system) const = 0;
+
+ /**
+ * Clear all references to the vectors.
+ */
+ virtual void clear () = 0;
+
+ /**
+ * Determine an estimate for the memory consumption (in bytes) of this
+ * object.
+ */
+ virtual std::size_t memory_consumption () const = 0;
+
+ /**
+ * Pointer to the DoFHandler object that the vector is based on.
+ */
+ SmartPointer<const DH> dof_handler;
+
+ /**
+ * Names of the components of this data vector.
+ */
+ const std::vector<std::string> names;
+
+ /**
+ * A vector that for each of the n_output_variables variables of the
+ * current data set indicates whether they are scalar fields, parts of a
+ * vector-field, or any of the other supported kinds of data.
+ */
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation>
+ data_component_interpretation;
+
+ /**
+ * Pointer to a DataPostprocessing object which shall be applied to this
+ * data vector.
+ */
+ SmartPointer<const dealii::DataPostprocessor<DH::space_dimension> > postprocessor;
+
+ /**
+ * Number of output variables this dataset provides (either number of
+ * components in vector valued function / data vector or number of
+ * computed quantities, if DataPostprocessor is applied). This variable
+ * is determined via and thus equivalent to <tt>names.size()</tt>.
+ */
+ unsigned int n_output_variables;
+ };
+
+
+ /**
+ * A data structure that holds all data needed in one thread when building
+ * patches in parallel. These data structures are created globally rather
+ * than on each cell to avoid allocation of memory in the threads. This is
+ * a base class for the AdditionalData kind of data structure discussed in
+ * the documentation of the WorkStream class.
+ *
+ * The <code>cell_to_patch_index_map</code> is an array that stores for
+ * index <tt>[i][j]</tt> the number of the patch that associated with the
+ * cell with index @p j on level @p i. This information is set up prior to
+ * generation of the patches, and is needed to generate neighborship
+ * information.
+ *
+ * This structure is used by several of the DataOut* classes, which
+ * derived their own ParallelData classes from it for additional fields.
+ */
+ template <int dim, int spacedim>
+ struct ParallelDataBase
+ {
+ ParallelDataBase (const unsigned int n_datasets,
+ const unsigned int n_subdivisions,
+ const std::vector<unsigned int> &n_postprocessor_outputs,
+ const Mapping<dim,spacedim> &mapping,
+ const std::vector<std_cxx1x::shared_ptr<dealii::hp::FECollection<dim,spacedim> > > &finite_elements,
+ const UpdateFlags update_flags,
+ const bool use_face_values);
+
+ ParallelDataBase (const ParallelDataBase &data);
+
+ template <typename DH>
+ void reinit_all_fe_values(std::vector<std_cxx1x::shared_ptr<DataEntryBase<DH> > > &dof_data,
+ const typename dealii::Triangulation<dim,spacedim>::cell_iterator &cell,
+ const unsigned int face = numbers::invalid_unsigned_int);
+
+ const FEValuesBase<dim,spacedim> &
+ get_present_fe_values(const unsigned int dataset) const;
+
+ void resize_system_vectors(const unsigned int n_components);
+
+ const unsigned int n_datasets;
+ const unsigned int n_subdivisions;
+
+ std::vector<double> patch_values;
+ std::vector<dealii::Vector<double> > patch_values_system;
+ std::vector<Tensor<1,spacedim> > patch_gradients;
+ std::vector<std::vector<Tensor<1,spacedim> > > patch_gradients_system;
+ std::vector<Tensor<2,spacedim> > patch_hessians;
+ std::vector<std::vector<Tensor<2,spacedim> > > patch_hessians_system;
+ std::vector<std::vector<dealii::Vector<double> > > postprocessed_values;
+
+ const dealii::hp::MappingCollection<dim,spacedim> mapping_collection;
+ const std::vector<std_cxx1x::shared_ptr<dealii::hp::FECollection<dim,spacedim> > > finite_elements;
+ const UpdateFlags update_flags;
+
+ std::vector<std_cxx1x::shared_ptr<dealii::hp::FEValues<dim,spacedim> > > x_fe_values;
+ std::vector<std_cxx1x::shared_ptr<dealii::hp::FEFaceValues<dim,spacedim> > > x_fe_face_values;
+ };
+ }
+}
+
+
+//TODO: Most of the documentation of DataOut_DoFData applies to DataOut.
+
+/**
+ * This is an abstract class which provides the functionality to generate
+ * patches for output by base classes from data vectors on a grid. It allows
+ * to store one or more pointers to a DoFHandler and attached node and cell
+ * data denoting functions on the grid which shall later be written in any of
+ * the implemented data formats.
+ *
+ *
+ * <h3>User visible interface</h3>
+ *
+ * The user visible interface of this class allows the user to specify data in
+ * two different ways. One is to make a DoFHandler object known to this class
+ * and to add data vectors that all correspond to this DoFHandler or the grid
+ * cells which will later be written to a file in some format. The second
+ * approach is to pass a DoFHandler object along with the vector. This allows
+ * setting data from different DoFHandlers in a neat way (of course, they both
+ * need to be based on the same triangulation). Instead of pondering about the
+ * different functions, an example for the first kind is probably the best
+ * explanation:
+ * @code
+ * ...
+ * ... // compute solution, which contains nodal values
+ * ...
+ * ... // compute error_estimator, which contains one value per cell
+ *
+ * std::vector<std::string> solution_names;
+ * solution_names.push_back ("x-displacement");
+ * solution_names.push_back ("y-displacement");
+ *
+ * DataOut<dim> data_out;
+ * data_out.attach_dof_handler (dof_handler);
+ * data_out.add_data_vector (solution, solution_names);
+ * data_out.add_data_vector (error_estimator, "estimated_error");
+ *
+ * data_out.build_patches ();
+ *
+ * ofstream output_file ("output");
+ * data_out.write_xxx (output_file);
+ *
+ * data_out.clear();
+ * @endcode
+ *
+ * attach_dof_handler() tells this class that all future operations
+ * are to take place with the DoFHandler object and the triangulation
+ * it lives on. We then add the solution vector and the error
+ * estimator; note that they have different dimensions, because the
+ * solution is a nodal vector, here consisting of two components
+ * ("x-displacement" and "y-displacement") while the error estimator
+ * probably is a vector holding cell data. When attaching a data
+ * vector, you have to give a name to each component of the vector,
+ * which is done through an object of type <tt>vector<string></tt> as
+ * second argument; if only one component is in the vector, for
+ * example if we are adding cell data as in the second case, or if the
+ * finite element used by the DoFHandler has only one component, then
+ * you can use the second add_data_vector() function which takes a @p
+ * string instead of the <tt>vector<string></tt>.
+ *
+ * The add_data_vector() functions have additional arguments (with default
+ * values) that can be used to specify certain transformations. In particular,
+ * it allows to attach DataPostprocessor arguments to compute derived
+ * information from a data vector at each point at which the field will
+ * be evaluated so that it can be written to a file (for example, the
+ * Mach number in hypersonic flow can be computed from density and velocities;
+ * step-29 also shows an example); another piece of information
+ * specified through arguments with default values is how certain output
+ * components should be interpreted, i.e. whether each component of the data
+ * is logically an independent scalar field, or whether some of them together
+ * form logically a vector-field (see the
+ * DataComponentInterpretation::DataComponentInterpretation enum, and the @ref
+ * step_22 "step-22" tutorial program).
+ *
+ * It should be noted that this class does not copy the vector given to it through
+ * the add_data_vector() functions, for memory consumption reasons. It only
+ * stores a reference to it, so it is in your responsibility to make sure that
+ * the data vectors exist long enough.
+ *
+ * After adding all data vectors, you need to call a function which generates
+ * the patches for output from the stored data. Derived classes name this
+ * function build_patches(). Finally, you write() the data in one format or other,
+ * to a file.
+ *
+ * Please note that in the example above, an object of type DataOut was
+ * used, i.e. an object of a derived class. This is necessary since this
+ * class does not provide means to actually generate the patches, only aids to
+ * store and access data.
+ *
+ * Note that the base class of this class, DataOutInterface offers
+ * several functions to ease programming with run-time determinable
+ * output formats (i.e. you need not use a fixed format by calling
+ * DataOutInterface::write_xxx in the above example, but you can
+ * select it by a run-time parameter without having to write the
+ * <tt>if () ... else ...</tt> clauses yourself), and also functions
+ * and classes offering ways to control the appearance of the output
+ * by setting flags for each output format.
+ *
+ *
+ * <h3>Information for derived classes</h3>
+ *
+ * What is actually missing this class is a way to produce the patches
+ * for output itself, from the stored data and degree of freedom
+ * information. Since this task is often application dependent it is
+ * left to derived classes. For example, in many applications, it
+ * might be wanted to limit the depth of output to a certain number of
+ * refinement levels and write data from finer cells only in a way
+ * interpolated to coarser cells, to reduce the amount of
+ * output. Also, it might be wanted to use different numbers of
+ * subdivisions on different cells when forming a patch, for example
+ * to accomplish for different polynomial degrees of the trial space
+ * on different cells. Also, the output need not necessarily consist
+ * of a patch for each cell, but might be made up of patches for
+ * faces, of other things. Take a look at derived classes to what is
+ * possible in this respect.
+ *
+ * For this reason, it is left to a derived class to provide a
+ * function, named usually build_patches() or the like, which fills
+ * the #patches array of this class.
+ *
+ * Regarding the templates of this class, it needs three values: first
+ * the space dimension in which the triangulation and the DoF handler
+ * operate, second the dimension of the objects which the patches
+ * represent. Although in most cases they are equal, there are also
+ * classes for which this does not hold, for example if one outputs
+ * the result of a computation exploiting rotational symmetry in the
+ * original domain (in which the space dimension of the output would
+ * be one higher than that of the DoF handler, see the
+ * DataOut_Rotation() class), or one might conceive that one could
+ * write a class that only outputs the solution on a cut through the
+ * domain, in which case the space dimension of the output is less
+ * than that of the DoF handler. The last template argument denotes
+ * the dimension of the space into which the patches are embedded;
+ * usually, this dimension is the same as the dimensio of the patches
+ * themselves (which is also the default value of the template
+ * parameter), but there might be cases where this is not so. For
+ * example, in the DataOut_Faces() class, patches are generated
+ * from faces of the triangulation. Thus, the dimension of the patch
+ * is one less than the dimension of the embedding space, which is, in
+ * this case, equal to the dimension of the triangulation and DoF
+ * handler. However, for the cut through the domain mentioned above,
+ * if the cut is a straight one, then the cut can be embedded into a
+ * space of one dimension lower than the dimension of the
+ * triangulation, so that the last template parameter has the same
+ * value as the second one.
+ *
+ * @ingroup output
+ * @author Wolfgang Bangerth, 1999
+ */
+template <class DH, int patch_dim, int patch_space_dim=patch_dim>
+class DataOut_DoFData : public DataOutInterface<patch_dim,patch_space_dim>
+{
+public:
+
+ /**
+ * Typedef to the iterator type of the dof handler class under
+ * consideration.
+ */
+ typedef typename Triangulation<DH::dimension,DH::space_dimension>::cell_iterator cell_iterator;
+ typedef typename Triangulation<DH::dimension,DH::space_dimension>::active_cell_iterator active_cell_iterator;
+
+public:
+
+ /**
+ * Type describing what the vector given to add_data_vector() is: a vector
+ * that has one entry per degree of freedom in a DoFHandler object (such as
+ * solution vectors), or one entry per cell in the triangulation underlying
+ * the DoFHandler object (such as error per cell data). The value
+ * #type_automatic tells add_data_vector() to find out itself (see the
+ * documentation of add_data_vector() for the method used).
+ */
+ enum DataVectorType
+ {
+ /**
+ * Data vector entries are associated to degrees of freedom
+ */
+ type_dof_data,
+
+ /**
+ * Data vector entries are one per grid cell
+ */
+ type_cell_data,
+
+ /**
+ * Find out automatically
+ */
+ type_automatic
+ };
+
+ /**
+ * Constructor
+ */
+ DataOut_DoFData ();
+
+ /**
+ * Destructor.
+ */
+ virtual ~DataOut_DoFData ();
+
+ /**
+ * Designate a dof handler to be used to extract geometry data and the
+ * mapping between nodes and node values. This call is not necessary if all
+ * added data vectors are supplemented with a DoFHandler argument.
+ *
+ * This call is optional: If you add data vectors with specified DoFHandler
+ * object, then that contains all information needed to generate the output.
+ */
+ void attach_dof_handler (const DH &);
+
+ /**
+ * Designate a triangulation to be used to extract geometry data and the
+ * mapping between nodes and node values.
+ *
+ * This call is optional: If you add data vectors with specified DoFHandler
+ * object, then that contains all information needed to generate the
+ * output. This call is useful when you only output cell vectors and no
+ * DoFHandler at all, in which case it provides the geometry.
+ */
+ void attach_triangulation (const Triangulation<DH::dimension,
+ DH::space_dimension> &);
+
+ /**
+ * Add a data vector together with its name.
+ *
+ * A pointer to the vector is stored, so you have to make sure the vector
+ * exists at that address at least as long as you call the <tt>write_*</tt>
+ * functions.
+ *
+ * It is assumed that the vector has the same number of components as there
+ * are degrees of freedom in the dof handler, in which case it is assumed to
+ * be a vector storing nodal data; or the size may be the number of active
+ * cells on the present grid, in which case it is assumed to be a cell data
+ * vector. As the number of degrees of freedom and of cells is usually not
+ * equal, the function can determine itself which type of vector it is
+ * given. However, there are corner cases where this automatic determination
+ * does not work. One example is if you compute with piecewise constant
+ * elements and have a scalar solution, then there are as many cells as
+ * there are degrees of freedom (though they may be numbered
+ * differently). Another possibility is if you have a 1d mesh embedded in 2d
+ * space and the mesh consists of a closed curve of cells; in this case,
+ * there are as many nodes as there are cells, and when using a Q1 element
+ * you will have as many degrees of freedom as there are cells. In these
+ * cases, you can change the last argument of the function from its default
+ * value #type_automatic to either #type_dof_data or #type_cell_data,
+ * depending on what the vector represents. Apart from such corner cases,
+ * you can leave the argument at its default value and let the function
+ * determine the type of the vector itself.
+ *
+ * If it is a vector holding DoF data, the names given shall be one for each
+ * component of the underlying finite element. If it is a finite element
+ * composed of only one subelement, then there is another function following
+ * which takes a single name instead of a vector of names.
+ *
+ * The data_component_interpretation argument contains information about how
+ * the individual components of output files that consist of more than one
+ * data set are to be interpreted.
+ *
+ * For example, if one has a finite element for the Stokes equations in 2d,
+ * representing components (u,v,p), one would like to indicate that the
+ * first two, u and v, represent a logical vector so that later on when we
+ * generate graphical output we can hand them off to a visualization program
+ * that will automatically know to render them as a vector field, rather
+ * than as two separate and independent scalar fields.
+ *
+ * The default value of this argument (i.e. an empty vector) corresponds is
+ * equivalent to a vector of values
+ * DataComponentInterpretation::component_is_scalar, indicating that all
+ * output components are independent scalar fields. However, if the given
+ * data vector represents logical vectors, you may pass a vector that
+ * contains values
+ * DataComponentInterpretation::component_is_part_of_vector. In the example
+ * above, one would pass in a vector with components
+ * (DataComponentInterpretation::component_is_part_of_vector,
+ * DataComponentInterpretation::component_is_part_of_vector,
+ * DataComponentInterpretation::component_is_scalar) for (u,v,p).
+ *
+ * The names of a data vector shall only contain characters which are
+ * letters, underscore and a few other ones. Refer to the
+ * ExcInvalidCharacter exception declared in this class to see which
+ * characters are valid and which are not.
+ *
+ * @note The actual type for the vector argument may be any vector type from
+ * which FEValues can extract values on a cell using the
+ * FEValuesBase::get_function_values() function. In particular, this
+ * includes all of the usual vector types, but also IndexSet (see step-41
+ * for a use of this).
+ */
+ template <class VECTOR>
+ void add_data_vector (const VECTOR &data,
+ const std::vector<std::string> &names,
+ const DataVectorType type = type_automatic,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &data_component_interpretation
+ = std::vector<DataComponentInterpretation::DataComponentInterpretation>());
+
+ /**
+ * This function is an abbreviation to the above one (see there for a
+ * discussion of the various arguments), intended for use with finite
+ * elements that are not composed of subelements. In this case, only one
+ * name per data vector needs to be given, which is what this function
+ * takes. It simply relays its arguments after a conversion of the @p name
+ * to a vector of strings, to the other add_data_vector() function above.
+ *
+ * If @p data is a vector with multiple components this function will
+ * generate distinct names for all components by appending an underscore and
+ * the number of each component to @p name
+ *
+ * The actual type for the template argument may be any vector type from
+ * which FEValues can extract values on a cell using the
+ * FEValuesBase::get_function_values() function.
+ */
+ template <class VECTOR>
+ void add_data_vector (const VECTOR &data,
+ const std::string &name,
+ const DataVectorType type = type_automatic,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &data_component_interpretation
+ = std::vector<DataComponentInterpretation::DataComponentInterpretation>());
+
+ /**
+ * This function is an extension of the above one (see there for a
+ * discussion of the arguments except the first one) and allows to set a
+ * vector with its own DoFHandler object. This DoFHandler needs to be
+ * compatible with the other DoFHandler objects assigned with calls to @p
+ * add_data_vector or @p attach_dof_handler, in the sense that the
+ * DoFHandler objects need to be based on the same triangulation. This
+ * function allows you to export data from multiple DoFHandlers that
+ * describe different solution components.
+ *
+ * Since this function takes a DoFHandler object and hence naturally
+ * represents dof data, the data vector type argument present in the other
+ * methods above is skipped.
+ */
+ template <class VECTOR>
+ void add_data_vector (const DH &dof_handler,
+ const VECTOR &data,
+ const std::vector<std::string> &names,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &data_component_interpretation
+ = std::vector<DataComponentInterpretation::DataComponentInterpretation>());
+
+
+ /**
+ * This function is an abbreviation of the function above with only a scalar
+ * @p dof_handler given and a single data name.
+ */
+ template <class VECTOR>
+ void add_data_vector (const DH &dof_handler,
+ const VECTOR &data,
+ const std::string &name,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &data_component_interpretation
+ = std::vector<DataComponentInterpretation::DataComponentInterpretation>());
+
+ /**
+ * This function is an alternative to the above ones, allowing the output of
+ * derived quantities instead of the given data. This converison has to be
+ * done in a class derived from DataPostprocessor.
+ *
+ * The names for these derived quantities are provided by the @p
+ * data_postprocessor argument. Likewise, the data_component_interpretation
+ * argument of the other add_data_vector() functions is provided by the
+ * data_postprocessor argument. As only data of type @p type_dof_data can be
+ * transformed, this type is also known implicitly and does not have to be
+ * given.
+ *
+ * @note The actual type for the vector argument may be any vector type from
+ * which FEValues can extract values on a cell using the
+ * FEValuesBase::get_function_values() function. In particular, this
+ * includes all of the usual vector types, but also IndexSet (see step-41
+ * for a use of this).
+ */
+ template <class VECTOR>
+ void add_data_vector (const VECTOR &data,
+ const DataPostprocessor<DH::space_dimension> &data_postprocessor);
+
+ /**
+ * Same function as above, but with a DoFHandler object that does not need
+ * to coincide with the DoFHandler initially set. Note that the
+ * postprocessor can only read data from the given DoFHandler and solution
+ * vector, not other solution vectors or DoFHandlers.
+ */
+ template <class VECTOR>
+ void add_data_vector (const DH &dof_handler,
+ const VECTOR &data,
+ const DataPostprocessor<DH::space_dimension> &data_postprocessor);
+
+ /**
+ * Release the pointers to the data vectors. This allows output of a new set
+ * of vectors without supplying the DoF handler again. Therefore, the
+ * DataOut object can be used in an algebraic context. Note that besides the
+ * data vectors also the patches already computed are deleted.
+ */
+ void clear_data_vectors ();
+
+ /**
+ * Release pointers to all input data elements, i.e. pointers to data
+ * vectors and to the DoF handler object. This function may be useful when
+ * you have called the @p build_patches function of derived class, since
+ * then the patches are built and the input data is no more needed, nor is
+ * there a need to reference it. You can then output the patches detached
+ * from the main thread and need not make sure anymore that the DoF handler
+ * object and vectors must not be deleted before the output thread is
+ * finished.
+ */
+ void clear_input_data_references ();
+
+ /**
+ * This function can be used to merge the patches that were created using
+ * the @p build_patches function of the object given as argument into the
+ * list of patches created by this object. This is sometimes handy if one
+ * has, for example, a domain decomposition algorithm where each block is
+ * represented by a DoFHandler of its own, but one wants to output the
+ * solution on all the blocks at the same time.
+ *
+ * For this to work, the given argument and this object need to have the
+ * same number of output vectors, and they need to use the same number of
+ * subdivisions per patch. The output will probably look rather funny if
+ * patches in both objects overlap in space.
+ *
+ * If you call build_patches() for this object after merging in patches, the
+ * previous state is overwritten, and the merged-in patches are lost.
+ *
+ * The second parameter allows to shift each node of the patches in the
+ * object passed in in the first parameter by a certain amount. This is
+ * sometimes useful to generate "exploded" views of a collection of blocks.
+ *
+ * This function will fail if either this or the other object did not yet
+ * set up any patches.
+ */
+ template <class DH2>
+ void merge_patches (const DataOut_DoFData<DH2,patch_dim,patch_space_dim> &source,
+ const Point<patch_space_dim> &shift = Point<patch_space_dim>());
+
+ /**
+ * Release the pointers to the data vectors and the DoF handler. You have to
+ * set all data entries again using the add_data_vector() function. The
+ * pointer to the dof handler is cleared as well, along with all other
+ * data. In effect, this function resets everything to a virgin state.
+ */
+ virtual void clear ();
+
+ /**
+ * Determine an estimate for the memory consumption (in bytes) of this
+ * object.
+ */
+ std::size_t memory_consumption () const;
+
+ /**
+ * Exception
+ */
+ DeclException0 (ExcNoTriangulationSelected);
+
+ /**
+ * Exception
+ */
+ DeclException0 (ExcNoDoFHandlerSelected);
+
+ /**
+ * Exception
+ */
+ DeclException0 (ExcDataPostprocessingIsNotPossibleForCellData);
+
+ /**
+ * Exception
+ */
+ DeclException3 (ExcInvalidVectorSize,
+ int, int, int,
+ << "The vector has size " << arg1
+ << " but the DoFHandler objects says there are " << arg2
+ << " degrees of freedom and there are " << arg3
+ << " active cells.");
+ /**
+ * Exception
+ */
+ DeclException2 (ExcInvalidCharacter,
+ std::string, size_t,
+ << "Please use only the characters [a-zA-Z0-9_<>()] for" << std::endl
+ << "description strings since some graphics formats will only accept these."
+ << std::endl
+ << "The string you gave was <" << arg1
+ << ">, the invalid character is <" << arg1[arg2]
+ << ">." << std::endl);
+ /**
+ * Exception
+ */
+ DeclException0 (ExcOldDataStillPresent);
+ /**
+ * Exception
+ */
+ DeclException2 (ExcInvalidNumberOfNames,
+ int, int,
+ << "You have to give one name per component in your "
+ << "data vector. The number you gave was " << arg1
+ << ", but the number of components is " << arg2);
+ /**
+ * Exception
+ */
+ DeclException0 (ExcNoPatches);
+ /**
+ * Exception
+ */
+ DeclException0 (ExcIncompatibleDatasetNames);
+ /**
+ * Exception
+ */
+ DeclException0 (ExcIncompatiblePatchLists);
+
+ DeclException2 (ExcInvalidVectorDeclaration,
+ int, std::string,
+ << "When declaring that a number of components in a data\n"
+ << "set to be output logically form a vector instead of\n"
+ << "simply a set of scalar fields, you need to specify\n"
+ << "this for all relevant components. Furthermore,\n"
+ << "vectors must always consist of exactly <dim>\n"
+ << "components. However, the vector component at\n"
+ << "position " << arg1 << " with name <" << arg2
+ << "> does not satisfy these conditions.");
+
+protected:
+ /**
+ * Abbreviate the somewhat lengthy name for the Patch class.
+ */
+ typedef dealii::DataOutBase::Patch<patch_dim,patch_space_dim> Patch;
+
+ /**
+ * Pointer to the triangulation object.
+ */
+ SmartPointer<const Triangulation<DH::dimension,DH::space_dimension> > triangulation;
+
+ /**
+ * Pointer to the optional handler object.
+ */
+ SmartPointer<const DH> dofs;
+
+ /**
+ * List of data elements with vectors of values for each degree of freedom.
+ */
+ std::vector<std_cxx1x::shared_ptr<internal::DataOut::DataEntryBase<DH> > > dof_data;
+
+ /**
+ * List of data elements with vectors of values for each cell.
+ */
+ std::vector<std_cxx1x::shared_ptr<internal::DataOut::DataEntryBase<DH> > > cell_data;
+
+ /**
+ * This is a list of patches that is created each time build_patches() is
+ * called. These patches are used in the output routines of the base
+ * classes.
+ */
+ std::vector<Patch> patches;
+
+ /**
+ * Function by which the base class's functions get to know what patches
+ * they shall write to a file.
+ */
+ virtual
+ const std::vector<Patch> &get_patches () const;
+
+ /**
+ * Virtual function through which the names of data sets are obtained by the
+ * output functions of the base class.
+ */
+ virtual
+ std::vector<std::string> get_dataset_names () const;
+
+ /**
+ * Extracts the finite elements stored in the dof_data object, including a
+ * dummy object of FE_DGQ<dim>(0) in case only the triangulation is used.
+ */
+ std::vector<std_cxx1x::shared_ptr<dealii::hp::FECollection<DH::dimension,DH::space_dimension> > >
+ get_finite_elements() const;
+
+ /**
+ * Overload of the respective DataOutInterface::get_vector_data_ranges()
+ * function. See there for a more extensive documentation.
+ */
+ virtual
+ std::vector<std_cxx1x::tuple<unsigned int, unsigned int, std::string> >
+ get_vector_data_ranges () const;
+
+ /**
+ * Make all template siblings friends. Needed for the merge_patches()
+ * function.
+ */
+ template <class, int, int>
+ friend class DataOut_DoFData;
+};
+
+
+
+// -------------------- template and inline functions ------------------------
+
+
+template <class DH, int patch_dim, int patch_space_dim>
+template <class DH2>
+void
+DataOut_DoFData<DH,patch_dim,patch_space_dim>::
+merge_patches (const DataOut_DoFData<DH2,patch_dim,patch_space_dim> &source,
+ const Point<patch_space_dim> &shift)
+{
+ const std::vector<Patch> source_patches = source.get_patches ();
+ Assert (patches.size () != 0, ExcNoPatches ());
+ Assert (source_patches.size () != 0, ExcNoPatches ());
+ // check equality of component
+ // names
+ Assert (get_dataset_names() == source.get_dataset_names(),
+ ExcIncompatibleDatasetNames());
+ // make sure patches are compatible. we'll
+ // assume that if the first respective
+ // patches are ok that all the other ones
+ // are ok as well
+ Assert (patches[0].n_subdivisions == source_patches[0].n_subdivisions,
+ ExcIncompatiblePatchLists());
+ Assert (patches[0].data.n_rows() == source_patches[0].data.n_rows(),
+ ExcIncompatiblePatchLists());
+ Assert (patches[0].data.n_cols() == source_patches[0].data.n_cols(),
+ ExcIncompatiblePatchLists());
+
+ // check equality of the vector data
+ // specifications
+ Assert (get_vector_data_ranges().size() ==
+ source.get_vector_data_ranges().size(),
+ ExcMessage ("Both sources need to declare the same components "
+ "as vectors."));
+ for (unsigned int i=0; i<get_vector_data_ranges().size(); ++i)
+ {
+ Assert (std_cxx1x::get<0>(get_vector_data_ranges()[i]) ==
+ std_cxx1x::get<0>(source.get_vector_data_ranges()[i]),
+ ExcMessage ("Both sources need to declare the same components "
+ "as vectors."));
+ Assert (std_cxx1x::get<1>(get_vector_data_ranges()[i]) ==
+ std_cxx1x::get<1>(source.get_vector_data_ranges()[i]),
+ ExcMessage ("Both sources need to declare the same components "
+ "as vectors."));
+ Assert (std_cxx1x::get<2>(get_vector_data_ranges()[i]) ==
+ std_cxx1x::get<2>(source.get_vector_data_ranges()[i]),
+ ExcMessage ("Both sources need to declare the same components "
+ "as vectors."));
+ }
+
+ // merge patches. store old number
+ // of elements, since we need to
+ // adjust patch numbers, etc
+ // afterwards
+ const unsigned int old_n_patches = patches.size();
+ patches.insert (patches.end(),
+ source_patches.begin(),
+ source_patches.end());
+
+ // perform shift, if so desired
+ if (shift != Point<patch_space_dim>())
+ for (unsigned int i=old_n_patches; i<patches.size(); ++i)
+ for (unsigned int v=0; v<GeometryInfo<patch_dim>::vertices_per_cell; ++v)
+ patches[i].vertices[v] += shift;
+
+ // adjust patch numbers
+ for (unsigned int i=old_n_patches; i<patches.size(); ++i)
+ patches[i].patch_index += old_n_patches;
+
+ // adjust patch neighbors
+ for (unsigned int i=old_n_patches; i<patches.size(); ++i)
+ for (unsigned int n=0; n<GeometryInfo<patch_dim>::faces_per_cell; ++n)
+ if (patches[i].neighbors[n] != Patch::no_neighbor)
+ patches[i].neighbors[n] += old_n_patches;
+}
+
+
+DEAL_II_NAMESPACE_CLOSE
+
+#endif
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2011, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__data_out_faces_h
#define __deal2__data_out_faces_h
template <int dim, int spacedim>
struct ParallelData : public internal::DataOut::ParallelDataBase<dim,spacedim>
{
- template <class FE>
- ParallelData (const Quadrature<dim-1> &quadrature,
- const unsigned int n_components,
- const unsigned int n_datasets,
+ ParallelData (const unsigned int n_datasets,
const unsigned int n_subdivisions,
const std::vector<unsigned int> &n_postprocessor_outputs,
const Mapping<dim,spacedim> &mapping,
- const FE &finite_elements,
+ const std::vector<std_cxx1x::shared_ptr<dealii::hp::FECollection<dim,spacedim> > > &finite_elements,
const UpdateFlags update_flags);
- const dealii::hp::QCollection<dim-1> q_collection;
- const dealii::hp::MappingCollection<dim,spacedim> mapping_collection;
- dealii::hp::FEFaceValues<dim> x_fe_values;
-
std::vector<Point<dim> > patch_normals;
std::vector<Point<spacedim> > patch_evaluation_points;
};
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__data_out_rotation_h
#define __deal2__data_out_rotation_h
#include <deal.II/base/config.h>
-#include <deal.II/numerics/data_out.h>
+#include <deal.II/numerics/data_out_dof_data.h>
#include <string>
#include <vector>
template <int dim, int spacedim>
struct ParallelData : public internal::DataOut::ParallelDataBase<dim,spacedim>
{
- template <class FE>
- ParallelData (const Quadrature<dim> &quadrature,
- const unsigned int n_components,
- const unsigned int n_datasets,
+ ParallelData (const unsigned int n_datasets,
const unsigned int n_subdivisions,
const unsigned int n_patches_per_circle,
const std::vector<unsigned int> &n_postprocessor_outputs,
- const FE &finite_elements,
+ const Mapping<dim,spacedim> &mapping,
+ const std::vector<std_cxx1x::shared_ptr<dealii::hp::FECollection<dim,spacedim> > > &finite_elements,
const UpdateFlags update_flags);
const unsigned int n_patches_per_circle;
- const dealii::hp::QCollection<dim> q_collection;
- dealii::hp::FEValues<dim,spacedim> x_fe_values;
-
std::vector<Point<spacedim> > patch_evaluation_points;
};
}
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__data_out_stack_h
#define __deal2__data_out_stack_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2007, 2008, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2007 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__data_postprocessor_h
#define __deal2__data_postprocessor_h
* takes a solution that consists of velocity, pressure and temperature (dim+2
* components) and computes a variety of output quantities, some of which
* are vector valued and some of which are scalar. On the other hand,
- * in step-28 we implement a postprocessor that only computes the magnitude
+ * in step-29 we implement a postprocessor that only computes the magnitude
* of a complex number given by a two-component finite element. It seems silly
* to have to implement four virtual functions for this
* (compute_derived_quantities_scalar() or compute_derived_quantities_vector(),
-
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 2000 - 2013 by the deal.II authors
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2012 by the deal.II authors
+// This file is part of the deal.II library.
//
-// 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.
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
//
-//---------------------------------------------------------------------------
+// ---------------------------------------------------------------------
+
#ifndef __deal2__gradient_estimator_h
#define __deal2__gradient_estimator_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__dof_output_operator_h
#define __deal2__dof_output_operator_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2007, 2008, 2009, 2010, 2012 by Guido Kanschat
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/numerics/dof_output_operator.h>
#include <deal.II/numerics/data_out.h>
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__dof_print_solver_step_h
#define __deal2__dof_print_solver_step_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__error_estimator_h
#define __deal2__error_estimator_h
{
public:
/**
- * Implementation of the error
- * estimator described above. You
- * may give a coefficient, but
- * there is a default value which
- * denotes the constant
- * coefficient with value
- * one. The coefficient function
- * may either be a scalar one, in
- * which case it is used for all
- * components of the finite
- * element, or a vector-valued
- * one with as many components as
- * there are in the finite
- * element; in the latter case,
- * each component is weighted by
- * the respective component in
- * the coefficient.
+ * Implementation of the error estimator described above. You may give a
+ * coefficient, but there is a default value which denotes the constant
+ * coefficient with value one. The coefficient function may either be a
+ * scalar one, in which case it is used for all components of the finite
+ * element, or a vector-valued one with as many components as there are in
+ * the finite element; in the latter case, each component is weighted by the
+ * respective component in the coefficient.
*
- * You might give a list of
- * components you want to
- * evaluate, in case the finite
- * element used by the
- * DoFHandler object is
- * vector-valued. You then have
- * to set those entries to true
- * in the bit-vector
- * @p component_mask
- * (see @ref GlossComponentMask)
- * for which the
- * respective component is to be
- * used in the error
- * estimator. The default is to
- * use all components, which is
- * done by either providing a
- * bit-vector with all-set
- * entries, or an empty
- * bit-vector.
+ * You might give a list of components you want to evaluate, in case the
+ * finite element used by the DoFHandler object is vector-valued. You then
+ * have to set those entries to true in the bit-vector @p component_mask
+ * (see @ref GlossComponentMask) for which the respective component is to be
+ * used in the error estimator. The default is to use all components, which
+ * is done by either providing a bit-vector with all-set entries, or an
+ * empty bit-vector.
*
- * The @p subdomain_id parameter
- * indicates whether we shall compute
- * indicators for all cells (in case its
- * value is the default,
- * <tt>numbers::invalid_unsigned_int</tt>),
- * or only for the cells belonging to a
- * certain subdomain with the given
- * indicator. The latter case is used for
- * parallel computations where all
- * processor nodes have the global grid
- * stored, and could well compute all the
- * indicators for all cells themselves,
- * but where it is more efficient to have
- * each process compute only indicators
- * for the cells it owns, and have them
- * exchange the resulting information
- * afterwards. This is in particular true
- * for the case where meshes are very
- * large and computing indicators for @em
- * every cell is too expensive, while
- * computing indicators for only local
- * cells is acceptable. Note that if you
- * only ask for the indicators of a
- * certain subdomain to be computed, you
- * must nevertheless make sure that this
- * function has access to the correct
- * node values of @em all degrees of
- * freedom. This is since the function
- * needs to access DoF values on
- * neighboring cells as well, even if
- * they belong to a different subdomain.
+ * The @p subdomain_id parameter indicates whether we shall compute
+ * indicators for all cells (in case its value is the default,
+ * <tt>numbers::invalid_unsigned_int</tt>), or only for the cells belonging
+ * to a certain subdomain with the given indicator. The latter case is used
+ * for parallel computations where all processor nodes have the global grid
+ * stored, and could well compute all the indicators for all cells
+ * themselves, but where it is more efficient to have each process compute
+ * only indicators for the cells it owns, and have them exchange the
+ * resulting information afterwards. This is in particular true for the case
+ * where meshes are very large and computing indicators for @em every cell
+ * is too expensive, while computing indicators for only local cells is
+ * acceptable. Note that if you only ask for the indicators of a certain
+ * subdomain to be computed, you must nevertheless make sure that this
+ * function has access to the correct node values of @em all degrees of
+ * freedom. This is since the function needs to access DoF values on
+ * neighboring cells as well, even if they belong to a different subdomain.
*
- * The @p material_id parameter has a similar
- * meaning: if not set to its default value
- * (which is numbers::invalid_material_id),
- * it means that indicators will only be
- * computed for cells with this particular
- * material id.
+ * The @p material_id parameter has a similar meaning: if not set to its
+ * default value (which is numbers::invalid_material_id), it means that
+ * indicators will only be computed for cells with this particular material
+ * id.
*
- * The @p n_threads parameter used to
- * indicate the number of threads to be
- * used to compute the error
- * estimator. This parameter is now
- * ignored, with the number of threads
- * determined automatically. The
- * parameter is retained for
- * compatibility with old versions of the
- * library.
+ * The @p n_threads parameter used to indicate the number of threads to be
+ * used to compute the error estimator. This parameter is now ignored, with
+ * the number of threads determined automatically. The parameter is retained
+ * for compatibility with old versions of the library.
*
- * @note If the DoFHandler object
- * given as an argument to this
- * function builds on a
- * parallel::distributed::Triangulation,
- * this function skips
- * computations on all cells that
- * are not locally owned. In that
- * case, the only valid value for
- * the subdomain_id argument
- * (besides the invalid value) is
- * the subdomain id that is
- * associated with the currently
+ * @note If the DoFHandler object given as an argument to this function
+ * builds on a parallel::distributed::Triangulation, this function skips
+ * computations on all cells that are not locally owned. In that case, the
+ * only valid value for the subdomain_id argument (besides the invalid
+ * value) is the subdomain id that is associated with the currently
* processor, as reported by
* parallel::distributed::Triangulation::locally_owned_subdomain(). Even
- * though nothing is computed on
- * cells that we don't locally
- * own, the error indicator
- * vector must still have a
- * length equal to the number of
- * active cell in the mesh as
- * reported by
+ * though nothing is computed on cells that we don't locally own, the error
+ * indicator vector must still have a length equal to the number of active
+ * cell in the mesh as reported by
* parallel::distributed::Triangulation::n_locally_owned_active_cells().
*/
template <typename InputVector, class DH>
const types::material_id material_id = numbers::invalid_material_id);
/**
- * Calls the @p estimate
- * function, see above, with
+ * Calls the @p estimate function, see above, with
* <tt>mapping=MappingQ1@<dim@>()</tt>.
*/
template <typename InputVector, class DH>
const types::material_id material_id = numbers::invalid_material_id);
/**
- * Same function as above, but
- * accepts more than one solution
- * vector and returns one error
- * vector for each solution
- * vector. For the reason of
- * existence of this function,
- * see the general documentation
- * of this class.
+ * Same function as above, but accepts more than one solution vector and
+ * returns one error vector for each solution vector. For the reason of
+ * existence of this function, see the general documentation of this class.
*
- * Since we do not want to force
- * the user of this function to
- * copy around their solution
- * vectors, the vector of
- * solution vectors takes
- * pointers to the solutions,
- * rather than being a vector of
- * vectors. This makes it simpler
- * to have the solution vectors
- * somewhere in memory, rather
- * than to have them collected
- * somewhere special. (Note that
- * it is not possible to
- * construct of vector of
- * references, so we had to use a
- * vector of pointers.)
+ * Since we do not want to force the user of this function to copy around
+ * their solution vectors, the vector of solution vectors takes pointers to
+ * the solutions, rather than being a vector of vectors. This makes it
+ * simpler to have the solution vectors somewhere in memory, rather than to
+ * have them collected somewhere special. (Note that it is not possible to
+ * construct of vector of references, so we had to use a vector of
+ * pointers.)
*/
template <typename InputVector, class DH>
static void estimate (const Mapping<dim, spacedim> &mapping,
const types::material_id material_id = numbers::invalid_material_id);
/**
- * Calls the @p estimate
- * function, see above, with
+ * Calls the @p estimate function, see above, with
* <tt>mapping=MappingQ1@<dim@>()</tt>.
*/
template <typename InputVector, class DH>
/**
- * Equivalent to the set of functions
- * above, except that this one takes a
- * quadrature collection for hp finite
- * element dof handlers.
+ * Equivalent to the set of functions above, except that this one takes a
+ * quadrature collection for hp finite element dof handlers.
*/
template <typename InputVector, class DH>
static void estimate (const Mapping<dim, spacedim> &mapping,
/**
- * Equivalent to the set of functions
- * above, except that this one takes a
- * quadrature collection for hp finite
- * element dof handlers.
+ * Equivalent to the set of functions above, except that this one takes a
+ * quadrature collection for hp finite element dof handlers.
*/
template <typename InputVector, class DH>
static void estimate (const DH &dof,
/**
- * Equivalent to the set of functions
- * above, except that this one takes a
- * quadrature collection for hp finite
- * element dof handlers.
+ * Equivalent to the set of functions above, except that this one takes a
+ * quadrature collection for hp finite element dof handlers.
*/
template <typename InputVector, class DH>
static void estimate (const Mapping<dim, spacedim> &mapping,
/**
- * Equivalent to the set of functions
- * above, except that this one takes a
- * quadrature collection for hp finite
- * element dof handlers.
+ * Equivalent to the set of functions above, except that this one takes a
+ * quadrature collection for hp finite element dof handlers.
*/
template <typename InputVector, class DH>
static void estimate (const DH &dof,
{
public:
/**
- * Implementation of the error
- * estimator described above. You
- * may give a coefficient, but
- * there is a default value which
- * denotes the constant
- * coefficient with value
- * one. The coefficient function
- * may either be a scalar one, in
- * which case it is used for all
- * components of the finite
- * element, or a vector-valued
- * one with as many components as
- * there are in the finite
- * element; in the latter case,
- * each component is weighted by
- * the respective component in
- * the coefficient.
+ * Implementation of the error estimator described above. You may give a
+ * coefficient, but there is a default value which denotes the constant
+ * coefficient with value one. The coefficient function may either be a
+ * scalar one, in which case it is used for all components of the finite
+ * element, or a vector-valued one with as many components as there are in
+ * the finite element; in the latter case, each component is weighted by the
+ * respective component in the coefficient.
*
- * You might give a list of components
- * you want to evaluate, in case the
- * finite element used by the DoFHandler
- * object is vector-valued. You then have
- * to set those entries to true in the
- * bit-vector @p component_mask for which
- * the respective component is to be used
- * in the error estimator. The default is
- * to use all components, which is done
- * by either providing a bit-vector with
- * all-set entries, or an empty
- * bit-vector. All the other parameters
- * are as in the general case used for 2d
- * and higher.
+ * You might give a list of components you want to evaluate, in case the
+ * finite element used by the DoFHandler object is vector-valued. You then
+ * have to set those entries to true in the bit-vector @p component_mask for
+ * which the respective component is to be used in the error estimator. The
+ * default is to use all components, which is done by either providing a
+ * bit-vector with all-set entries, or an empty bit-vector. All the other
+ * parameters are as in the general case used for 2d and higher.
*
- * The estimator supports multithreading
- * and splits the cells to
- * <tt>multithread_info.n_default_threads</tt>
- * (default) threads. The number of
- * threads to be used in multithreaded
- * mode can be set with the last
- * parameter of the error estimator.
- * Multithreading is not presently
- * implemented for 1d, but we retain the
- * respective parameter for compatibility
- * with the function signature in the
- * general case.
+ * The estimator supports multithreading and splits the cells to
+ * <tt>multithread_info.n_default_threads</tt> (default) threads. The number
+ * of threads to be used in multithreaded mode can be set with the last
+ * parameter of the error estimator. Multithreading is not presently
+ * implemented for 1d, but we retain the respective parameter for
+ * compatibility with the function signature in the general case.
*/
template <typename InputVector, class DH>
static void estimate (const Mapping<1,spacedim> &mapping,
const types::material_id material_id = numbers::invalid_material_id);
/**
- * Calls the @p estimate
- * function, see above, with
+ * Calls the @p estimate function, see above, with
* <tt>mapping=MappingQ1<1>()</tt>.
*/
template <typename InputVector, class DH>
const types::material_id material_id = numbers::invalid_material_id);
/**
- * Same function as above, but
- * accepts more than one solution
- * vectors and returns one error
- * vector for each solution
- * vector. For the reason of
- * existence of this function,
- * see the general documentation
- * of this class.
+ * Same function as above, but accepts more than one solution vectors and
+ * returns one error vector for each solution vector. For the reason of
+ * existence of this function, see the general documentation of this class.
*
- * Since we do not want to force
- * the user of this function to
- * copy around their solution
- * vectors, the vector of
- * solution vectors takes
- * pointers to the solutions,
- * rather than being a vector of
- * vectors. This makes it simpler
- * to have the solution vectors
- * somewhere in memory, rather
- * than to have them collected
- * somewhere special. (Note that
- * it is not possible to
- * construct of vector of
- * references, so we had to use a
- * vector of pointers.)
+ * Since we do not want to force the user of this function to copy around
+ * their solution vectors, the vector of solution vectors takes pointers to
+ * the solutions, rather than being a vector of vectors. This makes it
+ * simpler to have the solution vectors somewhere in memory, rather than to
+ * have them collected somewhere special. (Note that it is not possible to
+ * construct of vector of references, so we had to use a vector of
+ * pointers.)
*/
template <typename InputVector, class DH>
static void estimate (const Mapping<1,spacedim> &mapping,
const types::material_id material_id = numbers::invalid_material_id);
/**
- * Calls the @p estimate
- * function, see above, with
+ * Calls the @p estimate function, see above, with
* <tt>mapping=MappingQ1<1>()</tt>.
*/
template <typename InputVector, class DH>
/**
- * Equivalent to the set of functions
- * above, except that this one takes a
- * quadrature collection for hp finite
- * element dof handlers.
+ * Equivalent to the set of functions above, except that this one takes a
+ * quadrature collection for hp finite element dof handlers.
*/
template <typename InputVector, class DH>
static void estimate (const Mapping<1,spacedim> &mapping,
/**
- * Equivalent to the set of functions
- * above, except that this one takes a
- * quadrature collection for hp finite
- * element dof handlers.
+ * Equivalent to the set of functions above, except that this one takes a
+ * quadrature collection for hp finite element dof handlers.
*/
template <typename InputVector, class DH>
static void estimate (const DH &dof,
/**
- * Equivalent to the set of functions
- * above, except that this one takes a
- * quadrature collection for hp finite
- * element dof handlers.
+ * Equivalent to the set of functions above, except that this one takes a
+ * quadrature collection for hp finite element dof handlers.
*/
template <typename InputVector, class DH>
static void estimate (const Mapping<1,spacedim> &mapping,
/**
- * Equivalent to the set of functions
- * above, except that this one takes a
- * quadrature collection for hp finite
- * element dof handlers.
+ * Equivalent to the set of functions above, except that this one takes a
+ * quadrature collection for hp finite element dof handlers.
*/
template <typename InputVector, class DH>
static void estimate (const DH &dof,
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2007, 2009, 2012, 2013 by the deal.II authors
+// Copyright (C) 2007 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__fe_function_h
#define __deal2__fe_function_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2007, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2007 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/utilities.h>
#include <deal.II/base/logstream.h>
typename DH::active_cell_iterator cell = cell_hint.get();
if (cell == dh->end())
cell = dh->begin_active();
-
+
boost::optional<Point<dim> >
qp = get_reference_coordinates (cell, p);
if (!qp)
{
const std::pair<typename DH::active_cell_iterator, Point<dim> > my_pair
= GridTools::find_active_cell_around_point (mapping, *dh, p);
- AssertThrow (my_pair.first->is_locally_owned(),
- ExcPointNotAvailableHere());
-
+ AssertThrow (my_pair.first->is_locally_owned(),
+ ExcPointNotAvailableHere());
+
cell = my_pair.first;
qp = my_pair.second;
}
{
const std::pair<typename DH::active_cell_iterator, Point<dim> > my_pair
= GridTools::find_active_cell_around_point (mapping, *dh, p);
- AssertThrow (my_pair.first->is_locally_owned(),
- ExcPointNotAvailableHere());
-
+ AssertThrow (my_pair.first->is_locally_owned(),
+ ExcPointNotAvailableHere());
+
cell = my_pair.first;
qp = my_pair.second;
}
{
const std::pair<typename DH::active_cell_iterator, Point<dim> > my_pair
= GridTools::find_active_cell_around_point (mapping, *dh, p);
- AssertThrow (my_pair.first->is_locally_owned(),
- ExcPointNotAvailableHere());
-
+ AssertThrow (my_pair.first->is_locally_owned(),
+ ExcPointNotAvailableHere());
+
cell = my_pair.first;
qp = my_pair.second;
}
const std::pair<typename DH::active_cell_iterator, Point<dim> >
my_pair = GridTools::find_active_cell_around_point
(mapping, *dh, points[0]);
- AssertThrow (my_pair.first->is_locally_owned(),
- ExcPointNotAvailableHere());
-
+ AssertThrow (my_pair.first->is_locally_owned(),
+ ExcPointNotAvailableHere());
+
cell = my_pair.first;
qp = my_pair.second;
point_flags[0] = true;
{
const std::pair<typename DH::active_cell_iterator, Point<dim> > my_pair
= GridTools::find_active_cell_around_point (mapping, *dh, points[first_outside]);
- AssertThrow (my_pair.first->is_locally_owned(),
- ExcPointNotAvailableHere());
-
+ AssertThrow (my_pair.first->is_locally_owned(),
+ ExcPointNotAvailableHere());
+
cells.push_back(my_pair.first);
qpoints.push_back(std::vector<Point<dim> >(1, my_pair.second));
maps.push_back(std::vector<unsigned int>(1, first_outside));
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__histogram_h
#define __deal2__histogram_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__matrix_tools_h
#define __deal2__matrix_tools_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2012 by Michael Rapson and the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __dealii__point_value_history_h
#define __dealii__point_value_history_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__solution_transfer_h
#define __deal2__solution_transfer_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__time_dependent_h
#define __deal2__time_dependent_h
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef __deal2__vector_tools_h
#define __deal2__vector_tools_h
*
* <li> Creation of right hand side vectors for point sources:
* The create_point_source_vector() function computes the vector
- * $f_i = \int_\Omega \delta_0(x-x_0) \phi_i(x) dx$.
+ * $f_i = \int_\Omega \delta(x-x_0) \phi_i(x) dx$.
*
* <li> Creation of boundary right hand side vectors: The
* create_boundary_right_hand_side() function computes the vector
/**
* Calls the project()
- * function, see above, with
+ * function above, with
* <tt>mapping=MappingQ1@<dim@>()</tt>.
*/
template <int dim, class VECTOR, int spacedim>
Quadrature<dim-1>(0)),
const bool project_to_boundary_first = false);
+ /**
+ * Same as above, but for arguments of type hp::DoFHandler,
+ * hp::QuadratureCollection, hp::MappingCollection
+ */
+ template <int dim, class VECTOR, int spacedim>
+ void project (const hp::MappingCollection<dim, spacedim> &mapping,
+ const hp::DoFHandler<dim,spacedim> &dof,
+ const ConstraintMatrix &constraints,
+ const hp::QCollection<dim> &quadrature,
+ const Function<spacedim> &function,
+ VECTOR &vec,
+ const bool enforce_zero_boundary = false,
+ const hp::QCollection<dim-1> &q_boundary = hp::QCollection<dim-1>(dim > 1 ?
+ QGauss<dim-1>(2) :
+ Quadrature<dim-1>(0)),
+ const bool project_to_boundary_first = false);
+
+ /**
+ * Calls the project()
+ * function above, with a collection of
+ * MappingQ1@<dim@>() objects.
+ */
+ template <int dim, class VECTOR, int spacedim>
+ void project (const hp::DoFHandler<dim,spacedim> &dof,
+ const ConstraintMatrix &constraints,
+ const hp::QCollection<dim> &quadrature,
+ const Function<spacedim> &function,
+ VECTOR &vec,
+ const bool enforce_zero_boundary = false,
+ const hp::QCollection<dim-1> &q_boundary = hp::QCollection<dim-1>(dim > 1 ?
+ QGauss<dim-1>(2) :
+ Quadrature<dim-1>(0)),
+ const bool project_to_boundary_first = false);
+
/**
* Compute Dirichlet boundary
* conditions. This function makes up a map
std::map<types::global_dof_index,double> &boundary_values,
const ComponentMask &component_mask = ComponentMask());
+ /**
+ * Like the previous function, but take a mapping collection to go with
+ * the hp::DoFHandler object.
+ */
+ template <int dim, int spacedim>
+ void
+ interpolate_boundary_values (const hp::MappingCollection<dim,spacedim> &mapping,
+ const hp::DoFHandler<dim,spacedim> &dof,
+ const typename FunctionMap<spacedim>::type &function_map,
+ std::map<types::global_dof_index,double> &boundary_values,
+ const ComponentMask &component_mask = ComponentMask());
+
/**
* Same function as above, but
* taking only one pair of
std::map<types::global_dof_index,double> &boundary_values,
std::vector<unsigned int> component_mapping = std::vector<unsigned int>());
+ /**
+ * Same as above, but for objects of type hp::DoFHandler
+ */
+ template <int dim, int spacedim>
+ void project_boundary_values (const hp::MappingCollection<dim, spacedim> &mapping,
+ const hp::DoFHandler<dim,spacedim> &dof,
+ const typename FunctionMap<spacedim>::type &boundary_functions,
+ const hp::QCollection<dim-1> &q,
+ std::map<types::global_dof_index,double> &boundary_values,
+ std::vector<unsigned int> component_mapping = std::vector<unsigned int>());
+
+ /**
+ * Calls the project_boundary_values()
+ * function, see above, with
+ * <tt>mapping=MappingQ1@<dim@>()</tt>.
+ */
+ template <int dim, int spacedim>
+ void project_boundary_values (const hp::DoFHandler<dim,spacedim> &dof,
+ const typename FunctionMap<spacedim>::type &boundary_function,
+ const hp::QCollection<dim-1> &q,
+ std::map<types::global_dof_index,double> &boundary_values,
+ std::vector<unsigned int> component_mapping = std::vector<unsigned int>());
+
/**
* Project a function to the boundary of
* the domain, using the given quadrature
/**
- * Compute the constraints that
- * correspond to boundary conditions of
- * the form $\vec n \cdot \vec u=0$,
- * i.e. no normal flux if $\vec u$ is a
- * vector-valued quantity. These
- * conditions have exactly the form
- * handled by the ConstraintMatrix class,
- * so instead of creating a map between
- * boundary degrees of freedom and
- * corresponding value, we here create a
- * list of constraints that are written
- * into a ConstraintMatrix. This object
- * may already have some content, for
- * example from hanging node constraints,
- * that remains untouched. These
- * constraints have to be applied to the
- * linear system like any other such
- * constraints, i.e. you have to condense
- * the linear system with the constraints
- * before solving, and you have to
- * distribute the solution vector
- * afterwards.
- *
- * The use of this function is
- * explained in more detail in
- * step-31. It
- * doesn't make much sense in 1d,
- * so the function throws an
- * exception in that case.
- *
- * The second argument of this
- * function denotes the first
- * vector component in the finite
- * element that corresponds to
- * the vector function that you
- * want to constrain. For
- * example, if we were solving a
- * Stokes equation in 2d and the
- * finite element had components
- * $(u,v,p)$, then @p
- * first_vector_component would
- * be zero. On the other hand, if
- * we solved the Maxwell
- * equations in 3d and the finite
- * element has components
- * $(E_x,E_y,E_z,B_x,B_y,B_z)$
- * and we want the boundary
- * condition $\vec n\cdot \vec
- * B=0$, then @p
- * first_vector_component would
- * be 3. Vectors are implicitly
- * assumed to have exactly
- * <code>dim</code> components
- * that are ordered in the same
- * way as we usually order the
- * coordinate directions,
- * i.e. $x$-, $y$-, and finally
- * $z$-component. The function
- * assumes, but can't check, that
- * the vector components in the
- * range
- * <code>[first_vector_component,first_vector_component+dim)</code>
- * come from the same base finite
- * element. For example, in the
- * Stokes example above, it would
- * not make sense to use a
- * <code>FESystem@<dim@>(FE_Q@<dim@>(2),
- * 1, FE_Q@<dim@>(1), dim)</code>
- * (note that the first velocity
- * vector component is a $Q_2$
- * element, whereas all the other
- * ones are $Q_1$ elements) as
- * there would be points on the
- * boundary where the
- * $x$-velocity is defined but no
- * corresponding $y$- or
- * $z$-velocities.
- *
- * The third argument denotes the set of
- * boundary indicators on which the
- * boundary condition is to be
- * enforced. Note that, as explained
- * below, this is one of the few
- * functions where it makes a difference
- * where we call the function multiple
- * times with only one boundary
- * indicator, or whether we call the
- * function onces with the whole set of
- * boundary indicators at once.
- *
- * The mapping argument is used to
- * compute the boundary points where the function
- * needs to request the normal vector $\vec n$
- * from the boundary description.
- *
- * @note When combining adaptively
- * refined meshes with hanging node
- * constraints and boundary conditions
- * like from the current function within
- * one ConstraintMatrix object, the
- * hanging node constraints should always
- * be set first, and then the boundary
- * conditions since boundary conditions
- * are not set in the second operation on
- * degrees of freedom that are already
- * constrained. This makes sure that the
- * discretization remains conforming as
- * is needed. See the discussion on
- * conflicting constraints in the module
- * on @ref constraints .
+ * Compute the constraints that correspond to boundary conditions of the
+ * form $\vec n \cdot \vec u=0$, i.e. no normal flux if $\vec u$ is a
+ * vector-valued quantity. These conditions have exactly the form handled by
+ * the ConstraintMatrix class, so instead of creating a map between boundary
+ * degrees of freedom and corresponding value, we here create a list of
+ * constraints that are written into a ConstraintMatrix. This object may
+ * already have some content, for example from hanging node constraints,
+ * that remains untouched. These constraints have to be applied to the
+ * linear system like any other such constraints, i.e. you have to condense
+ * the linear system with the constraints before solving, and you have to
+ * distribute the solution vector afterwards.
+ *
+ * The use of this function is explained in more detail in step-31. It
+ * doesn't make much sense in 1d, so the function throws an exception in
+ * that case.
+ *
+ * The second argument of this function denotes the first vector component
+ * in the finite element that corresponds to the vector function that you
+ * want to constrain. For example, if we were solving a Stokes equation in
+ * 2d and the finite element had components $(u,v,p)$, then @p
+ * first_vector_component would be zero. On the other hand, if we solved the
+ * Maxwell equations in 3d and the finite element has components
+ * $(E_x,E_y,E_z,B_x,B_y,B_z)$ and we want the boundary condition $\vec
+ * n\cdot \vec B=0$, then @p first_vector_component would be 3. Vectors are
+ * implicitly assumed to have exactly <code>dim</code> components that are
+ * ordered in the same way as we usually order the coordinate directions,
+ * i.e. $x$-, $y$-, and finally $z$-component. The function assumes, but
+ * can't check, that the vector components in the range
+ * <code>[first_vector_component,first_vector_component+dim)</code> come
+ * from the same base finite element. For example, in the Stokes example
+ * above, it would not make sense to use a
+ * <code>FESystem@<dim@>(FE_Q@<dim@>(2), 1, FE_Q@<dim@>(1), dim)</code>
+ * (note that the first velocity vector component is a $Q_2$ element,
+ * whereas all the other ones are $Q_1$ elements) as there would be points
+ * on the boundary where the $x$-velocity is defined but no corresponding
+ * $y$- or $z$-velocities.
+ *
+ * The third argument denotes the set of boundary indicators on which the
+ * boundary condition is to be enforced. Note that, as explained below, this
+ * is one of the few functions where it makes a difference where we call the
+ * function multiple times with only one boundary indicator, or whether we
+ * call the function onces with the whole set of boundary indicators at
+ * once.
+ *
+ * The mapping argument is used to compute the boundary points where the
+ * function needs to request the normal vector $\vec n$ from the boundary
+ * description.
+ *
+ * @note When combining adaptively refined meshes with hanging node
+ * constraints and boundary conditions like from the current function within
+ * one ConstraintMatrix object, the hanging node constraints should always
+ * be set first, and then the boundary conditions since boundary conditions
+ * are not set in the second operation on degrees of freedom that are
+ * already constrained. This makes sure that the discretization remains
+ * conforming as is needed. See the discussion on conflicting constraints in
+ * the module on @ref constraints .
*
*
* <h4>Computing constraints in 2d</h4>
*
- * Computing these constraints requires
- * some smarts. The main question
- * revolves around the question what the
- * normal vector is. Consider the
- * following situation:
- * <p ALIGN="center">
- * @image html no_normal_flux_1.png
+ * Computing these constraints requires some smarts. The main question
+ * revolves around the question what the normal vector is. Consider the
+ * following situation: <p ALIGN="center"> @image html no_normal_flux_1.png
* </p>
*
- * Here, we have two cells that use a
- * bilinear mapping
- * (i.e. MappingQ1). Consequently, for
- * each of the cells, the normal vector
- * is perpendicular to the straight
- * edge. If the two edges at the top and
- * right are meant to approximate a
- * curved boundary (as indicated by the
- * dashed line), then neither of the two
- * computed normal vectors are equal to
- * the exact normal vector (though they
- * approximate it as the mesh is refined
- * further). What is worse, if we
- * constrain $\vec n \cdot \vec u=0$ at
- * the common vertex with the normal
- * vector from both cells, then we
- * constrain the vector $\vec u$ with
- * respect to two linearly independent
- * vectors; consequently, the constraint
- * would be $\vec u=0$ at this point
- * (i.e. <i>all</i> components of the
- * vector), which is not what we wanted.
- *
- * To deal with this situation, the
- * algorithm works in the following way:
- * at each point where we want to
- * constrain $\vec u$, we first collect
- * all normal vectors that adjacent cells
- * might compute at this point. We then
- * do not constrain $\vec n \cdot \vec
- * u=0$ for <i>each</i> of these normal
- * vectors but only for the
- * <i>average</i> of the normal
- * vectors. In the example above, we
- * therefore record only a single
- * constraint $\vec n \cdot \vec {\bar
- * u}=0$, where $\vec {\bar u}$ is the
- * average of the two indicated normal
- * vectors.
- *
- * Unfortunately, this is not quite
- * enough. Consider the situation here:
+ * Here, we have two cells that use a bilinear mapping
+ * (i.e. MappingQ1). Consequently, for each of the cells, the normal vector
+ * is perpendicular to the straight edge. If the two edges at the top and
+ * right are meant to approximate a curved boundary (as indicated by the
+ * dashed line), then neither of the two computed normal vectors are equal
+ * to the exact normal vector (though they approximate it as the mesh is
+ * refined further). What is worse, if we constrain $\vec n \cdot \vec u=0$
+ * at the common vertex with the normal vector from both cells, then we
+ * constrain the vector $\vec u$ with respect to two linearly independent
+ * vectors; consequently, the constraint would be $\vec u=0$ at this point
+ * (i.e. <i>all</i> components of the vector), which is not what we wanted.
+ *
+ * To deal with this situation, the algorithm works in the following way: at
+ * each point where we want to constrain $\vec u$, we first collect all
+ * normal vectors that adjacent cells might compute at this point. We then
+ * do not constrain $\vec n \cdot \vec u=0$ for <i>each</i> of these normal
+ * vectors but only for the <i>average</i> of the normal vectors. In the
+ * example above, we therefore record only a single constraint $\vec n \cdot
+ * \vec {\bar u}=0$, where $\vec {\bar u}$ is the average of the two
+ * indicated normal vectors.
+ *
+ * Unfortunately, this is not quite enough. Consider the situation here:
*
* <p ALIGN="center">
* @image html no_normal_flux_2.png
* </p>
*
- * If again the top and right edges
- * approximate a curved boundary, and the
- * left boundary a separate boundary (for
- * example straight) so that the exact
- * boundary has indeed a corner at the
- * top left vertex, then the above
- * construction would not work: here, we
- * indeed want the constraint that $\vec
- * u$ at this point (because the normal
- * velocities with respect to both the
- * left normal as well as the top normal
- * vector should be zero), not that the
- * velocity in the direction of the
- * average normal vector is zero.
- *
- * Consequently, we use the following
- * heuristic to determine whether all
- * normal vectors computed at one point
- * are to be averaged: if two normal
- * vectors for the same point are
- * computed on <i>different</i> cells,
- * then they are to be averaged. This
- * covers the first example above. If
- * they are computed from the same cell,
- * then the fact that they are different
- * is considered indication that they
- * come from different parts of the
- * boundary that might be joined by a
- * real corner, and must not be averaged.
- *
- * There is one problem with this
- * scheme. If, for example, the same
- * domain we have considered above, is
- * discretized with the following mesh,
- * then we get into trouble:
+ * If again the top and right edges approximate a curved boundary, and the
+ * left boundary a separate boundary (for example straight) so that the
+ * exact boundary has indeed a corner at the top left vertex, then the above
+ * construction would not work: here, we indeed want the constraint that
+ * $\vec u$ at this point (because the normal velocities with respect to
+ * both the left normal as well as the top normal vector should be zero),
+ * not that the velocity in the direction of the average normal vector is
+ * zero.
+ *
+ * Consequently, we use the following heuristic to determine whether all
+ * normal vectors computed at one point are to be averaged: if two normal
+ * vectors for the same point are computed on <i>different</i> cells, then
+ * they are to be averaged. This covers the first example above. If they are
+ * computed from the same cell, then the fact that they are different is
+ * considered indication that they come from different parts of the boundary
+ * that might be joined by a real corner, and must not be averaged.
+ *
+ * There is one problem with this scheme. If, for example, the same domain
+ * we have considered above, is discretized with the following mesh, then we
+ * get into trouble:
*
* <p ALIGN="center">
* @image html no_normal_flux_3.png
* </p>
*
- * Here, the algorithm assumes that the
- * boundary does not have a corner at the
- * point where faces $F1$ and $F2$ join
- * because at that point there are two
- * different normal vectors computed from
- * different cells. If you intend for
- * there to be a corner of the exact
- * boundary at this point, the only way
- * to deal with this is to assign the two
- * parts of the boundary different
- * boundary indicators and call this
- * function twice, once for each boundary
- * indicators; doing so will yield only
- * one normal vector at this point per
- * invocation (because we consider only
- * one boundary part at a time), with the
- * result that the normal vectors will
- * not be averaged.
+ * Here, the algorithm assumes that the boundary does not have a corner at
+ * the point where faces $F1$ and $F2$ join because at that point there are
+ * two different normal vectors computed from different cells. If you intend
+ * for there to be a corner of the exact boundary at this point, the only
+ * way to deal with this is to assign the two parts of the boundary
+ * different boundary indicators and call this function twice, once for each
+ * boundary indicators; doing so will yield only one normal vector at this
+ * point per invocation (because we consider only one boundary part at a
+ * time), with the result that the normal vectors will not be averaged. This
+ * situation also needs to be taken into account when using this function
+ * around reentrant corners on Cartesian meshes. If no-normal-flux boundary
+ * conditions are to be enforced on non-Cartesian meshes around reentrant
+ * corners, one may even get cycles in the constraints as one will in
+ * general constrain different components from the two sides. In that case,
+ * set a no-slip constraint on the reentrant vertex first.
*
*
* <h4>Computing constraints in 3d</h4>
*
- * The situation is more
- * complicated in 3d. Consider
- * the following case where we
- * want to compute the
- * constraints at the marked
- * vertex:
+ * The situation is more complicated in 3d. Consider the following case
+ * where we want to compute the constraints at the marked vertex:
*
* <p ALIGN="center">
* @image html no_normal_flux_4.png
* </p>
*
- * Here, we get four different
- * normal vectors, one from each
- * of the four faces that meet at
- * the vertex. Even though they
- * may form a complete set of
- * vectors, it is not our intent
- * to constrain all components of
- * the vector field at this
- * point. Rather, we would like
- * to still allow tangential
- * flow, where the term
- * "tangential" has to be
- * suitably defined.
- *
- * In a case like this, the
- * algorithm proceeds as follows:
- * for each cell that has
- * computed two tangential
- * vectors at this point, we
- * compute the unconstrained
- * direction as the outer product
- * of the two tangential vectors
- * (if necessary multiplied by
- * minus one). We then average
- * these tangential
- * vectors. Finally, we compute
- * constraints for the two
- * directions perpendicular to
- * this averaged tangential
- * direction.
- *
- * There are cases where one cell
- * contributes two tangential
- * directions and another one
- * only one; for example, this
- * would happen if both top and
- * front faces of the left cell
- * belong to the boundary
- * selected whereas only the top
- * face of the right cell belongs
- * to it. This case is not
- * currently implemented.
+ * Here, we get four different normal vectors, one from each of the four
+ * faces that meet at the vertex. Even though they may form a complete set
+ * of vectors, it is not our intent to constrain all components of the
+ * vector field at this point. Rather, we would like to still allow
+ * tangential flow, where the term "tangential" has to be suitably defined.
+ *
+ * In a case like this, the algorithm proceeds as follows: for each cell
+ * that has computed two tangential vectors at this point, we compute the
+ * unconstrained direction as the outer product of the two tangential
+ * vectors (if necessary multiplied by minus one). We then average these
+ * tangential vectors. Finally, we compute constraints for the two
+ * directions perpendicular to this averaged tangential direction.
+ *
+ * There are cases where one cell contributes two tangential directions and
+ * another one only one; for example, this would happen if both top and
+ * front faces of the left cell belong to the boundary selected whereas only
+ * the top face of the right cell belongs to it. This case is not currently
+ * implemented.
*
*
* <h4>Results</h4>
*
- * Because it makes for good
- * pictures, here are two images
- * of vector fields on a circle
- * and on a sphere to which the
- * constraints computed by this
+ * Because it makes for good pictures, here are two images of vector fields
+ * on a circle and on a sphere to which the constraints computed by this
* function have been applied:
*
* <p ALIGN="center">
* @image html no_normal_flux_6.png
* </p>
*
- * The vectors fields are not
- * physically reasonable but the
- * tangentiality constraint is
- * clearly enforced. The fact
- * that the vector fields are
- * zero at some points on the
- * boundary is an artifact of the
- * way it is created, it is not
- * constrained to be zero at
- * these points.
+ * The vectors fields are not physically reasonable but the tangentiality
+ * constraint is clearly enforced. The fact that the vector fields are zero
+ * at some points on the boundary is an artifact of the way it is created,
+ * it is not constrained to be zero at these points.
*
* @ingroup constraints
*
ConstraintMatrix &constraints,
const Mapping<dim, spacedim> &mapping = StaticMappingQ1<dim>::mapping);
+ /**
+ * Compute the constraints that correspond to boundary conditions of the
+ * form $\vec n \times \vec u=0$, i.e. flow normal to the boundary if $\vec
+ * u$ is a vector-valued quantity. This function constrains exactly those
+ * vector-valued components that are left unconstrained by
+ * compute_no_normal_flux_constraints, and leaves the one component
+ * unconstrained that is constrained by compute_no_normal_flux_constraints.
+ */
+ template <int dim, template <int, int> class DH, int spacedim>
+ void
+ compute_normal_flux_constraints (const DH<dim,spacedim> &dof_handler,
+ const unsigned int first_vector_component,
+ const std::set<types::boundary_id> &boundary_ids,
+ ConstraintMatrix &constraints,
+ const Mapping<dim, spacedim> &mapping = StaticMappingQ1<dim>::mapping);
+
//@}
/**
/**
* Create a right hand side
- * vector for a point source at point @p p.
+ * vector for a point source at point @p p. In other words, it creates
+ * a vector $F$ so that
+ * $F_i = \int_\Omega \delta(x-p) \phi_i(x) dx$.
* Prior content of the
* given @p rhs_vector vector is
* deleted.
* using a Q1-mapping for cell
* boundaries to call the other
* point_difference() function.
+ *
+ * @note If the cell in which the point is found
+ * is not locally owned, an exception of type
+ * VectorTools<dim, InVector, spacedim>::ExcPointNotAvailableHere
+ * is thrown.
*/
template <int dim, class InVector, int spacedim>
void point_difference (const DoFHandler<dim,spacedim> &dof,
* this function uses an
* arbitrary mapping to evaluate
* the difference.
+ *
+ * @note If the cell in which the point is found
+ * is not locally owned, an exception of type
+ * VectorTools<dim, InVector, spacedim>::ExcPointNotAvailableHere
+ * is thrown.
*/
template <int dim, class InVector, int spacedim>
void point_difference (const Mapping<dim, spacedim> &mapping,
* using a Q1-mapping for cell
* boundaries to call the other
* point_difference() function.
+ *
+ * @note If the cell in which the point is found
+ * is not locally owned, an exception of type
+ * VectorTools<dim, InVector, spacedim>::ExcPointNotAvailableHere
+ * is thrown.
*/
template <int dim, class InVector, int spacedim>
void
/**
* Same as above for hp.
+ *
+ * @note If the cell in which the point is found
+ * is not locally owned, an exception of type
+ * VectorTools<dim, InVector, spacedim>::ExcPointNotAvailableHere
+ * is thrown.
*/
template <int dim, class InVector, int spacedim>
void
* "Possibilities for extensions" part of
* the results section of @ref step_3
* "step-3".
+ *
+ * @note If the cell in which the point is found
+ * is not locally owned, an exception of type
+ * VectorTools<dim, InVector, spacedim>::ExcPointNotAvailableHere
+ * is thrown.
*/
template <int dim, class InVector, int spacedim>
double
/**
* Same as above for hp.
+ *
+ * @note If the cell in which the point is found
+ * is not locally owned, an exception of type
+ * VectorTools<dim, InVector, spacedim>::ExcPointNotAvailableHere
+ * is thrown.
*/
template <int dim, class InVector, int spacedim>
double
* function of the same name,
* this function uses an arbitrary
* mapping to evaluate the difference.
+ *
+ * @note If the cell in which the point is found
+ * is not locally owned, an exception of type
+ * VectorTools<dim, InVector, spacedim>::ExcPointNotAvailableHere
+ * is thrown.
*/
template <int dim, class InVector, int spacedim>
void
/**
* Same as above for hp.
+ *
+ * @note If the cell in which the point is found
+ * is not locally owned, an exception of type
+ * VectorTools<dim, InVector, spacedim>::ExcPointNotAvailableHere
+ * is thrown.
*/
template <int dim, class InVector, int spacedim>
void
* function of the same name,
* this function uses an arbitrary
* mapping to evaluate the difference.
+ *
+ * @note If the cell in which the point is found
+ * is not locally owned, an exception of type
+ * VectorTools<dim, InVector, spacedim>::ExcPointNotAvailableHere
+ * is thrown.
*/
template <int dim, class InVector, int spacedim>
double
/**
* Same as above for hp.
+ *
+ * @note If the cell in which the point is found
+ * is not locally owned, an exception of type
+ * VectorTools<dim, InVector, spacedim>::ExcPointNotAvailableHere
+ * is thrown.
*/
template <int dim, class InVector, int spacedim>
double
DeclException0 (ExcNonInterpolatingFE);
/**
- * Exception
- */
- DeclException0 (ExcNoComponentSelected);
+ * Exception
+ */
+ DeclException0 (ExcPointNotAvailableHere);
}
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#ifndef _deal2__vector_tools_templates_h
#define _deal2__vector_tools_templates_h
#include <deal.II/numerics/vector_tools.h>
#include <deal.II/numerics/matrix_tools.h>
+#include <deal.II/base/std_cxx1x/array.h>
#include <numeric>
#include <algorithm>
#include <vector>
namespace internal
{
+ /**
+ * Interpolate zero boundary values. We don't need to worry about a mapping
+ * here because the function we evaluate for the DoFs is zero in the mapped
+ * locations as well as in the original, unmapped locations
+ */
+ template <class DH>
void
- interpolate_zero_boundary_values (const dealii::DoFHandler<1> &dof_handler,
- std::map<types::global_dof_index,double> &boundary_values)
- {
- // we only need to find the
- // left-most and right-most
- // vertex and query its vertex
- // dof indices. that's easy :-)
- for (unsigned int direction=0; direction<2; ++direction)
- {
- dealii::DoFHandler<1>::cell_iterator
- cell = dof_handler.begin(0);
- while (!cell->at_boundary(direction))
- cell = cell->neighbor(direction);
-
- for (unsigned int i=0; i<dof_handler.get_fe().dofs_per_vertex; ++i)
- boundary_values[cell->vertex_dof_index (direction, i)] = 0.;
- }
- }
-
-
-
- // codimension 1
- void
- interpolate_zero_boundary_values (const dealii::DoFHandler<1,2> &dof_handler,
- std::map<types::global_dof_index,double> &boundary_values)
- {
- // we only need to find the
- // left-most and right-most
- // vertex and query its vertex
- // dof indices. that's easy :-)
- for (unsigned int direction=0; direction<2; ++direction)
- {
- dealii::DoFHandler<1,2>::cell_iterator
- cell = dof_handler.begin(0);
- while (!cell->at_boundary(direction))
- cell = cell->neighbor(direction);
-
- for (unsigned int i=0; i<dof_handler.get_fe().dofs_per_vertex; ++i)
- boundary_values[cell->vertex_dof_index (direction, i)] = 0.;
- }
- }
-
-
-
- template <int dim, int spacedim>
- void
- interpolate_zero_boundary_values (const dealii::DoFHandler<dim,spacedim> &dof_handler,
+ interpolate_zero_boundary_values (const DH &dof_handler,
std::map<types::global_dof_index,double> &boundary_values)
{
- const FiniteElement<dim,spacedim> &fe = dof_handler.get_fe();
+ const unsigned int dim = DH::dimension;
// loop over all boundary faces
// to get all dof indices of
// that is actually wholly on
// the boundary, not only by
// one line or one vertex
- typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator
+ typename DH::active_cell_iterator
cell = dof_handler.begin_active(),
endc = dof_handler.end();
- std::vector<types::global_dof_index> face_dof_indices (fe.dofs_per_face);
+ std::vector<types::global_dof_index> face_dof_indices;
for (; cell!=endc; ++cell)
for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
if (cell->at_boundary(f))
{
- cell->face(f)->get_dof_indices (face_dof_indices);
- for (unsigned int i=0; i<fe.dofs_per_face; ++i)
+ face_dof_indices.resize (cell->get_fe().dofs_per_face);
+ cell->face(f)->get_dof_indices (face_dof_indices,
+ cell->active_fe_index());
+ for (unsigned int i=0; i<cell->get_fe().dofs_per_face; ++i)
// enter zero boundary values
// for all boundary nodes
//
}
-
- template <int dim, class VECTOR, int spacedim>
- void project (const Mapping<dim, spacedim> &mapping,
- const DoFHandler<dim,spacedim> &dof,
- const ConstraintMatrix &constraints,
- const Quadrature<dim> &quadrature,
- const Function<spacedim> &function,
- VECTOR &vec_result,
- const bool enforce_zero_boundary,
- const Quadrature<dim-1> &q_boundary,
- const bool project_to_boundary_first)
+ namespace
{
- Assert (dof.get_fe().n_components() == function.n_components,
- ExcDimensionMismatch(dof.get_fe().n_components(),
- function.n_components));
-
- Assert (vec_result.size() == dof.n_dofs(),
- ExcDimensionMismatch (vec_result.size(), dof.n_dofs()));
-
- // make up boundary values
- std::map<types::global_dof_index,double> boundary_values;
-
- if (enforce_zero_boundary == true)
- // no need to project boundary
- // values, but enforce
- // homogeneous boundary values
- // anyway
- internal::
- interpolate_zero_boundary_values (dof, boundary_values);
-
- else
- // no homogeneous boundary values
- if (project_to_boundary_first == true)
- // boundary projection required
- {
- // set up a list of boundary
- // functions for the
- // different boundary
- // parts. We want the
- // function to hold on
- // all parts of the boundary
- typename FunctionMap<spacedim>::type boundary_functions;
- for (types::boundary_id c=0; c<numbers::internal_face_boundary_id; ++c)
- boundary_functions[c] = &function;
- project_boundary_values (dof, boundary_functions, q_boundary,
- boundary_values);
- }
+ /**
+ * Compute the boundary values to be used in the project() functions.
+ */
+ template <int dim, int spacedim,
+ template <int,int> class DH,
+ template <int,int> class M_or_MC,
+ template <int> class Q_or_QC>
+ void project_compute_b_v (const M_or_MC<dim, spacedim> &mapping,
+ const DH<dim,spacedim> &dof,
+ const Function<spacedim> &function,
+ const bool enforce_zero_boundary,
+ const Q_or_QC<dim-1> &q_boundary,
+ const bool project_to_boundary_first,
+ std::map<types::global_dof_index,double> &boundary_values)
+ {
+ if (enforce_zero_boundary == true)
+ // no need to project boundary
+ // values, but enforce
+ // homogeneous boundary values
+ // anyway
+ internal::
+ interpolate_zero_boundary_values (dof, boundary_values);
+
+ else
+ // no homogeneous boundary values
+ if (project_to_boundary_first == true)
+ // boundary projection required
+ {
+ // set up a list of boundary
+ // functions for the
+ // different boundary
+ // parts. We want the
+ // function to hold on
+ // all parts of the boundary
+ const std::vector<types::boundary_id>
+ used_boundary_indicators = dof.get_tria().get_boundary_indicators();
+
+ typename FunctionMap<spacedim>::type boundary_functions;
+ for (unsigned int i=0; i<used_boundary_indicators.size(); ++i)
+ boundary_functions[used_boundary_indicators[i]] = &function;
+ project_boundary_values (mapping, dof, boundary_functions, q_boundary,
+ boundary_values);
+ }
+ }
- // set up mass matrix and right hand side
- Vector<double> vec (dof.n_dofs());
- SparsityPattern sparsity;
- // check if constraints are compatible (see below)
- bool constraints_are_compatible = true;
+ /**
+ * Return whether the boundary values try to constrain a degree of
+ * freedom that is already constrained to something else
+ */
+ bool constraints_and_b_v_are_compatible (const ConstraintMatrix &constraints,
+ std::map<types::global_dof_index,double> &boundary_values)
{
for (std::map<types::global_dof_index,double>::iterator it=boundary_values.begin();
it != boundary_values.end(); ++it)
if (constraints.is_constrained(it->first))
+//TODO: This looks wrong -- shouldn't it be ==0 in the first condition and && ?
if (!(constraints.get_constraint_entries(it->first)->size() > 0
||
(constraints.get_inhomogeneity(it->first) == it->second)))
- {
- constraints_are_compatible = false;
- break;
- }
- }
-
- // use csp to consume less memory and to
- // still be fast
- {
- CompressedSimpleSparsityPattern csp (dof.n_dofs(), dof.n_dofs());
- DoFTools::make_sparsity_pattern (dof, csp, constraints,
- !constraints_are_compatible);
+ return false;
- sparsity.copy_from (csp);
+ return true;
}
- SparseMatrix<double> mass_matrix (sparsity);
- Vector<double> tmp (mass_matrix.n());
- // If the constraint matrix does not conflict with the given boundary
- // values (i.e., it either does not contain boundary values or it contains
- // the same as boundary_values), we can let it call
- // distribute_local_to_global straight away, otherwise we need to first
- // interpolate the boundary values and then condense the matrix and vector
- if (constraints_are_compatible)
+ /**
+ * Generic implementation of the project() function
+ */
+ template <int dim, int spacedim,
+ class Vector,
+ template <int,int> class DH,
+ template <int,int> class M_or_MC,
+ template <int> class Q_or_QC>
+ void do_project (const M_or_MC<dim, spacedim> &mapping,
+ const DH<dim,spacedim> &dof,
+ const ConstraintMatrix &constraints,
+ const Q_or_QC<dim> &quadrature,
+ const Function<spacedim> &function,
+ Vector &vec_result,
+ const bool enforce_zero_boundary,
+ const Q_or_QC<dim-1> &q_boundary,
+ const bool project_to_boundary_first)
+ {
+ Assert (dof.get_fe().n_components() == function.n_components,
+ ExcDimensionMismatch(dof.get_fe().n_components(),
+ function.n_components));
+ Assert (vec_result.size() == dof.n_dofs(),
+ ExcDimensionMismatch (vec_result.size(), dof.n_dofs()));
+
+ // make up boundary values
+ std::map<types::global_dof_index,double> boundary_values;
+ project_compute_b_v(mapping, dof, function, enforce_zero_boundary,
+ q_boundary, project_to_boundary_first, boundary_values);
+
+ // check if constraints are compatible (see below)
+ const bool constraints_are_compatible =
+ constraints_and_b_v_are_compatible(constraints, boundary_values);
+
+ // set up mass matrix and right hand side
+ dealii::Vector<double> vec (dof.n_dofs());
+ SparsityPattern sparsity;
{
- const Function<spacedim>* dummy = 0;
- MatrixCreator::create_mass_matrix (mapping, dof, quadrature,
- mass_matrix, function, tmp,
- dummy, constraints);
- if (boundary_values.size() > 0)
+ CompressedSimpleSparsityPattern csp (dof.n_dofs(), dof.n_dofs());
+ DoFTools::make_sparsity_pattern (dof, csp, constraints,
+ !constraints_are_compatible);
+
+ sparsity.copy_from (csp);
+ }
+ SparseMatrix<double> mass_matrix (sparsity);
+ dealii::Vector<double> tmp (mass_matrix.n());
+
+ // If the constraint matrix does not conflict with the given boundary
+ // values (i.e., it either does not contain boundary values or it contains
+ // the same as boundary_values), we can let it call
+ // distribute_local_to_global straight away, otherwise we need to first
+ // interpolate the boundary values and then condense the matrix and vector
+ if (constraints_are_compatible)
+ {
+ const Function<spacedim> *dummy = 0;
+ MatrixCreator::create_mass_matrix (mapping, dof, quadrature,
+ mass_matrix, function, tmp,
+ dummy, constraints);
+ if (boundary_values.size() > 0)
+ MatrixTools::apply_boundary_values (boundary_values,
+ mass_matrix, vec, tmp,
+ true);
+ }
+ else
+ {
+ // create mass matrix and rhs at once, which is faster.
+ MatrixCreator::create_mass_matrix (mapping, dof, quadrature,
+ mass_matrix, function, tmp);
MatrixTools::apply_boundary_values (boundary_values,
mass_matrix, vec, tmp,
true);
- }
- else
- {
- // create mass matrix and rhs at once, which is faster.
- MatrixCreator::create_mass_matrix (mapping, dof, quadrature,
- mass_matrix, function, tmp);
- MatrixTools::apply_boundary_values (boundary_values,
- mass_matrix, vec, tmp,
- true);
- constraints.condense(mass_matrix, tmp);
- }
+ constraints.condense(mass_matrix, tmp);
+ }
- // Allow for a maximum of 5*n steps to reduce the residual by 10^-12. n
- // steps may not be sufficient, since roundoff errors may accumulate for
- // badly conditioned matrices
- ReductionControl control(5*tmp.size(), 0., 1e-12, false, false);
- GrowingVectorMemory<> memory;
- SolverCG<> cg(control,memory);
+ // Allow for a maximum of 5*n steps to reduce the residual by 10^-12. n
+ // steps may not be sufficient, since roundoff errors may accumulate for
+ // badly conditioned matrices
+ ReductionControl control(5*tmp.size(), 0., 1e-12, false, false);
+ GrowingVectorMemory<> memory;
+ SolverCG<> cg(control,memory);
- PreconditionSSOR<> prec;
- prec.initialize(mass_matrix, 1.2);
+ PreconditionSSOR<> prec;
+ prec.initialize(mass_matrix, 1.2);
- cg.solve (mass_matrix, vec, tmp, prec);
+ cg.solve (mass_matrix, vec, tmp, prec);
- constraints.distribute (vec);
+ constraints.distribute (vec);
- // copy vec into vec_result. we can't use vec_result itself above, since
- // it may be of another type than Vector<double> and that wouldn't
- // necessarily go together with the matrix and other functions
- for (unsigned int i=0; i<vec.size(); ++i)
- vec_result(i) = vec(i);
+ // copy vec into vec_result. we can't use vec_result itself above, since
+ // it may be of another type than Vector<double> and that wouldn't
+ // necessarily go together with the matrix and other functions
+ for (unsigned int i=0; i<vec.size(); ++i)
+ vec_result(i) = vec(i);
+ }
+ }
+
+
+ template <int dim, class VECTOR, int spacedim>
+ void project (const Mapping<dim, spacedim> &mapping,
+ const DoFHandler<dim,spacedim> &dof,
+ const ConstraintMatrix &constraints,
+ const Quadrature<dim> &quadrature,
+ const Function<spacedim> &function,
+ VECTOR &vec_result,
+ const bool enforce_zero_boundary,
+ const Quadrature<dim-1> &q_boundary,
+ const bool project_to_boundary_first)
+ {
+ do_project (mapping, dof, constraints, quadrature,
+ function, vec_result,
+ enforce_zero_boundary, q_boundary,
+ project_to_boundary_first);
}
+ template <int dim, class VECTOR, int spacedim>
+ void project (const hp::MappingCollection<dim, spacedim> &mapping,
+ const hp::DoFHandler<dim,spacedim> &dof,
+ const ConstraintMatrix &constraints,
+ const hp::QCollection<dim> &quadrature,
+ const Function<spacedim> &function,
+ VECTOR &vec_result,
+ const bool enforce_zero_boundary,
+ const hp::QCollection<dim-1> &q_boundary,
+ const bool project_to_boundary_first)
+ {
+ do_project (mapping, dof, constraints, quadrature,
+ function, vec_result,
+ enforce_zero_boundary, q_boundary,
+ project_to_boundary_first);
+ }
+
+
+ template <int dim, class VECTOR, int spacedim>
+ void project (const hp::DoFHandler<dim,spacedim> &dof,
+ const ConstraintMatrix &constraints,
+ const hp::QCollection<dim> &quadrature,
+ const Function<spacedim> &function,
+ VECTOR &vec,
+ const bool enforce_zero_boundary,
+ const hp::QCollection<dim-1> &q_boundary,
+ const bool project_to_boundary_first)
+ {
+ project(hp::StaticMappingQ1<dim,spacedim>::mapping_collection,
+ dof, constraints, quadrature, function, vec,
+ enforce_zero_boundary, q_boundary, project_to_boundary_first);
+ }
+
template <int dim, int spacedim>
void create_right_hand_side (const Mapping<dim, spacedim> &mapping,
-// separate implementation for 1D because otherwise we get linker errors since
-// FEFaceValues<1> is not compiled
- template <>
- void
- create_boundary_right_hand_side (const Mapping<1,1> &,
- const DoFHandler<1,1> &,
- const Quadrature<0> &,
- const Function<1> &,
- Vector<double> &,
- const std::set<types::boundary_id> &)
- {
- Assert (false, ExcImpossibleInDim(1));
- }
-
-
-
- template <>
- void
- create_boundary_right_hand_side (const Mapping<1,2> &,
- const DoFHandler<1,2> &,
- const Quadrature<0> &,
- const Function<2> &,
- Vector<double> &,
- const std::set<types::boundary_id> &)
- {
- Assert (false, ExcImpossibleInDim(1));
- }
-
-
-
template <int dim, int spacedim>
void
create_boundary_right_hand_side (const Mapping<dim, spacedim> &mapping,
-// separate implementation for 1D because otherwise we get linker errors since
-// hp::FEFaceValues<1> is not compiled
- template <>
- void
- create_boundary_right_hand_side (const hp::MappingCollection<1,1> &,
- const hp::DoFHandler<1,1> &,
- const hp::QCollection<0> &,
- const Function<1> &,
- Vector<double> &,
- const std::set<types::boundary_id> &)
- {
- Assert (false, ExcImpossibleInDim(1));
- }
-
-
-
- template <>
- void
- create_boundary_right_hand_side (const hp::MappingCollection<1,2> &,
- const hp::DoFHandler<1,2> &,
- const hp::QCollection<0> &,
- const Function<2> &,
- Vector<double> &,
- const std::set<types::boundary_id> &)
- {
- Assert (false, ExcImpossibleInDim(1));
- }
-
-
-
template <int dim, int spacedim>
void
create_boundary_right_hand_side (const hp::MappingCollection<dim,spacedim> &mapping,
// ----------- interpolate_boundary_values for std::map --------------------
- namespace internal
+ namespace
{
// interpolate boundary values in
// 1d. in higher dimensions, we
// faces are points and it is far
// easier to simply work on
// individual vertices
- template <class DH>
+ template <class DH,
+ template <int,int> class M_or_MC>
static inline
- void interpolate_boundary_values (const Mapping<DH::dimension, DH::space_dimension> &,
+ void do_interpolate_boundary_values (const M_or_MC<DH::dimension, DH::space_dimension> &,
const DH &dof,
const typename FunctionMap<DH::space_dimension>::type &function_map,
std::map<types::global_dof_index,double> &boundary_values,
boundary_function.n_components));
Assert (component_mask.n_selected_components(fe.n_components()) > 0,
- ExcNoComponentSelected());
+ ComponentMask::ExcNoComponentSelected());
// now set the value of
// the vertex degree of
- template <class DH>
+ template <class DH,
+ template <int,int> class M_or_MC>
static inline
void
- interpolate_boundary_values (const Mapping<DH::dimension, DH::space_dimension> &mapping,
+ do_interpolate_boundary_values (const M_or_MC<DH::dimension, DH::space_dimension> &mapping,
const DH &dof,
const typename FunctionMap<DH::space_dimension>::type &function_map,
std::map<types::global_dof_index,double> &boundary_values,
std::map<types::global_dof_index,double> &boundary_values,
const ComponentMask &component_mask_)
{
- internal::
- interpolate_boundary_values (mapping, dof, function_map, boundary_values,
+ do_interpolate_boundary_values (mapping, dof, function_map, boundary_values,
component_mask_,
dealii::internal::int2type<DH::dimension>());
}
}
+ template <int dim, int spacedim>
+ void
+ interpolate_boundary_values (const hp::MappingCollection<dim,spacedim> &mapping,
+ const hp::DoFHandler<dim,spacedim> &dof,
+ const typename FunctionMap<spacedim>::type &function_map,
+ std::map<types::global_dof_index,double> &boundary_values,
+ const ComponentMask &component_mask_)
+ {
+ do_interpolate_boundary_values (mapping, dof, function_map, boundary_values,
+ component_mask_,
+ dealii::internal::int2type<dim>());
+ }
+
+
template <class DH>
void
// -------- implementation for project_boundary_values with std::map --------
-// separate implementations for 1D because otherwise we get linking errors
-// because create_boundary_mass_matrix is not compiled for 1D
- template <>
- void
- project_boundary_values (const Mapping<1,1> &mapping,
- const DoFHandler<1,1> &dof,
- const FunctionMap<1>::type &boundary_functions,
- const Quadrature<0> &,
- std::map<types::global_dof_index,double> &boundary_values,
- std::vector<unsigned int> component_mapping)
- {
- Assert (component_mapping.size() == 0, ExcNotImplemented());
- // projection in 1d is equivalent
- // to interpolation
- interpolate_boundary_values (mapping, dof, boundary_functions,
- boundary_values, ComponentMask());
- }
-
-
- template <>
- void
- project_boundary_values (const Mapping<1,2> &mapping,
- const DoFHandler<1,2> &dof,
- const FunctionMap<2>::type &boundary_functions,
- const Quadrature<0> &,
- std::map<types::global_dof_index,double> &boundary_values,
- std::vector<unsigned int> component_mapping)
+ namespace
{
- Assert (component_mapping.size() == 0, ExcNotImplemented());
- // projection in 1d is equivalent
- // to interpolation
- interpolate_boundary_values (mapping, dof, boundary_functions,
- boundary_values, ComponentMask());
- }
+ template <int dim, int spacedim,
+ template <int,int> class DH,
+ template <int,int> class M_or_MC,
+ template <int> class Q_or_QC>
+ void
+ do_project_boundary_values (const M_or_MC<dim, spacedim> &mapping,
+ const DH<dim, spacedim> &dof,
+ const typename FunctionMap<spacedim>::type &boundary_functions,
+ const Q_or_QC<dim-1> &q,
+ std::map<types::global_dof_index,double> &boundary_values,
+ std::vector<unsigned int> component_mapping)
+ {
+ // in 1d, projection onto the 0d end points == interpolation
+ if (dim == 1)
+ {
+ Assert (component_mapping.size() == 0, ExcNotImplemented());
+ interpolate_boundary_values (mapping, dof, boundary_functions,
+ boundary_values, ComponentMask());
+ return;
+ }
+ //TODO:[?] In project_boundary_values, no condensation of sparsity
+ // structures, matrices and right hand sides or distribution of
+ // solution vectors is performed. This is ok for dim<3 because then
+ // there are no constrained nodes on the boundary, but is not
+ // acceptable for higher dimensions. Fix this.
+ if (component_mapping.size() == 0)
+ {
+ AssertDimension (dof.get_fe().n_components(), boundary_functions.begin()->second->n_components);
+ // I still do not see why i
+ // should create another copy
+ // here
+ component_mapping.resize(dof.get_fe().n_components());
+ for (unsigned int i= 0 ; i < component_mapping.size() ; ++i)
+ component_mapping[i] = i;
+ }
+ else
+ AssertDimension (dof.get_fe().n_components(), component_mapping.size());
+ std::vector<types::global_dof_index> dof_to_boundary_mapping;
+ std::set<types::boundary_id> selected_boundary_components;
+ for (typename FunctionMap<spacedim>::type::const_iterator i=boundary_functions.begin();
+ i!=boundary_functions.end(); ++i)
+ selected_boundary_components.insert (i->first);
- template <int dim, int spacedim>
- void
- project_boundary_values (const Mapping<dim, spacedim> &mapping,
- const DoFHandler<dim, spacedim> &dof,
- const typename FunctionMap<spacedim>::type &boundary_functions,
- const Quadrature<dim-1> &q,
- std::map<types::global_dof_index,double> &boundary_values,
- std::vector<unsigned int> component_mapping)
- {
-//TODO:[?] In project_boundary_values, no condensation of sparsity
-// structures, matrices and right hand sides or distribution of
-// solution vectors is performed. This is ok for dim<3 because then
-// there are no constrained nodes on the boundary, but is not
-// acceptable for higher dimensions. Fix this.
+ DoFTools::map_dof_to_boundary_indices (dof, selected_boundary_components,
+ dof_to_boundary_mapping);
- if (component_mapping.size() == 0)
- {
- AssertDimension (dof.get_fe().n_components(), boundary_functions.begin()->second->n_components);
- // I still do not see why i
- // should create another copy
- // here
- component_mapping.resize(dof.get_fe().n_components());
- for (unsigned int i= 0 ; i < component_mapping.size() ; ++i)
- component_mapping[i] = i;
- }
- else
- AssertDimension (dof.get_fe().n_components(), component_mapping.size());
-
- std::vector<types::global_dof_index> dof_to_boundary_mapping;
- std::set<types::boundary_id> selected_boundary_components;
- for (typename FunctionMap<spacedim>::type::const_iterator i=boundary_functions.begin();
- i!=boundary_functions.end(); ++i)
- selected_boundary_components.insert (i->first);
-
- DoFTools::map_dof_to_boundary_indices (dof, selected_boundary_components,
- dof_to_boundary_mapping);
-
- // Done if no degrees of freedom on the boundary
- if (dof.n_boundary_dofs (boundary_functions) == 0)
- return;
-
- // set up sparsity structure
- CompressedSparsityPattern c_sparsity(dof.n_boundary_dofs (boundary_functions),
- dof.n_boundary_dofs (boundary_functions));
- DoFTools::make_boundary_sparsity_pattern (dof,
- boundary_functions,
- dof_to_boundary_mapping,
- c_sparsity);
- SparsityPattern sparsity;
- sparsity.copy_from(c_sparsity);
-
-
-
- // note: for three or more dimensions, there
- // may be constrained nodes on the boundary
- // in this case the boundary mass matrix has
- // to be condensed and the solution is to
- // be distributed afterwards, which is not
- // yet implemented. The reason for this is
- // that we cannot simply use the condense
- // family of functions, since the matrices
- // and vectors do not use the global
- // numbering but rather the boundary
- // numbering, i.e. the condense function
- // needs to use another indirection. There
- // should be not many technical problems,
- // but it needs to be implemented
- if (dim>=3)
- {
-#ifdef DEBUG
-// Assert that there are no hanging nodes at the boundary
- int level = -1;
- for (typename DoFHandler<dim,spacedim>::active_cell_iterator cell = dof.begin_active();
- cell != dof.end(); ++cell)
- for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
- {
- if (cell->at_boundary(f))
- {
- if (level == -1)
- level = cell->level();
- else
- {
- Assert (level == cell->level(), ExcNotImplemented());
- }
- }
- }
-#endif
- }
- sparsity.compress();
+ // Done if no degrees of freedom on the boundary
+ if (dof.n_boundary_dofs (boundary_functions) == 0)
+ return;
+
+ // set up sparsity structure
+ CompressedSparsityPattern c_sparsity(dof.n_boundary_dofs (boundary_functions),
+ dof.n_boundary_dofs (boundary_functions));
+ DoFTools::make_boundary_sparsity_pattern (dof,
+ boundary_functions,
+ dof_to_boundary_mapping,
+ c_sparsity);
+ SparsityPattern sparsity;
+ sparsity.copy_from(c_sparsity);
+
+
+
+ // note: for three or more dimensions, there
+ // may be constrained nodes on the boundary
+ // in this case the boundary mass matrix has
+ // to be condensed and the solution is to
+ // be distributed afterwards, which is not
+ // yet implemented. The reason for this is
+ // that we cannot simply use the condense
+ // family of functions, since the matrices
+ // and vectors do not use the global
+ // numbering but rather the boundary
+ // numbering, i.e. the condense function
+ // needs to use another indirection. There
+ // should be not many technical problems,
+ // but it needs to be implemented
+ if (dim>=3)
+ {
+ #ifdef DEBUG
+ // Assert that there are no hanging nodes at the boundary
+ int level = -1;
+ for (typename DH<dim,spacedim>::active_cell_iterator cell = dof.begin_active();
+ cell != dof.end(); ++cell)
+ for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
+ {
+ if (cell->at_boundary(f))
+ {
+ if (level == -1)
+ level = cell->level();
+ else
+ {
+ Assert (level == cell->level(), ExcNotImplemented());
+ }
+ }
+ }
+ #endif
+ }
+ sparsity.compress();
- // make mass matrix and right hand side
- SparseMatrix<double> mass_matrix(sparsity);
- Vector<double> rhs(sparsity.n_rows());
+ // make mass matrix and right hand side
+ SparseMatrix<double> mass_matrix(sparsity);
+ Vector<double> rhs(sparsity.n_rows());
- MatrixCreator::create_boundary_mass_matrix (mapping, dof, q,
- mass_matrix, boundary_functions,
- rhs, dof_to_boundary_mapping, (const Function<spacedim> *) 0,
- component_mapping);
+ MatrixCreator::create_boundary_mass_matrix (mapping, dof, q,
+ mass_matrix, boundary_functions,
+ rhs, dof_to_boundary_mapping, (const Function<spacedim> *) 0,
+ component_mapping);
- // For certain weird elements,
- // there might be degrees of
- // freedom on the boundary, but
- // their shape functions do not
- // have support there. Let's
- // eliminate them here.
+ // For certain weird elements,
+ // there might be degrees of
+ // freedom on the boundary, but
+ // their shape functions do not
+ // have support there. Let's
+ // eliminate them here.
- // The Bogner-Fox-Schmidt element
- // is an example for those.
+ // The Bogner-Fox-Schmidt element
+ // is an example for those.
//TODO: Maybe we should figure out if the element really needs this
- FilteredMatrix<Vector<double> > filtered_mass_matrix(mass_matrix, true);
- FilteredMatrix<Vector<double> > filtered_precondition;
- std::vector<bool> excluded_dofs(mass_matrix.m(), false);
+ FilteredMatrix<Vector<double> > filtered_mass_matrix(mass_matrix, true);
+ FilteredMatrix<Vector<double> > filtered_precondition;
+ std::vector<bool> excluded_dofs(mass_matrix.m(), false);
- double max_element = 0.;
- for (unsigned int i=0; i<mass_matrix.m(); ++i)
- if (mass_matrix.diag_element(i) > max_element)
- max_element = mass_matrix.diag_element(i);
+ double max_element = 0.;
+ for (unsigned int i=0; i<mass_matrix.m(); ++i)
+ if (mass_matrix.diag_element(i) > max_element)
+ max_element = mass_matrix.diag_element(i);
- for (unsigned int i=0; i<mass_matrix.m(); ++i)
- if (mass_matrix.diag_element(i) < 1.e-8 * max_element)
- {
- filtered_mass_matrix.add_constraint(i, 0.);
- filtered_precondition.add_constraint(i, 0.);
- mass_matrix.diag_element(i) = 1.;
- excluded_dofs[i] = true;
- }
+ for (unsigned int i=0; i<mass_matrix.m(); ++i)
+ if (mass_matrix.diag_element(i) < 1.e-8 * max_element)
+ {
+ filtered_mass_matrix.add_constraint(i, 0.);
+ filtered_precondition.add_constraint(i, 0.);
+ mass_matrix.diag_element(i) = 1.;
+ excluded_dofs[i] = true;
+ }
- Vector<double> boundary_projection (rhs.size());
-
- // Allow for a maximum of 5*n
- // steps to reduce the residual by
- // 10^-12. n steps may not be
- // sufficient, since roundoff
- // errors may accumulate for badly
- // conditioned matrices
- ReductionControl control(5*rhs.size(), 0., 1.e-12, false, false);
- GrowingVectorMemory<> memory;
- SolverCG<> cg(control,memory);
-
- PreconditionSSOR<> prec;
- prec.initialize(mass_matrix, 1.2);
- filtered_precondition.initialize(prec, true);
- // solve
- cg.solve (filtered_mass_matrix, boundary_projection, rhs, filtered_precondition);
- filtered_precondition.apply_constraints(boundary_projection, true);
- filtered_precondition.clear();
- // fill in boundary values
- for (unsigned int i=0; i<dof_to_boundary_mapping.size(); ++i)
- if (dof_to_boundary_mapping[i] != DoFHandler<dim,spacedim>::invalid_dof_index
- && ! excluded_dofs[dof_to_boundary_mapping[i]])
- {
- Assert(numbers::is_finite(boundary_projection(dof_to_boundary_mapping[i])), ExcNumberNotFinite());
+ Vector<double> boundary_projection (rhs.size());
+
+ // Allow for a maximum of 5*n
+ // steps to reduce the residual by
+ // 10^-12. n steps may not be
+ // sufficient, since roundoff
+ // errors may accumulate for badly
+ // conditioned matrices
+ ReductionControl control(5*rhs.size(), 0., 1.e-12, false, false);
+ GrowingVectorMemory<> memory;
+ SolverCG<> cg(control,memory);
+
+ PreconditionSSOR<> prec;
+ prec.initialize(mass_matrix, 1.2);
+ filtered_precondition.initialize(prec, true);
+ // solve
+ cg.solve (filtered_mass_matrix, boundary_projection, rhs, filtered_precondition);
+ filtered_precondition.apply_constraints(boundary_projection, true);
+ filtered_precondition.clear();
+ // fill in boundary values
+ for (unsigned int i=0; i<dof_to_boundary_mapping.size(); ++i)
+ if (dof_to_boundary_mapping[i] != DoFHandler<dim,spacedim>::invalid_dof_index
+ && ! excluded_dofs[dof_to_boundary_mapping[i]])
+ {
+ Assert(numbers::is_finite(boundary_projection(dof_to_boundary_mapping[i])), ExcNumberNotFinite());
- // this dof is on one of the
- // interesting boundary parts
- //
- // remember: i is the global dof
- // number, dof_to_boundary_mapping[i]
- // is the number on the boundary and
- // thus in the solution vector
- boundary_values[i] = boundary_projection(dof_to_boundary_mapping[i]);
- }
+ // this dof is on one of the
+ // interesting boundary parts
+ //
+ // remember: i is the global dof
+ // number, dof_to_boundary_mapping[i]
+ // is the number on the boundary and
+ // thus in the solution vector
+ boundary_values[i] = boundary_projection(dof_to_boundary_mapping[i]);
+ }
+ }
+ }
+
+ template <int dim, int spacedim>
+ void
+ project_boundary_values (const Mapping<dim, spacedim> &mapping,
+ const DoFHandler<dim, spacedim> &dof,
+ const typename FunctionMap<spacedim>::type &boundary_functions,
+ const Quadrature<dim-1> &q,
+ std::map<types::global_dof_index,double> &boundary_values,
+ std::vector<unsigned int> component_mapping)
+ {
+ do_project_boundary_values(mapping, dof, boundary_functions, q,
+ boundary_values, component_mapping);
}
-// ----- implementation for project_boundary_values with ConstraintMatrix -----
+ template <int dim, int spacedim>
+ void project_boundary_values (const hp::MappingCollection<dim, spacedim> &mapping,
+ const hp::DoFHandler<dim,spacedim> &dof,
+ const typename FunctionMap<spacedim>::type &boundary_functions,
+ const hp::QCollection<dim-1> &q,
+ std::map<types::global_dof_index,double> &boundary_values,
+ std::vector<unsigned int> component_mapping)
+ {
+ do_project_boundary_values (mapping, dof,
+ boundary_functions,
+ q, boundary_values,
+ component_mapping);
+ }
+
+
+
+ template <int dim, int spacedim>
+ void project_boundary_values (const hp::DoFHandler<dim,spacedim> &dof,
+ const typename FunctionMap<spacedim>::type &boundary_function,
+ const hp::QCollection<dim-1> &q,
+ std::map<types::global_dof_index,double> &boundary_values,
+ std::vector<unsigned int> component_mapping)
+ {
+ project_boundary_values (hp::StaticMappingQ1<dim,spacedim>::mapping_collection, dof,
+ boundary_function,
+ q, boundary_values,
+ component_mapping);
+ }
+
+
+ // ----- implementation for project_boundary_values with ConstraintMatrix -----
std::vector<double> &dof_values,
std::vector<bool> &dofs_processed)
{
- const double tol = 0.5 * cell->get_fe ().degree * 1e-13 / cell->face (face)->line (line)->diameter ();
+ const double tol = 0.5 * cell->face (face)->line (line)->diameter () / cell->get_fe ().degree;
const unsigned int dim = 3;
const unsigned int spacedim = 3;
{
case 2:
{
+ const double tol = 0.5 * cell->face (face)->diameter () / cell->get_fe ().degree;
std::vector<Point<dim> >
tangentials (fe_values.n_quadrature_points);
= reference_quadrature_points[q_point];
shifted_reference_point_1 (face_coordinate_direction[face])
- += 1e-13;
+ += tol;
shifted_reference_point_2 (face_coordinate_direction[face])
- -= 1e-13;
+ -= tol;
tangentials[q_point]
- = 2e13
- * (fe_values.get_mapping ()
+ = (fe_values.get_mapping ()
.transform_unit_to_real_cell (cell,
shifted_reference_point_1)
-
fe_values.get_mapping ()
.transform_unit_to_real_cell (cell,
- shifted_reference_point_2));
+ shifted_reference_point_2))
+ / tol;
tangentials[q_point]
/= std::sqrt (tangentials[q_point].square ());
// Compute the degrees
}
}
- // Create the system
- // matrix by
- // multiplying the
- // assembling matrix
- // with its transposed
- // and the right
- // hand side vector
- // by mutliplying
- // the assembling
- // matrix with the
- // assembling vector.
- // Invert the system
- // matrix.
+ // Create the system matrix by multiplying the assembling matrix
+ // with its transposed and the right hand side vector by mutliplying
+ // the assembling matrix with the assembling vector. Invert the
+ // system matrix.
assembling_matrix.mTmult (cell_matrix, assembling_matrix);
cell_matrix_inv.invert (cell_matrix);
assembling_matrix.vmult (cell_rhs, assembling_vector);
}
}
- // Now we do the
- // same as above
- // with the vertical
- // shape functions
- // instead of the
- // horizontal ones.
+ // Now we do the same as above with the vertical shape functions
+ // instead of the horizontal ones.
for (unsigned int q_point = 0;
q_point < fe_values.n_quadrature_points; ++q_point)
{
ConstraintMatrix &constraints,
const Mapping<dim> &mapping)
{
- // Projection-based interpolation
- // is performed in two (in 2D)
- // respectively three (in 3D)
- // steps. First the tangential
- // component of the function is
- // interpolated on each edge. This
- // gives the values for the degrees
- // of freedom corresponding to the
- // edge shape functions. Now we are
- // done for 2D, but in 3D we possibly
- // have also degrees of freedom, which
- // are located in the interior of
- // the faces. Therefore we compute
- // the residual of the function
- // describing the boundary values
- // and the interpolated part, which
- // we have computed in the last
- // step. On the faces there are
- // two kinds of shape functions,
- // the horizontal and the vertical
- // ones. Thus we have to solve two
- // linear systems of equations of
- // size <tt>degree * (degree +
- // 1)<tt> to obtain the values for
- // the corresponding degrees of
- // freedom.
+ // Projection-based interpolation is performed in two (in 2D) respectively
+ // three (in 3D) steps. First the tangential component of the function is
+ // interpolated on each edge. This gives the values for the degrees of
+ // freedom corresponding to the edge shape functions. Now we are done for
+ // 2D, but in 3D we possibly have also degrees of freedom, which are
+ // located in the interior of the faces. Therefore we compute the residual
+ // of the function describing the boundary values and the interpolated
+ // part, which we have computed in the last step. On the faces there are
+ // two kinds of shape functions, the horizontal and the vertical
+ // ones. Thus we have to solve two linear systems of equations of size
+ // <tt>degree * (degree + 1)<tt> to obtain the values for the
+ // corresponding degrees of freedom.
const unsigned int superdegree = dof_handler.get_fe ().degree;
const QGauss<dim - 1> reference_face_quadrature (2 * superdegree);
const unsigned int dofs_per_face = dof_handler.get_fe ().dofs_per_face;
// if the degree of
// freedom is not
// already constrained.
- const double tol = 0.5 * cell->get_fe ().degree * 1e-13 / cell->face (face)->diameter ();
-
for (unsigned int dof = 0; dof < dofs_per_face; ++dof)
if (dofs_processed[dof] && constraints.can_store_line (face_dof_indices[dof])
&& !(constraints.is_constrained (face_dof_indices[dof])))
{
constraints.add_line (face_dof_indices[dof]);
- if (std::abs (dof_values[dof]) > tol)
+ if (std::abs (dof_values[dof]) > 1e-13)
constraints.set_inhomogeneity (face_dof_indices[dof], dof_values[dof]);
}
}
// Store the computed
// values in the global
// vector.
-
cell->face (face)->get_dof_indices (face_dof_indices,
cell->active_fe_index ());
- const double tol = 0.5 * superdegree * 1e-13 / cell->face (face)->diameter ();
-
for (unsigned int dof = 0; dof < dofs_per_face; ++dof)
if (dofs_processed[dof] && constraints.can_store_line (face_dof_indices[dof])
&& !(constraints.is_constrained (face_dof_indices[dof])))
{
constraints.add_line (face_dof_indices[dof]);
- if (std::abs (dof_values[dof]) > tol)
+ if (std::abs (dof_values[dof]) > 1e-13)
constraints.set_inhomogeneity (face_dof_indices[dof], dof_values[dof]);
}
}
for (unsigned int face = 0; face < GeometryInfo<dim>::faces_per_cell; ++face)
if (cell->face (face)->boundary_indicator () == boundary_component)
{
- // if the FE is a
- // FE_Nothing object
- // there is no work to
- // do
+ // if the FE is a FE_Nothing object there is no work to do
if (dynamic_cast<const FE_Nothing<dim>*> (&cell->get_fe ()) != 0)
return;
- // This is only
- // implemented, if the
- // FE is a Nedelec
- // element. If the FE is
- // a FESystem we cannot
- // check this.
+ // This is only implemented, if the FE is a Nedelec
+ // element. If the FE is a FESystem we cannot check this.
if (dynamic_cast<const FESystem<dim>*> (&cell->get_fe ()) == 0)
{
typedef FiniteElement<dim> FEL;
cell->face (face)->get_dof_indices (face_dof_indices,
cell->active_fe_index ());
- const double tol = 0.5 * cell->get_fe ().degree * 1e-13 / cell->face (face)->diameter ();
-
for (unsigned int dof = 0; dof < dofs_per_face; ++dof)
if (dofs_processed[dof] && constraints.can_store_line (face_dof_indices[dof])
&& !(constraints.is_constrained (face_dof_indices[dof])))
{
constraints.add_line (face_dof_indices[dof]);
- if (std::abs (dof_values[dof]) > tol)
+ if (std::abs (dof_values[dof]) > 1e-13)
constraints.set_inhomogeneity (face_dof_indices[dof], dof_values[dof]);
}
}
for (unsigned int face = 0; face < GeometryInfo<dim>::faces_per_cell; ++face)
if (cell->face (face)->boundary_indicator () == boundary_component)
{
- // if the FE is a
- // FE_Nothing object
- // there is no work to
- // do
+ // if the FE is a FE_Nothing object there is no work to do
if (dynamic_cast<const FE_Nothing<dim>*> (&cell->get_fe ()) != 0)
return;
- // This is only
- // implemented, if the
- // FE is a Nedelec
- // element. If the FE is
- // a FESystem we cannot
- // check this.
+ // This is only implemented, if the FE is a Nedelec
+ // element. If the FE is a FESystem we cannot check this.
if (dynamic_cast<const FESystem<dim>*> (&cell->get_fe ()) == 0)
{
typedef FiniteElement<dim> FEL;
first_vector_component,
dof_values, dofs_processed);
- // If there are higher
- // order shape
- // functions, there is
- // still some work
- // left.
+ // If there are higher order shape functions, there is still
+ // some work left.
if (degree > 0)
internals
::compute_face_projection_curl_conforming (cell, face, fe_face_values,
cell->face (face)->get_dof_indices (face_dof_indices,
cell->active_fe_index ());
- const double tol = 0.5 * superdegree * 1e-13 / cell->face (face)->diameter ();
-
for (unsigned int dof = 0; dof < dofs_per_face; ++dof)
if (dofs_processed[dof] && constraints.can_store_line (face_dof_indices[dof])
&& !(constraints.is_constrained (face_dof_indices[dof])))
{
constraints.add_line (face_dof_indices[dof]);
- if (std::abs (dof_values[dof]) > tol)
+ if (std::abs (dof_values[dof]) > 1e-13)
constraints.set_inhomogeneity (face_dof_indices[dof], dof_values[dof]);
}
}
namespace internals
{
- // This function computes the
- // projection of the boundary
- // function on the boundary
- // in 2d.
+ // This function computes the projection of the boundary function on the
+ // boundary in 2d.
template <typename cell_iterator>
void
compute_face_projection_div_conforming (const cell_iterator &cell,
const std::vector<DerivativeForm<1,2,2> > &jacobians,
ConstraintMatrix &constraints)
{
- // Compute the intergral over
- // the product of the normal
- // components of the boundary
- // function times the normal
- // components of the shape
- // functions supported on the
- // boundary.
+ // Compute the intergral over the product of the normal components of
+ // the boundary function times the normal components of the shape
+ // functions supported on the boundary.
const FEValuesExtractors::Vector vec (first_vector_component);
const FiniteElement<2> &fe = cell->get_fe ();
const std::vector<Point<2> > &normals = fe_values.get_normal_vectors ();
values (fe_values.n_quadrature_points, Vector<double> (2));
Vector<double> dof_values (fe.dofs_per_face);
- // Get the values of the
- // boundary function at the
- // quadrature points.
+ // Get the values of the boundary function at the quadrature points.
{
const std::vector<Point<2> > &
quadrature_points = fe_values.get_quadrature_points ();
cell->face (face)->get_dof_indices (face_dof_indices, cell->active_fe_index ());
- // Copy the computed values
- // in the ConstraintMatrix only,
- // if the degree of freedom is
- // not already constrained.
+ // Copy the computed values in the ConstraintMatrix only, if the degree
+ // of freedom is not already constrained.
for (unsigned int i = 0; i < fe.dofs_per_face; ++i)
if (!(constraints.is_constrained (face_dof_indices[i])))
{
}
}
- // dummy implementation of above
- // function for all other
- // dimensions
+ // dummy implementation of above function for all other dimensions
template<int dim, typename cell_iterator>
void
compute_face_projection_div_conforming (const cell_iterator &,
Assert (false, ExcNotImplemented ());
}
- // This function computes the
- // projection of the boundary
- // function on the boundary
- // in 3d.
+ // This function computes the projection of the boundary function on the
+ // boundary in 3d.
template<typename cell_iterator>
void
compute_face_projection_div_conforming (const cell_iterator &cell,
std::vector<double> &dof_values,
std::vector<types::global_dof_index> &projected_dofs)
{
- // Compute the intergral over
- // the product of the normal
- // components of the boundary
- // function times the normal
- // components of the shape
- // functions supported on the
- // boundary.
+ // Compute the intergral over the product of the normal components of
+ // the boundary function times the normal components of the shape
+ // functions supported on the boundary.
const FEValuesExtractors::Vector vec (first_vector_component);
const FiniteElement<3> &fe = cell->get_fe ();
const std::vector<Point<3> > &normals = fe_values.get_normal_vectors ();
hp::FEFaceValues<dim,spacedim> x_fe_face_values (mapping_collection,
fe_collection,
face_quadrature_collection,
- update_q_points);
+ update_q_points |
+ update_normal_vectors);
// have a map that stores normal vectors for each vector-dof tuple we want
// to constrain. since we can get at the same vector dof tuple more than
// to check that they are small *relative to something
// else*). we do this and then normalize the length of the
// vector back to one, just to be on the safe side
+ //
+ // one more point: we would like to use the "real" normal
+ // vector here, as provided by the boundary description
+ // and as opposed to what we get from the FEValues object.
+ // we do this in the immediately next line, but as is
+ // obvious, the boundary only has a vague idea which side
+ // of a cell it is on -- indicated by the face number. in
+ // other words, it may provide the inner or outer normal.
+ // by and large, there is no harm from this, since the
+ // tangential vector we compute is still the same. however,
+ // we do average over normal vectors from adjacent cells
+ // and if they have recorded normal vectors from the inside
+ // once and from the outside the other time, then this
+ // averaging is going to run into trouble. as a consequence
+ // we ask the mapping after all for its normal vector,
+ // but we only ask it so that we can possibly correct the
+ // sign of the normal vector provided by the boundary
+ // if they should point in different directions. this is the
+ // case in tests/deal.II/no_flux_11.
Point<dim> normal_vector
= (cell->face(face_no)->get_boundary()
.normal_vector (cell->face(face_no),
fe_values.quadrature_point(i)));
+ if (normal_vector * fe_values.normal_vector(i) < 0)
+ normal_vector *= -1;
Assert (std::fabs(normal_vector.norm() - 1) < 1e-14,
ExcInternalError());
for (unsigned int d=0; d<dim; ++d)
if (std::fabs(normal_vector[d]) < 1e-13)
normal_vector[d] = 0;
normal_vector /= normal_vector.norm();
-
+
// now enter the (dofs,(normal_vector,cell)) entry into
// the map
dof_to_normals_map
+ namespace
+ {
+ template <int dim>
+ struct PointComparator
+ {
+ bool operator ()(const std_cxx1x::array<types::global_dof_index,dim> &p1,
+ const std_cxx1x::array<types::global_dof_index,dim> &p2)
+ {
+ for (unsigned int d=0; d<dim; ++d)
+ if (p1[d] < p2[d])
+ return true;
+ return false;
+ }
+ };
+ }
+
+
+
+ template <int dim, template <int, int> class DH, int spacedim>
+ void
+ compute_normal_flux_constraints (const DH<dim,spacedim>&dof_handler,
+ const unsigned int first_vector_component,
+ const std::set<types::boundary_id> &boundary_ids,
+ ConstraintMatrix &constraints,
+ const Mapping<dim, spacedim> &mapping)
+ {
+ ConstraintMatrix no_normal_flux_constraints(constraints.get_local_lines());
+ compute_no_normal_flux_constraints (dof_handler,
+ first_vector_component,
+ boundary_ids,
+ no_normal_flux_constraints,
+ mapping);
+
+ // Extract a list that collects all vector components that belong to the
+ // same node (scalar basis function). When creating that list, we use an
+ // array of dim components that stores the global degree of freedom.
+ std::set<std_cxx1x::array<types::global_dof_index,dim>, PointComparator<dim> > vector_dofs;
+ std::vector<types::global_dof_index> face_dofs;
+
+ std::vector<std_cxx1x::array<types::global_dof_index,dim> > cell_vector_dofs;
+ for (typename DH<dim,spacedim>::active_cell_iterator cell =
+ dof_handler.begin_active(); cell != dof_handler.end(); ++cell)
+ if (!cell->is_artificial())
+ for (unsigned int face_no=0; face_no < GeometryInfo<dim>::faces_per_cell;
+ ++face_no)
+ if (boundary_ids.find(cell->face(face_no)->boundary_indicator())
+ != boundary_ids.end())
+ {
+ const FiniteElement<dim> &fe = cell->get_fe();
+ typename DH<dim,spacedim>::face_iterator face=cell->face(face_no);
+
+ // get the indices of the dofs on this cell...
+ face_dofs.resize (fe.dofs_per_face);
+ face->get_dof_indices (face_dofs, cell->active_fe_index());
+
+ unsigned int n_scalar_indices = 0;
+ cell_vector_dofs.resize(fe.dofs_per_face);
+ for (unsigned int i=0; i<fe.dofs_per_face; ++i)
+ if (fe.face_system_to_component_index(i).first >= first_vector_component &&
+ fe.face_system_to_component_index(i).first < first_vector_component + dim)
+ {
+ n_scalar_indices =
+ std::max(n_scalar_indices,
+ fe.face_system_to_component_index(i).second+1);
+ cell_vector_dofs[fe.face_system_to_component_index(i).second]
+ [fe.face_system_to_component_index(i).first-first_vector_component]
+ = face_dofs[i];
+ }
+
+ // now we identified the vector indices on the cell, so next
+ // insert them into the set (it would be expensive to directly
+ // insert incomplete points into the set)
+ for (unsigned int i=0; i<n_scalar_indices; ++i)
+ vector_dofs.insert(cell_vector_dofs[i]);
+ }
+
+ // iterate over the list of all vector components we found and see if we
+ // can find constrained ones
+ unsigned int n_total_constraints_found = 0;
+ for (typename std::set<std_cxx1x::array<types::global_dof_index,dim>,
+ PointComparator<dim> >::const_iterator it=vector_dofs.begin();
+ it!=vector_dofs.end(); ++it)
+ {
+ unsigned int n_constraints = 0;
+ bool is_constrained[dim];
+ for (unsigned int d=0; d<dim; ++d)
+ if (no_normal_flux_constraints.is_constrained((*it)[d]))
+ {
+ is_constrained[d] = true;
+ ++n_constraints;
+ ++n_total_constraints_found;
+ }
+ else
+ is_constrained[d] = false;
+ if (n_constraints > 0)
+ {
+ // if more than one no-flux constraint is present, we need to
+ // constrain all vector degrees of freedom (we are in a corner
+ // where several faces meet and to get a continuous FE solution we
+ // need to set all conditions to zero).
+ if (n_constraints > 1)
+ {
+ for (unsigned int d=0; d<dim; ++d)
+ constraints.add_line((*it)[d]);
+ continue;
+ }
+
+ // ok, this is a no-flux constraint, so get the index of the dof
+ // that is currently constrained and make it unconstrained. The
+ // constraint indices will get the normal that contain the other
+ // indices.
+ Tensor<1,dim> normal;
+ unsigned constrained_index = -1;
+ for (unsigned int d=0; d<dim; ++d)
+ if (is_constrained[d])
+ {
+ constrained_index = d;
+ normal[d] = 1.;
+ }
+ AssertIndexRange(constrained_index, dim);
+ const std::vector<std::pair<types::global_dof_index, double> >* constrained
+ = no_normal_flux_constraints.get_constraint_entries((*it)[constrained_index]);
+ // find components to which this index is constrained to
+ Assert(constrained != 0, ExcInternalError());
+ Assert(constrained->size() < dim, ExcInternalError());
+ for (unsigned int c=0; c<constrained->size(); ++c)
+ {
+ int index = -1;
+ for (unsigned int d=0; d<dim; ++d)
+ if ((*constrained)[c].first == (*it)[d])
+ index = d;
+ Assert (index != -1, ExcInternalError());
+ normal[index] = (*constrained)[c].second;
+ }
+ for (unsigned int d=0; d<dim; ++d)
+ {
+ if (is_constrained[d])
+ continue;
+ const unsigned int new_index = (*it)[d];
+ if (!constraints.is_constrained(new_index))
+ {
+ constraints.add_line(new_index);
+ if (std::abs(normal[d]) > 1e-13)
+ constraints.add_entry(new_index, (*it)[constrained_index],
+ -normal[d]);
+ }
+ }
+ }
+ }
+ AssertDimension(n_total_constraints_found,
+ no_normal_flux_constraints.n_constraints());
+ }
+
+
+
namespace internal
{
+ template <int dim, int spacedim>
+ struct IDScratchData
+ {
+ IDScratchData (const dealii::hp::MappingCollection<dim,spacedim> &mapping,
+ const dealii::hp::FECollection<dim,spacedim> &fe,
+ const dealii::hp::QCollection<dim> &q,
+ const UpdateFlags update_flags);
+
+ IDScratchData (const IDScratchData &data);
+
+ void resize_vectors (const unsigned int n_q_points,
+ const unsigned int n_components);
+
+ std::vector<dealii::Vector<double> > function_values;
+ std::vector<std::vector<Tensor<1,spacedim> > > function_grads;
+ std::vector<double> weight_values;
+ std::vector<dealii::Vector<double> > weight_vectors;
+
+ std::vector<dealii::Vector<double> > psi_values;
+ std::vector<std::vector<Tensor<1,spacedim> > > psi_grads;
+ std::vector<double> psi_scalar;
+
+ std::vector<double> tmp_values;
+ std::vector<Tensor<1,spacedim> > tmp_gradients;
+
+ dealii::hp::FEValues<dim,spacedim> x_fe_values;
+ };
+
+
+ template <int dim, int spacedim>
+ IDScratchData<dim,spacedim>
+ ::IDScratchData(const dealii::hp::MappingCollection<dim,spacedim> &mapping,
+ const dealii::hp::FECollection<dim,spacedim> &fe,
+ const dealii::hp::QCollection<dim> &q,
+ const UpdateFlags update_flags)
+ :
+ x_fe_values(mapping, fe, q, update_flags)
+ {}
+
+ template <int dim, int spacedim>
+ IDScratchData<dim,spacedim>::IDScratchData (const IDScratchData &data)
+ :
+ x_fe_values(data.x_fe_values.get_mapping_collection(),
+ data.x_fe_values.get_fe_collection(),
+ data.x_fe_values.get_quadrature_collection(),
+ data.x_fe_values.get_update_flags())
+ {}
+
+ template <int dim, int spacedim>
+ void
+ IDScratchData<dim,spacedim>::resize_vectors (const unsigned int n_q_points,
+ const unsigned int n_components)
+ {
+ function_values.resize (n_q_points,
+ dealii::Vector<double>(n_components));
+ function_grads.resize (n_q_points,
+ std::vector<Tensor<1,spacedim> >(n_components));
+
+ weight_values.resize (n_q_points);
+ weight_vectors.resize (n_q_points,
+ dealii::Vector<double>(n_components));
+
+ psi_values.resize (n_q_points,
+ dealii::Vector<double>(n_components));
+ psi_grads.resize (n_q_points,
+ std::vector<Tensor<1,spacedim> >(n_components));
+ psi_scalar.resize (n_q_points);
+
+ tmp_values.resize (n_q_points);
+ tmp_gradients.resize (n_q_points);
+ }
+
+
+ // avoid compiling inner function for many vector types when we always
+ // really do the same thing by putting the main work into this helper
+ // function
+ template <int dim, int spacedim>
+ double
+ integrate_difference_inner (const Function<spacedim> &exact_solution,
+ const NormType &norm,
+ const Function<spacedim> *weight,
+ const UpdateFlags update_flags,
+ const double exponent,
+ const unsigned int n_components,
+ IDScratchData<dim,spacedim> &data)
+ {
+ const bool fe_is_system = (n_components != 1);
+ const dealii::FEValues<dim, spacedim> &fe_values = data.x_fe_values.get_present_fe_values ();
+ const unsigned int n_q_points = fe_values.n_quadrature_points;
+
+ if (weight!=0)
+ {
+ if (weight->n_components>1)
+ weight->vector_value_list (fe_values.get_quadrature_points(),
+ data.weight_vectors);
+ else
+ {
+ weight->value_list (fe_values.get_quadrature_points(),
+ data.weight_values);
+ for (unsigned int k=0; k<n_q_points; ++k)
+ data.weight_vectors[k] = data.weight_values[k];
+ }
+ }
+ else
+ {
+ for (unsigned int k=0; k<n_q_points; ++k)
+ data.weight_vectors[k] = 1.;
+ }
+
+
+ if (update_flags & update_values)
+ {
+ // first compute the exact solution (vectors) at the quadrature
+ // points try to do this as efficient as possible by avoiding a
+ // second virtual function call in case the function really has only
+ // one component
+ if (fe_is_system)
+ exact_solution.vector_value_list (fe_values.get_quadrature_points(),
+ data.psi_values);
+ else
+ {
+ exact_solution.value_list (fe_values.get_quadrature_points(),
+ data.tmp_values);
+ for (unsigned int i=0; i<n_q_points; ++i)
+ data.psi_values[i](0) = data.tmp_values[i];
+ }
+
+ // then subtract finite element fe_function
+ for (unsigned int q=0; q<n_q_points; ++q)
+ data.psi_values[q] -= data.function_values[q];
+ }
+
+ // Do the same for gradients, if required
+ if (update_flags & update_gradients)
+ {
+ // try to be a little clever to avoid recursive virtual function
+ // calls when calling gradient_list for functions that are really
+ // scalar functions
+ if (fe_is_system)
+ exact_solution.vector_gradient_list (fe_values.get_quadrature_points(),
+ data.psi_grads);
+ else
+ {
+ exact_solution.gradient_list (fe_values.get_quadrature_points(),
+ data.tmp_gradients);
+ for (unsigned int i=0; i<n_q_points; ++i)
+ data.psi_grads[i][0] = data.tmp_gradients[i];
+ }
+
+ // then subtract finite element function_grads. We need to be
+ // careful in the codimension one case, since there we only have
+ // tangential gradients in the finite element function, not the full
+ // gradient. This is taken care of, by subtracting the normal
+ // component of the gradient from the exact function.
+ if (update_flags & update_normal_vectors)
+ for (unsigned int k=0; k<n_components; ++k)
+ for (unsigned int q=0; q<n_q_points; ++q)
+ data.psi_grads[q][k] -= (data.function_grads[q][k] +
+ (data.psi_grads[q][k]* // (f.n) n
+ fe_values.normal_vector(q))*
+ fe_values.normal_vector(q));
+ else
+ for (unsigned int k=0; k<n_components; ++k)
+ for (unsigned int q=0; q<n_q_points; ++q)
+ data.psi_grads[q][k] -= data.function_grads[q][k];
+ }
+
+ double diff = 0;
+ switch (norm)
+ {
+ case mean:
+ // Compute values in quadrature points and integrate
+ for (unsigned int q=0; q<n_q_points; ++q)
+ {
+ double sum = 0;
+ for (unsigned int k=0; k<n_components; ++k)
+ sum += data.psi_values[q](k) * data.weight_vectors[q](k);
+ diff += sum * fe_values.JxW(q);
+ }
+ break;
+
+ case Lp_norm:
+ case L1_norm:
+ case W1p_norm:
+ // Compute values in quadrature points and integrate
+ for (unsigned int q=0; q<n_q_points; ++q)
+ {
+ double sum = 0;
+ for (unsigned int k=0; k<n_components; ++k)
+ sum += std::pow(data.psi_values[q](k)*data.psi_values[q](k),
+ exponent/2.) * data.weight_vectors[q](k);
+ diff += sum * fe_values.JxW(q);
+ }
+
+ // Compute the root only, if no derivative values are added later
+ if (!(update_flags & update_gradients))
+ diff = std::pow(diff, 1./exponent);
+ break;
+
+ case L2_norm:
+ case H1_norm:
+ // Compute values in quadrature points and integrate
+ for (unsigned int q=0; q<n_q_points; ++q)
+ {
+ double sum = 0;
+ for (unsigned int k=0; k<n_components; ++k)
+ sum += data.psi_values[q](k) * data.psi_values[q](k) *
+ data.weight_vectors[q](k);
+ diff += sum * fe_values.JxW(q);
+ }
+ // Compute the root only, if no derivative values are added later
+ if (norm == L2_norm)
+ diff=std::sqrt(diff);
+ break;
+
+ case Linfty_norm:
+ case W1infty_norm:
+ for (unsigned int q=0; q<n_q_points; ++q)
+ for (unsigned int k=0; k<n_components; ++k)
+ diff = std::max (diff, std::abs(data.psi_values[q](k)*
+ data.weight_vectors[q](k)));
+ break;
+
+ case H1_seminorm:
+ case W1p_seminorm:
+ case W1infty_seminorm:
+ break;
+
+ default:
+ Assert (false, ExcNotImplemented());
+ break;
+ }
+
+ switch (norm)
+ {
+ case W1p_seminorm:
+ case W1p_norm:
+ for (unsigned int q=0; q<n_q_points; ++q)
+ {
+ double sum = 0;
+ for (unsigned int k=0; k<n_components; ++k)
+ sum += std::pow(data.psi_grads[q][k]*data.psi_grads[q][k],
+ exponent/2.) * data.weight_vectors[q](k);
+ diff += sum * fe_values.JxW(q);
+ }
+ diff = std::pow(diff, 1./exponent);
+ break;
+
+ case H1_seminorm:
+ case H1_norm:
+ for (unsigned int q=0; q<n_q_points; ++q)
+ {
+ double sum = 0;
+ for (unsigned int k=0; k<n_components; ++k)
+ sum += (data.psi_grads[q][k] * data.psi_grads[q][k]) *
+ data.weight_vectors[q](k);
+ diff += sum * fe_values.JxW(q);
+ }
+ diff = std::sqrt(diff);
+ break;
+
+ case W1infty_seminorm:
+ case W1infty_norm:
+ {
+ double t = 0;
+ for (unsigned int q=0; q<n_q_points; ++q)
+ for (unsigned int k=0; k<n_components; ++k)
+ for (unsigned int d=0; d<dim; ++d)
+ t = std::max(t, std::abs(data.psi_grads[q][k][d]) *
+ data.weight_vectors[q](k));
+
+ // then add seminorm to norm if that had previously been computed
+ diff += t;
+ }
+ break;
+ default:
+ break;
+ }
+
+ // append result of this cell to the end of the vector
+ Assert (numbers::is_finite(diff), ExcNumberNotFinite());
+ return diff;
+ }
+
+
+
template <int dim, class InVector, class OutVector, class DH, int spacedim>
static
void
- do_integrate_difference (const dealii::hp::MappingCollection<dim,spacedim> &mapping,
+ do_integrate_difference (const dealii::hp::MappingCollection<dim,spacedim> &mapping,
const DH &dof,
const InVector &fe_function,
const Function<spacedim> &exact_solution,
const Function<spacedim> *weight,
const double exponent_1)
{
- // we mark the "exponent" parameter
- // to this function "const" since
- // it is strictly incoming, but we
- // need to set it to something
- // different later on, if
- // necessary, so have a read-write
- // version of it:
+ // we mark the "exponent" parameter to this function "const" since it is
+ // strictly incoming, but we need to set it to something different later
+ // on, if necessary, so have a read-write version of it:
double exponent = exponent_1;
const unsigned int n_components = dof.get_fe().n_components();
- const bool fe_is_system = (n_components != 1);
if (weight!=0)
{
}
dealii::hp::FECollection<dim,spacedim> fe_collection (dof.get_fe());
- dealii::hp::FEValues<dim,spacedim> x_fe_values(mapping, fe_collection, q, update_flags);
-
- const unsigned int max_n_q_points = q.max_n_quadrature_points ();
-
- std::vector< dealii::Vector<double> >
- function_values (max_n_q_points, dealii::Vector<double>(n_components));
- std::vector<std::vector<Tensor<1,spacedim> > >
- function_grads (max_n_q_points, std::vector<Tensor<1,spacedim> >(n_components));
-
- std::vector<double>
- weight_values (max_n_q_points);
- std::vector<dealii::Vector<double> >
- weight_vectors (max_n_q_points, dealii::Vector<double>(n_components));
-
- std::vector<dealii::Vector<double> >
- psi_values (max_n_q_points, dealii::Vector<double>(n_components));
- std::vector<std::vector<Tensor<1,spacedim> > >
- psi_grads (max_n_q_points, std::vector<Tensor<1,spacedim> >(n_components));
- std::vector<double>
- psi_scalar (max_n_q_points);
-
- // tmp vector when we use the
- // Function<spacedim> functions for
- // scalar functions
- std::vector<double> tmp_values (max_n_q_points);
- std::vector<Tensor<1,spacedim> > tmp_gradients (max_n_q_points);
+ IDScratchData<dim,spacedim> data(mapping, fe_collection, q, update_flags);
// loop over all cells
typename DH::active_cell_iterator cell = dof.begin_active(),
for (unsigned int index=0; cell != endc; ++cell, ++index)
if (cell->is_locally_owned())
{
- double diff=0;
// initialize for this cell
- x_fe_values.reinit (cell);
+ data.x_fe_values.reinit (cell);
- const dealii::FEValues<dim, spacedim> &fe_values = x_fe_values.get_present_fe_values ();
+ const dealii::FEValues<dim, spacedim> &fe_values = data.x_fe_values.get_present_fe_values ();
const unsigned int n_q_points = fe_values.n_quadrature_points;
-
- // resize all out scratch
- // arrays to the number of
- // quadrature points we use
- // for the present cell
- function_values.resize (n_q_points,
- dealii::Vector<double>(n_components));
- function_grads.resize (n_q_points,
- std::vector<Tensor<1,spacedim> >(n_components));
-
- weight_values.resize (n_q_points);
- weight_vectors.resize (n_q_points,
- dealii::Vector<double>(n_components));
-
- psi_values.resize (n_q_points,
- dealii::Vector<double>(n_components));
- psi_grads.resize (n_q_points,
- std::vector<Tensor<1,spacedim> >(n_components));
- psi_scalar.resize (n_q_points);
-
- tmp_values.resize (n_q_points);
- tmp_gradients.resize (n_q_points);
-
- if (weight!=0)
- {
- if (weight->n_components>1)
- weight->vector_value_list (fe_values.get_quadrature_points(),
- weight_vectors);
- else
- {
- weight->value_list (fe_values.get_quadrature_points(),
- weight_values);
- for (unsigned int k=0; k<n_q_points; ++k)
- weight_vectors[k] = weight_values[k];
- }
- }
- else
- {
- for (unsigned int k=0; k<n_q_points; ++k)
- weight_vectors[k] = 1.;
- }
-
+ data.resize_vectors (n_q_points, n_components);
if (update_flags & update_values)
- {
- // first compute the exact solution
- // (vectors) at the quadrature points
- // try to do this as efficient as
- // possible by avoiding a second
- // virtual function call in case
- // the function really has only
- // one component
- if (fe_is_system)
- exact_solution.vector_value_list (fe_values.get_quadrature_points(),
- psi_values);
- else
- {
- exact_solution.value_list (fe_values.get_quadrature_points(),
- tmp_values);
- for (unsigned int i=0; i<n_q_points; ++i)
- psi_values[i](0) = tmp_values[i];
- }
-
- // then subtract finite element
- // fe_function
- fe_values.get_function_values (fe_function, function_values);
- for (unsigned int q=0; q<n_q_points; ++q)
- psi_values[q] -= function_values[q];
- }
-
- // Do the same for gradients, if required
+ fe_values.get_function_values (fe_function, data.function_values);
if (update_flags & update_gradients)
- {
- // try to be a little clever
- // to avoid recursive virtual
- // function calls when calling
- // gradient_list for functions
- // that are really scalar
- // functions
- if (fe_is_system)
- exact_solution.vector_gradient_list (fe_values.get_quadrature_points(),
- psi_grads);
- else
- {
- exact_solution.gradient_list (fe_values.get_quadrature_points(),
- tmp_gradients);
- for (unsigned int i=0; i<n_q_points; ++i)
- psi_grads[i][0] = tmp_gradients[i];
- }
-
- // then subtract finite element
- // function_grads. We
- // need to be careful
- // in the codimension
- // one case, since
- // there we only have
- // tangential gradients
- // in the finite
- // element function,
- // not the full
- // gradient. This is
- // taken care of, by
- // subtracting the
- // normal component of
- // the gradient from
- // the exact function.
- fe_values.get_function_grads (fe_function, function_grads);
- if (update_flags & update_normal_vectors)
- for (unsigned int k=0; k<n_components; ++k)
- for (unsigned int q=0; q<n_q_points; ++q)
- psi_grads[q][k] -= (function_grads[q][k] +
- (psi_grads[q][k]* // (f.n) n
- fe_values.normal_vector(q))*
- fe_values.normal_vector(q));
- else
- for (unsigned int k=0; k<n_components; ++k)
- for (unsigned int q=0; q<n_q_points; ++q)
- psi_grads[q][k] -= function_grads[q][k];
- }
-
- switch (norm)
- {
- case mean:
- std::fill_n (psi_scalar.begin(), n_q_points, 0.0);
- // Compute values in
- // quadrature points
- for (unsigned int k=0; k<n_components; ++k)
- for (unsigned int q=0; q<n_q_points; ++q)
- psi_scalar[q] += psi_values[q](k)
- * weight_vectors[q](k);
-
- // Integrate
- diff = std::inner_product (psi_scalar.begin(), psi_scalar.end(),
- fe_values.get_JxW_values().begin(),
- 0.0);
- break;
- case Lp_norm:
- case L1_norm:
- case W1p_norm:
- std::fill_n (psi_scalar.begin(), n_q_points, 0.0);
- // Compute values in
- // quadrature points
- for (unsigned int k=0; k<n_components; ++k)
- for (unsigned int q=0; q<n_q_points; ++q)
- psi_scalar[q] += std::pow(psi_values[q](k)*psi_values[q](k),
- exponent/2.)
- * weight_vectors[q](k);
-
- // Integrate
- diff = std::inner_product (psi_scalar.begin(), psi_scalar.end(),
- fe_values.get_JxW_values().begin(),
- 0.0);
- // Compute the root only,
- // if no derivative
- // values are added later
- if (!(update_flags & update_gradients))
- diff = std::pow(diff, 1./exponent);
- break;
- case L2_norm:
- case H1_norm:
- std::fill_n (psi_scalar.begin(), n_q_points, 0.0);
- // Compute values in
- // quadrature points
- for (unsigned int k=0; k<n_components; ++k)
- for (unsigned int q=0; q<n_q_points; ++q)
- psi_scalar[q] += psi_values[q](k)*psi_values[q](k)
- * weight_vectors[q](k);
-
- // Integrate
- diff = std::inner_product (psi_scalar.begin(), psi_scalar.end(),
- fe_values.get_JxW_values().begin(),
- 0.0);
- // Compute the root only,
- // if no derivative
- // values are added later
- if (norm == L2_norm)
- diff=std::sqrt(diff);
- break;
- case Linfty_norm:
- case W1infty_norm:
- std::fill_n (psi_scalar.begin(), n_q_points, 0.0);
- for (unsigned int k=0; k<n_components; ++k)
- for (unsigned int q=0; q<n_q_points; ++q)
- {
- double newval = std::fabs(psi_values[q](k))
- * weight_vectors[q](k);
- if (psi_scalar[q]<newval)
- psi_scalar[q] = newval;
- }
- // Maximum on one cell
- diff = *std::max_element (psi_scalar.begin(), psi_scalar.end());
- break;
- case H1_seminorm:
- case W1p_seminorm:
- case W1infty_seminorm:
- break;
- default:
- Assert (false, ExcNotImplemented());
- break;
- }
+ fe_values.get_function_grads (fe_function, data.function_grads);
- switch (norm)
- {
- case W1p_seminorm:
- case W1p_norm:
- std::fill_n (psi_scalar.begin(), n_q_points, 0.0);
- for (unsigned int k=0; k<n_components; ++k)
- for (unsigned int q=0; q<n_q_points; ++q)
- psi_scalar[q] += std::pow(psi_grads[q][k] * psi_grads[q][k],
- exponent/2.)
- * weight_vectors[q](k);
-
- diff += std::inner_product (psi_scalar.begin(), psi_scalar.end(),
- fe_values.get_JxW_values().begin(),
- 0.0);
- diff = std::pow(diff, 1./exponent);
- break;
- case H1_seminorm:
- case H1_norm:
- // take square of integrand
- std::fill_n (psi_scalar.begin(), n_q_points, 0.0);
- for (unsigned int k=0; k<n_components; ++k)
- for (unsigned int q=0; q<n_q_points; ++q)
- psi_scalar[q] += (psi_grads[q][k] * psi_grads[q][k])
- * weight_vectors[q](k);
-
- // add seminorm to L_2 norm or
- // to zero
- diff += std::inner_product (psi_scalar.begin(), psi_scalar.end(),
- fe_values.get_JxW_values().begin(),
- 0.0);
- diff = std::sqrt(diff);
- break;
-
- case W1infty_seminorm:
- case W1infty_norm:
- std::fill_n (psi_scalar.begin(), n_q_points, 0.0);
- for (unsigned int k=0; k<n_components; ++k)
- for (unsigned int q=0; q<n_q_points; ++q)
- {
- double t = 0.;
- for (unsigned int d=0; d<dim; ++d)
- t = std::max(t,std::fabs(psi_grads[q][k][d])
- * weight_vectors[q](k));
-
- psi_scalar[q] = std::max(psi_scalar[q],t);
- }
-
- // compute seminorm
- {
- double t = 0;
- for (unsigned int i=0; i<psi_scalar.size(); ++i)
- t = std::max (t, psi_scalar[i]);
-
- // then add seminorm to norm if that had previously been
- // computed
- diff += t;
- }
- break;
- default:
- break;
- }
- // append result of this cell
- // to the end of the vector
- Assert (numbers::is_finite(diff), ExcNumberNotFinite());
- difference(index) = diff;
+ difference(index) =
+ integrate_difference_inner (exact_solution, norm, weight,
+ update_flags, exponent,
+ n_components, data);
}
else
- // the cell is a ghost cell
- // or is artificial. write
- // a zero into the
- // corresponding value of
- // the returned vector
+ // the cell is a ghost cell or is artificial. write a zero into the
+ // corresponding value of the returned vector
difference(index) = 0;
}
const double exponent)
{
internal
- ::do_integrate_difference(hp::StaticMappingQ1<dim>::mapping_collection,
+ ::do_integrate_difference(hp::StaticMappingQ1<dim,spacedim>::mapping_collection,
dof, fe_function, exact_solution,
difference, q,
norm, weight, exponent);
const std::pair<typename DoFHandler<dim,spacedim>::active_cell_iterator, Point<spacedim> >
cell_point = GridTools::find_active_cell_around_point (mapping, dof, point);
+ AssertThrow(cell_point.first->is_locally_owned(),
+ ExcPointNotAvailableHere());
Assert(GeometryInfo<dim>::distance_to_unit_cell(cell_point.second) < 1e-10,
ExcInternalError());
cell_point
= GridTools::find_active_cell_around_point (mapping, dof, point);
+ AssertThrow(cell_point.first->is_locally_owned(),
+ ExcPointNotAvailableHere());
Assert(GeometryInfo<dim>::distance_to_unit_cell(cell_point.second) < 1e-10,
ExcInternalError());
const std::pair<typename hp::DoFHandler<dim,spacedim>::active_cell_iterator, Point<spacedim> >
cell_point = GridTools::find_active_cell_around_point (mapping, dof, point);
+ AssertThrow(cell_point.first->is_locally_owned(),
+ ExcPointNotAvailableHere());
Assert(GeometryInfo<dim>::distance_to_unit_cell(cell_point.second) < 1e-10,
ExcInternalError());
const std::pair<typename DoFHandler<dim,spacedim>::active_cell_iterator, Point<spacedim> >
cell_point = GridTools::find_active_cell_around_point (mapping, dof, point);
+ AssertThrow(cell_point.first->is_locally_owned(),
+ ExcPointNotAvailableHere());
Assert(GeometryInfo<dim>::distance_to_unit_cell(cell_point.second) < 1e-10,
ExcInternalError());
const std::pair<typename hp::DoFHandler<dim,spacedim>::active_cell_iterator, Point<spacedim> >
cell_point = GridTools::find_active_cell_around_point (mapping, dof, point);
+ AssertThrow(cell_point.first->is_locally_owned(),
+ ExcPointNotAvailableHere());
Assert(GeometryInfo<dim>::distance_to_unit_cell(cell_point.second) < 1e-10,
ExcInternalError());
subtract_mean_value(VECTOR &v,
const std::vector<bool> &p_select)
{
- if(p_select.size() == 0)
+ if (p_select.size() == 0)
{
// In case of an empty boolean mask operate on the whole vector:
v.add( - v.mean_value() );
// This function is not implemented for distributed vectors, so
// if v is not a boring Vector or BlockVector:
Assert( dynamic_cast<Vector<double> *>(& v)
- || dynamic_cast<Vector<float> *>(& v)
- || dynamic_cast<Vector<long double> *>(& v)
- || dynamic_cast<BlockVector<double> *>(& v)
- || dynamic_cast<BlockVector<float> *>(& v)
- || dynamic_cast<BlockVector<long double> *>(& v),
- ExcNotImplemented());
+ || dynamic_cast<Vector<float> *>(& v)
+ || dynamic_cast<Vector<long double> *>(& v)
+ || dynamic_cast<BlockVector<double> *>(& v)
+ || dynamic_cast<BlockVector<float> *>(& v)
+ || dynamic_cast<BlockVector<long double> *>(& v),
+ ExcNotImplemented());
const unsigned int n = v.size();
}
// Error out if we have not constrained anything. Note that in this
// case the vector v is always nonempty.
- Assert (n == 0 || counter > 0, ExcNoComponentSelected());
+ Assert (n == 0 || counter > 0, ComponentMask::ExcNoComponentSelected());
s /= counter;
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
#
# Compile the deal.II library
ADD_SUBDIRECTORY(meshworker)
+ADD_CUSTOM_TARGET(library)
+
FOREACH(build ${DEAL_II_BUILD_TYPES})
STRING(TOLOWER ${build} build_lowercase)
deal_ii_objects_${build_lowercase}
)
ADD_LIBRARY(${DEAL_II_BASE_NAME}${DEAL_II_${build}_SUFFIX}
- base/dummy.cc # Workaround for a bug in the Xcode generator
+ dummy.cc # Workaround for a bug in the Xcode generator
${deal_ii_objects_${build_lowercase}}
)
+ ADD_DEPENDENCIES(library ${DEAL_II_BASE_NAME}${DEAL_II_${_build}_SUFFIX})
+
SET_TARGET_PROPERTIES(${DEAL_II_BASE_NAME}${DEAL_II_${build}_SUFFIX}
PROPERTIES
VERSION "${DEAL_II_PACKAGE_VERSION}"
# a C++ library is still ABI backwards compatible :-]
#
SOVERSION "${DEAL_II_PACKAGE_VERSION}"
- LINK_FLAGS "${DEAL_II_SHARED_LINKER_FLAGS_${build}}"
+ LINK_FLAGS "${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${build}}"
COMPILE_DEFINITIONS "${DEAL_II_DEFINITIONS};${DEAL_II_DEFINITIONS_${build}}"
COMPILE_FLAGS "${DEAL_II_CXX_FLAGS_${build}}"
INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${DEAL_II_LIBRARY_RELDIR}"
+ ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
)
TARGET_LINK_LIBRARIES(${DEAL_II_BASE_NAME}${DEAL_II_${build}_SUFFIX}
- ${DEAL_II_EXTERNAL_LIBRARIES}
${DEAL_II_EXTERNAL_LIBRARIES_${build}}
+ ${DEAL_II_EXTERNAL_LIBRARIES}
+ )
+
+ FILE(MAKE_DIRECTORY
+ ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}
+ )
+ EXPORT(TARGETS ${DEAL_II_BASE_NAME}${DEAL_II_${build}_SUFFIX}
+ FILE ${CMAKE_BINARY_DIR}/${DEAL_II_PROJECT_CONFIG_RELDIR}/${DEAL_II_PROJECT_CONFIG_NAME}BuildTargets.cmake
+ APPEND
)
INSTALL(TARGETS ${DEAL_II_BASE_NAME}${DEAL_II_${build}_SUFFIX}
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
## Copyright (C) 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
-FILE(GLOB _header
- ${CMAKE_SOURCE_DIR}/include/deal.II/algorithms/*.h
- )
-
SET(_src
operator.cc
timestep_control.cc
operator.inst.in
)
+FILE(GLOB _header
+ ${CMAKE_SOURCE_DIR}/include/deal.II/algorithms/*.h
+ )
+
DEAL_II_ADD_LIBRARY(obj_algorithms OBJECT ${_src} ${_header} ${_inst})
EXPAND_INSTANTIATIONS(obj_algorithms "${_inst}")
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/parameter_handler.h>
#include <deal.II/base/logstream.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (VEC : SERIAL_VECTORS)
{
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2007, 2010, 2012 by Guido Kanschat
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/algorithms/timestep_control.h>
#include <deal.II/base/parameter_handler.h>
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
-FILE(GLOB _header
- ${CMAKE_SOURCE_DIR}/include/deal.II/base/*.h
- )
-
SET(_src
auto_derivative_function.cc
conditional_ostream.cc
config.cc
convergence_table.cc
data_out_base.cc
- # do NOT include dummy.cc
event.cc
exceptions.cc
flow_function.cc
polynomials_adini.cc
polynomials_bdm.cc
polynomials_nedelec.cc
- polynomials_piecewise.cc
polynomial_space.cc
polynomials_p.cc
+ polynomials_piecewise.cc
polynomials_raviart_thomas.cc
quadrature.cc
quadrature_lib.cc
utilities.cc
)
+FILE(GLOB _header
+ ${CMAKE_SOURCE_DIR}/include/deal.II/base/*.h
+ )
+
DEAL_II_ADD_LIBRARY(obj_base OBJECT ${_src} ${_header}
${CMAKE_BINARY_DIR}/include/deal.II/base/config.h
)
-
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/point.h>
#include <deal.II/base/auto_derivative_function.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2007, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/conditional_ostream.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2007, 2010, 2012 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/config.h>
#include <cmath>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/convergence_table.h>
#include <cmath>
// Calculate all missing rate values:
for (unsigned int i = no_rate_entries; i<n; ++i)
{
- if(i == 0)
+ if (i == 0)
{
// no value available for the first row
add_value(rate_key, std::string("-"));
// Calculate all missing rate values:
for (unsigned int i = no_rate_entries; i<n; ++i)
{
- if(i == 0)
+ if (i == 0)
{
// no value available for the first row
add_value(rate_key, std::string("-"));
}
// only add rate_key to the supercolumn once
- if(no_rate_entries == 0)
+ if (no_rate_entries == 0)
{
add_column_to_supercolumn(rate_key, superkey);
}
// Calculate all missing rate values:
for (unsigned int i = no_rate_entries; i<n; ++i)
{
- if(i == 0)
+ if (i == 0)
{
// no value available for the first row
add_value(rate_key, std::string("-"));
// Calculate all missing rate values:
for (unsigned int i = no_rate_entries; i<n; ++i)
{
- if(i == 0)
+ if (i == 0)
{
// no value available for the first row
add_value(rate_key, std::string("-"));
}
// only add rate_key to the supercolumn once
- if(no_rate_entries == 0)
+ if (no_rate_entries == 0)
{
add_column_to_supercolumn(rate_key, superkey);
}
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
//TODO: Do neighbors for dx and povray smooth triangles
#endif
}
+//----------------------------------------------------------------------//
+// DataOutFilter class member functions
+//----------------------------------------------------------------------//
+
+template<int dim>
+void DataOutBase::DataOutFilter::write_point(const unsigned int &index, const Point<dim> &p)
+{
+ Map3DPoint::const_iterator it;
+ unsigned int internal_ind;
+ Point<3> int_pt;
+
+ for (int d=0; d<3; ++d) int_pt(d) = (d < dim ? p(d) : 0);
+ node_dim = dim;
+ it = existing_points.find(int_pt);
+
+ // If the point isn't in the set, or we're not filtering duplicate points, add it
+ if (it == existing_points.end() || !flags.filter_duplicate_vertices)
+ {
+ internal_ind = existing_points.size();
+ existing_points.insert(std::make_pair(int_pt, internal_ind));
+ }
+ else
+ {
+ internal_ind = it->second;
+ }
+ // Now add the index to the list of filtered points
+ filtered_points[index] = internal_ind;
+}
+
+void DataOutBase::DataOutFilter::internal_add_cell(const unsigned int &cell_index, const unsigned int &pt_index)
+{
+ filtered_cells[cell_index] = filtered_points[pt_index];
+}
+
+void DataOutBase::DataOutFilter::fill_node_data(std::vector<double> &node_data) const
+{
+ Map3DPoint::const_iterator it;
+
+ node_data.resize(existing_points.size()*node_dim);
+
+ for (it=existing_points.begin(); it!=existing_points.end(); ++it)
+ {
+ for (int d=0; d<node_dim; ++d) node_data[node_dim*it->second+d] = it->first(d);
+ }
+}
+
+void DataOutBase::DataOutFilter::fill_cell_data(const unsigned int &local_node_offset, std::vector<unsigned int> &cell_data) const
+{
+ std::map<unsigned int, unsigned int>::const_iterator it;
+
+ cell_data.resize(filtered_cells.size());
+
+ for (it=filtered_cells.begin(); it!=filtered_cells.end(); ++it)
+ {
+ cell_data[it->first] = it->second+local_node_offset;
+ }
+}
+
+template<int dim>
+void
+DataOutBase::DataOutFilter::write_cell(
+ unsigned int index,
+ unsigned int start,
+ unsigned int d1,
+ unsigned int d2,
+ unsigned int d3)
+{
+ unsigned int base_entry = index * GeometryInfo<dim>::vertices_per_cell;
+ n_cell_verts = GeometryInfo<dim>::vertices_per_cell;
+ internal_add_cell(base_entry+0, start);
+ internal_add_cell(base_entry+1, start+d1);
+ if (dim>=2)
+ {
+ internal_add_cell(base_entry+2, start+d2+d1);
+ internal_add_cell(base_entry+3, start+d2);
+ if (dim>=3)
+ {
+ internal_add_cell(base_entry+4, start+d3);
+ internal_add_cell(base_entry+5, start+d3+d1);
+ internal_add_cell(base_entry+6, start+d3+d2+d1);
+ internal_add_cell(base_entry+7, start+d3+d2);
+ }
+ }
+}
+
+void DataOutBase::DataOutFilter::write_data_set(const std::string &name, const unsigned int &dimension, const unsigned int &set_num, const Table<2,double> &data_vectors)
+{
+ unsigned int num_verts = existing_points.size();
+ unsigned int i, r, d, new_dim;
+
+ // HDF5/XDMF output only supports 1D or 3D output, so force rearrangement if needed
+ if (flags.xdmf_hdf5_output && dimension != 1) new_dim = 3;
+ else new_dim = dimension;
+
+ // Record the data set name, dimension, and allocate space for it
+ data_set_names.push_back(name);
+ data_set_dims.push_back(new_dim);
+ data_sets.push_back(std::vector<double>(new_dim*num_verts));
+
+ // TODO: averaging, min/max, etc for merged vertices
+ for (i=0; i<filtered_points.size(); ++i)
+ {
+ for (d=0; d<new_dim; ++d)
+ {
+ r = filtered_points[i];
+ if (d < dimension) data_sets.back()[r*new_dim+d] = data_vectors(set_num+d, i);
+ else data_sets.back()[r] = 0;
+ }
+ }
+}
//----------------------------------------------------------------------//
};
#endif
- static unsigned int vtk_cell_type[4] =
+ // NOTE: (UK) The dimension of the array is choosen to 5 to allow the choice
+ // DataOutBase<deal_II_dimension,deal_II_dimension+1> in general
+ // Wolfgang supposed that we don't need it in general, but however this
+ // choice avoids a -Warray-bounds check warning
+ static unsigned int vtk_cell_type[5] =
{
- 0, 3, 9, 12
+ 0, 3, 9, 12, static_cast<unsigned int>(-1)
};
//----------------------------------------------------------------------//
}
}
-
-
-
-
/**
* Class for writing basic
* entities in @ref
};
- class HDF5MemStream
- {
- public:
- /**
- * Constructor, storing
- * persistent values for
- * later use.
- */
- HDF5MemStream (const unsigned int local_points_cell_count[2], const unsigned int global_points_cell_offsets[2], const unsigned int dim);
-
- /**
- * Output operator for points.
- */
- template <int dim>
- void write_point (const unsigned int index,
- const Point<dim> &);
-
- /**
- * Do whatever is necessary to
- * terminate the list of points.
- * In this case, nothing.
- */
- void flush_points () {};
-
- /**
- * Write dim-dimensional cell
- * with first vertex at
- * number start and further
- * vertices offset by the
- * specified values. Values
- * not needed are ignored.
- *
- * The order of vertices for
- * these cells in different
- * dimensions is
- * <ol>
- * <li> [0,1]
- * <li> []
- * <li> []
- * </ol>
- */
- template <int dim>
- void write_cell(const unsigned int index,
- const unsigned int start,
- const unsigned int x_offset,
- const unsigned int y_offset,
- const unsigned int z_offset);
-
- /**
- * Do whatever is necessary to
- * terminate the list of cells.
- * In this case, nothing.
- */
- void flush_cells () {};
-
- const double *node_data(void) const
- {
- return &vertices[0];
- };
- const unsigned int *cell_data(void) const
- {
- return &cells[0];
- };
-
- private:
- /**
- * A list of vertices and
- * cells, used to write HDF5 data.
- */
- std::vector<double> vertices;
- std::vector<unsigned int> cells;
- unsigned int cell_offset;
- };
-
-
//----------------------------------------------------------------------//
DXStream::DXStream(std::ostream &out,
return stream;
}
- HDF5MemStream::HDF5MemStream(const unsigned int local_points_cell_count[2], const unsigned int global_points_cell_offsets[2], const unsigned int dim)
- {
- unsigned int entries_per_cell = (2 << (dim-1));
-
- vertices.resize(local_points_cell_count[0]*dim);
- cells.resize(local_points_cell_count[1]*entries_per_cell);
- cell_offset = global_points_cell_offsets[1]*entries_per_cell;
- }
-
- template<int dim>
- void
- HDF5MemStream::write_point (const unsigned int index,
- const Point<dim> &p)
- {
- for (int i=0; i<dim; ++i) vertices[index*dim+i] = p(i);
- }
-
- template<int dim>
- void
- HDF5MemStream::write_cell(
- unsigned int index,
- unsigned int start,
- unsigned int d1,
- unsigned int d2,
- unsigned int d3)
- {
- unsigned int base_entry = index * GeometryInfo<dim>::vertices_per_cell;
- cells[base_entry+0] = cell_offset+start;
- cells[base_entry+1] = cell_offset+start+d1;
- if (dim>=2)
- {
- cells[base_entry+2] = cell_offset+start+d2+d1;
- cells[base_entry+3] = cell_offset+start+d2;
- if (dim>=3)
- {
- cells[base_entry+4] = cell_offset+start+d3;
- cells[base_entry+5] = cell_offset+start+d3+d1;
- cells[base_entry+6] = cell_offset+start+d3+d2+d1;
- cells[base_entry+7] = cell_offset+start+d3+d2;
- }
- }
- }
-
template <typename T>
std::ostream &
DXStream::operator<< (const T &t)
{}
+DataOutBase::DataOutFilterFlags::DataOutFilterFlags (const bool filter_duplicate_vertices,
+ const bool xdmf_hdf5_output) :
+ filter_duplicate_vertices(filter_duplicate_vertices),
+ xdmf_hdf5_output(xdmf_hdf5_output) {}
+
+void DataOutBase::DataOutFilterFlags::declare_parameters (ParameterHandler &prm)
+{
+ prm.declare_entry ("Filter duplicate vertices", "false",
+ Patterns::Bool(),
+ "Whether to remove duplicate vertex values.");
+ prm.declare_entry ("XDMF HDF5 output", "false",
+ Patterns::Bool(),
+ "Whether the data will be used in an XDMF/HDF5 combination.");
+}
+
+
+
+void DataOutBase::DataOutFilterFlags::parse_parameters (const ParameterHandler &prm)
+{
+ filter_duplicate_vertices = prm.get_bool ("Filter duplicate vertices");
+ xdmf_hdf5_output = prm.get_bool ("XDMF HDF5 output");
+}
+
+
+
+std::size_t
+DataOutBase::DataOutFilterFlags::memory_consumption () const
+{
+ // only simple data elements, so
+ // use sizeof operator
+ return sizeof (*this);
+}
+
+
+
DataOutBase::DXFlags::DXFlags (const bool write_neighbors,
const bool int_binary,
const bool coordinates_binary,
DataOutBase::VtkFlags::VtkFlags (const double time,
- const unsigned int cycle)
+ const unsigned int cycle,
+ const bool print_date_and_time)
:
time (time),
- cycle (cycle)
+ cycle (cycle),
+ print_date_and_time (print_date_and_time)
{}
DataOutBase::SvgFlags::SvgFlags (const unsigned int height_vector,
- const int azimuth_angle,
+ const int azimuth_angle,
const int polar_angle,
const unsigned int line_thickness,
const bool margin,
- const bool draw_colorbar) :
-height_vector(height_vector),
-azimuth_angle(azimuth_angle),
-polar_angle(polar_angle),
-line_thickness(line_thickness),
-margin(margin),
-draw_colorbar(draw_colorbar)
+ const bool draw_colorbar)
+ :
+ height(4000),
+ width(0),
+ height_vector(height_vector),
+ azimuth_angle(azimuth_angle),
+ polar_angle(polar_angle),
+ line_thickness(line_thickness),
+ margin(margin),
+ draw_colorbar(draw_colorbar)
{}
int i, j;
for (i = 0; i < 2; ++i)
- {
- for (j = 0; j < 2-i; ++j)
{
- if (points[j][2] > points[j + 1][2])
- {
- Point<3> temp = points[j];
- points[j] = points[j+1];
- points[j+1] = temp;
- }
+ for (j = 0; j < 2-i; ++j)
+ {
+ if (points[j][2] > points[j + 1][2])
+ {
+ Point<3> temp = points[j];
+ points[j] = points[j+1];
+ points[j+1] = temp;
+ }
+ }
}
- }
// save the related three-dimensional vectors v_min, v_inter, and v_max
v_min = points[0];
bool col_change = false;
if (A[0][0] == 0)
- {
- col_change = true;
+ {
+ col_change = true;
- A[0][0] = A[0][1];
- A[0][1] = 0;
+ A[0][0] = A[0][1];
+ A[0][1] = 0;
- double temp = A[1][0];
- A[1][0] = A[1][1];
- A[1][1] = temp;
- }
+ double temp = A[1][0];
+ A[1][0] = A[1][1];
+ A[1][1] = temp;
+ }
- for (unsigned int k = 0; k < 1; k++)
- {
- for (unsigned int i = k+1; i < 2; i++)
+ for (unsigned int k = 0; k < 1; k++)
{
- x = A[i][k] / A[k][k];
+ for (unsigned int i = k+1; i < 2; i++)
+ {
+ x = A[i][k] / A[k][k];
- for (unsigned int j = k+1; j < 2; j++) A[i][j] = A[i][j] - A[k][j] * x;
+ for (unsigned int j = k+1; j < 2; j++) A[i][j] = A[i][j] - A[k][j] * x;
- b[i] = b[i] - b[k]*x;
+ b[i] = b[i] - b[k]*x;
+ }
}
- }
b[1] = b[1] / A[1][1];
- for (int i = 0; i >= 0; i--)
- {
- sum = b[i];
+ for (int i = 0; i >= 0; i--)
+ {
+ sum = b[i];
- for (unsigned int j = i+1; j < 2; j++) sum = sum - A[i][j] * b[j];
+ for (unsigned int j = i+1; j < 2; j++) sum = sum - A[i][j] * b[j];
- b[i] = sum / A[i][i];
- }
+ b[i] = sum / A[i][i];
+ }
if (col_change)
- {
- double temp = b[0];
- b[0] = b[1];
- b[1] = temp;
- }
+ {
+ double temp = b[0];
+ b[0] = b[1];
+ b[1] = temp;
+ }
double c = b[0] * (v_max[2] - v_min[2]) + b[1] * (v_inter[2] - v_min[2]) + v_min[2];
col_change = false;
if (A[0][0] == 0)
- {
- col_change = true;
+ {
+ col_change = true;
- A[0][0] = A[0][1];
- A[0][1] = 0;
+ A[0][0] = A[0][1];
+ A[0][1] = 0;
- double temp = A[1][0];
- A[1][0] = A[1][1];
- A[1][1] = temp;
- }
+ double temp = A[1][0];
+ A[1][0] = A[1][1];
+ A[1][1] = temp;
+ }
- for (unsigned int k = 0; k < 1; k++)
- {
- for (unsigned int i = k+1; i < 2; i++)
+ for (unsigned int k = 0; k < 1; k++)
{
- x = A[i][k] / A[k][k];
+ for (unsigned int i = k+1; i < 2; i++)
+ {
+ x = A[i][k] / A[k][k];
- for (unsigned int j = k+1; j < 2; j++) A[i][j] = A[i][j] - A[k][j] * x;
+ for (unsigned int j = k+1; j < 2; j++) A[i][j] = A[i][j] - A[k][j] * x;
- b[i] = b[i] - b[k] * x;
+ b[i] = b[i] - b[k] * x;
+ }
}
- }
b[1]=b[1] / A[1][1];
- for (int i = 0; i >= 0; i--)
- {
- sum = b[i];
+ for (int i = 0; i >= 0; i--)
+ {
+ sum = b[i];
- for (unsigned int j = i+1; j < 2; j++) sum = sum - A[i][j]*b[j];
+ for (unsigned int j = i+1; j < 2; j++) sum = sum - A[i][j]*b[j];
- b[i] = sum / A[i][i];
- }
+ b[i] = sum / A[i][i];
+ }
if (col_change)
- {
- double temp = b[0];
- b[0] = b[1];
- b[1] = temp;
- }
+ {
+ double temp = b[0];
+ b[0] = b[1];
+ b[1] = temp;
+ }
gradient[0] = b[0] * (v_max[2] - v_min[2]) + b[1] * (v_inter[2] - v_min[2]) - c + v_min[2];
col_change = false;
if (A[0][0] == 0)
- {
- col_change = true;
+ {
+ col_change = true;
- A[0][0] = A[0][1];
- A[0][1] = 0;
+ A[0][0] = A[0][1];
+ A[0][1] = 0;
- double temp = A[1][0];
- A[1][0] = A[1][1];
- A[1][1] = temp;
- }
+ double temp = A[1][0];
+ A[1][0] = A[1][1];
+ A[1][1] = temp;
+ }
- for (unsigned int k = 0; k < 1; k++)
- {
- for (unsigned int i = k+1; i < 2; i++)
+ for (unsigned int k = 0; k < 1; k++)
{
- x = A[i][k] / A[k][k];
+ for (unsigned int i = k+1; i < 2; i++)
+ {
+ x = A[i][k] / A[k][k];
- for (unsigned int j = k+1; j < 2; j++) A[i][j] = A[i][j] - A[k][j] * x;
+ for (unsigned int j = k+1; j < 2; j++) A[i][j] = A[i][j] - A[k][j] * x;
- b[i] = b[i] - b[k] * x;
+ b[i] = b[i] - b[k] * x;
+ }
}
- }
b[1] = b[1] / A[1][1];
- for (int i = 0; i >= 0; i--)
- {
- sum = b[i];
+ for (int i = 0; i >= 0; i--)
+ {
+ sum = b[i];
- for (unsigned int j = i+1; j < 2; j++) sum = sum - A[i][j] * b[j];
+ for (unsigned int j = i+1; j < 2; j++) sum = sum - A[i][j] * b[j];
- b[i] = sum / A[i][i];
- }
+ b[i] = sum / A[i][i];
+ }
if (col_change)
- {
- double temp = b[0];
- b[0] = b[1];
- b[1] = temp;
- }
+ {
+ double temp = b[0];
+ b[0] = b[1];
+ b[1] = temp;
+ }
gradient[1] = b[0] * (v_max[2] - v_min[2]) + b[1] * (v_inter[2] - v_min[2]) - c + v_min[2];
gradient_parameters[0] = v_min[0];
gradient_parameters[1] = v_min[1];
-
+
gradient_parameters[2] = v_min[0] + lambda * gradient[0];
gradient_parameters[3] = v_min[1] + lambda * gradient[1];
std::tm *time = std::localtime(&time1);
out << "# vtk DataFile Version 3.0"
<< '\n'
- << "#This file was generated by the deal.II library on "
- << time->tm_year+1900 << "/"
- << time->tm_mon+1 << "/"
- << time->tm_mday << " at "
- << time->tm_hour << ":"
- << std::setw(2) << time->tm_min << ":"
- << std::setw(2) << time->tm_sec
- << '\n'
+ << "#This file was generated by the deal.II library";
+ if (flags.print_date_and_time)
+ out << " on "
+ << time->tm_year+1900 << "/"
+ << time->tm_mon+1 << "/"
+ << time->tm_mday << " at "
+ << time->tm_hour << ":"
+ << std::setw(2) << time->tm_min << ":"
+ << std::setw(2) << time->tm_sec;
+ else
+ out << ".";
+ out << '\n'
<< "ASCII"
<< '\n';
// now output the data header
}
-void DataOutBase::write_vtu_header (std::ostream &out)
+void DataOutBase::write_vtu_header (std::ostream &out,
+ const VtkFlags &flags)
{
AssertThrow (out, ExcIO());
std::time_t time1= std::time (0);
out << "<!-- \n";
out << "# vtk DataFile Version 3.0"
<< '\n'
- << "#This file was generated by the deal.II library on "
- << time->tm_year+1900 << "/"
- << time->tm_mon+1 << "/"
- << time->tm_mday << " at "
- << time->tm_hour << ":"
- << std::setw(2) << time->tm_min << ":"
- << std::setw(2) << time->tm_sec
- << "\n-->\n";
-
+ << "#This file was generated by the deal.II library";
+ if (flags.print_date_and_time)
+ out << " on "
+ << time->tm_year+1900 << "/"
+ << time->tm_mon+1 << "/"
+ << time->tm_mday << " at "
+ << time->tm_hour << ":"
+ << std::setw(2) << time->tm_min << ":"
+ << std::setw(2) << time->tm_sec;
+ else
+ out << ".";
+ out << "\n-->\n";
out << "<VTKFile type=\"UnstructuredGrid\" version=\"0.1\"";
#ifdef DEAL_II_WITH_ZLIB
out << " compressor=\"vtkZLibDataCompressor\"";
const VtkFlags &flags,
std::ostream &out)
{
- write_vtu_header(out);
+ write_vtu_header(out, flags);
write_vtu_main (patches, data_names, vector_data_ranges, flags, out);
write_vtu_footer(out);
if (n_metadata > 0)
out << "</FieldData>\n";
-}
+ }
VtuStream vtu_out(out, flags);
// do not allow volume rendering
AssertThrow (dim==2, ExcNotImplemented());
- const unsigned int height = 4000;
- unsigned int width;
+ const unsigned int height = flags.height;
+ unsigned int width = flags.width;
// margin around the plotted area
unsigned int margin_in_percent = 0;
- if(flags.margin) margin_in_percent = 5;
+ if (flags.margin) margin_in_percent = 5;
// determine the bounding box in the model space
Point<2> projection_decomposition;
Point<2> projection_decompositions[4];
- compute_node(projected_point, &*patch, 0, 0, 0, n_subdivisions);
-
+ compute_node(projected_point, &*patch, 0, 0, 0, n_subdivisions);
+
Assert ((flags.height_vector < patch->data.n_rows()) ||
patch->data.n_rows() == 0,
ExcIndexRange (flags.height_vector, 0, patch->data.n_rows()));
// iterate over the patches
for (; patch != patches.end(); ++patch)
- {
- n_subdivisions = patch->n_subdivisions;
- n = n_subdivisions + 1;
-
- for (unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
- {
- for (unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
- {
- compute_node(projected_points[0], &*patch, i1, i2, 0, n_subdivisions);
- compute_node(projected_points[1], &*patch, i1+1, i2, 0, n_subdivisions);
- compute_node(projected_points[2], &*patch, i1, i2+1, 0, n_subdivisions);
- compute_node(projected_points[3], &*patch, i1+1, i2+1, 0, n_subdivisions);
-
- x_min = std::min(x_min, (double)projected_points[0][0]);
- x_min = std::min(x_min, (double)projected_points[1][0]);
- x_min = std::min(x_min, (double)projected_points[2][0]);
- x_min = std::min(x_min, (double)projected_points[3][0]);
-
- x_max = std::max(x_max, (double)projected_points[0][0]);
- x_max = std::max(x_max, (double)projected_points[1][0]);
- x_max = std::max(x_max, (double)projected_points[2][0]);
- x_max = std::max(x_max, (double)projected_points[3][0]);
-
- y_min = std::min(y_min, (double)projected_points[0][1]);
- y_min = std::min(y_min, (double)projected_points[1][1]);
- y_min = std::min(y_min, (double)projected_points[2][1]);
- y_min = std::min(y_min, (double)projected_points[3][1]);
-
- y_max = std::max(y_max, (double)projected_points[0][1]);
- y_max = std::max(y_max, (double)projected_points[1][1]);
- y_max = std::max(y_max, (double)projected_points[2][1]);
- y_max = std::max(y_max, (double)projected_points[3][1]);
-
- Assert ((flags.height_vector < patch->data.n_rows()) ||
- patch->data.n_rows() == 0,
- ExcIndexRange (flags.height_vector, 0, patch->data.n_rows()));
-
- z_min = std::min(z_min, (double)patch->data(flags.height_vector, i1*d1 + i2*d2));
- z_min = std::min(z_min, (double)patch->data(flags.height_vector, (i1+1)*d1 + i2*d2));
- z_min = std::min(z_min, (double)patch->data(flags.height_vector, i1*d1 + (i2+1)*d2));
- z_min = std::min(z_min, (double)patch->data(flags.height_vector, (i1+1)*d1 + (i2+1)*d2));
-
- z_max = std::max(z_max, (double)patch->data(flags.height_vector, i1*d1 + i2*d2));
- z_max = std::max(z_max, (double)patch->data(flags.height_vector, (i1+1)*d1 + i2*d2));
- z_max = std::max(z_max, (double)patch->data(flags.height_vector, i1*d1 + (i2+1)*d2));
- z_max = std::max(z_max, (double)patch->data(flags.height_vector, (i1+1)*d1 + (i2+1)*d2));
- }
- }
- }
+ {
+ n_subdivisions = patch->n_subdivisions;
+ n = n_subdivisions + 1;
+
+ for (unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
+ {
+ for (unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
+ {
+ compute_node(projected_points[0], &*patch, i1, i2, 0, n_subdivisions);
+ compute_node(projected_points[1], &*patch, i1+1, i2, 0, n_subdivisions);
+ compute_node(projected_points[2], &*patch, i1, i2+1, 0, n_subdivisions);
+ compute_node(projected_points[3], &*patch, i1+1, i2+1, 0, n_subdivisions);
+
+ x_min = std::min(x_min, (double)projected_points[0][0]);
+ x_min = std::min(x_min, (double)projected_points[1][0]);
+ x_min = std::min(x_min, (double)projected_points[2][0]);
+ x_min = std::min(x_min, (double)projected_points[3][0]);
+
+ x_max = std::max(x_max, (double)projected_points[0][0]);
+ x_max = std::max(x_max, (double)projected_points[1][0]);
+ x_max = std::max(x_max, (double)projected_points[2][0]);
+ x_max = std::max(x_max, (double)projected_points[3][0]);
+
+ y_min = std::min(y_min, (double)projected_points[0][1]);
+ y_min = std::min(y_min, (double)projected_points[1][1]);
+ y_min = std::min(y_min, (double)projected_points[2][1]);
+ y_min = std::min(y_min, (double)projected_points[3][1]);
+
+ y_max = std::max(y_max, (double)projected_points[0][1]);
+ y_max = std::max(y_max, (double)projected_points[1][1]);
+ y_max = std::max(y_max, (double)projected_points[2][1]);
+ y_max = std::max(y_max, (double)projected_points[3][1]);
+
+ Assert ((flags.height_vector < patch->data.n_rows()) ||
+ patch->data.n_rows() == 0,
+ ExcIndexRange (flags.height_vector, 0, patch->data.n_rows()));
+
+ z_min = std::min(z_min, (double)patch->data(flags.height_vector, i1*d1 + i2*d2));
+ z_min = std::min(z_min, (double)patch->data(flags.height_vector, (i1+1)*d1 + i2*d2));
+ z_min = std::min(z_min, (double)patch->data(flags.height_vector, i1*d1 + (i2+1)*d2));
+ z_min = std::min(z_min, (double)patch->data(flags.height_vector, (i1+1)*d1 + (i2+1)*d2));
+
+ z_max = std::max(z_max, (double)patch->data(flags.height_vector, i1*d1 + i2*d2));
+ z_max = std::max(z_max, (double)patch->data(flags.height_vector, (i1+1)*d1 + i2*d2));
+ z_max = std::max(z_max, (double)patch->data(flags.height_vector, i1*d1 + (i2+1)*d2));
+ z_max = std::max(z_max, (double)patch->data(flags.height_vector, (i1+1)*d1 + (i2+1)*d2));
+ }
+ }
+ }
x_dimension = x_max - x_min;
y_dimension = y_max - y_min;
camera_position[1] -= (z_min + 2. * z_dimension) * sin(angle_factor * flags.polar_angle) * cos(angle_factor * flags.azimuth_angle);
-// determine the bounding box on the projection plane
+// determine the bounding box on the projection plane
double x_min_perspective, y_min_perspective;
double x_max_perspective, y_max_perspective;
double x_dimension_perspective, y_dimension_perspective;
Point<3> point(true);
- compute_node(projected_point, &*patch, 0, 0, 0, n_subdivisions);
-
+ compute_node(projected_point, &*patch, 0, 0, 0, n_subdivisions);
+
Assert ((flags.height_vector < patch->data.n_rows()) ||
patch->data.n_rows() == 0,
ExcIndexRange (flags.height_vector, 0, patch->data.n_rows()));
// iterate over the patches
for (; patch != patches.end(); ++patch)
- {
- n_subdivisions = patch->n_subdivisions;
- n = n_subdivisions + 1;
+ {
+ n_subdivisions = patch->n_subdivisions;
+ n = n_subdivisions + 1;
- for (unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
- {
- for (unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
- {
- Point<spacedim> projected_vertices[4];
- Point<3> vertices[4];
-
- compute_node(projected_vertices[0], &*patch, i1, i2, 0, n_subdivisions);
- compute_node(projected_vertices[1], &*patch, i1+1, i2, 0, n_subdivisions);
- compute_node(projected_vertices[2], &*patch, i1, i2+1, 0, n_subdivisions);
- compute_node(projected_vertices[3], &*patch, i1+1, i2+1, 0, n_subdivisions);
-
- Assert ((flags.height_vector < patch->data.n_rows()) ||
- patch->data.n_rows() == 0,
- ExcIndexRange (flags.height_vector, 0, patch->data.n_rows()));
-
- vertices[0][0] = projected_vertices[0][0];
- vertices[0][1] = projected_vertices[0][1];
- vertices[0][2] = patch->data.n_rows() != 0 ? patch->data(0,i1*d1 + i2*d2) : 0;
-
- vertices[1][0] = projected_vertices[1][0];
- vertices[1][1] = projected_vertices[1][1];
- vertices[1][2] = patch->data.n_rows() != 0 ? patch->data(0,(i1+1)*d1 + i2*d2) : 0;
-
- vertices[2][0] = projected_vertices[2][0];
- vertices[2][1] = projected_vertices[2][1];
- vertices[2][2] = patch->data.n_rows() != 0 ? patch->data(0,i1*d1 + (i2+1)*d2) : 0;
-
- vertices[3][0] = projected_vertices[3][0];
- vertices[3][1] = projected_vertices[3][1];
- vertices[3][2] = patch->data.n_rows() != 0 ? patch->data(0,(i1+1)*d1 + (i2+1)*d2) : 0;
-
- projection_decompositions[0] = svg_project_point(vertices[0], camera_position, camera_direction, camera_horizontal, camera_focus);
- projection_decompositions[1] = svg_project_point(vertices[1], camera_position, camera_direction, camera_horizontal, camera_focus);
- projection_decompositions[2] = svg_project_point(vertices[2], camera_position, camera_direction, camera_horizontal, camera_focus);
- projection_decompositions[3] = svg_project_point(vertices[3], camera_position, camera_direction, camera_horizontal, camera_focus);
-
- x_min_perspective = std::min(x_min_perspective, (double)projection_decompositions[0][0]);
- x_min_perspective = std::min(x_min_perspective, (double)projection_decompositions[1][0]);
- x_min_perspective = std::min(x_min_perspective, (double)projection_decompositions[2][0]);
- x_min_perspective = std::min(x_min_perspective, (double)projection_decompositions[3][0]);
-
- x_max_perspective = std::max(x_max_perspective, (double)projection_decompositions[0][0]);
- x_max_perspective = std::max(x_max_perspective, (double)projection_decompositions[1][0]);
- x_max_perspective = std::max(x_max_perspective, (double)projection_decompositions[2][0]);
- x_max_perspective = std::max(x_max_perspective, (double)projection_decompositions[3][0]);
-
- y_min_perspective = std::min(y_min_perspective, (double)projection_decompositions[0][1]);
- y_min_perspective = std::min(y_min_perspective, (double)projection_decompositions[1][1]);
- y_min_perspective = std::min(y_min_perspective, (double)projection_decompositions[2][1]);
- y_min_perspective = std::min(y_min_perspective, (double)projection_decompositions[3][1]);
-
- y_max_perspective = std::max(y_max_perspective, (double)projection_decompositions[0][1]);
- y_max_perspective = std::max(y_max_perspective, (double)projection_decompositions[1][1]);
- y_max_perspective = std::max(y_max_perspective, (double)projection_decompositions[2][1]);
- y_max_perspective = std::max(y_max_perspective, (double)projection_decompositions[3][1]);
- }
+ for (unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
+ {
+ for (unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
+ {
+ Point<spacedim> projected_vertices[4];
+ Point<3> vertices[4];
+
+ compute_node(projected_vertices[0], &*patch, i1, i2, 0, n_subdivisions);
+ compute_node(projected_vertices[1], &*patch, i1+1, i2, 0, n_subdivisions);
+ compute_node(projected_vertices[2], &*patch, i1, i2+1, 0, n_subdivisions);
+ compute_node(projected_vertices[3], &*patch, i1+1, i2+1, 0, n_subdivisions);
+
+ Assert ((flags.height_vector < patch->data.n_rows()) ||
+ patch->data.n_rows() == 0,
+ ExcIndexRange (flags.height_vector, 0, patch->data.n_rows()));
+
+ vertices[0][0] = projected_vertices[0][0];
+ vertices[0][1] = projected_vertices[0][1];
+ vertices[0][2] = patch->data.n_rows() != 0 ? patch->data(0,i1*d1 + i2*d2) : 0;
+
+ vertices[1][0] = projected_vertices[1][0];
+ vertices[1][1] = projected_vertices[1][1];
+ vertices[1][2] = patch->data.n_rows() != 0 ? patch->data(0,(i1+1)*d1 + i2*d2) : 0;
+
+ vertices[2][0] = projected_vertices[2][0];
+ vertices[2][1] = projected_vertices[2][1];
+ vertices[2][2] = patch->data.n_rows() != 0 ? patch->data(0,i1*d1 + (i2+1)*d2) : 0;
+
+ vertices[3][0] = projected_vertices[3][0];
+ vertices[3][1] = projected_vertices[3][1];
+ vertices[3][2] = patch->data.n_rows() != 0 ? patch->data(0,(i1+1)*d1 + (i2+1)*d2) : 0;
+
+ projection_decompositions[0] = svg_project_point(vertices[0], camera_position, camera_direction, camera_horizontal, camera_focus);
+ projection_decompositions[1] = svg_project_point(vertices[1], camera_position, camera_direction, camera_horizontal, camera_focus);
+ projection_decompositions[2] = svg_project_point(vertices[2], camera_position, camera_direction, camera_horizontal, camera_focus);
+ projection_decompositions[3] = svg_project_point(vertices[3], camera_position, camera_direction, camera_horizontal, camera_focus);
+
+ x_min_perspective = std::min(x_min_perspective, (double)projection_decompositions[0][0]);
+ x_min_perspective = std::min(x_min_perspective, (double)projection_decompositions[1][0]);
+ x_min_perspective = std::min(x_min_perspective, (double)projection_decompositions[2][0]);
+ x_min_perspective = std::min(x_min_perspective, (double)projection_decompositions[3][0]);
+
+ x_max_perspective = std::max(x_max_perspective, (double)projection_decompositions[0][0]);
+ x_max_perspective = std::max(x_max_perspective, (double)projection_decompositions[1][0]);
+ x_max_perspective = std::max(x_max_perspective, (double)projection_decompositions[2][0]);
+ x_max_perspective = std::max(x_max_perspective, (double)projection_decompositions[3][0]);
+
+ y_min_perspective = std::min(y_min_perspective, (double)projection_decompositions[0][1]);
+ y_min_perspective = std::min(y_min_perspective, (double)projection_decompositions[1][1]);
+ y_min_perspective = std::min(y_min_perspective, (double)projection_decompositions[2][1]);
+ y_min_perspective = std::min(y_min_perspective, (double)projection_decompositions[3][1]);
+
+ y_max_perspective = std::max(y_max_perspective, (double)projection_decompositions[0][1]);
+ y_max_perspective = std::max(y_max_perspective, (double)projection_decompositions[1][1]);
+ y_max_perspective = std::max(y_max_perspective, (double)projection_decompositions[2][1]);
+ y_max_perspective = std::max(y_max_perspective, (double)projection_decompositions[3][1]);
+ }
+ }
}
- }
x_dimension_perspective = x_max_perspective - x_min_perspective;
y_dimension_perspective = y_max_perspective - y_min_perspective;
// iterate over the patches
for (patch = patches.begin(); patch != patches.end(); ++patch)
- {
- n_subdivisions = patch->n_subdivisions;
- n = n_subdivisions + 1;
+ {
+ n_subdivisions = patch->n_subdivisions;
+ n = n_subdivisions + 1;
- for (unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
- {
- for (unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
- {
- Point<spacedim> projected_vertices[4];
- SvgCell cell;
-
- compute_node(projected_vertices[0], &*patch, i1, i2, 0, n_subdivisions);
- compute_node(projected_vertices[1], &*patch, i1+1, i2, 0, n_subdivisions);
- compute_node(projected_vertices[2], &*patch, i1, i2+1, 0, n_subdivisions);
- compute_node(projected_vertices[3], &*patch, i1+1, i2+1, 0, n_subdivisions);
-
- Assert ((flags.height_vector < patch->data.n_rows()) ||
- patch->data.n_rows() == 0,
- ExcIndexRange (flags.height_vector, 0, patch->data.n_rows()));
-
- cell.vertices[0][0] = projected_vertices[0][0];
- cell.vertices[0][1] = projected_vertices[0][1];
- cell.vertices[0][2] = patch->data.n_rows() != 0 ? patch->data(0,i1*d1 + i2*d2) : 0;
-
- cell.vertices[1][0] = projected_vertices[1][0];
- cell.vertices[1][1] = projected_vertices[1][1];
- cell.vertices[1][2] = patch->data.n_rows() != 0 ? patch->data(0,(i1+1)*d1 + i2*d2) : 0;
-
- cell.vertices[2][0] = projected_vertices[2][0];
- cell.vertices[2][1] = projected_vertices[2][1];
- cell.vertices[2][2] = patch->data.n_rows() != 0 ? patch->data(0,i1*d1 + (i2+1)*d2) : 0;
-
- cell.vertices[3][0] = projected_vertices[3][0];
- cell.vertices[3][1] = projected_vertices[3][1];
- cell.vertices[3][2] = patch->data.n_rows() != 0 ? patch->data(0,(i1+1)*d1 + (i2+1)*d2) : 0;
-
- cell.projected_vertices[0] = svg_project_point(cell.vertices[0], camera_position, camera_direction, camera_horizontal, camera_focus);
- cell.projected_vertices[1] = svg_project_point(cell.vertices[1], camera_position, camera_direction, camera_horizontal, camera_focus);
- cell.projected_vertices[2] = svg_project_point(cell.vertices[2], camera_position, camera_direction, camera_horizontal, camera_focus);
- cell.projected_vertices[3] = svg_project_point(cell.vertices[3], camera_position, camera_direction, camera_horizontal, camera_focus);
-
- cell.center = .25 * (cell.vertices[0] + cell.vertices[1] + cell.vertices[2] + cell.vertices[3]);
- cell.projected_center = svg_project_point(cell.center, camera_position, camera_direction, camera_horizontal, camera_focus);
-
- cell.depth = cell.center.distance(camera_position);
-
- cells.insert(cell);
- }
+ for (unsigned int i2 = 0; i2 < n_subdivisions; ++i2)
+ {
+ for (unsigned int i1 = 0; i1 < n_subdivisions; ++i1)
+ {
+ Point<spacedim> projected_vertices[4];
+ SvgCell cell;
+
+ compute_node(projected_vertices[0], &*patch, i1, i2, 0, n_subdivisions);
+ compute_node(projected_vertices[1], &*patch, i1+1, i2, 0, n_subdivisions);
+ compute_node(projected_vertices[2], &*patch, i1, i2+1, 0, n_subdivisions);
+ compute_node(projected_vertices[3], &*patch, i1+1, i2+1, 0, n_subdivisions);
+
+ Assert ((flags.height_vector < patch->data.n_rows()) ||
+ patch->data.n_rows() == 0,
+ ExcIndexRange (flags.height_vector, 0, patch->data.n_rows()));
+
+ cell.vertices[0][0] = projected_vertices[0][0];
+ cell.vertices[0][1] = projected_vertices[0][1];
+ cell.vertices[0][2] = patch->data.n_rows() != 0 ? patch->data(0,i1*d1 + i2*d2) : 0;
+
+ cell.vertices[1][0] = projected_vertices[1][0];
+ cell.vertices[1][1] = projected_vertices[1][1];
+ cell.vertices[1][2] = patch->data.n_rows() != 0 ? patch->data(0,(i1+1)*d1 + i2*d2) : 0;
+
+ cell.vertices[2][0] = projected_vertices[2][0];
+ cell.vertices[2][1] = projected_vertices[2][1];
+ cell.vertices[2][2] = patch->data.n_rows() != 0 ? patch->data(0,i1*d1 + (i2+1)*d2) : 0;
+
+ cell.vertices[3][0] = projected_vertices[3][0];
+ cell.vertices[3][1] = projected_vertices[3][1];
+ cell.vertices[3][2] = patch->data.n_rows() != 0 ? patch->data(0,(i1+1)*d1 + (i2+1)*d2) : 0;
+
+ cell.projected_vertices[0] = svg_project_point(cell.vertices[0], camera_position, camera_direction, camera_horizontal, camera_focus);
+ cell.projected_vertices[1] = svg_project_point(cell.vertices[1], camera_position, camera_direction, camera_horizontal, camera_focus);
+ cell.projected_vertices[2] = svg_project_point(cell.vertices[2], camera_position, camera_direction, camera_horizontal, camera_focus);
+ cell.projected_vertices[3] = svg_project_point(cell.vertices[3], camera_position, camera_direction, camera_horizontal, camera_focus);
+
+ cell.center = .25 * (cell.vertices[0] + cell.vertices[1] + cell.vertices[2] + cell.vertices[3]);
+ cell.projected_center = svg_project_point(cell.center, camera_position, camera_direction, camera_horizontal, camera_focus);
+
+ cell.depth = cell.center.distance(camera_position);
+
+ cells.insert(cell);
+ }
+ }
}
- }
// write the svg file
- width = static_cast<unsigned int>(.5 + height * (x_dimension_perspective / y_dimension_perspective));
+ if (width==0)
+ width = static_cast<unsigned int>(.5 + height * (x_dimension_perspective / y_dimension_perspective));
unsigned int additional_width = 0;
- if(flags.draw_colorbar) additional_width = static_cast<unsigned int>(.5 + height * .3); // additional width for colorbar
-
+ if (flags.draw_colorbar) additional_width = static_cast<unsigned int>(.5 + height * .3); // additional width for colorbar
+
// basic svg header and background rectangle
- out << "<svg width=\"" << width + additional_width << "\" height=\"" << height << "\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">" << '\n'
+ out << "<svg width=\"" << width + additional_width << "\" height=\"" << height << "\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">" << '\n'
<< " <rect width=\"" << width + additional_width << "\" height=\"" << height << "\" style=\"fill:white\"/>" << '\n' << '\n';
unsigned int triangle_counter = 0;
-
+
// write the cells in the correct order
for (typename std::multiset<SvgCell>::const_iterator cell = cells.begin(); cell != cells.end(); ++cell)
- {
- Point<3> points3d_triangle[3];
-
- for (unsigned int triangle_index = 0; triangle_index < 4; triangle_index++)
{
- switch (triangle_index)
- {
- case 0: points3d_triangle[0] = cell->vertices[0], points3d_triangle[1] = cell->vertices[1], points3d_triangle[2] = cell->center; break;
- case 1: points3d_triangle[0] = cell->vertices[1], points3d_triangle[1] = cell->vertices[3], points3d_triangle[2] = cell->center; break;
- case 2: points3d_triangle[0] = cell->vertices[3], points3d_triangle[1] = cell->vertices[2], points3d_triangle[2] = cell->center; break;
- case 3: points3d_triangle[0] = cell->vertices[2], points3d_triangle[1] = cell->vertices[0], points3d_triangle[2] = cell->center; break;
- default: break;
- }
+ Point<3> points3d_triangle[3];
+
+ for (unsigned int triangle_index = 0; triangle_index < 4; triangle_index++)
+ {
+ switch (triangle_index)
+ {
+ case 0:
+ points3d_triangle[0] = cell->vertices[0], points3d_triangle[1] = cell->vertices[1], points3d_triangle[2] = cell->center;
+ break;
+ case 1:
+ points3d_triangle[0] = cell->vertices[1], points3d_triangle[1] = cell->vertices[3], points3d_triangle[2] = cell->center;
+ break;
+ case 2:
+ points3d_triangle[0] = cell->vertices[3], points3d_triangle[1] = cell->vertices[2], points3d_triangle[2] = cell->center;
+ break;
+ case 3:
+ points3d_triangle[0] = cell->vertices[2], points3d_triangle[1] = cell->vertices[0], points3d_triangle[2] = cell->center;
+ break;
+ default:
+ break;
+ }
- Point<6> gradient_param = svg_get_gradient_parameters(points3d_triangle);
+ Point<6> gradient_param = svg_get_gradient_parameters(points3d_triangle);
- double start_h = .667 - ((gradient_param[4] - z_min) / z_dimension) * .667;
- double stop_h = .667 - ((gradient_param[5] - z_min) / z_dimension) * .667;
+ double start_h = .667 - ((gradient_param[4] - z_min) / z_dimension) * .667;
+ double stop_h = .667 - ((gradient_param[5] - z_min) / z_dimension) * .667;
- unsigned int start_r = 0;
- unsigned int start_g = 0;
- unsigned int start_b = 0;
+ unsigned int start_r = 0;
+ unsigned int start_g = 0;
+ unsigned int start_b = 0;
- unsigned int stop_r = 0;
- unsigned int stop_g = 0;
- unsigned int stop_b = 0;
+ unsigned int stop_r = 0;
+ unsigned int stop_g = 0;
+ unsigned int stop_b = 0;
- unsigned int start_i = static_cast<unsigned int>(start_h * 6.);
- unsigned int stop_i = static_cast<unsigned int>(stop_h * 6.);
+ unsigned int start_i = static_cast<unsigned int>(start_h * 6.);
+ unsigned int stop_i = static_cast<unsigned int>(stop_h * 6.);
- double start_f = start_h * 6. - start_i;
- double start_q = 1. - start_f;
+ double start_f = start_h * 6. - start_i;
+ double start_q = 1. - start_f;
- double stop_f = stop_h * 6. - stop_i;
- double stop_q = 1. - stop_f;
+ double stop_f = stop_h * 6. - stop_i;
+ double stop_q = 1. - stop_f;
- switch (start_i % 6)
- {
- case 0: start_r = 255, start_g = static_cast<unsigned int>(.5 + 255. * start_f); break;
- case 1: start_r = static_cast<unsigned int>(.5 + 255. * start_q), start_g = 255; break;
- case 2: start_g = 255, start_b = static_cast<unsigned int>(.5 + 255. * start_f); break;
- case 3: start_g = static_cast<unsigned int>(.5 + 255. * start_q), start_b = 255; break;
- case 4: start_r = static_cast<unsigned int>(.5 + 255. * start_f), start_b = 255; break;
- case 5: start_r = 255, start_b = static_cast<unsigned int>(.5 + 255. * start_q); break;
- default: break;
- }
+ switch (start_i % 6)
+ {
+ case 0:
+ start_r = 255, start_g = static_cast<unsigned int>(.5 + 255. * start_f);
+ break;
+ case 1:
+ start_r = static_cast<unsigned int>(.5 + 255. * start_q), start_g = 255;
+ break;
+ case 2:
+ start_g = 255, start_b = static_cast<unsigned int>(.5 + 255. * start_f);
+ break;
+ case 3:
+ start_g = static_cast<unsigned int>(.5 + 255. * start_q), start_b = 255;
+ break;
+ case 4:
+ start_r = static_cast<unsigned int>(.5 + 255. * start_f), start_b = 255;
+ break;
+ case 5:
+ start_r = 255, start_b = static_cast<unsigned int>(.5 + 255. * start_q);
+ break;
+ default:
+ break;
+ }
- switch (stop_i % 6)
- {
- case 0: stop_r = 255, stop_g = static_cast<unsigned int>(.5 + 255. * stop_f); break;
- case 1: stop_r = static_cast<unsigned int>(.5 + 255. * stop_q), stop_g = 255; break;
- case 2: stop_g = 255, stop_b = static_cast<unsigned int>(.5 + 255. * stop_f); break;
- case 3: stop_g = static_cast<unsigned int>(.5 + 255. * stop_q), stop_b = 255; break;
- case 4: stop_r = static_cast<unsigned int>(.5 + 255. * stop_f), stop_b = 255; break;
- case 5: stop_r = 255, stop_b = static_cast<unsigned int>(.5 + 255. * stop_q); break;
- default: break;
- }
+ switch (stop_i % 6)
+ {
+ case 0:
+ stop_r = 255, stop_g = static_cast<unsigned int>(.5 + 255. * stop_f);
+ break;
+ case 1:
+ stop_r = static_cast<unsigned int>(.5 + 255. * stop_q), stop_g = 255;
+ break;
+ case 2:
+ stop_g = 255, stop_b = static_cast<unsigned int>(.5 + 255. * stop_f);
+ break;
+ case 3:
+ stop_g = static_cast<unsigned int>(.5 + 255. * stop_q), stop_b = 255;
+ break;
+ case 4:
+ stop_r = static_cast<unsigned int>(.5 + 255. * stop_f), stop_b = 255;
+ break;
+ case 5:
+ stop_r = 255, stop_b = static_cast<unsigned int>(.5 + 255. * stop_q);
+ break;
+ default:
+ break;
+ }
- Point<3> gradient_start_point_3d, gradient_stop_point_3d;
-
- gradient_start_point_3d[0] = gradient_param[0];
- gradient_start_point_3d[1] = gradient_param[1];
- gradient_start_point_3d[2] = gradient_param[4];
-
- gradient_stop_point_3d[0] = gradient_param[2];
- gradient_stop_point_3d[1] = gradient_param[3];
- gradient_stop_point_3d[2] = gradient_param[5];
-
- Point<2> gradient_start_point = svg_project_point(gradient_start_point_3d, camera_position, camera_direction, camera_horizontal, camera_focus);
- Point<2> gradient_stop_point = svg_project_point(gradient_stop_point_3d, camera_position, camera_direction, camera_horizontal, camera_focus);
-
- // define linear gradient
- out << " <linearGradient id=\"" << triangle_counter << "\" gradientUnits=\"userSpaceOnUse\" "
- << "x1=\""
- << static_cast<unsigned int>(.5 + ((gradient_start_point[0] - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent))
- << "\" "
- << "y1=\""
- << static_cast<unsigned int>(.5 + height - (height/100.) * margin_in_percent - ((gradient_start_point[1] - y_min_perspective) / y_dimension_perspective) * (height - (height/100.) * 2. * margin_in_percent))
- << "\" "
- << "x2=\""
- << static_cast<unsigned int>(.5 + ((gradient_stop_point[0] - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent))
- << "\" "
- << "y2=\""
- << static_cast<unsigned int>(.5 + height - (height/100.) * margin_in_percent - ((gradient_stop_point[1] - y_min_perspective) / y_dimension_perspective) * (height - (height/100.) * 2. * margin_in_percent))
- << "\""
- << ">" << '\n'
- << " <stop offset=\"0\" style=\"stop-color:rgb(" << start_r << "," << start_g << "," << start_b << ")\"/>" << '\n'
- << " <stop offset=\"1\" style=\"stop-color:rgb(" << stop_r << "," << stop_g << "," << stop_b << ")\"/>" << '\n'
- << " </linearGradient>" << '\n';
-
- // draw current triangle
- double x1 = 0, y1 = 0, x2 = 0, y2 = 0;
- double x3 = cell->projected_center[0];
- double y3 = cell->projected_center[1];
-
- switch (triangle_index)
- {
- case 0: x1 = cell->projected_vertices[0][0], y1 = cell->projected_vertices[0][1], x2 = cell->projected_vertices[1][0], y2 = cell->projected_vertices[1][1]; break;
- case 1: x1 = cell->projected_vertices[1][0], y1 = cell->projected_vertices[1][1], x2 = cell->projected_vertices[3][0], y2 = cell->projected_vertices[3][1]; break;
- case 2: x1 = cell->projected_vertices[3][0], y1 = cell->projected_vertices[3][1], x2 = cell->projected_vertices[2][0], y2 = cell->projected_vertices[2][1]; break;
- case 3: x1 = cell->projected_vertices[2][0], y1 = cell->projected_vertices[2][1], x2 = cell->projected_vertices[0][0], y2 = cell->projected_vertices[0][1]; break;
- default: break;
- }
+ Point<3> gradient_start_point_3d, gradient_stop_point_3d;
+
+ gradient_start_point_3d[0] = gradient_param[0];
+ gradient_start_point_3d[1] = gradient_param[1];
+ gradient_start_point_3d[2] = gradient_param[4];
+
+ gradient_stop_point_3d[0] = gradient_param[2];
+ gradient_stop_point_3d[1] = gradient_param[3];
+ gradient_stop_point_3d[2] = gradient_param[5];
+
+ Point<2> gradient_start_point = svg_project_point(gradient_start_point_3d, camera_position, camera_direction, camera_horizontal, camera_focus);
+ Point<2> gradient_stop_point = svg_project_point(gradient_stop_point_3d, camera_position, camera_direction, camera_horizontal, camera_focus);
+
+ // define linear gradient
+ out << " <linearGradient id=\"" << triangle_counter << "\" gradientUnits=\"userSpaceOnUse\" "
+ << "x1=\""
+ << static_cast<unsigned int>(.5 + ((gradient_start_point[0] - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent))
+ << "\" "
+ << "y1=\""
+ << static_cast<unsigned int>(.5 + height - (height/100.) * margin_in_percent - ((gradient_start_point[1] - y_min_perspective) / y_dimension_perspective) * (height - (height/100.) * 2. * margin_in_percent))
+ << "\" "
+ << "x2=\""
+ << static_cast<unsigned int>(.5 + ((gradient_stop_point[0] - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent))
+ << "\" "
+ << "y2=\""
+ << static_cast<unsigned int>(.5 + height - (height/100.) * margin_in_percent - ((gradient_stop_point[1] - y_min_perspective) / y_dimension_perspective) * (height - (height/100.) * 2. * margin_in_percent))
+ << "\""
+ << ">" << '\n'
+ << " <stop offset=\"0\" style=\"stop-color:rgb(" << start_r << "," << start_g << "," << start_b << ")\"/>" << '\n'
+ << " <stop offset=\"1\" style=\"stop-color:rgb(" << stop_r << "," << stop_g << "," << stop_b << ")\"/>" << '\n'
+ << " </linearGradient>" << '\n';
+
+ // draw current triangle
+ double x1 = 0, y1 = 0, x2 = 0, y2 = 0;
+ double x3 = cell->projected_center[0];
+ double y3 = cell->projected_center[1];
+
+ switch (triangle_index)
+ {
+ case 0:
+ x1 = cell->projected_vertices[0][0], y1 = cell->projected_vertices[0][1], x2 = cell->projected_vertices[1][0], y2 = cell->projected_vertices[1][1];
+ break;
+ case 1:
+ x1 = cell->projected_vertices[1][0], y1 = cell->projected_vertices[1][1], x2 = cell->projected_vertices[3][0], y2 = cell->projected_vertices[3][1];
+ break;
+ case 2:
+ x1 = cell->projected_vertices[3][0], y1 = cell->projected_vertices[3][1], x2 = cell->projected_vertices[2][0], y2 = cell->projected_vertices[2][1];
+ break;
+ case 3:
+ x1 = cell->projected_vertices[2][0], y1 = cell->projected_vertices[2][1], x2 = cell->projected_vertices[0][0], y2 = cell->projected_vertices[0][1];
+ break;
+ default:
+ break;
+ }
- out << " <path d=\"M "
- << static_cast<unsigned int>(.5 + ((x1 - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent))
- << ' '
- << static_cast<unsigned int>(.5 + height - (height/100.) * margin_in_percent - ((y1 - y_min_perspective) / y_dimension_perspective) * (height - (height/100.) * 2. * margin_in_percent))
- << " L "
- << static_cast<unsigned int>(.5 + ((x2 - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent))
- << ' '
- << static_cast<unsigned int>(.5 + height - (height/100.) * margin_in_percent - ((y2 - y_min_perspective) / y_dimension_perspective) * (height - (height/100.) * 2. * margin_in_percent))
- << " L "
- << static_cast<unsigned int>(.5 + ((x3 - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent))
- << ' '
- << static_cast<unsigned int>(.5 + height - (height/100.) * margin_in_percent - ((y3 - y_min_perspective) / y_dimension_perspective) * (height - (height/100.) * 2. * margin_in_percent))
- << " L "
- << static_cast<unsigned int>(.5 + ((x1 - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent))
- << ' '
- << static_cast<unsigned int>(.5 + height - (height/100.) * margin_in_percent - ((y1 - y_min_perspective) / y_dimension_perspective) * (height - (height/100.) * 2. * margin_in_percent))
- << "\" style=\"stroke:black; fill:url(#" << triangle_counter << "); stroke-width:" << flags.line_thickness << "\"/>" << '\n';
-
- triangle_counter++;
+ out << " <path d=\"M "
+ << static_cast<unsigned int>(.5 + ((x1 - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent))
+ << ' '
+ << static_cast<unsigned int>(.5 + height - (height/100.) * margin_in_percent - ((y1 - y_min_perspective) / y_dimension_perspective) * (height - (height/100.) * 2. * margin_in_percent))
+ << " L "
+ << static_cast<unsigned int>(.5 + ((x2 - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent))
+ << ' '
+ << static_cast<unsigned int>(.5 + height - (height/100.) * margin_in_percent - ((y2 - y_min_perspective) / y_dimension_perspective) * (height - (height/100.) * 2. * margin_in_percent))
+ << " L "
+ << static_cast<unsigned int>(.5 + ((x3 - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent))
+ << ' '
+ << static_cast<unsigned int>(.5 + height - (height/100.) * margin_in_percent - ((y3 - y_min_perspective) / y_dimension_perspective) * (height - (height/100.) * 2. * margin_in_percent))
+ << " L "
+ << static_cast<unsigned int>(.5 + ((x1 - x_min_perspective) / x_dimension_perspective) * (width - (width/100.) * 2. * margin_in_percent) + ((width/100.) * margin_in_percent))
+ << ' '
+ << static_cast<unsigned int>(.5 + height - (height/100.) * margin_in_percent - ((y1 - y_min_perspective) / y_dimension_perspective) * (height - (height/100.) * 2. * margin_in_percent))
+ << "\" style=\"stroke:black; fill:url(#" << triangle_counter << "); stroke-width:" << flags.line_thickness << "\"/>" << '\n';
+
+ triangle_counter++;
+ }
}
- }
// draw the colorbar
if (flags.draw_colorbar)
- {
- out << '\n' << " <!-- colorbar -->" << '\n';
+ {
+ out << '\n' << " <!-- colorbar -->" << '\n';
- unsigned int element_height = static_cast<unsigned int>(((height/100.) * (71. - 2.*margin_in_percent)) / 4);
- unsigned int element_width = static_cast<unsigned int>(.5 + (height/100.) * 2.5);
+ unsigned int element_height = static_cast<unsigned int>(((height/100.) * (71. - 2.*margin_in_percent)) / 4);
+ unsigned int element_width = static_cast<unsigned int>(.5 + (height/100.) * 2.5);
- additional_width = 0;
- if (!flags.margin) additional_width = static_cast<unsigned int>(.5 + (height/100.) * 2.5);
+ additional_width = 0;
+ if (!flags.margin) additional_width = static_cast<unsigned int>(.5 + (height/100.) * 2.5);
- for (unsigned int index = 0; index < 4; index++)
- {
- double start_h = .667 - ((index+1) / 4.) * .667;
- double stop_h = .667 - (index / 4.) * .667;
+ for (unsigned int index = 0; index < 4; index++)
+ {
+ double start_h = .667 - ((index+1) / 4.) * .667;
+ double stop_h = .667 - (index / 4.) * .667;
- unsigned int start_r = 0;
- unsigned int start_g = 0;
- unsigned int start_b = 0;
+ unsigned int start_r = 0;
+ unsigned int start_g = 0;
+ unsigned int start_b = 0;
- unsigned int stop_r = 0;
- unsigned int stop_g = 0;
- unsigned int stop_b = 0;
+ unsigned int stop_r = 0;
+ unsigned int stop_g = 0;
+ unsigned int stop_b = 0;
- unsigned int start_i = static_cast<unsigned int>(start_h * 6.);
- unsigned int stop_i = static_cast<unsigned int>(stop_h * 6.);
+ unsigned int start_i = static_cast<unsigned int>(start_h * 6.);
+ unsigned int stop_i = static_cast<unsigned int>(stop_h * 6.);
- double start_f = start_h * 6. - start_i;
- double start_q = 1. - start_f;
+ double start_f = start_h * 6. - start_i;
+ double start_q = 1. - start_f;
- double stop_f = stop_h * 6. - stop_i;
- double stop_q = 1. - stop_f;
+ double stop_f = stop_h * 6. - stop_i;
+ double stop_q = 1. - stop_f;
- switch (start_i % 6)
- {
- case 0: start_r = 255, start_g = static_cast<unsigned int>(.5 + 255. * start_f); break;
- case 1: start_r = static_cast<unsigned int>(.5 + 255. * start_q), start_g = 255; break;
- case 2: start_g = 255, start_b = static_cast<unsigned int>(.5 + 255. * start_f); break;
- case 3: start_g = static_cast<unsigned int>(.5 + 255. * start_q), start_b = 255; break;
- case 4: start_r = static_cast<unsigned int>(.5 + 255. * start_f), start_b = 255; break;
- case 5: start_r = 255, start_b = static_cast<unsigned int>(.5 + 255. * start_q); break;
- default: break;
- }
+ switch (start_i % 6)
+ {
+ case 0:
+ start_r = 255, start_g = static_cast<unsigned int>(.5 + 255. * start_f);
+ break;
+ case 1:
+ start_r = static_cast<unsigned int>(.5 + 255. * start_q), start_g = 255;
+ break;
+ case 2:
+ start_g = 255, start_b = static_cast<unsigned int>(.5 + 255. * start_f);
+ break;
+ case 3:
+ start_g = static_cast<unsigned int>(.5 + 255. * start_q), start_b = 255;
+ break;
+ case 4:
+ start_r = static_cast<unsigned int>(.5 + 255. * start_f), start_b = 255;
+ break;
+ case 5:
+ start_r = 255, start_b = static_cast<unsigned int>(.5 + 255. * start_q);
+ break;
+ default:
+ break;
+ }
- switch (stop_i % 6)
- {
- case 0: stop_r = 255, stop_g = static_cast<unsigned int>(.5 + 255. * stop_f); break;
- case 1: stop_r = static_cast<unsigned int>(.5 + 255. * stop_q), stop_g = 255; break;
- case 2: stop_g = 255, stop_b = static_cast<unsigned int>(.5 + 255. * stop_f); break;
- case 3: stop_g = static_cast<unsigned int>(.5 + 255. * stop_q), stop_b = 255; break;
- case 4: stop_r = static_cast<unsigned int>(.5 + 255. * stop_f), stop_b = 255; break;
- case 5: stop_r = 255, stop_b = static_cast<unsigned int>(.5 + 255. * stop_q); break;
- default: break;
- }
+ switch (stop_i % 6)
+ {
+ case 0:
+ stop_r = 255, stop_g = static_cast<unsigned int>(.5 + 255. * stop_f);
+ break;
+ case 1:
+ stop_r = static_cast<unsigned int>(.5 + 255. * stop_q), stop_g = 255;
+ break;
+ case 2:
+ stop_g = 255, stop_b = static_cast<unsigned int>(.5 + 255. * stop_f);
+ break;
+ case 3:
+ stop_g = static_cast<unsigned int>(.5 + 255. * stop_q), stop_b = 255;
+ break;
+ case 4:
+ stop_r = static_cast<unsigned int>(.5 + 255. * stop_f), stop_b = 255;
+ break;
+ case 5:
+ stop_r = 255, stop_b = static_cast<unsigned int>(.5 + 255. * stop_q);
+ break;
+ default:
+ break;
+ }
- // define gradient
- out << " <linearGradient id=\"colorbar_" << index << "\" gradientUnits=\"userSpaceOnUse\" "
- << "x1=\"" << width + additional_width << "\" "
- << "y1=\"" << static_cast<unsigned int>(.5 + (height/100.) * (margin_in_percent + 29)) + (3-index) * element_height << "\" "
- << "x2=\"" << width + additional_width << "\" "
- << "y2=\"" << static_cast<unsigned int>(.5 + (height/100.) * (margin_in_percent + 29)) + (4-index) * element_height << "\""
- << ">" << '\n'
- << " <stop offset=\"0\" style=\"stop-color:rgb(" << start_r << "," << start_g << "," << start_b << ")\"/>" << '\n'
- << " <stop offset=\"1\" style=\"stop-color:rgb(" << stop_r << "," << stop_g << "," << stop_b << ")\"/>" << '\n'
- << " </linearGradient>" << '\n';
-
- // draw box corresponding to the gradient above
- out << " <rect"
- << " x=\"" << width + additional_width
- << "\" y=\"" << static_cast<unsigned int>(.5 + (height/100.) * (margin_in_percent + 29)) + (3-index) * element_height
- << "\" width=\"" << element_width
- << "\" height=\"" << element_height
- << "\" style=\"stroke:black; stroke-width:2; fill:url(#colorbar_" << index << ")\"/>" << '\n';
- }
-
- for (unsigned int index = 0; index < 5; index++)
- {
- out << " <text x=\"" << width + additional_width + static_cast<unsigned int>(1.5 * element_width)
- << "\" y=\"" << static_cast<unsigned int>(.5 + (height/100.) * (margin_in_percent + 29) + (4.-index) * element_height + 30.) << "\""
- << " style=\"text-anchor:start; font-size:80; font-family:Helvetica";
+ // define gradient
+ out << " <linearGradient id=\"colorbar_" << index << "\" gradientUnits=\"userSpaceOnUse\" "
+ << "x1=\"" << width + additional_width << "\" "
+ << "y1=\"" << static_cast<unsigned int>(.5 + (height/100.) * (margin_in_percent + 29)) + (3-index) * element_height << "\" "
+ << "x2=\"" << width + additional_width << "\" "
+ << "y2=\"" << static_cast<unsigned int>(.5 + (height/100.) * (margin_in_percent + 29)) + (4-index) * element_height << "\""
+ << ">" << '\n'
+ << " <stop offset=\"0\" style=\"stop-color:rgb(" << start_r << "," << start_g << "," << start_b << ")\"/>" << '\n'
+ << " <stop offset=\"1\" style=\"stop-color:rgb(" << stop_r << "," << stop_g << "," << stop_b << ")\"/>" << '\n'
+ << " </linearGradient>" << '\n';
+
+ // draw box corresponding to the gradient above
+ out << " <rect"
+ << " x=\"" << width + additional_width
+ << "\" y=\"" << static_cast<unsigned int>(.5 + (height/100.) * (margin_in_percent + 29)) + (3-index) * element_height
+ << "\" width=\"" << element_width
+ << "\" height=\"" << element_height
+ << "\" style=\"stroke:black; stroke-width:2; fill:url(#colorbar_" << index << ")\"/>" << '\n';
+ }
+
+ for (unsigned int index = 0; index < 5; index++)
+ {
+ out << " <text x=\"" << width + additional_width + static_cast<unsigned int>(1.5 * element_width)
+ << "\" y=\"" << static_cast<unsigned int>(.5 + (height/100.) * (margin_in_percent + 29) + (4.-index) * element_height + 30.) << "\""
+ << " style=\"text-anchor:start; font-size:80; font-family:Helvetica";
- if (index == 0 || index == 4) out << "; font-weight:bold";
+ if (index == 0 || index == 4) out << "; font-weight:bold";
- out << "\">" << (float)(((int)((z_min + index * (z_dimension / 4.))*10000))/10000.);
+ out << "\">" << (float)(((int)((z_min + index * (z_dimension / 4.))*10000))/10000.);
- if (index == 4) out << " max";
- if (index == 0) out << " min";
+ if (index == 4) out << " max";
+ if (index == 0) out << " min";
- out << "</text>" << '\n';
+ out << "</text>" << '\n';
+ }
}
- }
// finalize the svg file
out << '\n' << "</svg>";
MPI_Info info;
MPI_Info_create(&info);
MPI_File fh;
- MPI_File_open(MPI_COMM_WORLD, const_cast<char *>(filename),
+ MPI_File_open(comm, const_cast<char *>(filename),
MPI_MODE_CREATE | MPI_MODE_WRONLY, info, &fh);
MPI_File_set_size(fh, 0); // delete the file contents
// this barrier is necessary, because otherwise others might already
if (myrank==0)
{
std::stringstream ss;
- DataOutBase::write_vtu_header(ss);
+ DataOutBase::write_vtu_header(ss, vtk_flags);
header_size = ss.str().size();
MPI_File_write(fh, const_cast<char *>(ss.str().c_str()), header_size, MPI_CHAR, NULL);
}
+template <int dim, int spacedim>
+void
+DataOutInterface<dim,spacedim>::write_visit_record (std::ostream &out,
+ const std::vector<std::vector<std::string> > &piece_names) const
+{
+ AssertThrow (out, ExcIO());
+
+ if (piece_names.size() == 0)
+ return;
+
+ const double nblocks = piece_names[0].size();
+ Assert(nblocks > 0, ExcMessage("piece_names should be a vector of nonempty vectors.") )
+
+ out << "!NBLOCKS " << nblocks << '\n';
+ for (std::vector<std::vector<std::string> >::const_iterator domain = piece_names.begin(); domain != piece_names.end(); ++domain)
+ {
+ Assert(domain->size() == nblocks, ExcMessage("piece_names should be a vector of equal sized vectors.") )
+ for (std::vector<std::string>::const_iterator subdomain = domain->begin(); subdomain != domain->end(); ++subdomain)
+ out << *subdomain << '\n';
+ }
+
+ out << std::flush;
+}
+
+
+
template <int dim, int spacedim>
void DataOutInterface<dim,spacedim>::
write_deal_II_intermediate (std::ostream &out) const
template <int dim, int spacedim>
XDMFEntry DataOutInterface<dim,spacedim>::
-create_xdmf_entry (const char *h5_filename, const double cur_time, MPI_Comm comm) const
+create_xdmf_entry (const std::string &h5_filename, const double cur_time, MPI_Comm comm) const
+{
+ DataOutBase::DataOutFilter data_filter(DataOutBase::DataOutFilterFlags(false, true));
+ write_filtered_data(data_filter);
+ return create_xdmf_entry(data_filter, h5_filename, cur_time, comm);
+}
+
+template <int dim, int spacedim>
+XDMFEntry DataOutInterface<dim,spacedim>::
+create_xdmf_entry (const DataOutFilter &data_filter, const std::string &h5_filename, const double cur_time, MPI_Comm comm) const
{
- return DataOutBase::create_xdmf_entry(get_patches(), get_dataset_names(), get_vector_data_ranges(),
- h5_filename, cur_time, comm);
+ return create_xdmf_entry(data_filter, h5_filename, h5_filename, cur_time, comm);
}
template <int dim, int spacedim>
-XDMFEntry DataOutBase::create_xdmf_entry (const std::vector<Patch<dim,spacedim> > &patches,
- const std::vector<std::string> &data_names,
- const std::vector<std_cxx1x::tuple<unsigned int, unsigned int, std::string> > &vector_data_ranges,
- const char *h5_filename,
- const double cur_time,
- MPI_Comm comm)
+XDMFEntry DataOutInterface<dim,spacedim>::
+create_xdmf_entry (const DataOutFilter &data_filter, const std::string &h5_mesh_filename, const std::string &h5_solution_filename, const double cur_time, MPI_Comm comm) const
{
unsigned int local_node_cell_count[2], global_node_cell_count[2];
- const unsigned int n_data_sets = data_names.size();
int myrank;
#ifndef DEAL_II_WITH_HDF5
// throw an exception, but first make
// sure the compiler does not warn about
// the now unused function arguments
- (void)patches;
- (void)data_names;
- (void)vector_data_ranges;
- (void)h5_filename;
+ (void)data_filter;
+ (void)h5_mesh_filename;
+ (void)h5_solution_filename;
(void)cur_time;
(void)comm;
AssertThrow(false, ExcMessage ("XDMF support requires HDF5 to be turned on."));
#endif
AssertThrow(dim == 2 || dim == 3, ExcMessage ("XDMF only supports 2 or 3 dimensions."));
- compute_sizes<dim,spacedim>(patches, local_node_cell_count[0], local_node_cell_count[1]);
+ local_node_cell_count[0] = data_filter.n_nodes();
+ local_node_cell_count[1] = data_filter.n_cells();
// And compute the global total
#ifdef DEAL_II_WITH_MPI
// Output the XDMF file only on the root process
if (myrank == 0)
{
- XDMFEntry entry(h5_filename, cur_time, global_node_cell_count[0], global_node_cell_count[1], dim);
+ XDMFEntry entry(h5_mesh_filename, h5_solution_filename, cur_time, global_node_cell_count[0], global_node_cell_count[1], dim);
+ unsigned int n_data_sets = data_filter.n_data_sets();
// The vector names generated here must match those generated in the HDF5 file
- unsigned int i, n_th_vector, data_set, pt_data_vector_dim;
- std::string vector_name;
- for (n_th_vector=0,data_set=0; data_set<n_data_sets;)
+ unsigned int i;
+ for (i=0; i<n_data_sets; ++i)
{
- // Advance n_th_vector to at least the current data set we are on
- while (n_th_vector < vector_data_ranges.size() && std_cxx1x::get<0>(vector_data_ranges[n_th_vector]) < data_set) n_th_vector++;
-
- // Determine whether the data is multiple dimensions or one
- if (std_cxx1x::get<0>(vector_data_ranges[n_th_vector]) == data_set)
- {
- // Multiple dimensions
- pt_data_vector_dim = std_cxx1x::get<1>(vector_data_ranges[n_th_vector]) - std_cxx1x::get<0>(vector_data_ranges[n_th_vector])+1;
-
- // Ensure the dimensionality of the data is correct
- AssertThrow (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]) >= std_cxx1x::get<0>(vector_data_ranges[n_th_vector]),
- ExcLowerRange (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]), std_cxx1x::get<0>(vector_data_ranges[n_th_vector])));
- AssertThrow (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]) < n_data_sets,
- ExcIndexRange (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]), 0, n_data_sets));
-
- // Determine the vector name
- // Concatenate all the
- // component names with double
- // underscores unless a vector
- // name has been specified
- if (std_cxx1x::get<2>(vector_data_ranges[n_th_vector]) != "")
- {
- vector_name = std_cxx1x::get<2>(vector_data_ranges[n_th_vector]);
- }
- else
- {
- vector_name = "";
- for (i=std_cxx1x::get<0>(vector_data_ranges[n_th_vector]); i<std_cxx1x::get<1>(vector_data_ranges[n_th_vector]); ++i)
- vector_name += data_names[i] + "__";
- vector_name += data_names[std_cxx1x::get<1>(vector_data_ranges[n_th_vector])];
- }
- }
- else
- {
- // One dimension
- pt_data_vector_dim = 1;
- vector_name = data_names[data_set];
- }
-
- entry.add_attribute(vector_name, pt_data_vector_dim);
-
- // Advance the current data set
- data_set += pt_data_vector_dim;
+ entry.add_attribute(data_filter.get_data_set_name(i), data_filter.get_data_set_dim(i));
}
return entry;
template <int dim, int spacedim>
void DataOutInterface<dim,spacedim>::
write_xdmf_file (const std::vector<XDMFEntry> &entries,
- const char *filename,
+ const std::string &filename,
MPI_Comm comm) const
-{
- DataOutBase::write_xdmf_file(get_patches(), entries, filename, comm);
-}
-
-
-
-template <int dim, int spacedim>
-void DataOutBase::write_xdmf_file (const std::vector<Patch<dim,spacedim> > &,
- const std::vector<XDMFEntry> &entries,
- const char *filename,
- MPI_Comm comm)
{
int myrank;
// Only rank 0 process writes the XDMF file
if (myrank == 0)
{
- std::ofstream xdmf_file(filename);
+ std::ofstream xdmf_file(filename.c_str());
std::vector<XDMFEntry>::const_iterator it;
xdmf_file << "<?xml version=\"1.0\" ?>\n";
}
-// Get the XDMF content associated with this entry
-// If the entry is not valid, this returns false
+/*
+ * Get the XDMF content associated with this entry.
+ * If the entry is not valid, this returns an empty string.
+ */
std::string XDMFEntry::get_xdmf_content(const unsigned int indent_level) const
{
std::stringstream ss;
ss << indent(indent_level+1) << "<Time Value=\"" << entry_time << "\"/>\n";
ss << indent(indent_level+1) << "<Geometry GeometryType=\"" << (dimension == 2 ? "XY" : "XYZ" ) << "\">\n";
ss << indent(indent_level+2) << "<DataItem Dimensions=\"" << num_nodes << " " << dimension << "\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n";
- ss << indent(indent_level+3) << h5_filename << ":/nodes\n";
+ ss << indent(indent_level+3) << h5_mesh_filename << ":/nodes\n";
ss << indent(indent_level+2) << "</DataItem>\n";
ss << indent(indent_level+1) << "</Geometry>\n";
// If we have cells defined, use a quadrilateral (2D) or hexahedron (3D) topology
{
ss << indent(indent_level+1) << "<Topology TopologyType=\"" << (dimension == 2 ? "Quadrilateral" : "Hexahedron") << "\" NumberOfElements=\"" << num_cells << "\">\n";
ss << indent(indent_level+2) << "<DataItem Dimensions=\"" << num_cells << " " << (2 << (dimension-1)) << "\" NumberType=\"UInt\" Format=\"HDF\">\n";
- ss << indent(indent_level+3) << h5_filename << ":/cells\n";
+ ss << indent(indent_level+3) << h5_mesh_filename << ":/cells\n";
ss << indent(indent_level+2) << "</DataItem>\n";
ss << indent(indent_level+1) << "</Topology>\n";
}
ss << indent(indent_level+1) << "<Attribute Name=\"" << it->first << "\" AttributeType=\"" << (it->second > 1 ? "Vector" : "Scalar") << "\" Center=\"Node\">\n";
// Vectors must have 3 elements even for 2D models
ss << indent(indent_level+2) << "<DataItem Dimensions=\"" << num_nodes << " " << (it->second > 1 ? 3 : 1) << "\" NumberType=\"Float\" Precision=\"8\" Format=\"HDF\">\n";
- ss << indent(indent_level+3) << h5_filename << ":/" << it->first << "\n";
+ ss << indent(indent_level+3) << h5_sol_filename << ":/" << it->first << "\n";
ss << indent(indent_level+2) << "</DataItem>\n";
ss << indent(indent_level+1) << "</Attribute>\n";
}
return ss.str();
}
+/*
+ * Write the data in this DataOutInterface to a DataOutFilter object.
+ * Filtering is performed based on the DataOutFilter flags.
+ */
template <int dim, int spacedim>
void DataOutInterface<dim,spacedim>::
-write_hdf5_parallel (const char *filename, MPI_Comm comm) const
+write_filtered_data (DataOutFilter &filtered_data) const
{
-#ifndef DEAL_II_WITH_HDF5
- AssertThrow(false, ExcMessage ("HDF5 support is disabled."));
-#endif
- DataOutBase::write_hdf5_parallel(get_patches(), get_dataset_names(),
+ DataOutBase::write_filtered_data(get_patches(), get_dataset_names(),
get_vector_data_ranges(),
- filename, comm);
+ filtered_data);
}
template <int dim, int spacedim>
-void DataOutBase::write_hdf5_parallel (const std::vector<Patch<dim,spacedim> > &patches,
+void DataOutBase::write_filtered_data (const std::vector<Patch<dim,spacedim> > &patches,
const std::vector<std::string> &data_names,
const std::vector<std_cxx1x::tuple<unsigned int, unsigned int, std::string> > &vector_data_ranges,
- const char *filename,
+ DataOutFilter &filtered_data)
+{
+ const unsigned int n_data_sets = data_names.size();
+ unsigned int n_node, n_cell;
+ Table<2,double> data_vectors;
+ Threads::Task<> reorder_task;
+
+#ifndef DEAL_II_WITH_MPI
+ // verify that there are indeed
+ // patches to be written out. most
+ // of the times, people just forget
+ // to call build_patches when there
+ // are no patches, so a warning is
+ // in order. that said, the
+ // assertion is disabled if we
+ // support MPI since then it can
+ // happen that on the coarsest
+ // mesh, a processor simply has no
+ // cells it actually owns, and in
+ // that case it is legit if there
+ // are no patches
+ Assert (patches.size() > 0, ExcNoPatches());
+#endif
+
+ compute_sizes<dim,spacedim>(patches, n_node, n_cell);
+
+ data_vectors = Table<2,double> (n_data_sets, n_node);
+ void (*fun_ptr) (const std::vector<Patch<dim,spacedim> > &, Table<2,double> &) = &DataOutBase::template write_gmv_reorder_data_vectors<dim,spacedim>;
+ reorder_task = Threads::new_task (fun_ptr, patches, data_vectors);
+
+ // Write the nodes/cells to the DataOutFilter object.
+ write_nodes(patches, filtered_data);
+ write_cells(patches, filtered_data);
+
+ // Ensure reordering is done before we output data set values
+ reorder_task.join ();
+
+ // when writing, first write out
+ // all vector data, then handle the
+ // scalar data sets that have been
+ // left over
+ unsigned int i, n, q, r, n_th_vector, data_set, pt_data_vector_dim, mem_vector_dim;
+ std::string vector_name;
+ for (n_th_vector=0,data_set=0; data_set<n_data_sets;)
+ {
+ // Advance n_th_vector to at least the current data set we are on
+ while (n_th_vector < vector_data_ranges.size() && std_cxx1x::get<0>(vector_data_ranges[n_th_vector]) < data_set) n_th_vector++;
+
+ // Determine the dimension of this data
+ if (std_cxx1x::get<0>(vector_data_ranges[n_th_vector]) == data_set)
+ {
+ // Multiple dimensions
+ pt_data_vector_dim = std_cxx1x::get<1>(vector_data_ranges[n_th_vector]) - std_cxx1x::get<0>(vector_data_ranges[n_th_vector])+1;
+
+ // Ensure the dimensionality of the data is correct
+ AssertThrow (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]) >= std_cxx1x::get<0>(vector_data_ranges[n_th_vector]),
+ ExcLowerRange (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]), std_cxx1x::get<0>(vector_data_ranges[n_th_vector])));
+ AssertThrow (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]) < n_data_sets,
+ ExcIndexRange (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]), 0, n_data_sets));
+
+ // Determine the vector name
+ // Concatenate all the
+ // component names with double
+ // underscores unless a vector
+ // name has been specified
+ if (std_cxx1x::get<2>(vector_data_ranges[n_th_vector]) != "")
+ {
+ vector_name = std_cxx1x::get<2>(vector_data_ranges[n_th_vector]);
+ }
+ else
+ {
+ vector_name = "";
+ for (i=std_cxx1x::get<0>(vector_data_ranges[n_th_vector]); i<std_cxx1x::get<1>(vector_data_ranges[n_th_vector]); ++i)
+ vector_name += data_names[i] + "__";
+ vector_name += data_names[std_cxx1x::get<1>(vector_data_ranges[n_th_vector])];
+ }
+ }
+ else
+ {
+ // One dimension
+ pt_data_vector_dim = 1;
+ vector_name = data_names[data_set];
+ }
+
+ // Write data to the filter object
+ filtered_data.write_data_set(vector_name, pt_data_vector_dim, data_set, data_vectors);
+
+ // Advance the current data set
+ data_set += pt_data_vector_dim;
+ }
+}
+
+template <int dim, int spacedim>
+void DataOutInterface<dim,spacedim>::
+write_hdf5_parallel (const std::string &filename, MPI_Comm comm) const
+{
+ DataOutBase::DataOutFilter data_filter(DataOutBase::DataOutFilterFlags(false, true));
+ write_filtered_data(data_filter);
+ write_hdf5_parallel(data_filter, filename, comm);
+}
+
+template <int dim, int spacedim>
+void DataOutInterface<dim,spacedim>::
+write_hdf5_parallel (const DataOutFilter &data_filter, const std::string &filename, MPI_Comm comm) const
+{
+ DataOutBase::write_hdf5_parallel(get_patches(), data_filter, filename, comm);
+}
+
+template <int dim, int spacedim>
+void DataOutInterface<dim,spacedim>::
+write_hdf5_parallel (const DataOutFilter &data_filter, const bool write_mesh_file, const std::string &mesh_filename, const std::string &solution_filename, MPI_Comm comm) const
+{
+ DataOutBase::write_hdf5_parallel(get_patches(), data_filter, write_mesh_file, mesh_filename, solution_filename, comm);
+}
+
+template <int dim, int spacedim>
+void DataOutBase::write_hdf5_parallel (const std::vector<Patch<dim,spacedim> > &patches,
+ const DataOutFilter &data_filter,
+ const std::string &filename,
+ MPI_Comm comm)
+{
+ write_hdf5_parallel(patches, data_filter, true, filename, filename, comm);
+}
+
+template <int dim, int spacedim>
+void DataOutBase::write_hdf5_parallel (const std::vector<Patch<dim,spacedim> > &patches,
+ const DataOutFilter &data_filter,
+ const bool write_mesh_file,
+ const std::string &mesh_filename,
+ const std::string &solution_filename,
MPI_Comm comm)
{
#ifndef DEAL_II_WITH_HDF5
// sure the compiler does not warn about
// the now unused function arguments
(void)patches;
- (void)data_names;
- (void)vector_data_ranges;
- (void)filename;
+ (void)data_filter;
+ (void)write_mesh_file;
+ (void)mesh_filename;
+ (void)solution_filename;
(void)comm;
AssertThrow(false, ExcMessage ("HDF5 support is disabled."));
#else
// cells it actually owns, and in
// that case it is legit if there
// are no patches
- Assert (patches.size() > 0, ExcNoPatches());
+ Assert (data_filter.n_nodes() > 0, ExcNoPatches());
#else
- hid_t h5_file_id, plist_id;
+ hid_t h5_mesh_file_id=-1, h5_solution_file_id, file_plist_id, plist_id;
hid_t node_dataspace, node_dataset, node_file_dataspace, node_memory_dataspace;
hid_t cell_dataspace, cell_dataset, cell_file_dataspace, cell_memory_dataspace;
hid_t pt_data_dataspace, pt_data_dataset, pt_data_file_dataspace, pt_data_memory_dataspace;
herr_t status;
unsigned int local_node_cell_count[2], global_node_cell_count[2], global_node_cell_offsets[2];
hsize_t count[2], offset[2], node_ds_dim[2], cell_ds_dim[2];
- const unsigned int n_data_sets = data_names.size();
bool empty_proc = false;
- Table<2,double> data_vectors;
- Threads::Task<> reorder_task;
+ std::vector<double> node_data_vec;
+ std::vector<unsigned int> cell_data_vec;
- if (patches.size() == 0) empty_proc = true;
+ if (data_filter.n_nodes() == 0) empty_proc = true;
// If HDF5 is not parallel and we're using multiple processes, abort
#ifndef H5_HAVE_PARALLEL
#endif
#endif
- if (empty_proc)
- {
- local_node_cell_count[0] = local_node_cell_count[1] = 0;
- }
- else
- {
- compute_sizes<dim,spacedim>(patches, local_node_cell_count[0], local_node_cell_count[1]);
-
- data_vectors = Table<2,double> (n_data_sets, local_node_cell_count[0]);
- void (*fun_ptr) (const std::vector<Patch<dim,spacedim> > &, Table<2,double> &) = &DataOutBase::template write_gmv_reorder_data_vectors<dim,spacedim>;
- reorder_task = Threads::new_task (fun_ptr, patches, data_vectors);
- }
+ local_node_cell_count[0] = data_filter.n_nodes();
+ local_node_cell_count[1] = data_filter.n_cells();
// Create file access properties
- plist_id = H5Pcreate(H5P_FILE_ACCESS);
- AssertThrow(plist_id != -1, ExcIO());
+ file_plist_id = H5Pcreate(H5P_FILE_ACCESS);
+ AssertThrow(file_plist_id != -1, ExcIO());
// If MPI is enabled *and* HDF5 is parallel, we can do parallel output
#ifdef DEAL_II_WITH_MPI
#ifdef H5_HAVE_PARALLEL
// Set the access to use the specified MPI_Comm object
- status = H5Pset_fapl_mpio(plist_id, comm, MPI_INFO_NULL);
+ status = H5Pset_fapl_mpio(file_plist_id, comm, MPI_INFO_NULL);
AssertThrow(status >= 0, ExcIO());
#endif
#endif
- // Overwrite any existing files (change this to an option?) and close the property list
- h5_file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, plist_id);
- AssertThrow(h5_file_id >= 0, ExcIO());
- status = H5Pclose(plist_id);
- AssertThrow(status >= 0, ExcIO());
-
// Compute the global total number of nodes/cells
// And determine the offset of the data for this process
#ifdef DEAL_II_WITH_MPI
global_node_cell_offsets[0] = global_node_cell_offsets[1] = 0;
#endif
- // Write the nodes/cells to the HDF5 "stream" object. Record the process offset
- // so that node reference indices are correctly calculated
- HDF5MemStream hdf5_data(local_node_cell_count, global_node_cell_offsets, dim);
- write_nodes(patches, hdf5_data);
- write_cells(patches, hdf5_data);
+ // Create the property list for a collective write
+ plist_id = H5Pcreate(H5P_DATASET_XFER);
+ AssertThrow(plist_id >= 0, ExcIO());
+#ifdef DEAL_II_WITH_MPI
+#ifdef H5_HAVE_PARALLEL
+ status = H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE);
+ AssertThrow(status >= 0, ExcIO());
+#endif
+#endif
+
+ if (write_mesh_file)
+ {
+ // Overwrite any existing files (change this to an option?)
+ h5_mesh_file_id = H5Fcreate(mesh_filename.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, file_plist_id);
+ AssertThrow(h5_mesh_file_id >= 0, ExcIO());
- // Create the dataspace for the nodes and cells
- node_ds_dim[0] = global_node_cell_count[0];
- node_ds_dim[1] = dim;
- node_dataspace = H5Screate_simple(2, node_ds_dim, NULL);
- AssertThrow(node_dataspace >= 0, ExcIO());
+ // Create the dataspace for the nodes and cells
+ node_ds_dim[0] = global_node_cell_count[0];
+ node_ds_dim[1] = dim;
+ node_dataspace = H5Screate_simple(2, node_ds_dim, NULL);
+ AssertThrow(node_dataspace >= 0, ExcIO());
- cell_ds_dim[0] = global_node_cell_count[1];
- cell_ds_dim[1] = GeometryInfo<dim>::vertices_per_cell;
- cell_dataspace = H5Screate_simple(2, cell_ds_dim, NULL);
- AssertThrow(cell_dataspace >= 0, ExcIO());
+ cell_ds_dim[0] = global_node_cell_count[1];
+ cell_ds_dim[1] = GeometryInfo<dim>::vertices_per_cell;
+ cell_dataspace = H5Screate_simple(2, cell_ds_dim, NULL);
+ AssertThrow(cell_dataspace >= 0, ExcIO());
- // Create the dataset for the nodes and cells
+ // Create the dataset for the nodes and cells
#if H5Gcreate_vers == 1
- node_dataset = H5Dcreate(h5_file_id, "nodes", H5T_NATIVE_DOUBLE, node_dataspace, H5P_DEFAULT);
+ node_dataset = H5Dcreate(h5_mesh_file_id, "nodes", H5T_NATIVE_DOUBLE, node_dataspace, H5P_DEFAULT);
#else
- node_dataset = H5Dcreate(h5_file_id, "nodes", H5T_NATIVE_DOUBLE, node_dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ node_dataset = H5Dcreate(h5_mesh_file_id, "nodes", H5T_NATIVE_DOUBLE, node_dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
#endif
- AssertThrow(node_dataset >= 0, ExcIO());
+ AssertThrow(node_dataset >= 0, ExcIO());
#if H5Gcreate_vers == 1
- cell_dataset = H5Dcreate(h5_file_id, "cells", H5T_NATIVE_UINT, cell_dataspace, H5P_DEFAULT);
+ cell_dataset = H5Dcreate(h5_mesh_file_id, "cells", H5T_NATIVE_UINT, cell_dataspace, H5P_DEFAULT);
#else
- cell_dataset = H5Dcreate(h5_file_id, "cells", H5T_NATIVE_UINT, cell_dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ cell_dataset = H5Dcreate(h5_mesh_file_id, "cells", H5T_NATIVE_UINT, cell_dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
#endif
- AssertThrow(cell_dataset >= 0, ExcIO());
+ AssertThrow(cell_dataset >= 0, ExcIO());
- // Close the node and cell dataspaces since we're done with them
- status = H5Sclose(node_dataspace);
- AssertThrow(status >= 0, ExcIO());
- status = H5Sclose(cell_dataspace);
- AssertThrow(status >= 0, ExcIO());
+ // Close the node and cell dataspaces since we're done with them
+ status = H5Sclose(node_dataspace);
+ AssertThrow(status >= 0, ExcIO());
+ status = H5Sclose(cell_dataspace);
+ AssertThrow(status >= 0, ExcIO());
- // Create the data subset we'll use to read from memory
- count[0] = local_node_cell_count[0];
- count[1] = dim;
- offset[0] = global_node_cell_offsets[0];
- offset[1] = 0;
- node_memory_dataspace = H5Screate_simple(2, count, NULL);
- AssertThrow(node_memory_dataspace >= 0, ExcIO());
-
- // Select the hyperslab in the file
- node_file_dataspace = H5Dget_space(node_dataset);
- AssertThrow(node_file_dataspace >= 0, ExcIO());
- status = H5Sselect_hyperslab(node_file_dataspace, H5S_SELECT_SET, offset, NULL, count, NULL);
- AssertThrow(status >= 0, ExcIO());
+ // Create the data subset we'll use to read from memory
+ count[0] = local_node_cell_count[0];
+ count[1] = dim;
+ offset[0] = global_node_cell_offsets[0];
+ offset[1] = 0;
+ node_memory_dataspace = H5Screate_simple(2, count, NULL);
+ AssertThrow(node_memory_dataspace >= 0, ExcIO());
- // And repeat for cells
- count[0] = local_node_cell_count[1];
- count[1] = GeometryInfo<dim>::vertices_per_cell;
- offset[0] = global_node_cell_offsets[1];
- offset[1] = 0;
- cell_memory_dataspace = H5Screate_simple(2, count, NULL);
- AssertThrow(cell_memory_dataspace >= 0, ExcIO());
-
- cell_file_dataspace = H5Dget_space(cell_dataset);
- AssertThrow(cell_file_dataspace >= 0, ExcIO());
- status = H5Sselect_hyperslab(cell_file_dataspace, H5S_SELECT_SET, offset, NULL, count, NULL);
- AssertThrow(status >= 0, ExcIO());
+ // Select the hyperslab in the file
+ node_file_dataspace = H5Dget_space(node_dataset);
+ AssertThrow(node_file_dataspace >= 0, ExcIO());
+ status = H5Sselect_hyperslab(node_file_dataspace, H5S_SELECT_SET, offset, NULL, count, NULL);
+ AssertThrow(status >= 0, ExcIO());
- // Create the property list for a collective write
- plist_id = H5Pcreate(H5P_DATASET_XFER);
- AssertThrow(plist_id >= 0, ExcIO());
-#ifdef DEAL_II_WITH_MPI
-#ifdef H5_HAVE_PARALLEL
- status = H5Pset_dxpl_mpio(plist_id, H5FD_MPIO_COLLECTIVE);
- AssertThrow(status >= 0, ExcIO());
-#endif
-#endif
+ // And repeat for cells
+ count[0] = local_node_cell_count[1];
+ count[1] = GeometryInfo<dim>::vertices_per_cell;
+ offset[0] = global_node_cell_offsets[1];
+ offset[1] = 0;
+ cell_memory_dataspace = H5Screate_simple(2, count, NULL);
+ AssertThrow(cell_memory_dataspace >= 0, ExcIO());
- // And finally, write the node data
- status = H5Dwrite(node_dataset, H5T_NATIVE_DOUBLE, node_memory_dataspace, node_file_dataspace, plist_id, hdf5_data.node_data());
- AssertThrow(status >= 0, ExcIO());
+ cell_file_dataspace = H5Dget_space(cell_dataset);
+ AssertThrow(cell_file_dataspace >= 0, ExcIO());
+ status = H5Sselect_hyperslab(cell_file_dataspace, H5S_SELECT_SET, offset, NULL, count, NULL);
+ AssertThrow(status >= 0, ExcIO());
- // And the cell data
- status = H5Dwrite(cell_dataset, H5T_NATIVE_UINT, cell_memory_dataspace, cell_file_dataspace, plist_id, hdf5_data.cell_data());
- AssertThrow(status >= 0, ExcIO());
+ // And finally, write the node data
+ data_filter.fill_node_data(node_data_vec);
+ status = H5Dwrite(node_dataset, H5T_NATIVE_DOUBLE, node_memory_dataspace, node_file_dataspace, plist_id, &node_data_vec[0]);
+ AssertThrow(status >= 0, ExcIO());
+ node_data_vec.clear();
- if (!empty_proc) reorder_task.join ();
+ // And the cell data
+ data_filter.fill_cell_data(global_node_cell_offsets[0], cell_data_vec);
+ status = H5Dwrite(cell_dataset, H5T_NATIVE_UINT, cell_memory_dataspace, cell_file_dataspace, plist_id, &cell_data_vec[0]);
+ AssertThrow(status >= 0, ExcIO());
+ cell_data_vec.clear();
- // when writing, first write out
- // all vector data, then handle the
- // scalar data sets that have been
- // left over
- unsigned int i, n, q, r, n_th_vector, data_set, pt_data_vector_dim, mem_vector_dim;
- double *pt_data;
- std::string vector_name;
- for (n_th_vector=0,data_set=0; data_set<n_data_sets;)
- {
- // Advance n_th_vector to at least the current data set we are on
- while (n_th_vector < vector_data_ranges.size() && std_cxx1x::get<0>(vector_data_ranges[n_th_vector]) < data_set) n_th_vector++;
+ // Close the file dataspaces
+ status = H5Sclose(node_file_dataspace);
+ AssertThrow(status >= 0, ExcIO());
+ status = H5Sclose(cell_file_dataspace);
+ AssertThrow(status >= 0, ExcIO());
- // Determine the dimension of this data
- if (std_cxx1x::get<0>(vector_data_ranges[n_th_vector]) == data_set)
- {
- // Multiple dimensions
- pt_data_vector_dim = std_cxx1x::get<1>(vector_data_ranges[n_th_vector]) - std_cxx1x::get<0>(vector_data_ranges[n_th_vector])+1;
+ // Close the memory dataspaces
+ status = H5Sclose(node_memory_dataspace);
+ AssertThrow(status >= 0, ExcIO());
+ status = H5Sclose(cell_memory_dataspace);
+ AssertThrow(status >= 0, ExcIO());
- // Ensure the dimensionality of the data is correct
- AssertThrow (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]) >= std_cxx1x::get<0>(vector_data_ranges[n_th_vector]),
- ExcLowerRange (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]), std_cxx1x::get<0>(vector_data_ranges[n_th_vector])));
- AssertThrow (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]) < n_data_sets,
- ExcIndexRange (std_cxx1x::get<1>(vector_data_ranges[n_th_vector]), 0, n_data_sets));
+ // Close the datasets
+ status = H5Dclose(node_dataset);
+ AssertThrow(status >= 0, ExcIO());
+ status = H5Dclose(cell_dataset);
+ AssertThrow(status >= 0, ExcIO());
- // Determine the vector name
- // Concatenate all the
- // component names with double
- // underscores unless a vector
- // name has been specified
- if (std_cxx1x::get<2>(vector_data_ranges[n_th_vector]) != "")
- {
- vector_name = std_cxx1x::get<2>(vector_data_ranges[n_th_vector]);
- }
- else
- {
- vector_name = "";
- for (i=std_cxx1x::get<0>(vector_data_ranges[n_th_vector]); i<std_cxx1x::get<1>(vector_data_ranges[n_th_vector]); ++i)
- vector_name += data_names[i] + "__";
- vector_name += data_names[std_cxx1x::get<1>(vector_data_ranges[n_th_vector])];
- }
- }
- else
+ // If the filenames are different, we need to close the mesh file
+ if (mesh_filename != solution_filename)
{
- // One dimension
- pt_data_vector_dim = 1;
- vector_name = data_names[data_set];
+ status = H5Fclose(h5_mesh_file_id);
+ AssertThrow(status >= 0, ExcIO());
}
+ }
+ // If the filenames are identical, continue with the same file
+ if (mesh_filename == solution_filename && write_mesh_file)
+ {
+ h5_solution_file_id = h5_mesh_file_id;
+ }
+ else
+ {
+ // Otherwise we need to open a new file
+ h5_solution_file_id = H5Fcreate(solution_filename.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, file_plist_id);
+ AssertThrow(h5_solution_file_id >= 0, ExcIO());
+ }
+
+ // when writing, first write out
+ // all vector data, then handle the
+ // scalar data sets that have been
+ // left over
+ unsigned int i, n, q, r, pt_data_vector_dim;
+ std::string vector_name;
+ for (i=0; i<data_filter.n_data_sets(); ++i)
+ {
// Allocate space for the point data
// Must be either 1D or 3D
- mem_vector_dim = (pt_data_vector_dim>1?3:1);
- pt_data = new double[local_node_cell_count[0]*mem_vector_dim];
+ pt_data_vector_dim = data_filter.get_data_set_dim(i);
+ vector_name = data_filter.get_data_set_name(i);
// Create the dataspace for the point data
node_ds_dim[0] = global_node_cell_count[0];
- node_ds_dim[1] = mem_vector_dim;
+ node_ds_dim[1] = pt_data_vector_dim;
pt_data_dataspace = H5Screate_simple(2, node_ds_dim, NULL);
AssertThrow(pt_data_dataspace >= 0, ExcIO());
#if H5Gcreate_vers == 1
- pt_data_dataset = H5Dcreate(h5_file_id, vector_name.c_str(), H5T_NATIVE_DOUBLE, pt_data_dataspace, H5P_DEFAULT);
+ pt_data_dataset = H5Dcreate(h5_solution_file_id, vector_name.c_str(), H5T_NATIVE_DOUBLE, pt_data_dataspace, H5P_DEFAULT);
#else
- pt_data_dataset = H5Dcreate(h5_file_id, vector_name.c_str(), H5T_NATIVE_DOUBLE, pt_data_dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ pt_data_dataset = H5Dcreate(h5_solution_file_id, vector_name.c_str(), H5T_NATIVE_DOUBLE, pt_data_dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
#endif
AssertThrow(pt_data_dataset >= 0, ExcIO());
// Create the data subset we'll use to read from memory
count[0] = local_node_cell_count[0];
- count[1] = mem_vector_dim;
+ count[1] = pt_data_vector_dim;
offset[0] = global_node_cell_offsets[0];
offset[1] = 0;
pt_data_memory_dataspace = H5Screate_simple(2, count, NULL);
status = H5Sselect_hyperslab(pt_data_file_dataspace, H5S_SELECT_SET, offset, NULL, count, NULL);
AssertThrow(status >= 0, ExcIO());
- // Write point data to the memory array
- r = 0;
- for (i=0; !empty_proc && i<local_node_cell_count[0]; ++i)
- {
- // Get the offset to the vector
- q = data_set;
- // Write the data vector
- for (n=0; n<pt_data_vector_dim; ++n) pt_data[r++] = data_vectors(q+n, i);
- // Write 0 for the remainder of entries in 2D
- for (; n<mem_vector_dim; ++n) pt_data[r++] = 0;
- }
-
// And finally, write the data
- status = H5Dwrite(pt_data_dataset, H5T_NATIVE_DOUBLE, pt_data_memory_dataspace, pt_data_file_dataspace, plist_id, pt_data);
+ status = H5Dwrite(pt_data_dataset, H5T_NATIVE_DOUBLE, pt_data_memory_dataspace, pt_data_file_dataspace, plist_id, data_filter.get_data_set(i));
AssertThrow(status >= 0, ExcIO());
- delete pt_data;
-
// Close the dataspaces
status = H5Sclose(pt_data_dataspace);
AssertThrow(status >= 0, ExcIO());
// Close the dataset
status = H5Dclose(pt_data_dataset);
AssertThrow(status >= 0, ExcIO());
-
- // Advance the current data set
- data_set += pt_data_vector_dim;
}
- // Close the file dataspaces
- status = H5Sclose(node_file_dataspace);
- AssertThrow(status >= 0, ExcIO());
- status = H5Sclose(cell_file_dataspace);
- AssertThrow(status >= 0, ExcIO());
-
- // Close the memory dataspaces
- status = H5Sclose(node_memory_dataspace);
- AssertThrow(status >= 0, ExcIO());
- status = H5Sclose(cell_memory_dataspace);
- AssertThrow(status >= 0, ExcIO());
-
- // Close the datasets
- status = H5Dclose(node_dataset);
- AssertThrow(status >= 0, ExcIO());
- status = H5Dclose(cell_dataset);
+ // Close the file property list
+ status = H5Pclose(file_plist_id);
AssertThrow(status >= 0, ExcIO());
// Close the parallel access
AssertThrow(status >= 0, ExcIO());
// Close the file
- status = H5Fclose(h5_file_id);
+ status = H5Fclose(h5_solution_file_id);
AssertThrow(status >= 0, ExcIO());
#endif
#endif
+++ /dev/null
-/*
- * Workaround for a bug in the Xcode generator.
- *
- * This file contains a dummy global symbol to trigger the link phase in
- * the generated Xcode project.
- */
-
-const int _global_symbol_42 = 42;
-
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/event.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 2000, 2001, 2002, 2003, 2005, 2006, 2009, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/exceptions.h>
#include <deal.II/base/logstream.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2007, 2008, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2007 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/tensor.h>
#include <deal.II/base/point.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/function.h>
#include <deal.II/base/tensor_function.h>
* to be size <tt>n_components</tt>.
*/
template <int dim>
-VectorFunctionFromTensorFunction<dim>::VectorFunctionFromTensorFunction (const TensorFunction<1,dim>& tensor_function,
+VectorFunctionFromTensorFunction<dim>::VectorFunctionFromTensorFunction (const TensorFunction<1,dim> &tensor_function,
const unsigned int selected_component,
const unsigned int n_components)
:
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2011, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/point.h>
#include <deal.II/base/function_derivative.h>
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/tensor.h>
#include <deal.II/base/point.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2010, 2012 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/tensor.h>
#include <deal.II/base/point.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2007, 2009, 2012 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/function_parser.h>
#include <deal.II/base/utilities.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/function_time.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/geometry_info.h>
#include <deal.II/base/tensor.h>
GeometryInfo<2>::child_cell_on_face (const RefinementCase<2> &ref_case,
const unsigned int face,
const unsigned int subface,
- const bool, const bool face_flip, const bool,
+ const bool /*face_orientation*/,
+ const bool face_flip,
+ const bool /*face_rotation*/,
const RefinementCase<1> &)
{
Assert (face<faces_per_cell, ExcIndexRange(face, 0, faces_per_cell));
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/memory_consumption.h>
#include <deal.II/base/index_set.h>
if (n_ranges)
in.read(reinterpret_cast<char *>(&*ranges.begin()),
ranges.size() * sizeof(Range));
+
+ do_compress(); // needed so that largest_range can be recomputed
}
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/job_identifier.h>
#include <ctime>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/logstream.h>
#include <deal.II/base/job_identifier.h>
// Print to the internal stringstream:
stream << p;
- // Next check whether this is the <tt>flush</tt> or <tt>endl</tt>
- // manipulator, and if so print out the message.
- std::ostream & (* const p_flush) (std::ostream &) = &std::flush;
- std::ostream & (* const p_endl) (std::ostream &) = &std::endl;
- if (p == p_flush || p == p_endl)
+
+ // This is a bloody hack until LogStream got reimplemented as a proper
+ // child of std::streambuf (or similar).
+ //
+ // The problem is that at this point we would like to know whether an
+ // std::flush or std::endl has called us, however, there is no way to
+ // detect this in a sane manner.
+ //
+ // The obvious idea to compare function pointers,
+ // std::ostream & (* const p_flush) (std::ostream &) = &std::flush;
+ // p == p_flush ? ...,
+ // is wrong as there doesn't has to be a _single_ std::flush instance...
+ // there could be multiple of it. And in fact, LLVM's libc++ implements
+ // std::flush and std::endl in a way that every shared library and
+ // executable has its local copy... fun...
+ //
+ // - Maier, 2013
+
+ class QueryStreambuf : public std::streambuf
+ {
+ // Implement a minimalistic stream buffer that only stores the fact
+ // whether overflow or sync was called
+ public:
+ QueryStreambuf()
+ : flushed_(false), newline_written_(false)
+ {
+ }
+ bool flushed() { return flushed_; }
+ bool newline_written() { return newline_written_; }
+ private:
+ int_type overflow(int_type ch)
+ {
+ newline_written_ = true;
+ return ch;
+ }
+ int sync()
+ {
+ flushed_ = true;
+ return 0;
+ }
+ bool flushed_;
+ bool newline_written_;
+ } query_streambuf;
+
+ {
+ // and initialize an ostream with this streambuf:
+ std::ostream inject (&query_streambuf);
+ inject << p;
+ }
+
+ if (query_streambuf.flushed())
{
Threads::Mutex::ScopedLock lock(write_lock);
- // Print the line head in case of a newline:
+ // Print the line head in case of a previous newline:
if (at_newline)
print_line_head();
- if(p == p_flush)
- at_newline = false;
-
- if(p == p_endl)
- at_newline = true;
+ at_newline = query_streambuf.newline_written();
if (get_prefixes().size() <= std_depth)
*std_out << stream.str();
if (file && (get_prefixes().size() <= file_depth))
*file << stream.str() << std::flush;
- // Start a new string
+ // Start a new string:
stream.str("");
}
const std::string &
LogStream::get_prefix() const
{
- return get_prefixes().top();
+ static std::string empty_string;
+
+ if (get_prefixes().size() > 0)
+ return get_prefixes().top();
+ else
+ return empty_string;
}
void
LogStream::push (const std::string &text)
{
- std::string pre=get_prefixes().top();
+ std::string pre;
+ if (get_prefixes().size() > 0)
+ pre = get_prefixes().top();
+
pre += text;
pre += std::string(":");
get_prefixes().push(pre);
void LogStream::pop ()
{
- if (get_prefixes().size() > 1)
+ if (get_prefixes().size() > 0)
get_prefixes().pop();
}
// If this is a new locally stored stack, copy the "blessed" prefixes
// from the initial thread that created logstream.
- if(! exists)
+ if (! exists)
{
const tbb::enumerable_thread_specific<std::stack<std::string> > &impl
= prefixes.get_implementation();
if (print_thread_id)
*std_out << '[' << thread << ']';
- *std_out << head << ':';
+ if (head.size() > 0)
+ *std_out << head << ':';
}
if (file && (get_prefixes().size() <= file_depth))
if (print_thread_id)
*file << '[' << thread << ']';
- *file << head << ':';
+ if (head.size() > 0)
+ *file << head << ':';
}
}
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2005, 2006, 2011, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/memory_consumption.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/mpi.h>
#include <deal.II/base/utilities.h>
MPI_InitFinalize::MPI_InitFinalize (int &argc,
- char ** &argv,
- unsigned int max_num_threads)
- :
- owns_mpi (true)
+ char ** &argv,
+ unsigned int max_num_threads)
+ :
+ owns_mpi (true)
{
do_init(argc, argv, max_num_threads);
}
void
MPI_InitFinalize::do_init(int &argc,
- char ** &argv,
- unsigned int max_num_threads)
+ char ** &argv,
+ unsigned int max_num_threads)
{
static bool constructor_has_already_run = false;
Assert (constructor_has_already_run == false,
ExcMessage ("You can only create a single object of this class "
"in a program since it initializes the MPI system."));
-#ifdef DEAL_II_WITH_PETSC
-# ifdef DEAL_II_WITH_SLEPC
- // Initialise SLEPc (with PETSc):
- SlepcInitialize(&argc, &argv, PETSC_NULL, PETSC_NULL);
-# else
- // or just initialise PETSc alone:
- PetscInitialize(&argc, &argv, PETSC_NULL, PETSC_NULL);
-# endif
-#else
-# ifdef DEAL_II_WITH_MPI
+
+
+#ifdef DEAL_II_WITH_MPI
// if we have PETSc, we will initialize it and let it handle MPI.
// Otherwise, we will do it.
int MPI_has_been_started = 0;
AssertThrow (MPI_has_been_started == 0,
ExcMessage ("MPI error. You can only start MPI once!"));
- int mpi_err;
- mpi_err = MPI_Init (&argc, &argv);
+ int mpi_err, provided;
+ // this works likempi_err = MPI_Init (&argc, &argv); but tells MPI that
+ // we might use several threads but never call two MPI functions at the
+ // same time. For an explanation see on why we do this see
+ // http://www.open-mpi.org/community/lists/users/2010/03/12244.php
+ int wanted = MPI_THREAD_SERIALIZED;
+ mpi_err = MPI_Init_thread(&argc, &argv, wanted, &provided);
AssertThrow (mpi_err == 0,
ExcMessage ("MPI could not be initialized."));
-# else
+
+ // disable for now because at least some implementations always return MPI_THREAD_SINGLE.
+ //Assert(max_num_threads==1 || provided != MPI_THREAD_SINGLE,
+ // ExcMessage("MPI reports that we are not allowed to use multiple threads."));
+#else
// make sure the compiler doesn't warn
// about these variables
(void)argc;
(void)argv;
(void)owns_mpi;
+#endif
+
+ // we are allowed to call MPI_Init ourselves and PETScInitialize will
+ // detect this. This allows us to use MPI_Init_thread instead.
+#ifdef DEAL_II_WITH_PETSC
+# ifdef DEAL_II_WITH_SLEPC
+ // Initialize SLEPc (with PETSc):
+ SlepcInitialize(&argc, &argv, PETSC_NULL, PETSC_NULL);
+# else
+ // or just initialize PETSc alone:
+ PetscInitialize(&argc, &argv, PETSC_NULL, PETSC_NULL);
# endif
#endif
// or just end PETSc.
PetscFinalize();
# endif
- }
-#endif
+ }
+#endif
- // only MPI_Finalize if we are running with MPI and we are not using PETSc
- // (otherwise we called it above already):
+ // only MPI_Finalize if we are running with MPI. We also need to do this
+ // when running PETSc, because we initialize MPI ourselves before calling
+ // PetscInitialize
#ifdef DEAL_II_WITH_MPI
-#ifndef DEAL_II_WITH_PETSC
- int mpi_err = 0;
+ int mpi_err = 0;
int MPI_has_been_started = 0;
MPI_Initialized(&MPI_has_been_started);
AssertThrow (mpi_err == 0,
ExcMessage ("An error occurred while calling MPI_Finalize()"));
-#endif
#endif
}
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2011, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/multithread_info.h>
#include <deal.II/base/utilities.h>
void MultithreadInfo::set_thread_limit(const unsigned int max_threads)
{
unsigned int max_threads_env = numbers::invalid_unsigned_int;
- char* penv;
+ char *penv;
penv = getenv ("DEAL_II_NUM_THREADS");
if (penv!=NULL)
if (n_max_threads == numbers::invalid_unsigned_int)
n_max_threads = tbb::task_scheduler_init::default_num_threads();
else
- {
+ {
static tbb::task_scheduler_init dummy (n_max_threads);
- }
+ }
}
bool MultithreadInfo::is_running_single_threaded()
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2012 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/parallel.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/parameter_handler.h>
#include <deal.II/base/logstream.h>
List::List (const PatternBase &p,
const unsigned int min_elements,
- const unsigned int max_elements)
+ const unsigned int max_elements,
+ const std::string &separator)
:
pattern (p.clone()),
min_elements (min_elements),
- max_elements (max_elements)
+ max_elements (max_elements),
+ separator (separator)
{
Assert (min_elements <= max_elements,
ExcInvalidRange (min_elements, max_elements));
+ Assert (separator.size() > 0,
+ ExcMessage ("The separator must have a non-zero length."));
}
{
std::string tmp = test_string_list;
std::vector<std::string> split_list;
- split_list.reserve (std::count (tmp.begin(), tmp.end(), ',')+1);
// first split the input list
while (tmp.length() != 0)
std::string name;
name = tmp;
- if (name.find(",") != std::string::npos)
+ if (name.find(separator) != std::string::npos)
{
- name.erase (name.find(","), std::string::npos);
- tmp.erase (0, tmp.find(",")+1);
+ name.erase (name.find(separator), std::string::npos);
+ tmp.erase (0, tmp.find(separator)+separator.size());
}
else
tmp = "";
name.erase (name.length()-1, 1);
split_list.push_back (name);
- };
+ }
if ((split_list.size() < min_elements) ||
(split_list.size() > max_elements))
description << description_init
<< " list of <" << pattern->description() << ">"
<< " of length " << min_elements << "..." << max_elements
- << " (inclusive)"
- << "]";
+ << " (inclusive)";
+ if (separator != ",")
+ description << " separated by <" << separator << ">";
+ description << "]";
return description.str();
}
PatternBase *
List::clone () const
{
- return new List(*pattern, min_elements, max_elements);
+ return new List(*pattern, min_elements, max_elements, separator);
}
List::memory_consumption () const
{
return (sizeof(*this) +
- MemoryConsumption::memory_consumption(*pattern));
+ MemoryConsumption::memory_consumption(*pattern) +
+ MemoryConsumption::memory_consumption(separator));
}
if (!(is >> max_elements))
return new List(*base_pattern, min_elements);
- return new List(*base_pattern, min_elements, max_elements);
+ is.ignore(strlen(" separated by <"));
+ std::string separator;
+ if (!is)
+ std::getline(is, separator, '>');
+ else
+ separator = ",";
+
+ return new List(*base_pattern, min_elements, max_elements, separator);
}
else
return 0;
Map::Map (const PatternBase &p_key,
const PatternBase &p_value,
const unsigned int min_elements,
- const unsigned int max_elements)
+ const unsigned int max_elements,
+ const std::string &separator)
:
key_pattern (p_key.clone()),
value_pattern (p_value.clone()),
min_elements (min_elements),
- max_elements (max_elements)
+ max_elements (max_elements),
+ separator (separator)
{
Assert (min_elements <= max_elements,
ExcInvalidRange (min_elements, max_elements));
+ Assert (separator.size() > 0,
+ ExcMessage ("The separator must have a non-zero length."));
+ Assert (separator != ":",
+ ExcMessage ("The separator can not be a colon ':' sicne that "
+ "is the separator between the two elements of <key:value> pairs"));
}
{
std::string tmp = test_string_list;
std::vector<std::string> split_list;
- split_list.reserve (std::count (tmp.begin(), tmp.end(), ',')+1);
// first split the input list at comma sites
while (tmp.length() != 0)
std::string map_entry;
map_entry = tmp;
- if (map_entry.find(",") != std::string::npos)
+ if (map_entry.find(separator) != std::string::npos)
{
- map_entry.erase (map_entry.find(","), std::string::npos);
- tmp.erase (0, tmp.find(",")+1);
+ map_entry.erase (map_entry.find(separator), std::string::npos);
+ tmp.erase (0, tmp.find(separator)+separator.size());
}
else
tmp = "";
map_entry.erase (map_entry.length()-1, 1);
split_list.push_back (map_entry);
- };
+ }
if ((split_list.size() < min_elements) ||
(split_list.size() > max_elements))
<< key_pattern->description() << ":"
<< value_pattern->description() << ">"
<< " of length " << min_elements << "..." << max_elements
- << " (inclusive)"
- << "]";
+ << " (inclusive)";
+ if (separator != ",")
+ description << " separated by <" << separator << ">";
+ description << "]";
return description.str();
}
PatternBase *
Map::clone () const
{
- return new Map(*key_pattern, *value_pattern, min_elements, max_elements);
+ return new Map(*key_pattern, *value_pattern,
+ min_elements, max_elements,
+ separator);
}
{
return (sizeof(*this) +
MemoryConsumption::memory_consumption (*key_pattern) +
- MemoryConsumption::memory_consumption (*value_pattern));
+ MemoryConsumption::memory_consumption (*value_pattern) +
+ MemoryConsumption::memory_consumption (separator));
}
if (!(is >> max_elements))
return new Map(*key_pattern, *value_pattern, min_elements);
- return new Map(*key_pattern, *value_pattern, min_elements, max_elements);
+ is.ignore(strlen(" separated by <"));
+ std::string separator;
+ if (!is)
+ std::getline(is, separator, '>');
+ else
+ separator = ",";
+
+ return new Map(*key_pattern, *value_pattern,
+ min_elements, max_elements,
+ separator);
}
else
return 0;
for (unsigned int i=0; i<s.size(); ++i)
{
static const std::string allowed_characters
- ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
+ ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
if ((! mangle_whole_string)
- &&
- (allowed_characters.find (s[i]) != std::string::npos))
- u.push_back (s[i]);
+ &&
+ (allowed_characters.find (s[i]) != std::string::npos))
+ u.push_back (s[i]);
else
- {
- u.push_back ('_');
- static const char hex[16]
- = { '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
- u.push_back (hex[static_cast<unsigned char>(s[i])/16]);
- u.push_back (hex[static_cast<unsigned char>(s[i])%16]);
- }
+ {
+ u.push_back ('_');
+ static const char hex[16]
+ = { '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
+ u.push_back (hex[static_cast<unsigned char>(s[i])/16]);
+ u.push_back (hex[static_cast<unsigned char>(s[i])%16]);
+ }
}
return u;
-bool ParameterHandler::read_input (std::istream &input)
+bool ParameterHandler::read_input (std::istream &input,
+ const std::string &filename)
{
AssertThrow (input, ExcIO());
{
++lineno;
getline (input, line);
- if (!scan_line (line, lineno))
- status = false;
+ status &= scan_line (line, filename, lineno);
}
return status;
std::ifstream input (openname.c_str());
AssertThrow(input, ExcIO());
- return read_input (input);
+ return read_input (input, filename);
}
catch (const PathSearch::ExcFileNotFound &)
{
bool ParameterHandler::read_input_from_string (const char *s)
{
- // if empty std::string then exit
- // with success
- if ((s == 0) || ((*s) == 0)) return true;
-
- std::string line;
- std::string input (s);
- int lineno=0;
-
- // if necessary append a newline char
- // to make all lines equal
- if (input[input.length()-1] != '\n')
- input += '\n';
-
- bool status = true;
- while (input.size() != 0)
- {
- // get one line from Input (=s)
- line.assign (input, 0, input.find('\n'));
- // delete this part including
- // the backspace
- input.erase (0, input.find('\n')+1);
- ++lineno;
-
- if (!scan_line (line, lineno))
- status = false;
- }
-
- return status;
+ // create an istringstream representation and pass it off
+ // to the other functions doing this work
+ std::istringstream in (s);
+ return read_input (in, "input string");
}
entries->put (get_current_full_path(entry) + path_separator +
"pattern_description",
patterns.back()->description());
+
+ // as documented, do the default value checking at the very end
+ AssertThrow (pattern.match (default_value),
+ ExcValueDoesNotMatchPattern (default_value, pattern.description()));
}
bool
-ParameterHandler::scan_line (std::string line,
- const unsigned int lineno)
+ParameterHandler::scan_line (std::string line,
+ const std::string &input_filename,
+ const unsigned int lineno)
{
// if there is a comment, delete it
if (line.find('#') != std::string::npos)
line.erase (line.find(" "), 1);
// now every existing whitespace
// should be exactly one ' ';
- // if at end or beginning: delete
- if ((line.length() != 0) && (std::isspace (line[0]))) line.erase (0, 1);
+ // if at beginning: delete
+ if ((line.length() != 0) && (std::isspace (line[0])))
+ line.erase (0, 1);
// if line is now empty: leave
- if (line.length() == 0) return true;
+ if (line.length() == 0)
+ return true;
+ // also delete spaces at the end
if (std::isspace (line[line.length()-1]))
line.erase (line.size()-1, 1);
// check whether subsection exists
if (!entries->get_child_optional (get_current_full_path(subsection)))
{
- std::cerr << "Line " << lineno
- << ": There is no such subsection to be entered: "
+ std::cerr << "Line <" << lineno
+ << "> of file <" << input_filename
+ << ">: There is no such subsection to be entered: "
<< demangle(get_current_full_path(subsection)) << std::endl;
for (unsigned int i=0; i<subsection_path.size(); ++i)
std::cerr << std::setw(i*2+4) << " "
{
if (subsection_path.size() == 0)
{
- std::cerr << "Line " << lineno
- << ": There is no subsection to leave here!" << std::endl;
+ std::cerr << "Line <" << lineno
+ << "> of file <" << input_filename
+ << ">: There is no subsection to leave here!" << std::endl;
return false;
}
else
= entries->get<unsigned int> (get_current_full_path(entry_name) + path_separator + "pattern");
if (!patterns[pattern_index]->match(entry_value))
{
- std::cerr << "Line " << lineno << ":" << std::endl
+ std::cerr << "Line <" << lineno
+ << "> of file <" << input_filename
+ << ">:" << std::endl
<< " The entry value" << std::endl
<< " " << entry_value << std::endl
<< " for the entry named" << std::endl
}
else
{
- std::cerr << "Line " << lineno
- << ": No such entry was declared:" << std::endl
+ std::cerr << "Line <" << lineno
+ << "> of file <" << input_filename
+ << ">: No such entry was declared:" << std::endl
<< " " << entry_name << std::endl
<< " <Present subsection:" << std::endl;
for (unsigned int i=0; i<subsection_path.size(); ++i)
}
}
+ // an include statement?
+ if ((line.find ("INCLUDE ") == 0) ||
+ (line.find ("include ") == 0))
+ {
+ // erase "set" statement and eliminate
+ // spaces around the '='
+ line.erase (0, 7);
+ while ((line.size() > 0) && (line[0] == ' '))
+ line.erase (0, 1);
+
+ // the remainder must then be a filename
+ if (line.size() == 0)
+ {
+ std::cerr << "Line <" << lineno
+ << "> of file <" << input_filename
+ << "> is an include statement but does not name a file!"
+ << std::endl;
+
+ return false;
+ }
+
+ std::ifstream input (line.c_str());
+ if (!input)
+ {
+ std::cerr << "Line <" << lineno
+ << "> of file <" << input_filename
+ << "> is an include statement but the file <"
+ << line << "> could not be opened!"
+ << std::endl;
+
+ return false;
+ }
+ else
+ return read_input (input);
+ }
+
// this line matched nothing known
- std::cerr << "Line " << lineno
- << ": This line matched nothing known ('set' or 'subsection' missing!?):" << std::endl
+ std::cerr << "Line <" << lineno
+ << "> of file <" << input_filename
+ << ">: This line matched nothing known ('set' or 'subsection' missing!?):" << std::endl
<< " " << line << std::endl;
return false;
}
-bool MultipleParameterLoop::read_input (std::istream &input)
+bool MultipleParameterLoop::read_input (std::istream &input,
+ const std::string &filename)
{
AssertThrow (input, ExcIO());
- bool x = ParameterHandler::read_input (input);
+ bool x = ParameterHandler::read_input (input, filename);
if (x)
init_branches ();
return x;
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2007, 2008, 2009, 2012 by the deal.II authors
+// Copyright (C) 2007 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/parsed_function.h>
#include <deal.II/base/utilities.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/partitioner.h>
void
Partitioner::set_ghost_indices (const IndexSet &ghost_indices_in)
{
- // Set ghost indices from input. To be sure
- // that no entries from the locally owned
- // range are present, subtract the locally
- // owned indices in any case.
+ // Set ghost indices from input. To be sure that no entries from the
+ // locally owned range are present, subtract the locally owned indices
+ // in any case.
Assert (ghost_indices_in.n_elements() == 0 ||
ghost_indices_in.size() == locally_owned_range_data.size(),
ExcDimensionMismatch (ghost_indices_in.size(),
ghost_indices_data.compress();
n_ghost_indices_data = ghost_indices_data.n_elements();
- // In the rest of this function, we determine
- // the point-to-point communication pattern of
- // the partitioner. We make up a list with
- // both the processors the ghost indices
- // actually belong to, and the indices that
- // are locally held but ghost indices of other
- // processors. This allows then to import and
- // export data very easily.
-
- // find out the end index for each processor
- // and communicate it (this implies the start
- // index for the next processor)
+ // In the rest of this function, we determine the point-to-point
+ // communication pattern of the partitioner. We make up a list with both
+ // the processors the ghost indices actually belong to, and the indices
+ // that are locally held but ghost indices of other processors. This
+ // allows then to import and export data very easily.
+
+ // find out the end index for each processor and communicate it (this
+ // implies the start index for the next processor)
#ifdef DEAL_II_WITH_MPI
if (n_procs < 2)
{
MPI_BYTE, communicator);
first_index[n_procs] = global_size;
- // fix case when there are some processors
- // without any locally owned indices: then
- // there might be a zero in some entries
+ // fix case when there are some processors without any locally owned
+ // indices: then there might be a zero in some entries
if (global_size > 0)
{
unsigned int first_proc_with_nonzero_dofs = 0;
if (first_index[i] == 0)
first_index[i] = first_index[i-1];
- // correct if our processor has a wrong local
- // range
+ // correct if our processor has a wrong local range
if (first_index[my_pid] != local_range_data.first)
{
Assert(local_range_data.first == local_range_data.second,
}
}
- // Allocate memory for data that will be
- // exported
+ // Allocate memory for data that will be exported
std::vector<types::global_dof_index> expanded_ghost_indices (n_ghost_indices_data);
unsigned int n_ghost_targets = 0;
if (n_ghost_indices_data > 0)
{
- // Create first a vector of ghost_targets from
- // the list of ghost indices and then push
- // back new values. When we are done, copy the
- // data to that field of the partitioner. This
- // way, the variable ghost_targets will have
- // exactly the size we need, whereas the
- // vector filled with push_back might actually
- // be too long.
+ // Create first a vector of ghost_targets from the list of ghost
+ // indices and then push back new values. When we are done, copy the
+ // data to that field of the partitioner. This way, the variable
+ // ghost_targets will have exactly the size we need, whereas the
+ // vector filled with push_back might actually be too long.
unsigned int current_proc = 0;
ghost_indices_data.fill_index_vector (expanded_ghost_indices);
unsigned int current_index = expanded_ghost_indices[0];
n_ghost_indices_data - ghost_targets_temp[n_ghost_targets-1].second;
ghost_targets_data = ghost_targets_temp;
}
- // find the processes that want to import to
- // me
+ // find the processes that want to import to me
{
std::vector<int> send_buffer (n_procs, 0);
std::vector<int> receive_buffer (n_procs, 0);
import_targets_data = import_targets_temp;
}
- // send and receive indices for import
- // data. non-blocking receives and blocking
- // sends
+ // send and receive indices for import data. non-blocking receives and
+ // blocking sends
std::vector<types::global_dof_index> expanded_import_indices (n_import_indices_data);
{
unsigned int current_index_start = 0;
MPI_Waitall (import_requests.size(), &import_requests[0],
MPI_STATUSES_IGNORE);
- // transform import indices to local index
- // space and compress contiguous indices in
- // form of ranges
+ // transform import indices to local index space and compress
+ // contiguous indices in form of ranges
{
types::global_dof_index last_index = numbers::invalid_dof_index-1;
std::vector<std::pair<types::global_dof_index,types::global_dof_index> > compressed_import_indices;
ExcIndexRange(expanded_import_indices[i], local_range_data.first,
local_range_data.second));
types::global_dof_index new_index = (expanded_import_indices[i] -
- local_range_data.first);
+ local_range_data.first);
if (new_index == last_index+1)
compressed_import_indices.back().second++;
else
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2012 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/path_search.h>
#include <deal.II/base/logstream.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/polynomial.h>
#include <deal.II/base/point.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 2002 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/polynomial_space.h>
#include <deal.II/base/exceptions.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2010, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/polynomials_abf.h>
#include <deal.II/base/quadrature_lib.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/polynomials_adini.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/polynomials_bdm.h>
#include <deal.II/base/quadrature_lib.h>
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/geometry_info.h>
#include <deal.II/base/quadrature_lib.h>
#include <deal.II/base/polynomial.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/polynomials_p.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/polynomials_piecewise.h>
}
}
else
- {
+ {
const double offset = step * interval;
if (x<offset || x>offset+step)
{
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/polynomials_raviart_thomas.h>
#include <deal.II/base/quadrature_lib.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/geometry_info.h>
#include <deal.II/base/quadrature.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/quadrature_lib.h>
#include <deal.II/base/geometry_info.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2005, 2006, 2010, 2012 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/quadrature_selector.h>
#include <deal.II/base/quadrature_lib.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2010, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/thread_management.h>
#include <deal.II/base/subscriptor.h>
// running the c++filt program over
// the output.
#ifdef DEBUG
- std::string infostring;
- for (map_iterator it = counter_map.begin(); it != counter_map.end(); ++it)
- {
- if (it->second > 0)
- infostring += std::string("\n from Subscriber ")
- + std::string(it->first);
- }
// if there are still active pointers, show
// a message and kill the program. However,
{
if (std::uncaught_exception() == false)
{
+ std::string infostring;
+ for (map_iterator it = counter_map.begin(); it != counter_map.end(); ++it)
+ {
+ if (it->second > 0)
+ infostring += std::string("\n from Subscriber ")
+ + std::string(it->first);
+ }
+
+ if (infostring == "")
+ infostring = "<none>";
+
Assert (counter == 0,
ExcInUse (counter, object_info->name(), infostring));
}
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/symmetric_tensor.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/table_handler.h>
#include <deal.II/base/table.h>
const unsigned int nrows = n_rows();
const unsigned int n_cols = sel_columns.size();
- // handle the simple format separately first
- if (format==simple_table_with_separate_column_description)
+ // cache the columns and compute the widths of each column for alignment
+ std::vector<const Column *> cols;
+ std::vector<unsigned int> column_widths (n_cols, 0);
+ for (unsigned int j=0; j<n_cols; ++j)
+ {
+ std::string key=sel_columns[j];
+ const std::map<std::string, Column>::const_iterator
+ col_iter=columns.find(key);
+ Assert(col_iter!=columns.end(), ExcInternalError());
+ cols.push_back(&(col_iter->second));
+
+ column_widths[j] = col_iter->second.max_length;
+ }
+
+ switch (format)
+ {
+ case org_mode_table:
{
// write the captions
+ out << "| " << std::left;
for (unsigned int j=0; j<n_cols; ++j)
{
const std::string &key = sel_columns[j];
- out << "# " << j+1 << ": " << key << '\n';
+ column_widths[j] = std::max(column_widths[j],
+ (unsigned int)key.length());
+ out << std::setw(column_widths[j]);
+ out << key << " | ";
+ }
+ out << std::endl;
+
+ // write the body
+ for (unsigned int i=0; i<nrows; ++i)
+ {
+ out << "| ";
+ for (unsigned int j=0; j<n_cols; ++j)
+ {
+ const Column &column=*(cols[j]);
+
+ out << std::setw(column_widths[j]);
+ out << column.entries[i].get_cached_string();
+ out << " | ";
+ }
+ out << '\n';
}
- // cache the columns
- std::vector<const Column *> cols;
+ out << std::flush;
+ return;
+ }
+
+ case simple_table_with_separate_column_description:
+ {
+ // write the captions
for (unsigned int j=0; j<n_cols; ++j)
{
- std::string key=sel_columns[j];
- const std::map<std::string, Column>::const_iterator
- col_iter=columns.find(key);
- Assert(col_iter!=columns.end(), ExcInternalError());
- cols.push_back(&(col_iter->second));
+ const std::string &key = sel_columns[j];
+ out << "# " << j+1 << ": " << key << '\n';
}
// write the body
out << std::flush;
return;
}
-
- // cache the columns and compute the widths of each column for alignment
- std::vector<const Column *> cols;
- std::vector<unsigned int> column_widths (n_cols, 0);
- for (unsigned int j=0; j<n_cols; ++j)
- {
- std::string key=sel_columns[j];
- const std::map<std::string, Column>::const_iterator
- col_iter=columns.find(key);
- Assert(col_iter!=columns.end(), ExcInternalError());
- cols.push_back(&(col_iter->second));
-
- column_widths[j] = col_iter->second.max_length;
- }
-
- // writing the captions for table_with_separate_column_description
- // means that we ignore supercolumns and output the column
- // header for each column. enumerate columns starting with 1
- if (format == table_with_separate_column_description)
+
+ case table_with_separate_column_description:
{
+ // writing the captions for table_with_separate_column_description
+ // means that we ignore supercolumns and output the column
+ // header for each column. enumerate columns starting with 1
for (unsigned int j=0; j<n_cols; ++j)
{
std::string key=sel_columns[j];
out << "# " << j+1 << ": " << key << '\n';
}
+ break;
}
- else if (format == table_with_headers)
+
+ case table_with_headers:
{
// This format output supercolumn headers and aligns them centered
// over all the columns that belong to it.
out << ' ';
}
out << '\n';
+ break;
+ }
+
+ default:
+ Assert (false, ExcInternalError());
}
- else
- Assert (false, ExcInternalError());
-
- // finally output the data itself
+
+ // finally output the data itself for
+ // table_with_headers or table_with_separate_column_description:
for (unsigned int i=0; i<nrows; ++i)
{
for (unsigned int j=0; j<n_cols; ++j)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/tensor_function.h>
#include <vector>
DEAL_II_NAMESPACE_OPEN
+
//////////////////////////////////////////////////////////////////////
// TensorFunction
//////////////////////////////////////////////////////////////////////
}
+
+//////////////////////////////////////////////////////////////////////
+// ConstantTensorFunction
+//////////////////////////////////////////////////////////////////////
+
+
+template <int rank, int dim>
+ConstantTensorFunction<rank, dim>::ConstantTensorFunction (const Tensor<rank, dim> &value,
+ const double initial_time)
+ :
+ TensorFunction<rank, dim> (initial_time),
+ _value(value)
+{}
+
+
+template <int rank, int dim>
+ConstantTensorFunction<rank, dim>::~ConstantTensorFunction ()
+{}
+
+
+template <int rank, int dim>
+typename TensorFunction<rank, dim>::value_type
+ConstantTensorFunction<rank, dim>::value (const Point<dim> &/*point*/) const
+{
+ return _value;
+}
+
+
+template <int rank, int dim>
+void
+ConstantTensorFunction<rank, dim>::value_list (const std::vector<Point<dim> > &points,
+ std::vector<typename TensorFunction<rank, dim>::value_type> &values) const
+{
+ Assert (values.size() == points.size(),
+ ExcDimensionMismatch(values.size(), points.size()));
+
+ for (unsigned int i=0; i<values.size(); ++i)
+ values[i] = _value;
+}
+
+
+template <int rank, int dim>
+typename TensorFunction<rank, dim>::gradient_type
+ConstantTensorFunction<rank, dim>::gradient (const Point<dim> &) const
+{
+ static const Tensor<rank+1,dim> zero;
+
+ return zero;
+}
+
+
+template <int rank, int dim>
+void
+ConstantTensorFunction<rank, dim>::gradient_list (const std::vector<Point<dim> > &points,
+ std::vector<typename TensorFunction<rank, dim>::gradient_type> &gradients) const
+{
+ Assert (gradients.size() == points.size(),
+ ExcDimensionMismatch(gradients.size(), points.size()));
+
+ static const Tensor<rank+1,dim> zero;
+
+ for (unsigned int i=0; i<gradients.size(); ++i)
+ gradients[i] = zero;
+}
+
+
+
+//////////////////////////////////////////////////////////////////////
+// ZeroTensorFunction
+//////////////////////////////////////////////////////////////////////
+
+
+template <int rank, int dim>
+ZeroTensorFunction<rank, dim>::ZeroTensorFunction (const double initial_time)
+ :
+ ConstantTensorFunction<rank, dim> (dealii::Tensor<rank, dim>(), initial_time)
+{}
+
+
+
+//////////////////////////////////////////////////////////////////////
+// Explicit instantiations:
+//////////////////////////////////////////////////////////////////////
+
template class TensorFunction<1,1>;
template class TensorFunction<2,1>;
template class TensorFunction<3,1>;
template class TensorFunction<3,3>;
template class TensorFunction<4,3>;
+template class ConstantTensorFunction<1,1>;
+template class ConstantTensorFunction<2,1>;
+template class ConstantTensorFunction<3,1>;
+template class ConstantTensorFunction<4,1>;
+template class ConstantTensorFunction<1,2>;
+template class ConstantTensorFunction<2,2>;
+template class ConstantTensorFunction<3,2>;
+template class ConstantTensorFunction<4,2>;
+template class ConstantTensorFunction<1,3>;
+template class ConstantTensorFunction<2,3>;
+template class ConstantTensorFunction<3,3>;
+template class ConstantTensorFunction<4,3>;
+
+template class ZeroTensorFunction<1,1>;
+template class ZeroTensorFunction<2,1>;
+template class ZeroTensorFunction<3,1>;
+template class ZeroTensorFunction<4,1>;
+template class ZeroTensorFunction<1,2>;
+template class ZeroTensorFunction<2,2>;
+template class ZeroTensorFunction<3,2>;
+template class ZeroTensorFunction<4,2>;
+template class ZeroTensorFunction<1,3>;
+template class ZeroTensorFunction<2,3>;
+template class ZeroTensorFunction<3,3>;
+template class ZeroTensorFunction<4,3>;
+
+
DEAL_II_NAMESPACE_CLOSE
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2010, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/tensor_product_polynomials.h>
#include <deal.II/base/polynomials_piecewise.h>
void compute_tensor_index(const unsigned int,
const unsigned int,
const unsigned int,
- unsigned int (&)[dim])
+ unsigned int ( &)[dim])
{
Assert(false, ExcNotImplemented());
}
-//---------------------------------------------------------------------------
-// $Id: trilinos_sparse_matrix.cc 27985 2013-01-08 21:36:23Z bangerth $
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2012, 2013 by the deal.II authors
+// Copyright (C) 2012 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/tensor_product_polynomials_const.h>
#include <deal.II/base/exceptions.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/thread_management.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/timer.h>
#include <deal.II/base/exceptions.h>
leave_subsection();
if ( (output_frequency == summary || output_frequency == every_call_and_summary)
- && output_is_enabled == true)
+ && output_is_enabled == true)
print_summary();
}
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/utilities.h>
#include <deal.II/base/exceptions.h>
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
-FILE(GLOB _header
- ${CMAKE_SOURCE_DIR}/include/deal.II/distributed/*.h
- )
-
SET(_src
grid_refinement.cc
solution_transfer.cc
tria.inst.in
)
+FILE(GLOB _header
+ ${CMAKE_SOURCE_DIR}/include/deal.II/distributed/*.h
+ )
+
DEAL_II_ADD_LIBRARY(obj_distributed OBJECT ${_src} ${_header} ${_inst})
EXPAND_INSTANTIATIONS(obj_distributed "${_inst}")
-
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/utilities.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/config.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/utilities.h>
#include <deal.II/base/memory_consumption.h>
#include <deal.II/grid/tria.h>
#include <deal.II/grid/tria_accessor.h>
#include <deal.II/grid/tria_iterator.h>
-#include <deal.II/distributed/tria.h>
#include <deal.II/grid/grid_tools.h>
+#include <deal.II/distributed/tria.h>
#ifdef DEAL_II_WITH_P4EST
# include <p4est_bits.h>
# include <p4est_vtk.h>
# include <p4est_ghost.h>
# include <p4est_communication.h>
+# include <p4est_iterate.h>
# include <p8est_bits.h>
# include <p8est_extended.h>
# include <p8est_vtk.h>
# include <p8est_ghost.h>
# include <p8est_communication.h>
+# include <p8est_iterate.h>
#endif
#include <algorithm>
namespace p4est
{
/**
- * A structure whose explicit
- * specializations contain
- * pointers to the relevant
- * p4est_* and p8est_*
- * functions. Using this
- * structure, for example by
- * saying
- * functions<dim>::quadrant_compare,
- * we can write code in a
- * dimension independent way,
- * either calling
- * p4est_quadrant_compare or
- * p8est_quadrant_compare,
- * depending on template
- * argument.
+ * A structure whose explicit specializations contain pointers to the
+ * relevant p4est_* and p8est_* functions. Using this structure, for
+ * example by saying functions<dim>::quadrant_compare, we can write code
+ * in a dimension independent way, either calling p4est_quadrant_compare
+ * or p8est_quadrant_compare, depending on template argument.
*/
template <int dim> struct functions;
int (&quadrant_is_ancestor) (const types<2>::quadrant *q1,
const types<2>::quadrant *q2);
+ static
+ int (&quadrant_ancestor_id) (const types<2>::quadrant *q,
+ int level);
+
static
int (&comm_find_owner) (types<2>::forest *p4est,
const types<2>::locidx which_tree,
types<2>::topidx num_corners,
types<2>::topidx num_vtt);
+ static
+ void (&connectivity_join_faces) (types<2>::connectivity *conn,
+ types<2>::topidx tree_left,
+ types<2>::topidx tree_right,
+ int face_left,
+ int face_right,
+ int orientation);
+
+
+
static
void (&connectivity_destroy) (p4est_connectivity_t *connectivity);
void (&connectivity_save) (const char *filename,
types<2>::connectivity *connectivity);
+ static
+ int (&connectivity_is_valid) (types<2>::connectivity *connectivity);
+
static
types<2>::connectivity *(&connectivity_load) (const char *filename,
long *length);
const types<2>::quadrant *q2)
= p4est_quadrant_is_ancestor;
+ int (&functions<2>::quadrant_ancestor_id) (const types<2>::quadrant *q,
+ int level)
+ = p4est_quadrant_ancestor_id;
+
int (&functions<2>::comm_find_owner) (types<2>::forest *p4est,
const types<2>::locidx which_tree,
const types<2>::quadrant *q,
types<2>::topidx num_vtt)
= p4est_connectivity_new;
+#if DEAL_II_P4EST_VERSION_GTE(0,3,4,1)
+ void (&functions<2>::connectivity_join_faces) (types<2>::connectivity *conn,
+ types<2>::topidx tree_left,
+ types<2>::topidx tree_right,
+ int face_left,
+ int face_right,
+ int orientation)
+ = p4est_connectivity_join_faces;
+#endif
+
void (&functions<2>::connectivity_destroy) (p4est_connectivity_t *connectivity)
= p4est_connectivity_destroy;
types<2>::connectivity *connectivity)
= p4est_connectivity_save;
+ int (&functions<2>::connectivity_is_valid) (types<2>::connectivity
+ *connectivity)
+ = p4est_connectivity_is_valid;
+
types<2>::connectivity *
(&functions<2>::connectivity_load) (const char *filename,
long *length)
int (&quadrant_is_ancestor) (const types<3>::quadrant *q1,
const types<3>::quadrant *q2);
+ static
+ int (&quadrant_ancestor_id) (const types<3>::quadrant *q,
+ int level);
+
static
int (&comm_find_owner) (types<3>::forest *p4est,
const types<3>::locidx which_tree,
types<3>::topidx num_corners,
types<3>::topidx num_ctt);
+ static
+ void (&connectivity_join_faces) (types<3>::connectivity *conn,
+ types<3>::topidx tree_left,
+ types<3>::topidx tree_right,
+ int face_left,
+ int face_right,
+ int orientation);
+
static
void (&connectivity_destroy) (p8est_connectivity_t *connectivity);
void (&connectivity_save) (const char *filename,
types<3>::connectivity *connectivity);
+ static
+ int (&connectivity_is_valid) (types<3>::connectivity *connectivity);
+
static
types<3>::connectivity *(&connectivity_load) (const char *filename,
long *length);
const types<3>::quadrant *q2)
= p8est_quadrant_is_ancestor;
+ int (&functions<3>::quadrant_ancestor_id) (const types<3>::quadrant *q,
+ int level)
+ = p8est_quadrant_ancestor_id;
+
int (&functions<3>::comm_find_owner) (types<3>::forest *p4est,
const types<3>::locidx which_tree,
const types<3>::quadrant *q,
void (&functions<3>::connectivity_destroy) (p8est_connectivity_t *connectivity)
= p8est_connectivity_destroy;
+#if DEAL_II_P4EST_VERSION_GTE(0,3,4,1)
+ void (&functions<3>::connectivity_join_faces) (types<3>::connectivity *conn,
+ types<3>::topidx tree_left,
+ types<3>::topidx tree_right,
+ int face_left,
+ int face_right,
+ int orientation)
+ = p8est_connectivity_join_faces;
+#endif
+
types<3>::forest *(&functions<3>::new_forest) (MPI_Comm mpicomm,
types<3>::connectivity *connectivity,
types<3>::locidx min_quadrants,
types<3>::connectivity *connectivity)
= p8est_connectivity_save;
+ int (&functions<3>::connectivity_is_valid) (types<3>::connectivity
+ *connectivity)
+ = p8est_connectivity_is_valid;
+
types<3>::connectivity *
(&functions<3>::connectivity_load) (const char *filename,
long *length)
{
return functions<dim>::quadrant_is_ancestor(&q1, &q2);
}
+
+ /**
+ * This struct templatizes the p4est iterate structs and function
+ * prototypes, which are used to execute callback functions for faces,
+ * edges, and corners that require local neighborhood information, i.e.
+ * the neighboring cells */
+ template <int dim> struct iter;
+
+ template <> struct iter<2>
+ {
+ typedef p4est_iter_corner_info_t corner_info;
+ typedef p4est_iter_corner_side_t corner_side;
+ typedef p4est_iter_corner_t corner_iter;
+ typedef p4est_iter_face_info_t face_info;
+ typedef p4est_iter_face_side_t face_side;
+ typedef p4est_iter_face_t face_iter;
+ };
+
+ template <> struct iter<3>
+ {
+ typedef p8est_iter_corner_info_t corner_info;
+ typedef p8est_iter_corner_side_t corner_side;
+ typedef p8est_iter_corner_t corner_iter;
+ typedef p8est_iter_edge_info_t edge_info;
+ typedef p8est_iter_edge_side_t edge_side;
+ typedef p8est_iter_edge_t edge_iter;
+ typedef p8est_iter_face_info_t face_info;
+ typedef p8est_iter_face_side_t face_side;
+ typedef p8est_iter_face_t face_iter;
+ };
+
}
}
/**
- * Set all vertex and cell
- * related information in the
- * p4est connectivity structure.
+ * Set all vertex and cell related information in the p4est connectivity
+ * structure.
*/
template <int dim, int spacedim>
void
const bool set_vertex_info,
typename internal::p4est::types<dim>::connectivity *connectivity)
{
- // copy the vertices into the
- // connectivity structure. the
- // triangulation exports the array of
- // vertices, but some of the entries are
- // sometimes unused; this shouldn't be
- // the case for a newly created
- // triangulation, but make sure
+ // copy the vertices into the connectivity structure. the triangulation
+ // exports the array of vertices, but some of the entries are sometimes
+ // unused; this shouldn't be the case for a newly created triangulation,
+ // but make sure
//
- // note that p4est stores coordinates as
- // a triplet of values even in 2d
+ // note that p4est stores coordinates as a triplet of values even in 2d
Assert (triangulation.get_used_vertices().size() ==
triangulation.get_vertices().size(),
ExcInternalError());
triangulation.get_vertices()[v][2]);
}
- // next store the tree_to_vertex indices
- // (each tree is here only a single cell
- // in the coarse mesh). p4est requires
- // vertex numbering in clockwise
+ // next store the tree_to_vertex indices (each tree is here only a single
+ // cell in the coarse mesh). p4est requires vertex numbering in clockwise
// orientation
//
- // while we're at it, also copy the
- // neighborship information between cells
+ // while we're at it, also copy the neighborship information between cells
typename Triangulation<dim>::active_cell_iterator
cell = triangulation.begin_active(),
endc = triangulation.end();
connectivity->tree_to_corner[index*GeometryInfo<dim>::vertices_per_cell+v] = cell->vertex_index(v);
}
- // neighborship information. if a
- // cell is at a boundary, then enter
+ // neighborship information. if a cell is at a boundary, then enter
// the index of the cell itself here
for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
if (cell->face(f)->at_boundary() == false)
connectivity->tree_to_tree[index*GeometryInfo<dim>::faces_per_cell + f]
= coarse_cell_to_p4est_tree_permutation[cell->index()];
- // fill tree_to_face, which is
- // essentially neighbor_to_neighbor;
- // however, we have to remap the
- // resulting face number as well
+ // fill tree_to_face, which is essentially neighbor_to_neighbor;
+ // however, we have to remap the resulting face number as well
for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
if (cell->face(f)->at_boundary() == false)
{
case 3:
{
/*
- * The values for
- * tree_to_face are in
- * 0..23 where ttf % 6
- * gives the face
- * number and ttf / 6
- * the face orientation
- * code. The
- * orientation is
- * determined as
- * follows. Let
- * my_face and
- * other_face be the
- * two face numbers of
- * the connecting trees
- * in 0..5. Then the
- * first face vertex of
- * the lower of my_face
- * and other_face
- * connects to a face
- * vertex numbered 0..3
- * in the higher of
- * my_face and
- * other_face. The
- * face orientation is
- * defined as this
- * number. If my_face
- * == other_face,
- * treating either of
- * both faces as the
- * lower one leads to
- * the same result.
+ * The values for tree_to_face are in 0..23 where ttf % 6
+ * gives the face number and ttf / 6 the face orientation
+ * code. The orientation is determined as follows. Let
+ * my_face and other_face be the two face numbers of the
+ * connecting trees in 0..5. Then the first face vertex of
+ * the lower of my_face and other_face connects to a face
+ * vertex numbered 0..3 in the higher of my_face and
+ * other_face. The face orientation is defined as this
+ * number. If my_face == other_face, treating either of
+ * both faces as the lower one leads to the same result.
*/
connectivity->tree_to_face[index*6 + f]
unsigned int v = 0;
- // global vertex index of
- // vertex 0 on face of
- // cell with smaller
- // local face index
+ // global vertex index of vertex 0 on face of cell with
+ // smaller local face index
unsigned int g_idx =
cell_list[smaller_idx]->vertex_index(
GeometryInfo<dim>::face_to_cell_vertices(
cell_list[smaller_idx]->face_rotation(face_idx_list[smaller_idx]))
);
- // loop over vertices on
- // face from other cell
- // and compare global
- // vertex numbers
+ // loop over vertices on face from other cell and compare
+ // global vertex numbers
for (unsigned int i=0; i<GeometryInfo<dim>::vertices_per_face; ++i)
{
unsigned int idx
const typename internal::p4est::types<dim>::forest &forest,
const types::subdomain_id my_subdomain)
{
- // check if this cell exists in
- // the local p4est cell
+ // check if this cell exists in the local p4est cell
if (sc_array_bsearch(const_cast<sc_array_t *>(&tree.quadrants),
&p4est_cell,
internal::p4est::functions<dim>::quadrant_compare)
}
else
{
- // no, cell not found in
- // local part of
- // p4est. this means that
- // the local part is more
- // refined than the current
- // cell. if this cell has
- // no children of its own,
- // we need to refine it,
- // and if it does already
- // have children then loop
- // over all children and
- // see if they are locally
- // available as well
+ // no, cell not found in local part of p4est. this means that the
+ // local part is more refined than the current cell. if this cell has
+ // no children of its own, we need to refine it, and if it does
+ // already have children then loop over all children and see if they
+ // are locally available as well
if (dealii_cell->has_children () == false)
dealii_cell->set_refine_flag ();
else
&p4est_child[c])
== false)
{
- // no, this child
- // is locally not
- // available in
- // the p4est.
- // delete all
- // its children
- // but, because this
- // may not be successfull,
- // make sure to mark all
- // children recursively as
- // not local.
+ // no, this child is locally not available in the p4est.
+ // delete all its children but, because this may not be
+ // successfull, make sure to mark all children recursively
+ // as not local.
delete_all_children<dim,spacedim> (dealii_cell->child(c));
dealii_cell->child(c)
->recursively_set_subdomain_id(numbers::artificial_subdomain_id);
}
else
{
- // at least some
- // part of the
- // tree rooted in
- // this child is
- // locally
- // available
+ // at least some part of the tree rooted in this child is
+ // locally available
match_tree_recursively<dim,spacedim> (tree,
dealii_cell->child(c),
p4est_child[c],
template <int dim, int spacedim>
void
- match_quadrant_recursively (const typename internal::p4est::types<dim>::quadrant &this_quadrant,
- const typename Triangulation<dim,spacedim>::cell_iterator &dealii_cell,
- const typename internal::p4est::types<dim>::quadrant &ghost_quadrant,
- const typename internal::p4est::types<dim>::forest &forest,
- unsigned int ghost_owner)
+ match_quadrant (const dealii::Triangulation<dim,spacedim> *tria,
+ unsigned int dealii_index,
+ typename internal::p4est::types<dim>::quadrant &ghost_quadrant,
+ unsigned int ghost_owner)
{
- if (internal::p4est::functions<dim>::quadrant_is_equal(&this_quadrant, &ghost_quadrant))
- {
- // this is the ghostcell
+ int i, child_id;
+ int l = ghost_quadrant.level;
- if (dealii_cell->has_children())
- delete_all_children<dim,spacedim> (dealii_cell);
- else
+ for (i = 0; i < l; i++)
+ {
+ typename Triangulation<dim,spacedim>::cell_iterator cell (tria, i, dealii_index);
+ if (cell->has_children () == false)
{
- dealii_cell->clear_coarsen_flag();
- dealii_cell->set_subdomain_id(ghost_owner);
+ cell->clear_coarsen_flag();
+ cell->set_refine_flag ();
+ return;
}
- return;
- }
- if (! internal::p4est::functions<dim>::quadrant_is_ancestor ( &this_quadrant, &ghost_quadrant))
- {
- return;
- }
-
- if (dealii_cell->has_children () == false)
- {
- dealii_cell->clear_coarsen_flag();
- dealii_cell->set_refine_flag ();
- return;
+ child_id = internal::p4est::functions<dim>::quadrant_ancestor_id (&ghost_quadrant, i + 1);
+ dealii_index = cell->child_index(child_id);
}
- typename internal::p4est::types<dim>::quadrant
- p4est_child[GeometryInfo<dim>::max_children_per_cell];
- for (unsigned int c=0;
- c<GeometryInfo<dim>::max_children_per_cell; ++c)
- switch (dim)
- {
- case 2:
- P4EST_QUADRANT_INIT(&p4est_child[c]);
- break;
- case 3:
- P8EST_QUADRANT_INIT(&p4est_child[c]);
- break;
- default:
- Assert (false, ExcNotImplemented());
- }
-
-
- internal::p4est::functions<dim>::
- quadrant_childrenv (&this_quadrant, p4est_child);
-
- for (unsigned int c=0;
- c<GeometryInfo<dim>::max_children_per_cell; ++c)
-
+ typename Triangulation<dim,spacedim>::cell_iterator cell (tria, l, dealii_index);
+ if (cell->has_children())
+ delete_all_children<dim,spacedim> (cell);
+ else
{
- match_quadrant_recursively<dim,spacedim> (p4est_child[c], dealii_cell->child(c), ghost_quadrant, forest, ghost_owner);
+ cell->clear_coarsen_flag();
+ cell->set_subdomain_id(ghost_owner);
}
-
-
}
{
//this cell got refined
- //attach to the first child, because
- // we can only attach to active
+ //attach to the first child, because we can only attach to active
// quadrants
typename internal::p4est::types<dim>::quadrant
p4est_child[GeometryInfo<dim>::max_children_per_cell];
}
else
{
- //it's children got coarsened into
- //this cell
+ //it's children got coarsened into this cell
typename internal::p4est::types<dim>::quadrant *q;
q = static_cast<typename internal::p4est::types<dim>::quadrant *> (
sc_array_index (const_cast<sc_array_t *>(&tree.quadrants), idx)
quadrant_overlaps_tree (const_cast<typename internal::p4est::types<dim>::tree *>(&tree),
&p4est_cell)
== false))
- // this quadrant and none of
- // it's children belong to us.
+ // this quadrant and none of it's children belong to us.
return;
void *ptr = static_cast<char *>(q->p.user_data) + offset;
typename parallel::distributed::Triangulation<dim,spacedim>::CellStatus
status = * static_cast<
- typename parallel::distributed::Triangulation<dim,spacedim>::CellStatus*
+ typename parallel::distributed::Triangulation<dim,spacedim>::CellStatus *
>(q->p.user_data);
switch (status)
{
/**
- * A data structure that we use to store
- * which cells (indicated by
- * internal::p4est::types<dim>::quadrant objects) shall be
- * refined and which shall be coarsened.
+ * A data structure that we use to store which cells (indicated by
+ * internal::p4est::types<dim>::quadrant objects) shall be refined and which
+ * shall be coarsened.
*/
template <int dim, int spacedim>
class RefineAndCoarsenList
typename internal::p4est::types<dim>::forest &forest);
/**
- * A callback function that we
- * pass to the p4est data
- * structures when a forest is
- * to be refined. The p4est
- * functions call it back with
- * a tree (the index of the
- * tree that grows out of a
- * given coarse cell) and a
- * refinement path from that
- * coarse cell to a
- * terminal/leaf cell. The
- * function returns whether the
- * corresponding cell in the
- * deal.II triangulation has
- * the refined flag set.
+ * A callback function that we pass to the p4est data structures when a
+ * forest is to be refined. The p4est functions call it back with a tree
+ * (the index of the tree that grows out of a given coarse cell) and a
+ * refinement path from that coarse cell to a terminal/leaf cell. The
+ * function returns whether the corresponding cell in the deal.II
+ * triangulation has the refined flag set.
*/
static
int
typename internal::p4est::types<dim>::quadrant *quadrant);
/**
- * Same as the refine_callback
- * function, but return whether
- * all four of the given
- * children of a non-terminal
- * cell are to be coarsened
- * away.
+ * Same as the refine_callback function, but return whether all four of
+ * the given children of a non-terminal cell are to be coarsened away.
*/
static
int
template <int dim, int spacedim>
RefineAndCoarsenList<dim,spacedim>::
RefineAndCoarsenList (const Triangulation<dim,spacedim> &triangulation,
- const std::vector<types::global_dof_index> &p4est_tree_to_coarse_cell_permutation,
- const types::subdomain_id my_subdomain,
+ const std::vector<types::global_dof_index> &p4est_tree_to_coarse_cell_permutation,
+ const types::subdomain_id my_subdomain,
typename internal::p4est::types<dim>::forest &forest)
:
forest(forest)
{
- // count how many flags are set and
- // allocate that much memory
+ // count how many flags are set and allocate that much memory
unsigned int n_refine_flags = 0,
n_coarsen_flags = 0;
for (typename Triangulation<dim,spacedim>::active_cell_iterator
coarsen_list.reserve (n_coarsen_flags);
- // now build the lists of cells that
- // are flagged. note that p4est will
- // traverse its cells in the order in
- // which trees appear in the
- // forest. this order is not the same
- // as the order of coarse cells in the
- // deal.II Triangulation because we
- // have translated everything by the
- // coarse_cell_to_p4est_tree_permutation
- // permutation. in order to make sure
- // that the output array is already in
- // the correct order, traverse our
- // coarse cells in the same order in
- // which p4est will:
+ // now build the lists of cells that are flagged. note that p4est will
+ // traverse its cells in the order in which trees appear in the
+ // forest. this order is not the same as the order of coarse cells in the
+ // deal.II Triangulation because we have translated everything by the
+ // coarse_cell_to_p4est_tree_permutation permutation. in order to make
+ // sure that the output array is already in the correct order, traverse
+ // our coarse cells in the same order in which p4est will:
for (unsigned int c=0; c<triangulation.n_cells(0); ++c)
{
unsigned int coarse_cell_index =
Assert(coarsen_list.size() == n_coarsen_flags,
ExcInternalError());
- // make sure that our ordering in fact
- // worked
+ // make sure that our ordering in fact worked
for (unsigned int i=1; i<refine_list.size(); ++i)
Assert (refine_list[i].p.which_tree >=
refine_list[i-1].p.which_tree,
RefineAndCoarsenList<dim,spacedim> *this_object
= reinterpret_cast<RefineAndCoarsenList<dim,spacedim>*>(forest->user_pointer);
- // if there are no more cells in our
- // list the current cell can't be
+ // if there are no more cells in our list the current cell can't be
// flagged for refinement
if (this_object->current_refine_pointer == this_object->refine_list.end())
return false;
this_object->current_refine_pointer->p.which_tree,
ExcInternalError());
- // if p4est hasn't yet reached the tree
- // of the next flagged cell the current
- // cell can't be flagged for refinement
+ // if p4est hasn't yet reached the tree of the next flagged cell the
+ // current cell can't be flagged for refinement
if (coarse_cell_index <
this_object->current_refine_pointer->p.which_tree)
return false;
- // now we're in the right tree in the
- // forest
+ // now we're in the right tree in the forest
Assert (coarse_cell_index <=
this_object->current_refine_pointer->p.which_tree,
ExcInternalError());
- // make sure that the p4est loop over
- // cells hasn't gotten ahead of our own
+ // make sure that the p4est loop over cells hasn't gotten ahead of our own
// pointer
Assert (internal::p4est::functions<dim>::
quadrant_compare (quadrant,
&*this_object->current_refine_pointer) <= 0,
ExcInternalError());
- // now, if the p4est cell is one in the
- // list, it is supposed to be refined
+ // now, if the p4est cell is one in the list, it is supposed to be refined
if (internal::p4est::functions<dim>::
quadrant_is_equal (quadrant, &*this_object->current_refine_pointer))
{
RefineAndCoarsenList<dim,spacedim> *this_object
= reinterpret_cast<RefineAndCoarsenList<dim,spacedim>*>(forest->user_pointer);
- // if there are no more cells in our
- // list the current cell can't be
+ // if there are no more cells in our list the current cell can't be
// flagged for coarsening
if (this_object->current_coarsen_pointer ==
this_object->coarsen_list.end())
this_object->current_coarsen_pointer->p.which_tree,
ExcInternalError());
- // if p4est hasn't yet reached the tree
- // of the next flagged cell the current
- // cell can't be flagged for coarsening
+ // if p4est hasn't yet reached the tree of the next flagged cell the
+ // current cell can't be flagged for coarsening
if (coarse_cell_index <
this_object->current_coarsen_pointer->p.which_tree)
return false;
- // now we're in the right tree in the
- // forest
+ // now we're in the right tree in the forest
Assert (coarse_cell_index <=
this_object->current_coarsen_pointer->p.which_tree,
ExcInternalError());
- // make sure that the p4est loop over
- // cells hasn't gotten ahead of our own
+ // make sure that the p4est loop over cells hasn't gotten ahead of our own
// pointer
Assert (internal::p4est::functions<dim>::
quadrant_compare (children[0],
&*this_object->current_coarsen_pointer) <= 0,
ExcInternalError());
- // now, if the p4est cell is one in the
- // list, it is supposed to be coarsened
+ // now, if the p4est cell is one in the list, it is supposed to be
+ // coarsened
if (internal::p4est::functions<dim>::
quadrant_is_equal (children[0],
&*this_object->current_coarsen_pointer))
// move current pointer one up
++this_object->current_coarsen_pointer;
- // note that the next 3 cells in
- // our list need to correspond to
- // the other siblings of the cell
- // we have just found
+ // note that the next 3 cells in our list need to correspond to the
+ // other siblings of the cell we have just found
for (unsigned int c=1; c<GeometryInfo<dim>::max_children_per_cell; ++c)
{
Assert (internal::p4est::functions<dim>::
{
Singleton ()
{
- // ensure that the
- // initialization
- // code is run only
- // once, even if we
- // link with 1d, 2d,
- // and 3d libraries
+ // ensure that the initialization code is run only once, even if we
+ // link with 1d, 2d, and 3d libraries
static bool initialized = false;
if (initialized == false)
if (deinitialized == false)
{
- // p4est has no
- // p4est_finalize
- // function
+ // p4est has no p4est_finalize function
sc_finalize ();
deinitialized = true;
};
public:
- // do run the initialization code, at least the first time around we
- // get to this function
+ // do run the initialization code, at least the first time around we get
+ // to this function
static void do_initialize ()
{
static Singleton singleton;
const typename dealii::Triangulation<dim,spacedim>::MeshSmoothing smooth_grid,
const Settings settings_)
:
- // do not check
- // for distorted
- // cells
+ // do not check for distorted cells
dealii::Triangulation<dim,spacedim>
(smooth_grid,
false),
n_attached_datas(0),
n_attached_deserialize(0)
{
- // initialize p4est. do this in a separate function since it has
- // to happen only once, even if we have triangulation objects
- // for several different space dimensions
+ // initialize p4est. do this in a separate function since it has to
+ // happen only once, even if we have triangulation objects for several
+ // different space dimensions
dealii::internal::p4est::InitFinalize::do_initialize ();
+ parallel_ghost = 0;
+
number_cache.n_locally_owned_active_cells
.resize (Utilities::MPI::n_mpi_processes (mpi_communicator));
}
Assert (parallel_forest == 0, ExcInternalError());
Assert (refinement_in_progress == false, ExcInternalError());
- // get rid of the unique
- // communicator used here again
+ // get rid of the unique communicator used here again
MPI_Comm_free (&mpi_communicator);
}
}
catch (const typename dealii::Triangulation<dim,spacedim>::DistortedCellList &)
{
- // the underlying
- // triangulation should not
- // be checking for
- // distorted cells
+ // the underlying triangulation should not be checking for distorted
+ // cells
AssertThrow (false, ExcInternalError());
}
- // note that now we have some content in
- // the p4est objects and call the
- // functions that do the actual work
- // (which are dimension dependent, so
+ // note that now we have some content in the p4est objects and call the
+ // functions that do the actual work (which are dimension dependent, so
// separate)
triangulation_has_content = true;
}
catch (const typename Triangulation<dim>::DistortedCellList &)
{
- // the underlying
- // triangulation should not
- // be checking for
- // distorted cells
+ // the underlying triangulation should not be checking for distorted
+ // cells
AssertThrow (false, ExcInternalError());
}
{
triangulation_has_content = false;
+ if (parallel_ghost != 0)
+ {
+ dealii::internal::p4est::functions<dim>::ghost_destroy (parallel_ghost);
+ parallel_ghost = 0;
+ }
+
if (parallel_forest != 0)
{
dealii::internal::p4est::functions<dim>::destroy (parallel_forest);
Triangulation<dim,spacedim>::
load(const char *filename)
{
+ if (parallel_ghost != 0) {
+ dealii::internal::p4est::functions<dim>::ghost_destroy (parallel_ghost);
+ parallel_ghost = 0;
+ }
dealii::internal::p4est::functions<dim>::destroy (parallel_forest);
parallel_forest = 0;
dealii::internal::p4est::functions<dim>::connectivity_destroy (connectivity);
Assert (this->n_cells(0) > 0, ExcInternalError());
Assert (this->n_levels() == 1, ExcInternalError());
- // data structures that counts how many
- // cells touch each vertex
- // (vertex_touch_count), and which cells
- // touch a given vertex (together with
- // the local numbering of that vertex
- // within the cells that touch it)
+ // data structures that counts how many cells touch each vertex
+ // (vertex_touch_count), and which cells touch a given vertex (together
+ // with the local numbering of that vertex within the cells that touch
+ // it)
std::vector<unsigned int> vertex_touch_count;
std::vector<
std::list<
vertex_touch_count.end(),
0);
- // now create a connectivity
- // object with the right sizes
- // for all arrays. set vertex
- // information only in debug
- // mode (saves a few bytes in
- // optimized mode)
+ // now create a connectivity object with the right sizes for all
+ // arrays. set vertex information only in debug mode (saves a few bytes
+ // in optimized mode)
const bool set_vertex_info
#ifdef DEBUG
= true
Assert (p4est_connectivity_is_valid (connectivity) == 1,
ExcInternalError());
- // now create a forest out of the
- // connectivity data structure
+ // now create a forest out of the connectivity data structure
parallel_forest
= dealii::internal::p4est::functions<2>::
new_forest (mpi_communicator,
- // TODO: This is a verbatim copy of the 2,2
- // case. However, we can't just specialize the
- // dim template argument, but let spacedim open
+ // TODO: This is a verbatim copy of the 2,2 case. However, we can't just
+ // specialize the dim template argument, but let spacedim open
template <>
void
Triangulation<2,3>::copy_new_triangulation_to_p4est (dealii::internal::int2type<2>)
Assert (this->n_cells(0) > 0, ExcInternalError());
Assert (this->n_levels() == 1, ExcInternalError());
- // data structures that counts how many
- // cells touch each vertex
- // (vertex_touch_count), and which cells
- // touch a given vertex (together with
- // the local numbering of that vertex
- // within the cells that touch it)
+ // data structures that counts how many cells touch each vertex
+ // (vertex_touch_count), and which cells touch a given vertex (together
+ // with the local numbering of that vertex within the cells that touch
+ // it)
std::vector<unsigned int> vertex_touch_count;
std::vector<
std::list<
vertex_touch_count.end(),
0);
- // now create a connectivity
- // object with the right sizes
- // for all arrays. set vertex
- // information only in debug
- // mode (saves a few bytes in
- // optimized mode)
+ // now create a connectivity object with the right sizes for all
+ // arrays. set vertex information only in debug mode (saves a few bytes
+ // in optimized mode)
const bool set_vertex_info
#ifdef DEBUG
= true
Assert (p4est_connectivity_is_valid (connectivity) == 1,
ExcInternalError());
- // now create a forest out of the
- // connectivity data structure
+ // now create a forest out of the connectivity data structure
parallel_forest
= dealii::internal::p4est::functions<2>::
new_forest (mpi_communicator,
Assert (this->n_cells(0) > 0, ExcInternalError());
Assert (this->n_levels() == 1, ExcInternalError());
- // data structures that counts how many
- // cells touch each vertex
- // (vertex_touch_count), and which cells
- // touch a given vertex (together with
- // the local numbering of that vertex
- // within the cells that touch it)
+ // data structures that counts how many cells touch each vertex
+ // (vertex_touch_count), and which cells touch a given vertex (together
+ // with the local numbering of that vertex within the cells that touch
+ // it)
std::vector<unsigned int> vertex_touch_count;
std::vector<
std::list<
num_ett = std::accumulate (edge_touch_count.begin(),
edge_touch_count.end(),
0);
- // now create a connectivity object with
- // the right sizes for all arrays
-
+
+ // now create a connectivity object with the right sizes for all arrays
const bool set_vertex_info
#ifdef DEBUG
= true
Assert (p8est_connectivity_is_valid (connectivity) == 1,
ExcInternalError());
- // now create a forest out of the
- // connectivity data structure
+ // now create a forest out of the connectivity data structure
parallel_forest
= dealii::internal::p4est::functions<3>::
new_forest (mpi_communicator,
void
Triangulation<dim,spacedim>::copy_local_forest_to_triangulation ()
{
- // disable mesh smoothing for
- // recreating the deal.II
- // triangulation, otherwise we might
- // not be able to reproduce the p4est
- // mesh exactly. We restore the
- // original smoothing at the end of
- // this function. Note that the
- // smoothing flag is used in the normal
+ // disable mesh smoothing for recreating the deal.II triangulation,
+ // otherwise we might not be able to reproduce the p4est mesh
+ // exactly. We restore the original smoothing at the end of this
+ // function. Note that the smoothing flag is used in the normal
// refinement process.
typename Triangulation<dim,spacedim>::MeshSmoothing
- save_smooth = this->smooth_grid;
- this->smooth_grid = dealii::Triangulation<dim,spacedim>::none;
- bool mesh_changed = false;
+ save_smooth = this->smooth_grid;
+
+ // We will refine manually to match the p4est further down, which
+ // obeys a level difference of 2 at each vertex (see the balance call
+ // to p4est). We can disable this here so we store fewer artificial
+ // cells (in some cases). For geometric multigrid it turns out that
+ // we will miss level cells at shared vertices if we ignore this.
+ // See tests/mpi/mg_06.
+ if (settings & construct_multigrid_hierarchy)
+ this->smooth_grid = dealii::Triangulation<dim,spacedim>::limit_level_difference_at_vertices;
+ else
+ this->smooth_grid = dealii::Triangulation<dim,spacedim>::none;
+ bool mesh_changed = false;
// remove all deal.II refinements. Note that we could skip this and
// start from our current state, because the algorithm later coarsens as
}
catch (const typename Triangulation<dim, spacedim>::DistortedCellList &)
{
- // the underlying
- // triangulation should not
- // be checking for
+ // the underlying triangulation should not be checking for
// distorted cells
AssertThrow (false, ExcInternalError());
}
// query p4est for the ghost cells
- typename dealii::internal::p4est::types<dim>::ghost *ghostlayer;
- ghostlayer = dealii::internal::p4est::functions<dim>::ghost_new (parallel_forest,
+ if (parallel_ghost != 0)
+ {
+ dealii::internal::p4est::functions<dim>::ghost_destroy (parallel_ghost);
+ parallel_ghost = 0;
+ }
+ parallel_ghost = dealii::internal::p4est::functions<dim>::ghost_new (parallel_forest,
(dim == 2
?
typename dealii::internal::p4est::types<dim>::
- balance_type(P4EST_BALANCE_CORNER)
+ balance_type(P4EST_CONNECT_CORNER)
:
typename dealii::internal::p4est::types<dim>::
- balance_type(P8EST_BALANCE_CORNER)));
+ balance_type(P8EST_CONNECT_CORNER)));
- Assert (ghostlayer, ExcInternalError());
+ Assert (parallel_ghost, ExcInternalError());
// set all cells to artificial. we will later set it to the correct
cell != this->end(0);
++cell)
{
- // if this processor
- // stores no part of the
- // forest that comes out
- // of this coarse grid
- // cell, then we need to
- // delete all children of
- // this cell (the coarse
- // grid cell remains)
+ // if this processor stores no part of the forest that comes out
+ // of this coarse grid cell, then we need to delete all children
+ // of this cell (the coarse grid cell remains)
if (tree_exists_locally<dim,spacedim>(parallel_forest,
coarse_cell_to_p4est_tree_permutation[cell->index()])
== false)
else
{
-
- // this processor
- // stores at least a
- // part of the tree
- // that comes out of
- // this cell.
-
+ // this processor stores at least a part of the tree that
+ // comes out of this cell.
typename dealii::internal::p4est::types<dim>::quadrant p4est_coarse_cell;
typename dealii::internal::p4est::types<dim>::tree *tree =
}
}
- // check mesh for ghostcells,
- // refine as necessary.
- // iterate over every ghostquadrant,
- // find corresponding deal coarsecell
- // and recurse.
+ // check mesh for ghostcells, refine as necessary. iterate over
+ // every ghostquadrant, find corresponding deal coarsecell and
+ // recurse.
typename dealii::internal::p4est::types<dim>::quadrant *quadr;
unsigned int ghost_owner=0;
+ typename dealii::internal::p4est::types<dim>::topidx ghost_tree=0;
- for (unsigned int g_idx=0; g_idx<ghostlayer->ghosts.elem_count; ++g_idx)
+ for (unsigned int g_idx=0; g_idx<parallel_ghost->ghosts.elem_count; ++g_idx)
{
- while (g_idx >= (unsigned int)ghostlayer->proc_offsets[ghost_owner+1])
+ while (g_idx >= (unsigned int)parallel_ghost->proc_offsets[ghost_owner+1])
++ghost_owner;
+ while (g_idx >= (unsigned int)parallel_ghost->tree_offsets[ghost_tree+1])
+ ++ghost_tree;
quadr = static_cast<typename dealii::internal::p4est::types<dim>::quadrant *>
- ( sc_array_index(&ghostlayer->ghosts, g_idx) );
+ ( sc_array_index(¶llel_ghost->ghosts, g_idx) );
unsigned int coarse_cell_index =
- p4est_tree_to_coarse_cell_permutation[quadr->p.piggy3.which_tree];
-
- const typename Triangulation<dim,spacedim>::cell_iterator
- cell (this, 0U, coarse_cell_index);
+ p4est_tree_to_coarse_cell_permutation[ghost_tree];
- typename dealii::internal::p4est::types<dim>::quadrant p4est_coarse_cell;
- dealii::internal::p4est::init_coarse_quadrant<dim> (p4est_coarse_cell);
-
- match_quadrant_recursively<dim,spacedim> (p4est_coarse_cell, cell, *quadr,
- *parallel_forest, ghost_owner);
+ match_quadrant<dim,spacedim> (this, coarse_cell_index, *quadr, ghost_owner);
}
- // fix all the flags to make
- // sure we have a consistent
- // mesh
+ // fix all the flags to make sure we have a consistent mesh
this->prepare_coarsening_and_refinement ();
// see if any flags are still set
break;
}
- // actually do the refinement
- // but prevent the refinement
- // hook below from taking
- // over
+ // actually do the refinement but prevent the refinement hook below
+ // from taking over
const bool saved_refinement_in_progress = refinement_in_progress;
refinement_in_progress = true;
}
catch (const typename Triangulation<dim,spacedim>::DistortedCellList &)
{
- // the underlying
- // triangulation should not
- // be checking for
+ // the underlying triangulation should not be checking for
// distorted cells
AssertThrow (false, ExcInternalError());
}
++num_ghosts;
}
- Assert( num_ghosts == ghostlayer->ghosts.elem_count, ExcInternalError());
+ Assert( num_ghosts == parallel_ghost->ghosts.elem_count, ExcInternalError());
#endif
// we need this information for all our ancestors and the same-level neighbors of our own cells (=level ghosts)
if (settings & construct_multigrid_hierarchy)
{
- // step 1: We set our own ids all the way down and all the others to -1. Note that we do not fill
- // other cells we could figure out the same way, because we might accidentally set an id for a
- // cell that is not a ghost cell.
+ // step 1: We set our own ids all the way down and all the others to
+ // -1. Note that we do not fill other cells we could figure out the
+ // same way, because we might accidentally set an id for a cell that
+ // is not a ghost cell.
for (unsigned int lvl=this->n_levels(); lvl>0;)
{
--lvl;
}
}
- //step 2: make sure all the neighbors to our level_cells exist. Need to look up in p4est...
+ //step 2: make sure all the neighbors to our level_cells exist. Need
+ //to look up in p4est...
std::vector<std::vector<bool> > marked_vertices(this->n_levels());
for (unsigned int lvl=0; lvl<this->n_levels(); ++lvl)
{
if (cell->child(c)->level_subdomain_id()==this->locally_owned_subdomain())
{
- //at least one of the children belongs to us, so make sure we set the level subdomain id
+ //at least one of the children belongs to us, so
+ //make sure we set the level subdomain id
types::subdomain_id mark = numbers::artificial_subdomain_id;
mark = cell->child(0)->level_subdomain_id();
Assert(mark != numbers::artificial_subdomain_id, ExcInternalError()); //we should know the child(0)
}
}
+ //step 4: Special case: on each level we need all the face neighbors
+ // of our own level cells these are normally on the same level,
+ // unless the neighbor is active and coarser. It can end up on a
+ // different processor. Luckily, the level_subdomain_id can be
+ // figured out without communication, because the cell is active
+ // (and so level_subdomain_id=subdomain_id):
+ for (typename Triangulation<dim,spacedim>::cell_iterator cell = this->begin(); cell!=this->end(); ++cell)
+ {
+ if (cell->level_subdomain_id()!=this->locally_owned_subdomain())
+ continue;
+ for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
+ {
+ if (cell->face(f)->at_boundary())
+ continue;
+ if (cell->neighbor(f)->level() < cell->level()
+ &&
+ cell->neighbor(f)->level_subdomain_id()!=this->locally_owned_subdomain())
+ {
+ Assert(cell->neighbor(f)->active(), ExcInternalError());
+ Assert(cell->neighbor(f)->subdomain_id() != numbers::artificial_subdomain_id, ExcInternalError());
+ Assert(cell->neighbor(f)->level_subdomain_id() == numbers::artificial_subdomain_id
+ || cell->neighbor(f)->level_subdomain_id() == cell->neighbor(f)->subdomain_id(), ExcInternalError());
+ cell->neighbor(f)->set_level_subdomain_id(cell->neighbor(f)->subdomain_id());
+ }
+ }
+
+ }
}
- // check that our local copy has
- // exactly as many cells as the
- // p4est original (at least if we
- // are on only one processor);
- // for parallel computations, we
- // want to check that we have at
- // least as many as p4est stores
- // locally (in the future we
- // should check that we have
- // exactly as many non-artificial
- // cells as
- // parallel_forest->local_num_quadrants)
+ // check that our local copy has exactly as many cells as the p4est
+ // original (at least if we are on only one processor); for parallel
+ // computations, we want to check that we have at least as many as p4est
+ // stores locally (in the future we should check that we have exactly as
+ // many non-artificial cells as parallel_forest->local_num_quadrants)
{
const unsigned int total_local_cells = this->n_active_cells();
total_local_cells,
ExcInternalError());
- // count the number of owned, active
- // cells and compare with p4est.
+ // count the number of owned, active cells and compare with p4est.
unsigned int n_owned = 0;
for (typename Triangulation<dim,spacedim>::active_cell_iterator
cell = this->begin_active();
}
- dealii::internal::p4est::functions<dim>::ghost_destroy (ghostlayer);
-
this->smooth_grid = save_smooth;
}
void
Triangulation<dim, spacedim>::execute_coarsening_and_refinement ()
{
- // first make sure that recursive
- // calls are handled correctly
+ // first make sure that recursive calls are handled correctly
if (refinement_in_progress == true)
{
dealii::Triangulation<dim,spacedim>::execute_coarsening_and_refinement ();
// do not allow anisotropic refinement
#ifdef DEBUG
for (typename Triangulation<dim,spacedim>::active_cell_iterator
- cell = this->begin_active();
- cell != this->end(); ++cell)
- if (cell->is_locally_owned() && cell->refine_flag_set())
- Assert (cell->refine_flag_set() ==
- RefinementPossibilities<dim>::isotropic_refinement,
- ExcMessage ("This class does not support anisotropic refinement"));
+ cell = this->begin_active();
+ cell != this->end(); ++cell)
+ if (cell->is_locally_owned() && cell->refine_flag_set())
+ Assert (cell->refine_flag_set() ==
+ RefinementPossibilities<dim>::isotropic_refinement,
+ ExcMessage ("This class does not support anisotropic refinement"));
#endif
if (this->n_levels()==dealii::internal::p4est::functions<dim>::max_level)
{
for (typename Triangulation<dim,spacedim>::active_cell_iterator
- cell = this->begin_active(dealii::internal::p4est::functions<dim>::max_level-1);
- cell != this->end(dealii::internal::p4est::functions<dim>::max_level-1); ++cell)
+ cell = this->begin_active(dealii::internal::p4est::functions<dim>::max_level-1);
+ cell != this->end(dealii::internal::p4est::functions<dim>::max_level-1); ++cell)
{
AssertThrow(!(cell->refine_flag_set()),
- ExcMessage("Fatal Error: maximum refinement level of p4est reached."));
+ ExcMessage("Fatal Error: maximum refinement level of p4est reached."));
}
}
- // now do the work we're
- // supposed to do when we are
- // in charge
+ // now do the work we're supposed to do when we are in charge
refinement_in_progress = true;
this->prepare_coarsening_and_refinement ();
- // make sure all flags are
- // cleared on cells we don't
- // own, since nothing good can
- // come of that if they are
- // still around
+ // make sure all flags are cleared on cells we don't own, since nothing
+ // good can come of that if they are still around
for (typename Triangulation<dim,spacedim>::active_cell_iterator
cell = this->begin_active();
cell != this->end(); ++cell)
}
- // count how many cells will be refined
- // and coarsened, and allocate that much
- // memory
+ // count how many cells will be refined and coarsened, and allocate that
+ // much memory
RefineAndCoarsenList<dim,spacedim>
refine_and_coarsen_list (*this,
p4est_tree_to_coarse_cell_permutation,
my_subdomain,
*parallel_forest);
- // copy refine and coarsen flags into
- // p4est and execute the refinement and
- // coarsening. this uses the
- // refine_and_coarsen_list just built,
- // which is communicated to the callback
- // functions through the
+ // copy refine and coarsen flags into p4est and execute the refinement
+ // and coarsening. this uses the refine_and_coarsen_list just built,
+ // which is communicated to the callback functions through the
// user_pointer
Assert (parallel_forest->user_pointer == this,
ExcInternalError());
parallel_forest->user_pointer = &refine_and_coarsen_list;
+ if (parallel_ghost != 0)
+ {
+ dealii::internal::p4est::functions<dim>::ghost_destroy (parallel_ghost);
+ parallel_ghost = 0;
+ }
dealii::internal::p4est::functions<dim>::
refine (parallel_forest, /* refine_recursive */ false,
&RefineAndCoarsenList<dim,spacedim>::refine_callback,
&RefineAndCoarsenList<dim,spacedim>::coarsen_callback,
/*init_callback=*/NULL);
- // make sure all cells in the lists have
- // been consumed
+ // make sure all cells in the lists have been consumed
Assert (refine_and_coarsen_list.pointers_are_at_end(),
ExcInternalError());
(dim == 2
?
typename dealii::internal::p4est::types<dim>::
- balance_type(P4EST_BALANCE_FULL)
+ balance_type(P4EST_CONNECT_FULL)
:
typename dealii::internal::p4est::types<dim>::
- balance_type(P8EST_BALANCE_FULL)),
+ balance_type(P8EST_CONNECT_FULL)),
/*init_callback=*/NULL);
- // before repartitioning the mesh let
- // others attach mesh related info
- // (such as SolutionTransfer data) to
- // the p4est
+ // before repartitioning the mesh let others attach mesh related info
+ // (such as SolutionTransfer data) to the p4est
attach_mesh_data();
- // partition the new mesh between
- // all processors
+ // partition the new mesh between all processors
dealii::internal::p4est::functions<dim>::
partition (parallel_forest,
/* prepare coarsening */ 1,
/* weight_callback */ NULL);
- // finally copy back from local
- // part of tree to deal.II
- // triangulation. before doing
- // so, make sure there are no
- // refine or coarsen flags
- // pending
+ // finally copy back from local part of tree to deal.II
+ // triangulation. before doing so, make sure there are no refine or
+ // coarsen flags pending
for (typename Triangulation<dim,spacedim>::active_cell_iterator
cell = this->begin_active();
cell != this->end(); ++cell)
}
catch (const typename Triangulation<dim>::DistortedCellList &)
{
- // the underlying
- // triangulation should not
- // be checking for
- // distorted cells
+ // the underlying triangulation should not be checking for distorted
+ // cells
AssertThrow (false, ExcInternalError());
}
number_cache.n_global_active_cells
= std::accumulate (number_cache.n_locally_owned_active_cells.begin(),
number_cache.n_locally_owned_active_cells.end(),
- /* ensure sum is
- computed with
- correct data
- type:*/
+ /* ensure sum is computed with correct data type:*/
static_cast<types::global_dof_index>(0));
number_cache.n_global_levels = Utilities::MPI::max(this->n_levels(), mpi_communicator);
}
dealii::internal::p4est::init_coarse_quadrant<dim> (p4est_coarse_cell);
- // parent_cell is not correct here,
- // but is only used in a refined
+ // parent_cell is not correct here, but is only used in a refined
// cell
post_mesh_data_recursively<dim, spacedim> (*tree,
cell,
}
// important: only remove data if we are not in the deserialization
- // process. There, each SolutionTransfer registers and unpacks
- // before the next one does this, so n_attached_datas is only 1 here.
- // This would destroy the saved data before the second SolutionTransfer
- // can get it. This created a bug that is documented in
+ // process. There, each SolutionTransfer registers and unpacks before
+ // the next one does this, so n_attached_datas is only 1 here. This
+ // would destroy the saved data before the second SolutionTransfer can
+ // get it. This created a bug that is documented in
// tests/mpi/p4est_save_03 with more than one SolutionTransfer.
if (!n_attached_datas && n_attached_deserialize == 0)
{
return p4est_tree_to_coarse_cell_permutation;
}
+ namespace
+ {
+ /**
+ * This is the callback data structure used to fill
+ * vertices_with_ghost_neighbors via the p4est_iterate tool
+ */
+ template <int dim, int spacedim>
+ struct find_ghosts
+ {
+ typename dealii::parallel::distributed::Triangulation<dim,spacedim> *triangulation;
+ sc_array_t * subids;
+ std::map<unsigned int, std::set<dealii::types::subdomain_id> >
+ *vertices_with_ghost_neighbors;
+ };
+
+ /** At a corner (vertex), determine if any of the neighboring cells are
+ * ghosts. If there are, find out their subdomain ids, and if this is a
+ * local vertex, then add these subdomain ids to the map
+ * vertices_with_ghost_neighbors of that index
+ */
+ template <int dim, int spacedim>
+ void
+ find_ghosts_corner
+ (typename dealii::internal::p4est::iter<dim>::corner_info * info,
+ void *user_data)
+ {
+ int i, j;
+ int nsides = info->sides.elem_count;
+ typename dealii::internal::p4est::iter<dim>::corner_side * sides =
+ (typename dealii::internal::p4est::iter<dim>::corner_side *)
+ (info->sides.array);
+ struct find_ghosts<dim,spacedim> *fg = static_cast<struct find_ghosts<dim,spacedim> *>(user_data);
+ sc_array_t *subids = fg->subids;
+ typename dealii::parallel::distributed::Triangulation<dim,spacedim> *triangulation = fg->triangulation;
+ int nsubs;
+ dealii::types::subdomain_id *subdomain_ids;
+ std::map<unsigned int, std::set<dealii::types::subdomain_id> >
+ *vertices_with_ghost_neighbors = fg->vertices_with_ghost_neighbors;
+
+ subids->elem_count = 0;
+ for (i = 0; i < nsides; i++) {
+ if (sides[i].is_ghost) {
+ typename dealii::parallel::distributed::Triangulation<dim,spacedim>::cell_iterator cell = cell_from_quad (triangulation, sides[i].treeid, *(sides[i].quad));
+ Assert (cell->is_ghost(), ExcMessage ("ghost quad did not find ghost cell"));
+ dealii::types::subdomain_id *subid =
+ static_cast<dealii::types::subdomain_id *>(sc_array_push (subids));
+ *subid = cell->subdomain_id();
+ }
+ }
+
+ if (!subids->elem_count) {
+ return;
+ }
+
+ nsubs = (int) subids->elem_count;
+ subdomain_ids = (dealii::types::subdomain_id *) (subids->array);
+
+ for (i = 0; i < nsides; i++) {
+ if (!sides[i].is_ghost) {
+ typename dealii::parallel::distributed::Triangulation<dim,spacedim>::cell_iterator cell = cell_from_quad (triangulation, sides[i].treeid, *(sides[i].quad));
+
+ Assert (!cell->is_ghost(), ExcMessage ("local quad found ghost cell"));
+
+ for (j = 0; j < nsubs; j++) {
+ (*vertices_with_ghost_neighbors)[cell->vertex_index(sides[i].corner)]
+ .insert (subdomain_ids[j]);
+ }
+ }
+ }
+
+ subids->elem_count = 0;
+ }
+
+ /** Similar to find_ghosts_corner, but for the hanging vertex in the
+ * middle of an edge
+ */
+ template <int dim, int spacedim>
+ void
+ find_ghosts_edge
+ (typename dealii::internal::p4est::iter<dim>::edge_info * info,
+ void *user_data)
+ {
+ int i, j, k;
+ int nsides = info->sides.elem_count;
+ typename dealii::internal::p4est::iter<dim>::edge_side * sides =
+ (typename dealii::internal::p4est::iter<dim>::edge_side *)
+ (info->sides.array);
+ struct find_ghosts<dim,spacedim> *fg = static_cast<struct find_ghosts<dim,spacedim> *>(user_data);
+ sc_array_t *subids = fg->subids;
+ typename dealii::parallel::distributed::Triangulation<dim,spacedim> *triangulation = fg->triangulation;
+ int nsubs;
+ dealii::types::subdomain_id *subdomain_ids;
+ std::map<unsigned int, std::set<dealii::types::subdomain_id> >
+ *vertices_with_ghost_neighbors = fg->vertices_with_ghost_neighbors;
+
+ subids->elem_count = 0;
+ for (i = 0; i < nsides; i++) {
+ if (sides[i].is_hanging) {
+ for (j = 0; j < 2; j++) {
+ if (sides[i].is.hanging.is_ghost[j]) {
+ typename dealii::parallel::distributed::Triangulation<dim,spacedim>::cell_iterator cell = cell_from_quad (triangulation, sides[i].treeid, *(sides[i].is.hanging.quad[j]));
+ dealii::types::subdomain_id *subid =
+ static_cast<dealii::types::subdomain_id *>(sc_array_push (subids));
+ *subid = cell->subdomain_id();
+ }
+ }
+ }
+ }
+
+ if (!subids->elem_count) {
+ return;
+ }
+
+ nsubs = (int) subids->elem_count;
+ subdomain_ids = (dealii::types::subdomain_id *) (subids->array);
+
+ for (i = 0; i < nsides; i++) {
+ if (sides[i].is_hanging) {
+ for (j = 0; j < 2; j++) {
+ if (!sides[i].is.hanging.is_ghost[j]) {
+ typename dealii::parallel::distributed::Triangulation<dim,spacedim>::cell_iterator cell = cell_from_quad (triangulation, sides[i].treeid, *(sides[i].is.hanging.quad[j]));
+
+ for (k = 0; k < nsubs; k++) {
+ (*vertices_with_ghost_neighbors)[cell->vertex_index(p8est_edge_corners[sides[i].edge][1^j])]
+ .insert (subdomain_ids[k]);
+ }
+ }
+ }
+ }
+ }
+
+ subids->elem_count = 0;
+ }
+
+ /** Similar to find_ghosts_corner, but for the hanging vertex in the
+ * middle of a face
+ */
+ template <int dim, int spacedim>
+ void
+ find_ghosts_face
+ (typename dealii::internal::p4est::iter<dim>::face_info * info,
+ void *user_data)
+ {
+ int i, j, k;
+ int nsides = info->sides.elem_count;
+ typename dealii::internal::p4est::iter<dim>::face_side * sides =
+ (typename dealii::internal::p4est::iter<dim>::face_side *)
+ (info->sides.array);
+ struct find_ghosts<dim,spacedim> *fg = static_cast<struct find_ghosts<dim,spacedim> *>(user_data);
+ sc_array_t *subids = fg->subids;
+ typename dealii::parallel::distributed::Triangulation<dim,spacedim> *triangulation = fg->triangulation;
+ int nsubs;
+ dealii::types::subdomain_id *subdomain_ids;
+ std::map<unsigned int, std::set<dealii::types::subdomain_id> >
+ *vertices_with_ghost_neighbors = fg->vertices_with_ghost_neighbors;
+ int limit = (dim == 2) ? 2 : 4;
+
+ subids->elem_count = 0;
+ for (i = 0; i < nsides; i++) {
+ if (sides[i].is_hanging) {
+ for (j = 0; j < limit; j++) {
+ if (sides[i].is.hanging.is_ghost[j]) {
+ typename dealii::parallel::distributed::Triangulation<dim,spacedim>::cell_iterator cell = cell_from_quad (triangulation, sides[i].treeid, *(sides[i].is.hanging.quad[j]));
+ dealii::types::subdomain_id *subid =
+ static_cast<dealii::types::subdomain_id *>(sc_array_push (subids));
+ *subid = cell->subdomain_id();
+ }
+ }
+ }
+ }
+
+ if (!subids->elem_count) {
+ return;
+ }
+
+ nsubs = (int) subids->elem_count;
+ subdomain_ids = (dealii::types::subdomain_id *) (subids->array);
+
+ for (i = 0; i < nsides; i++) {
+ if (sides[i].is_hanging) {
+ for (j = 0; j < limit; j++) {
+ if (!sides[i].is.hanging.is_ghost[j]) {
+ typename dealii::parallel::distributed::Triangulation<dim,spacedim>::cell_iterator cell = cell_from_quad (triangulation, sides[i].treeid, *(sides[i].is.hanging.quad[j]));
+
+ for (k = 0; k < nsubs; k++) {
+ if (dim == 2) {
+ (*vertices_with_ghost_neighbors)[cell->vertex_index(p4est_face_corners[sides[i].face][(limit - 1)^j])]
+ .insert (subdomain_ids[k]);
+ }
+ else {
+ (*vertices_with_ghost_neighbors)[cell->vertex_index(p8est_face_corners[sides[i].face][(limit - 1)^j])]
+ .insert (subdomain_ids[k]);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ subids->elem_count = 0;
+ }
+ }
+
+ template <>
+ void
+ Triangulation<1,1>::
+ fill_vertices_with_ghost_neighbors
+ (std::map<unsigned int, std::set<dealii::types::subdomain_id> >
+ &vertices_with_ghost_neighbors)
+ {
+ Assert (false, ExcNotImplemented());
+ }
+ template <>
+ void
+ Triangulation<1,2>::
+ fill_vertices_with_ghost_neighbors
+ (std::map<unsigned int, std::set<dealii::types::subdomain_id> >
+ &vertices_with_ghost_neighbors)
+ {
+ Assert (false, ExcNotImplemented());
+ }
+
+ template <>
+ void
+ Triangulation<1,3>::
+ fill_vertices_with_ghost_neighbors
+ (std::map<unsigned int, std::set<dealii::types::subdomain_id> >
+ &vertices_with_ghost_neighbors)
+ {
+ Assert (false, ExcNotImplemented());
+ }
+
+ /**
+ * Determine the neighboring subdomains that are adjacent to each vertex.
+ * This is achieved via the p4est_iterate tool
+ */
+ template <>
+ void
+ Triangulation<2,2>::
+ fill_vertices_with_ghost_neighbors
+ (std::map<unsigned int, std::set<dealii::types::subdomain_id> >
+ &vertices_with_ghost_neighbors)
+ {
+ struct find_ghosts<2,2> fg;
+
+ fg.subids = sc_array_new (sizeof (dealii::types::subdomain_id));
+ fg.triangulation = this;
+ fg.vertices_with_ghost_neighbors = &(vertices_with_ghost_neighbors);
+
+ p4est_iterate (this->parallel_forest, this->parallel_ghost, static_cast<void *>(&fg),
+ NULL, find_ghosts_face<2,2>, find_ghosts_corner<2,2>);
+
+ sc_array_destroy (fg.subids);
+ }
+
+ /**
+ * Determine the neighboring subdomains that are adjacent to each vertex.
+ * This is achieved via the p4est_iterate tool
+ */
+ template <>
+ void
+ Triangulation<2,3>::
+ fill_vertices_with_ghost_neighbors
+ (std::map<unsigned int, std::set<dealii::types::subdomain_id> >
+ &vertices_with_ghost_neighbors)
+ {
+ struct find_ghosts<2,3> fg;
+
+ fg.subids = sc_array_new (sizeof (dealii::types::subdomain_id));
+ fg.triangulation = this;
+ fg.vertices_with_ghost_neighbors = &(vertices_with_ghost_neighbors);
+
+ p4est_iterate (this->parallel_forest, this->parallel_ghost, static_cast<void *>(&fg),
+ NULL, find_ghosts_face<2,3>, find_ghosts_corner<2,3>);
+
+ sc_array_destroy (fg.subids);
+ }
+
+ /**
+ * Determine the neighboring subdomains that are adjacent to each vertex.
+ * This is achieved via the p8est_iterate tool
+ */
+ template <>
+ void
+ Triangulation<3,3>::
+ fill_vertices_with_ghost_neighbors
+ (std::map<unsigned int, std::set<dealii::types::subdomain_id> >
+ &vertices_with_ghost_neighbors)
+ {
+ struct find_ghosts<3,3> fg;
+
+ fg.subids = sc_array_new (sizeof (dealii::types::subdomain_id));
+ fg.triangulation = this;
+ fg.vertices_with_ghost_neighbors = &(vertices_with_ghost_neighbors);
+
+ p8est_iterate (this->parallel_forest, this->parallel_ghost, static_cast<void *>(&fg),
+ NULL, find_ghosts_face<3,3>, find_ghosts_edge<3,3>, find_ghosts_corner<3,3>);
+
+ sc_array_destroy (fg.subids);
+ }
template <int dim, int spacedim>
MPI_Comm
return mpi_communicator;
}
+ template<int dim, int spacedim>
+ void
+ Triangulation<dim,spacedim>::add_periodicity
+ (const std::vector<GridTools::PeriodicFacePair<cell_iterator> >&
+ periodicity_vector)
+ {
+ #if DEAL_II_P4EST_VERSION_GTE(0,3,4,1)
+ Assert (triangulation_has_content == true,
+ ExcMessage ("The triangulation is empty!"));
+ Assert (this->n_levels() == 1,
+ ExcMessage ("The triangulation is refined!"));
+
+ typedef std::vector<GridTools::PeriodicFacePair<cell_iterator> >
+ FaceVector;
+ typename FaceVector::const_iterator it, periodic_end;
+ it = periodicity_vector.begin();
+ periodic_end = periodicity_vector.end();
+
+ for (; it<periodic_end; ++it)
+ {
+ const cell_iterator first_cell = it->cell[0];
+ const cell_iterator second_cell = it->cell[1];
+ const unsigned int face_left = it->face_idx[0];
+ const unsigned int face_right = it->face_idx[1];
+
+ //respective cells of the matching faces in p4est
+ const unsigned int tree_left
+ = coarse_cell_to_p4est_tree_permutation[std::distance(this->begin(),
+ first_cell)];
+ const unsigned int tree_right
+ = coarse_cell_to_p4est_tree_permutation[std::distance(this->begin(),
+ second_cell)];
+
+ //TODO Add support for non default orientation.
+ Assert(it->orientation == 1,
+ ExcMessage("Found a face match with non standard orientation. "
+ "This function is only suitable for meshes with "
+ "cells in default orientation"));
+
+ dealii::internal::p4est::functions<dim>::
+ connectivity_join_faces (connectivity,
+ tree_left,
+ tree_right,
+ face_left,
+ face_right,
+ /* orientation */ 0);
+
+ /* The orientation parameter above describes the difference between
+ * the cell on the left and the cell on the right would number of the
+ * corners of the face. In the periodic domains most users will want,
+ * this orientation will be 0, i.e. the two cells would number the
+ * corners the same way. More exotic periodicity, like moebius strips
+ * or converting an unstructured quad/hex mesh into a periodic domain,
+ * are not supported right now, and undefined behavior will occur if
+ * users try to make them periodic. This may be addressed at a later
+ * date.
+ */
+ }
+
+
+ Assert(dealii::internal::p4est::functions<dim>::connectivity_is_valid
+ (connectivity) == 1, ExcInternalError());
+
+ // now create a forest out of the connectivity data structure
+ dealii::internal::p4est::functions<dim>::destroy (parallel_forest);
+ parallel_forest
+ = dealii::internal::p4est::functions<dim>::
+ new_forest (mpi_communicator,
+ connectivity,
+ /* minimum initial number of quadrants per tree */ 0,
+ /* minimum level of upfront refinement */ 0,
+ /* use uniform upfront refinement */ 1,
+ /* user_data_size = */ 0,
+ /* user_data_constructor = */ NULL,
+ /* user_pointer */ this);
+
+
+ try
+ {
+ copy_local_forest_to_triangulation ();
+ }
+ catch (const typename Triangulation<dim>::DistortedCellList &)
+ {
+ // the underlying triangulation should not be checking for distorted
+ // cells
+ AssertThrow (false, ExcInternalError());
+ }
+
+ #else
+ Assert(false, ExcMessage ("Need p4est version >= 0.3.4.1!"));
+ #endif
+ }
+
+
+ template <int dim, int spacedim>
+ void
+ Triangulation<dim,spacedim>::add_periodicity
+ (const std::vector<std_cxx1x::tuple<cell_iterator, unsigned int,
+ cell_iterator, unsigned int> >&
+ periodicity_vector)
+ {
+#if DEAL_II_P4EST_VERSION_GTE(0,3,4,1)
+ typedef std::vector<std_cxx1x::tuple <cell_iterator, unsigned int,
+ cell_iterator, unsigned int> >
+ FaceVector;
+
+ typename FaceVector::const_iterator it, end_periodic;
+ it = periodicity_vector.begin();
+ end_periodic = periodicity_vector.end();
+
+ std::vector<GridTools::PeriodicFacePair<cell_iterator> > periodic_faces;
+
+ for(; it!=end_periodic; ++it)
+ {
+ const cell_iterator cell1 = std_cxx1x::get<0> (*it);
+ const cell_iterator cell2 = std_cxx1x::get<2> (*it);
+ const unsigned int face_idx1 = std_cxx1x::get<1> (*it);
+ const unsigned int face_idx2 = std_cxx1x::get<3> (*it);
+ const GridTools::PeriodicFacePair<cell_iterator> matched_face
+ = {{cell1, cell2},{face_idx1, face_idx2}, 1};
+ periodic_faces.push_back(matched_face);
+ }
+
+ add_periodicity(periodic_faces);
+#else
+ Assert(false, ExcMessage ("Need p4est version >= 0.3.4.1!"));
+#endif
+ }
template <int dim, int spacedim>
template <int dim, int spacedim>
void
Triangulation<dim,spacedim>::
- copy_triangulation (const dealii::Triangulation<dim, spacedim> &)
+ copy_triangulation (const dealii::Triangulation<dim, spacedim> &old_tria)
{
- Assert (false, ExcNotImplemented());
+ try
+ {
+ dealii::Triangulation<dim,spacedim>::
+ copy_triangulation (old_tria);
+ }
+ catch (const typename dealii::Triangulation<dim,spacedim>::DistortedCellList &)
+ {
+ // the underlying triangulation should not be checking for distorted
+ // cells
+ AssertThrow (false, ExcInternalError());
+ }
+
+ // note that now we have some content in the p4est objects and call the
+ // functions that do the actual work (which are dimension dependent, so
+ // separate)
+ triangulation_has_content = true;
+
+ Assert (old_tria.n_levels() == 1,
+ ExcMessage ("Parallel distributed triangulations can only be copied, "
+ "if they are not refined!"));
+
+ if (const dealii::parallel::distributed::Triangulation<dim,spacedim> *
+ old_tria_x = dynamic_cast<const dealii::parallel::distributed::Triangulation<dim,spacedim> *>(&old_tria))
+ {
+ Assert (!old_tria_x->refinement_in_progress,
+ ExcMessage ("Parallel distributed triangulations can only "
+ "be copied, if no refinement is in progress!"));
+
+ mpi_communicator = Utilities::MPI::duplicate_communicator (old_tria_x->get_communicator ());
+
+ coarse_cell_to_p4est_tree_permutation = old_tria_x->coarse_cell_to_p4est_tree_permutation;
+ p4est_tree_to_coarse_cell_permutation = old_tria_x->p4est_tree_to_coarse_cell_permutation;
+ attached_data_size = old_tria_x->attached_data_size;
+ n_attached_datas = old_tria_x->n_attached_datas;
+
+ settings = old_tria_x->settings;
+ }
+ else
+ {
+ setup_coarse_cell_to_p4est_tree_permutation ();
+ }
+
+ copy_new_triangulation_to_p4est (dealii::internal::int2type<dim>());
+
+ try
+ {
+ copy_local_forest_to_triangulation ();
+ }
+ catch (const typename Triangulation<dim>::DistortedCellList &)
+ {
+ // the underlying triangulation should not be checking for distorted
+ // cells
+ AssertThrow (false, ExcInternalError());
+ }
+
+ update_number_cache ();
}
Triangulation<dim,spacedim>::
attach_mesh_data()
{
- // determine size of memory in bytes to
- // attach to each cell. This needs to
- // be constant because of p4est.
+ // determine size of memory in bytes to attach to each cell. This needs
+ // to be constant because of p4est.
if (attached_data_size==0)
{
Assert(n_attached_datas==0, ExcInternalError());
}
}
+ template <int dim, int spacedim>
+ typename dealii::Triangulation<dim,spacedim>::cell_iterator
+ cell_from_quad
+ (typename dealii::parallel::distributed::Triangulation<dim,spacedim> *triangulation,
+ typename dealii::internal::p4est::types<dim>::topidx treeidx,
+ typename dealii::internal::p4est::types<dim>::quadrant &quad)
+ {
+ int i, l = quad.level;
+ int child_id;
+ const std::vector<types::global_dof_index> perm = triangulation->get_p4est_tree_to_coarse_cell_permutation ();
+ types::global_dof_index dealii_index = perm[treeidx];
+
+ for (i = 0; i < l; i++) {
+ typename dealii::Triangulation<dim,spacedim>::cell_iterator cell (triangulation, i, dealii_index);
+ child_id = internal::p4est::functions<dim>::quadrant_ancestor_id (&quad, i + 1);
+ Assert (cell->has_children (), ExcMessage ("p4est quadrant does not correspond to a cell!"));
+ dealii_index = cell->child_index(child_id);
+ }
+
+ typename dealii::Triangulation<dim,spacedim>::cell_iterator out_cell (triangulation, l, dealii_index);
+
+ return out_cell;
+ }
+
- // TODO: again problems with specialization in
- // only one template argument
+ // TODO: again problems with specialization in only one template argument
template <>
Triangulation<1,1>::Triangulation (MPI_Comm)
{
}
template <>
- const std::vector<unsigned int> &
+ const std::vector<types::global_dof_index> &
Triangulation<1,1>::get_p4est_tree_to_coarse_cell_permutation() const
{
- static std::vector<unsigned int> a;
+ static std::vector<types::global_dof_index> a;
return a;
}
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
-FILE(GLOB _header
- ${CMAKE_SOURCE_DIR}/include/deal.II/dofs/*.h
- )
-
SET(_src
block_info.cc
dof_accessor.cc
+ dof_accessor_get.cc
+ dof_accessor_set.cc
dof_faces.cc
dof_handler.cc
dof_handler_policy.cc
dof_objects.cc
dof_renumbering.cc
dof_tools.cc
+ dof_tools_constraints.cc
+ dof_tools_sparsity.cc
number_cache.cc
)
SET(_inst
block_info.inst.in
+ dof_accessor_get.inst.in
dof_accessor.inst.in
+ dof_accessor_set.inst.in
dof_handler.inst.in
dof_handler_policy.inst.in
dof_objects.inst.in
dof_renumbering.inst.in
+ dof_tools_constraints.inst.in
dof_tools.inst.in
+ dof_tools_sparsity.inst.in
+ )
+
+FILE(GLOB _header
+ ${CMAKE_SOURCE_DIR}/include/deal.II/dofs/*.h
)
DEAL_II_ADD_LIBRARY(obj_dofs OBJECT ${_src} ${_header} ${_inst})
EXPAND_INSTANTIATIONS(obj_dofs "${_inst}")
-
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/dofs/block_info.h>
#include <deal.II/dofs/dof_handler.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
{
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
-
-#include <deal.II/lac/vector.h>
-#include <deal.II/lac/block_vector.h>
-#include <deal.II/lac/parallel_vector.h>
-#include <deal.II/lac/parallel_block_vector.h>
-#include <deal.II/lac/petsc_vector.h>
-#include <deal.II/lac/petsc_block_vector.h>
-#include <deal.II/lac/trilinos_vector.h>
-#include <deal.II/lac/trilinos_block_vector.h>
-#include <deal.II/lac/sparse_matrix.h>
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/dofs/dof_accessor.h>
#include <deal.II/dofs/dof_handler.h>
-template <class DH, bool lda>
-template <class InputVector, typename number>
-void
-DoFCellAccessor<DH,lda>::
-get_interpolated_dof_values (const InputVector &values,
- Vector<number> &interpolated_values) const
-{
- const FiniteElement<dim,spacedim> &fe = this->get_fe();
- const unsigned int dofs_per_cell = fe.dofs_per_cell;
-
- Assert (this->dof_handler != 0,
- typename BaseClass::ExcInvalidObject());
- Assert (&fe != 0,
- typename BaseClass::ExcInvalidObject());
- Assert (interpolated_values.size() == dofs_per_cell,
- typename BaseClass::ExcVectorDoesNotMatch());
- Assert (values.size() == this->dof_handler->n_dofs(),
- typename BaseClass::ExcVectorDoesNotMatch());
-
- if (!this->has_children())
- // if this cell has no children: simply
- // return the exact values on this cell
- this->get_dof_values (values, interpolated_values);
- else
- // otherwise clobber them from the children
- {
- Vector<number> tmp1(dofs_per_cell);
- Vector<number> tmp2(dofs_per_cell);
-
- interpolated_values = 0;
-
- // later on we will have to
- // push the values interpolated
- // from the child to the mother
- // cell into the output
- // vector. unfortunately, there
- // are two types of elements:
- // ones where you add up the
- // contributions from the
- // different child cells, and
- // ones where you overwrite.
- //
- // an example for the first is
- // piecewise constant (and
- // discontinuous) elements,
- // where we build the value on
- // the coarse cell by averaging
- // the values from the cell
- // (i.e. by adding up a
- // fraction of the values of
- // their values)
- //
- // an example for the latter
- // are the usual continuous
- // elements. the value on a
- // vertex of a coarse cell must
- // there be the same,
- // irrespective of the adjacent
- // cell we are presently on. so
- // we always overwrite. in
- // fact, we must, since we
- // cannot know in advance how
- // many neighbors there will
- // be, so there is no way to
- // compute the average with
- // fixed factors
- //
- // so we have to find out to
- // which type this element
- // belongs. the difficulty is:
- // the finite element may be a
- // composed one, so we can only
- // hope to do this for each
- // shape function
- // individually. in fact, there
- // are even weird finite
- // elements (for example the
- // Raviart-Thomas element)
- // which have shape functions
- // that are additive (interior
- // ones) and others that are
- // overwriting (face degrees of
- // freedom that need to be
- // continuous across the
- // face). to avoid checking
- // this over and over again, we
- // do this once now and cache
- // the results
- std::vector<bool> restriction_is_additive (dofs_per_cell);
- for (unsigned int i=0; i<dofs_per_cell; ++i)
- restriction_is_additive[i] = fe.restriction_is_additive(i);
-
- for (unsigned int child=0; child<this->n_children(); ++child)
- {
- // get the values from the present
- // child, if necessary by
- // interpolation itself
- this->child(child)->get_interpolated_dof_values (values,
- tmp1);
- // interpolate these to the mother
- // cell
- fe.get_restriction_matrix(child, this->refinement_case()).vmult (tmp2, tmp1);
-
- // and add up or set them
- // in the output vector
- for (unsigned int i=0; i<dofs_per_cell; ++i)
- if (restriction_is_additive[i])
- interpolated_values(i) += tmp2(i);
- else if (tmp2(i) != number())
- interpolated_values(i) = tmp2(i);
- }
- }
-}
-
-
-
-template <class DH, bool lda>
-template <class OutputVector, typename number>
-void
-DoFCellAccessor<DH,lda>::
-set_dof_values_by_interpolation (const Vector<number> &local_values,
- OutputVector &values) const
-{
- const unsigned int dofs_per_cell = this->get_fe().dofs_per_cell;
-
- Assert (this->dof_handler != 0,
- typename BaseClass::ExcInvalidObject());
- Assert (&this->get_fe() != 0,
- typename BaseClass::ExcInvalidObject());
- Assert (local_values.size() == dofs_per_cell,
- typename BaseClass::ExcVectorDoesNotMatch());
- Assert (values.size() == this->dof_handler->n_dofs(),
- typename BaseClass::ExcVectorDoesNotMatch());
-
- if (!this->has_children())
- // if this cell has no children: simply
- // set the values on this cell
- this->set_dof_values (local_values, values);
- else
- // otherwise distribute them to the children
- {
- Vector<number> tmp(dofs_per_cell);
-
- for (unsigned int child=0; child<this->n_children(); ++child)
- {
- Assert (this->child(child)->get_fe().dofs_per_cell == dofs_per_cell,
- ExcNotImplemented());
-
- // prolong the given data
- // to the present
- // cell. FullMatrix only
- // wants us to call vmult
- // if the matrix size is
- // actually non-zero, so
- // check that case
- if (tmp.size() > 0)
- {
- this->get_fe().get_prolongation_matrix(child, this->refinement_case())
- .vmult (tmp, local_values);
-
- this->child(child)->set_dof_values_by_interpolation (tmp, values);
- }
- }
- }
-}
-
-
-
// --------------------------------------------------------------------------
// explicit instantiations
#include "dof_accessor.inst"
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
// TODO: This could surely be made more systematic!
#endif
}
-
-for (VEC : SERIAL_VECTORS; SCALAR : REAL_SCALARS; deal_II_dimension : DIMENSIONS; lda : BOOL)
- {
- template
- void
- DoFCellAccessor<DoFHandler<deal_II_dimension>, lda>::get_interpolated_dof_values
- (const VEC&, Vector<SCALAR>&) const;
- template
- void
- DoFCellAccessor<DoFHandler<deal_II_dimension>, lda>::set_dof_values_by_interpolation
- (const Vector<SCALAR>&, VEC&) const;
-
-#if deal_II_dimension != 3
-
- template
- void
- DoFCellAccessor<DoFHandler<deal_II_dimension,deal_II_dimension+1>, lda>::get_interpolated_dof_values
- (const VEC&, Vector<SCALAR>&) const;
- template
- void
- DoFCellAccessor<DoFHandler<deal_II_dimension,deal_II_dimension+1>, lda>::set_dof_values_by_interpolation
- (const Vector<SCALAR>&, VEC&) const;
-
-#endif
-
-#if deal_II_dimension == 3
-
- template
- void
- DoFCellAccessor<DoFHandler<1,3>, lda>::get_interpolated_dof_values
- (const VEC&, Vector<SCALAR>&) const;
- template
- void
- DoFCellAccessor<DoFHandler<1,3>, lda>::set_dof_values_by_interpolation
- (const Vector<SCALAR>&, VEC&) const;
-
-#endif
-
- }
-
-
-for (VEC : SERIAL_VECTORS; SCALAR : REAL_SCALARS; deal_II_dimension : DIMENSIONS; lda : BOOL)
- {
- template
- void
- DoFCellAccessor<hp::DoFHandler<deal_II_dimension>, lda>::get_interpolated_dof_values
- (const VEC&, Vector<SCALAR>&) const;
- template
- void
- DoFCellAccessor<hp::DoFHandler<deal_II_dimension>, lda>::set_dof_values_by_interpolation
- (const Vector<SCALAR>&, VEC&) const;
-
-#if deal_II_dimension != 3
-
- template
- void
- DoFCellAccessor<hp::DoFHandler<deal_II_dimension,deal_II_dimension+1>, lda>::get_interpolated_dof_values
- (const VEC&, Vector<SCALAR>&) const;
- template
- void
- DoFCellAccessor<hp::DoFHandler<deal_II_dimension,deal_II_dimension+1>, lda>::set_dof_values_by_interpolation
- (const Vector<SCALAR>&, VEC&) const;
-
-#endif
-
-#if deal_II_dimension == 3
-
- template
- void
- DoFCellAccessor<hp::DoFHandler<1,3>, lda>::get_interpolated_dof_values
- (const VEC&, Vector<SCALAR>&) const;
- template
- void
- DoFCellAccessor<hp::DoFHandler<1,3>, lda>::set_dof_values_by_interpolation
- (const Vector<SCALAR>&, VEC&) const;
-
-#endif
- }
-
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1998 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+#include <deal.II/lac/vector.h>
+#include <deal.II/lac/block_vector.h>
+#include <deal.II/lac/parallel_vector.h>
+#include <deal.II/lac/parallel_block_vector.h>
+#include <deal.II/lac/petsc_vector.h>
+#include <deal.II/lac/petsc_block_vector.h>
+#include <deal.II/lac/trilinos_vector.h>
+#include <deal.II/lac/trilinos_block_vector.h>
+#include <deal.II/lac/sparse_matrix.h>
+
+#include <deal.II/dofs/dof_accessor.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/dofs/dof_levels.h>
+#include <deal.II/hp/dof_handler.h>
+#include <deal.II/grid/tria_boundary.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/tria_iterator.templates.h>
+#include <deal.II/fe/fe.h>
+
+#include <vector>
+
+DEAL_II_NAMESPACE_OPEN
+
+
+template <class DH, bool lda>
+template <class InputVector, typename number>
+void
+DoFCellAccessor<DH,lda>::
+get_interpolated_dof_values (const InputVector &values,
+ Vector<number> &interpolated_values) const
+{
+ const FiniteElement<dim,spacedim> &fe = this->get_fe();
+ const unsigned int dofs_per_cell = fe.dofs_per_cell;
+
+ Assert (this->dof_handler != 0,
+ typename BaseClass::ExcInvalidObject());
+ Assert (&fe != 0,
+ typename BaseClass::ExcInvalidObject());
+ Assert (interpolated_values.size() == dofs_per_cell,
+ typename BaseClass::ExcVectorDoesNotMatch());
+ Assert (values.size() == this->dof_handler->n_dofs(),
+ typename BaseClass::ExcVectorDoesNotMatch());
+
+ if (!this->has_children())
+ // if this cell has no children: simply return the exact values on this
+ // cell
+ this->get_dof_values (values, interpolated_values);
+ else
+ // otherwise clobber them from the children
+ {
+ Vector<number> tmp1(dofs_per_cell);
+ Vector<number> tmp2(dofs_per_cell);
+
+ interpolated_values = 0;
+
+ // later on we will have to push the values interpolated from the child
+ // to the mother cell into the output vector. unfortunately, there are
+ // two types of elements: ones where you add up the contributions from
+ // the different child cells, and ones where you overwrite.
+ //
+ // an example for the first is piecewise constant (and discontinuous)
+ // elements, where we build the value on the coarse cell by averaging
+ // the values from the cell (i.e. by adding up a fraction of the values
+ // of their values)
+ //
+ // an example for the latter are the usual continuous elements. the
+ // value on a vertex of a coarse cell must there be the same,
+ // irrespective of the adjacent cell we are presently on. so we always
+ // overwrite. in fact, we must, since we cannot know in advance how many
+ // neighbors there will be, so there is no way to compute the average
+ // with fixed factors
+ //
+ // so we have to find out to which type this element belongs. the
+ // difficulty is: the finite element may be a composed one, so we can
+ // only hope to do this for each shape function individually. in fact,
+ // there are even weird finite elements (for example the Raviart-Thomas
+ // element) which have shape functions that are additive (interior ones)
+ // and others that are overwriting (face degrees of freedom that need to
+ // be continuous across the face). to avoid checking this over and over
+ // again, we do this once now and cache the results
+ std::vector<bool> restriction_is_additive (dofs_per_cell);
+ for (unsigned int i=0; i<dofs_per_cell; ++i)
+ restriction_is_additive[i] = fe.restriction_is_additive(i);
+
+ for (unsigned int child=0; child<this->n_children(); ++child)
+ {
+ // get the values from the present child, if necessary by
+ // interpolation itself
+ this->child(child)->get_interpolated_dof_values (values,
+ tmp1);
+ // interpolate these to the mother cell
+ fe.get_restriction_matrix(child, this->refinement_case()).vmult (tmp2, tmp1);
+
+ // and add up or set them in the output vector
+ for (unsigned int i=0; i<dofs_per_cell; ++i)
+ if (restriction_is_additive[i])
+ interpolated_values(i) += tmp2(i);
+ else if (tmp2(i) != number())
+ interpolated_values(i) = tmp2(i);
+ }
+ }
+}
+
+
+// --------------------------------------------------------------------------
+// explicit instantiations
+#include "dof_accessor_get.inst"
+
+DEAL_II_NAMESPACE_CLOSE
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1998 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+
+for (VEC : SERIAL_VECTORS; SCALAR : REAL_SCALARS; deal_II_dimension : DIMENSIONS; lda : BOOL)
+ {
+ template
+ void
+ DoFCellAccessor<DoFHandler<deal_II_dimension>, lda>::get_interpolated_dof_values
+ (const VEC&, Vector<SCALAR>&) const;
+
+#if deal_II_dimension != 3
+
+ template
+ void
+ DoFCellAccessor<DoFHandler<deal_II_dimension,deal_II_dimension+1>, lda>::get_interpolated_dof_values
+ (const VEC&, Vector<SCALAR>&) const;
+
+#endif
+
+#if deal_II_dimension == 3
+
+ template
+ void
+ DoFCellAccessor<DoFHandler<1,3>, lda>::get_interpolated_dof_values
+ (const VEC&, Vector<SCALAR>&) const;
+
+#endif
+
+ }
+
+
+for (VEC : SERIAL_VECTORS; SCALAR : REAL_SCALARS; deal_II_dimension : DIMENSIONS; lda : BOOL)
+ {
+ template
+ void
+ DoFCellAccessor<hp::DoFHandler<deal_II_dimension>, lda>::get_interpolated_dof_values
+ (const VEC&, Vector<SCALAR>&) const;
+
+#if deal_II_dimension != 3
+
+ template
+ void
+ DoFCellAccessor<hp::DoFHandler<deal_II_dimension,deal_II_dimension+1>, lda>::get_interpolated_dof_values
+ (const VEC&, Vector<SCALAR>&) const;
+
+#endif
+
+#if deal_II_dimension == 3
+
+ template
+ void
+ DoFCellAccessor<hp::DoFHandler<1,3>, lda>::get_interpolated_dof_values
+ (const VEC&, Vector<SCALAR>&) const;
+
+#endif
+ }
+
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1998 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+#include <deal.II/lac/vector.h>
+#include <deal.II/lac/block_vector.h>
+#include <deal.II/lac/parallel_vector.h>
+#include <deal.II/lac/parallel_block_vector.h>
+#include <deal.II/lac/petsc_vector.h>
+#include <deal.II/lac/petsc_block_vector.h>
+#include <deal.II/lac/trilinos_vector.h>
+#include <deal.II/lac/trilinos_block_vector.h>
+#include <deal.II/lac/sparse_matrix.h>
+
+#include <deal.II/dofs/dof_accessor.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/dofs/dof_levels.h>
+#include <deal.II/hp/dof_handler.h>
+#include <deal.II/grid/tria_boundary.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/tria_iterator.templates.h>
+#include <deal.II/fe/fe.h>
+
+#include <vector>
+
+DEAL_II_NAMESPACE_OPEN
+
+
+
+template <class DH, bool lda>
+template <class OutputVector, typename number>
+void
+DoFCellAccessor<DH,lda>::
+set_dof_values_by_interpolation (const Vector<number> &local_values,
+ OutputVector &values) const
+{
+ const unsigned int dofs_per_cell = this->get_fe().dofs_per_cell;
+
+ Assert (this->dof_handler != 0,
+ typename BaseClass::ExcInvalidObject());
+ Assert (&this->get_fe() != 0,
+ typename BaseClass::ExcInvalidObject());
+ Assert (local_values.size() == dofs_per_cell,
+ typename BaseClass::ExcVectorDoesNotMatch());
+ Assert (values.size() == this->dof_handler->n_dofs(),
+ typename BaseClass::ExcVectorDoesNotMatch());
+
+ if (!this->has_children())
+ // if this cell has no children: simply set the values on this cell
+ this->set_dof_values (local_values, values);
+ else
+ // otherwise distribute them to the children
+ {
+ Vector<number> tmp(dofs_per_cell);
+
+ for (unsigned int child=0; child<this->n_children(); ++child)
+ {
+ Assert (this->child(child)->get_fe().dofs_per_cell == dofs_per_cell,
+ ExcNotImplemented());
+
+ // prolong the given data to the present cell. FullMatrix only wants
+ // us to call vmult if the matrix size is actually non-zero, so
+ // check that case
+ if (tmp.size() > 0)
+ {
+ this->get_fe().get_prolongation_matrix(child, this->refinement_case())
+ .vmult (tmp, local_values);
+
+ this->child(child)->set_dof_values_by_interpolation (tmp, values);
+ }
+ }
+ }
+}
+
+
+
+// --------------------------------------------------------------------------
+// explicit instantiations
+#include "dof_accessor_set.inst"
+
+DEAL_II_NAMESPACE_CLOSE
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1998 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+
+for (VEC : SERIAL_VECTORS; SCALAR : REAL_SCALARS; deal_II_dimension : DIMENSIONS; lda : BOOL)
+ {
+ template
+ void
+ DoFCellAccessor<DoFHandler<deal_II_dimension>, lda>::set_dof_values_by_interpolation
+ (const Vector<SCALAR>&, VEC&) const;
+
+#if deal_II_dimension != 3
+
+ template
+ void
+ DoFCellAccessor<DoFHandler<deal_II_dimension,deal_II_dimension+1>, lda>::set_dof_values_by_interpolation
+ (const Vector<SCALAR>&, VEC&) const;
+
+#endif
+
+#if deal_II_dimension == 3
+
+ template
+ void
+ DoFCellAccessor<DoFHandler<1,3>, lda>::set_dof_values_by_interpolation
+ (const Vector<SCALAR>&, VEC&) const;
+
+#endif
+
+ }
+
+
+for (VEC : SERIAL_VECTORS; SCALAR : REAL_SCALARS; deal_II_dimension : DIMENSIONS; lda : BOOL)
+ {
+ template
+ void
+ DoFCellAccessor<hp::DoFHandler<deal_II_dimension>, lda>::set_dof_values_by_interpolation
+ (const Vector<SCALAR>&, VEC&) const;
+
+#if deal_II_dimension != 3
+
+ template
+ void
+ DoFCellAccessor<hp::DoFHandler<deal_II_dimension,deal_II_dimension+1>, lda>::set_dof_values_by_interpolation
+ (const Vector<SCALAR>&, VEC&) const;
+
+#endif
+
+#if deal_II_dimension == 3
+
+ template
+ void
+ DoFCellAccessor<hp::DoFHandler<1,3>, lda>::set_dof_values_by_interpolation
+ (const Vector<SCALAR>&, VEC&) const;
+
+#endif
+ }
+
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/exceptions.h>
#include <deal.II/base/memory_consumption.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/memory_consumption.h>
#include <deal.II/dofs/dof_handler.h>
max_couplings_between_dofs (const DoFHandler<1,spacedim> &dof_handler)
{
return std::min(static_cast<types::global_dof_index>(3*dof_handler.selected_fe->dofs_per_vertex +
- 2*dof_handler.selected_fe->dofs_per_line),
+ 2*dof_handler.selected_fe->dofs_per_line),
dof_handler.n_dofs());
}
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
//TODO [TH]: renumber DoFs for multigrid is not done yet
const bool check_validity)
{
for (typename std::vector<typename DoFHandler<1,spacedim>::MGVertexDoFs>::iterator
- i=dof_handler.mg_vertex_dofs.begin();
+ i=dof_handler.mg_vertex_dofs.begin();
i!=dof_handler.mg_vertex_dofs.end();
- ++i)
+ ++i)
// if the present vertex lives on
// the current level
if ((i->get_coarsest_level() <= level) &&
(i->get_finest_level() >= level))
for (unsigned int d=0; d<dof_handler.get_fe().dofs_per_vertex; ++d)
{
- unsigned int idx = i->get_index (level, d);
+ dealii::types::global_dof_index idx = i->get_index (level, d);
if (idx != DoFHandler<1>::invalid_dof_index)
i->set_index (level, d,
(indices.n_elements() == 0)?
for (std::vector<types::global_dof_index>::iterator
- i=dof_handler.mg_levels[level]->dof_object.dofs.begin();
+ i=dof_handler.mg_levels[level]->dof_object.dofs.begin();
i!=dof_handler.mg_levels[level]->dof_object.dofs.end();
- ++i)
+ ++i)
{
if (*i != DoFHandler<1>::invalid_dof_index)
{
{
for (unsigned int d=0; d<dof_handler.get_fe().dofs_per_line; ++d)
{
- unsigned int idx = cell->line(l)->mg_dof_index(level, d);
+ dealii::types::global_dof_index idx = cell->line(l)->mg_dof_index(level, d);
if (idx != DoFHandler<1>::invalid_dof_index)
cell->line(l)->set_mg_dof_index (level, d, ((indices.n_elements() == 0) ?
new_numbers[idx] :
static
void
renumber_mg_dofs (const std::vector<dealii::types::global_dof_index> &,
- const IndexSet &,
- DoFHandler<3,spacedim> &,
+ const IndexSet &,
+ DoFHandler<3,spacedim> &,
const unsigned int ,
const bool )
{
}
}
+ //additionally (multigrid only), we can have the case that children of our neighbor
+ //have us as a neighbor. In this case we and the children are active.
+ if (dealii_cell->active())
+ {
+ for (unsigned int f=0;f<GeometryInfo<dim>::faces_per_cell;++f)
+ {
+ if (dealii_cell->at_boundary(f))
+ continue;
+ typename DoFHandler<dim,spacedim>::level_cell_iterator neighbor = dealii_cell->neighbor(f);
+ if (!neighbor->has_children())
+ continue;
+
+ for (unsigned int subface=0; subface<GeometryInfo<dim>::max_children_per_face; ++subface)
+ {
+ typename DoFHandler<dim,spacedim>::level_cell_iterator child = dealii_cell->neighbor_child_on_subface(f,subface);
+ dealii::types::subdomain_id dest = child->subdomain_id();
+ Assert(dest != dealii::numbers::artificial_subdomain_id, ExcInternalError());
+ if (dest != tria.locally_owned_subdomain())
+ send_to.insert(dest);
+ }
+
+ }
+
+ }
+
+
+ // send if we have something to send
if (send_to.size() > 0)
{
// this cell's dof_indices
const typename dealii::internal::p4est::types<dim>::quadrant &p4est_cell,
const typename DoFHandler<dim,spacedim>::level_cell_iterator &dealii_cell,
const typename dealii::internal::p4est::types<dim>::quadrant &quadrant,
- dealii::types::global_dof_index* dofs,
+ dealii::types::global_dof_index *dofs,
unsigned int level)
{
if (internal::p4est::quadrant_is_equal<dim>(p4est_cell, quadrant))
=reinterpret_cast<typename dealii::internal::p4est::types<dim>::quadrant *>(ptr);
ptr+=cells*sizeof(typename dealii::internal::p4est::types<dim>::quadrant);
dealii::types::global_dof_index *dofs
- = reinterpret_cast<dealii::types::global_dof_index*>(ptr);
+ = reinterpret_cast<dealii::types::global_dof_index *>(ptr);
- // the dofs pointer contains for each cell the number of dofs
- // on that cell (dofs[0]) followed by the dof indices itself.
+ // the dofs pointer contains for each cell the number of dofs
+ // on that cell (dofs[0]) followed by the dof indices itself.
for (unsigned int c=0; c<cells; ++c, dofs+=1+dofs[0])
{
typename DoFHandler<dim,spacedim>::level_cell_iterator
MPI_Get_count(&status, MPI_BYTE, &len);
receive.resize(len);
+#ifdef DEBUG
+ Assert(senders.find(status.MPI_SOURCE)!=senders.end(), ExcInternalError());
+#endif
+
char *ptr = &receive[0];
MPI_Recv(ptr, len, MPI_BYTE, status.MPI_SOURCE, status.MPI_TAG,
tr->get_communicator(), &status);
=reinterpret_cast<typename dealii::internal::p4est::types<dim>::quadrant *>(ptr);
ptr+=cells*sizeof(typename dealii::internal::p4est::types<dim>::quadrant);
dealii::types::global_dof_index *dofs
- = reinterpret_cast<dealii::types::global_dof_index*>(ptr);
+ = reinterpret_cast<dealii::types::global_dof_index *>(ptr);
- // the dofs pointer contains for each cell the number of dofs
- // on that cell (dofs[0]) followed by the dof indices itself.
+ // the dofs pointer contains for each cell the number of dofs
+ // on that cell (dofs[0]) followed by the dof indices itself.
for (unsigned int c=0; c<cells; ++c, dofs+=1+dofs[0])
{
typename DoFHandler<dim,spacedim>::level_cell_iterator
unsigned int sent=needs_to_get_cells.size();
unsigned int recv=senders.size();
- MPI_Reduce(&sent, &sum_send, 1, MPI_UNSIGNED, MPI_SUM, 0, tr->get_communicator());
- MPI_Reduce(&recv, &sum_recv, 1, MPI_UNSIGNED, MPI_SUM, 0, tr->get_communicator());
+ MPI_Reduce(&sent, &sum_send, 1, MPI_UNSIGNED, MPI_SUM, 56345, tr->get_communicator());
+ MPI_Reduce(&recv, &sum_recv, 1, MPI_UNSIGNED, MPI_SUM, 56346, tr->get_communicator());
Assert(sum_send==sum_recv, ExcInternalError());
}
#endif
if (!cell->is_artificial())
cell->set_user_flag();
- //mark the vertices we are interested
- //in, i.e. belonging to own and marked cells
- const std::vector<bool> locally_active_vertices
- = mark_locally_active_vertices (*tr);
-
// add each ghostcells'
// subdomain to the vertex and
// keep track of interesting
// neighbors
std::map<unsigned int, std::set<dealii::types::subdomain_id> >
vertices_with_ghost_neighbors;
- for (typename DoFHandler<dim,spacedim>::active_cell_iterator
- cell = dof_handler.begin_active();
- cell != dof_handler.end(); ++cell)
- if (cell->is_ghost ())
- for (unsigned int v=0; v<GeometryInfo<dim>::vertices_per_cell; ++v)
- if (locally_active_vertices[cell->vertex_index(v)])
- vertices_with_ghost_neighbors[cell->vertex_index(v)]
- .insert (cell->subdomain_id());
+
+ tr->fill_vertices_with_ghost_neighbors (vertices_with_ghost_neighbors);
/* Send and receive cells. After this,
for (typename DoFHandler<dim,spacedim>::level_cell_iterator
cell = dof_handler.begin(level);
cell != dof_handler.end(level); ++cell)
- if (cell->level_subdomain_id() != dealii::numbers::artificial_subdomain_id && cell->level_subdomain_id() != tr->locally_owned_subdomain())
+ if (cell->level_subdomain_id() != dealii::numbers::artificial_subdomain_id
+ && cell->level_subdomain_id() != tr->locally_owned_subdomain())
for (unsigned int v=0; v<GeometryInfo<dim>::vertices_per_cell; ++v)
if (locally_active_vertices[cell->vertex_index(v)])
vertices_with_ghost_neighbors[cell->vertex_index(v)]
local_dof_indices.end(),
DoFHandler<dim,spacedim>::invalid_dof_index))
{
- Assert(false, ExcMessage ("not all dofs got distributed!"));
+ Assert(false, ExcMessage ("not all DoFs got distributed!"));
}
}
}
// to blocks. If yes, we can add the block
// ranges to the IndexSet, otherwise we need
// to go through the indices once again and
- // add each element individually (slow!)
+ // add each element individually
unsigned int sum = 0;
for (unsigned int i=0; i<n_filled_blocks; ++i)
sum += block_indices[i].second;
block_indices[i].first+
block_indices[i].second);
else
- for (it=new_numbers.begin() ; it != new_numbers.end(); ++it)
- number_cache.locally_owned_dofs.add_index (*it);
+ number_cache.locally_owned_dofs.add_indices(new_numbers.begin(), new_numbers.end());
}
for (cell = dof_handler.begin_active(); cell != endc; ++cell)
if (!cell->is_artificial())
cell->set_user_flag();
- //mark the vertices we are interested
- //in, i.e. belonging to own and marked cells
- const std::vector<bool> locally_active_vertices
- = mark_locally_active_vertices (*tr);
// add each ghostcells'
// subdomain to the vertex and
// neighbors
std::map<unsigned int, std::set<dealii::types::subdomain_id> >
vertices_with_ghost_neighbors;
- for (typename DoFHandler<dim,spacedim>::active_cell_iterator
- cell = dof_handler.begin_active();
- cell != dof_handler.end(); ++cell)
- if (cell->is_ghost ())
- for (unsigned int v=0; v<GeometryInfo<dim>::vertices_per_cell; ++v)
- if (locally_active_vertices[cell->vertex_index(v)])
- vertices_with_ghost_neighbors[cell->vertex_index(v)]
- .insert (cell->subdomain_id());
+
+ tr->fill_vertices_with_ghost_neighbors (vertices_with_ghost_neighbors);
// Send and receive cells. After this, only
// the local cells are marked, that received
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
{
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/exceptions.h>
#include <deal.II/base/memory_consumption.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2010, 2011 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/thread_management.h>
#include <deal.II/base/utilities.h>
{
Assert(dof_handler.n_dofs(level) != numbers::invalid_dof_index,
ExcNotInitialized());
-//TODO: we should be doing the same here as in the other compute_CMK function to preserve some memory
// make the connection graph
- SparsityPattern sparsity (dof_handler.n_dofs(level),
- dof_handler.max_couplings_between_dofs());
- MGTools::make_sparsity_pattern (dof_handler, sparsity, level);
+ SparsityPattern sparsity;
+ if (DH::dimension < 2)
+ {
+ sparsity.reinit (dof_handler.n_dofs(level),
+ dof_handler.n_dofs(level),
+ dof_handler.max_couplings_between_dofs());
+ MGTools::make_sparsity_pattern (dof_handler, sparsity, level);
+ sparsity.compress();
+ }
+ else
+ {
+ CompressedSimpleSparsityPattern csp (dof_handler.n_dofs(level),
+ dof_handler.n_dofs(level));
+ MGTools::make_sparsity_pattern (dof_handler, csp, level);
+ sparsity.copy_from (csp);
+ }
std::vector<types::global_dof_index> new_indices(sparsity.n_rows());
SparsityTools::reorder_Cuthill_McKee (sparsity, new_indices,
{
//TODO: Merge with previous function
std::vector<types::global_dof_index> renumbering (dof_handler.n_dofs(),
- hp::DoFHandler<dim>::invalid_dof_index);
+ hp::DoFHandler<dim>::invalid_dof_index);
typename hp::DoFHandler<dim>::active_cell_iterator
start = dof_handler.begin_active();
ExcNotInitialized());
std::vector<types::global_dof_index> renumbering (dof_handler.n_dofs(level),
- DH::invalid_dof_index);
+ DH::invalid_dof_index);
typename DH::level_cell_iterator start =dof_handler.begin(level);
typename DH::level_cell_iterator end = dof_handler.end(level);
Utilities::MPI::n_mpi_processes (tria->get_communicator()));
MPI_Allgather ( &local_dof_count[0],
- n_buckets, DEAL_II_DOF_INDEX_MPI_TYPE,
- &all_dof_counts[0],
n_buckets, DEAL_II_DOF_INDEX_MPI_TYPE,
- tria->get_communicator());
+ &all_dof_counts[0],
+ n_buckets, DEAL_II_DOF_INDEX_MPI_TYPE,
+ tria->get_communicator());
for (unsigned int i=0; i<n_buckets; ++i)
Assert (all_dof_counts[n_buckets*tria->locally_owned_subdomain()+i]
block_wise (DoFHandler<dim,spacedim> &dof_handler)
{
std::vector<types::global_dof_index> renumbering (dof_handler.n_locally_owned_dofs(),
- DoFHandler<dim>::invalid_dof_index);
+ DoFHandler<dim>::invalid_dof_index);
typename DoFHandler<dim,spacedim>::active_cell_iterator
start = dof_handler.begin_active();
ExcNotInitialized());
std::vector<types::global_dof_index> renumbering (dof_handler.n_dofs(level),
- DoFHandler<dim>::invalid_dof_index);
+ DoFHandler<dim>::invalid_dof_index);
typename DoFHandler<dim>::level_cell_iterator
start =dof_handler.begin(level);
all_dof_counts(fe_collection.n_components() *
Utilities::MPI::n_mpi_processes (tria->get_communicator()));
- Assert (sizeof(types::global_dof_index) == sizeof(unsigned int),
- ExcNotImplemented());
+ Assert (sizeof(types::global_dof_index) == sizeof(unsigned int),
+ ExcNotImplemented());
MPI_Allgather ( &local_dof_count[0],
- n_buckets, DEAL_II_DOF_INDEX_MPI_TYPE,
- &all_dof_counts[0],
n_buckets, DEAL_II_DOF_INDEX_MPI_TYPE,
- tria->get_communicator());
+ &all_dof_counts[0],
+ n_buckets, DEAL_II_DOF_INDEX_MPI_TYPE,
+ tria->get_communicator());
for (unsigned int i=0; i<n_buckets; ++i)
Assert (all_dof_counts[n_buckets*tria->locally_owned_subdomain()+i]
hierarchical (DoFHandler<dim> &dof_handler)
{
std::vector<types::global_dof_index> renumbering (dof_handler.n_locally_owned_dofs(),
- DoFHandler<dim>::invalid_dof_index);
+ DoFHandler<dim>::invalid_dof_index);
typename DoFHandler<dim>::level_cell_iterator cell;
if (tria)
{
#ifdef DEAL_II_WITH_P4EST
- //this is a distributed Triangulation. We need to traverse the coarse
- //cells in the order p4est does
+ // this is a distributed Triangulation. We need to traverse the coarse
+ // cells in the order p4est does
for (unsigned int c = 0; c < tria->n_cells (0); ++c)
{
- unsigned int coarse_cell_index =
+ const unsigned int coarse_cell_index =
tria->get_p4est_tree_to_coarse_cell_permutation() [c];
const typename DoFHandler<dim>::level_cell_iterator
ExcNotInitialized());
std::vector<types::global_dof_index> renumbering(dof_handler.n_dofs(level),
- DH::invalid_dof_index);
+ DH::invalid_dof_index);
compute_sort_selected_dofs_back(renumbering, dof_handler, selected_dofs, level);
dof_handler.renumber_dofs(level, renumbering);
{
if (dof_wise_renumbering == false)
{
- std::vector<typename DH::active_cell_iterator>
- ordered_cells(dof.get_tria().n_active_cells());
+ std::vector<typename DH::active_cell_iterator> ordered_cells;
+ ordered_cells.reserve(dof.get_tria().n_active_cells());
const CompareDownstream<typename DH::active_cell_iterator, DH::space_dimension> comparator(direction);
- typename DH::active_cell_iterator begin = dof.begin_active();
+ typename DH::active_cell_iterator p = dof.begin_active();
typename DH::active_cell_iterator end = dof.end();
- copy (begin, end, ordered_cells.begin());
+ while (p!=end)
+ {
+ ordered_cells.push_back(p);
+ ++p;
+ }
std::sort (ordered_cells.begin(), ordered_cells.end(), comparator);
compute_cell_wise(new_indices, reverse, dof, ordered_cells);
{
if (dof_wise_renumbering == false)
{
- std::vector<typename DH::level_cell_iterator>
- ordered_cells(dof.get_tria().n_cells(level));
+ std::vector<typename DH::level_cell_iterator> ordered_cells;
+ ordered_cells.reserve (dof.get_tria().n_cells(level));
const CompareDownstream<typename DH::level_cell_iterator, DH::space_dimension> comparator(direction);
- typename DH::level_cell_iterator begin = dof.begin(level);
+ typename DH::level_cell_iterator p = dof.begin(level);
typename DH::level_cell_iterator end = dof.end(level);
- std::copy (begin, end, ordered_cells.begin());
+ while (p!=end)
+ {
+ ordered_cells.push_back(p);
+ ++p;
+ }
std::sort (ordered_cells.begin(), ordered_cells.end(), comparator);
compute_cell_wise(new_indices, reverse, dof, level, ordered_cells);
const Point<DH::space_dimension> ¢er,
const bool counter)
{
- std::vector<typename DH::active_cell_iterator>
- ordered_cells(dof.get_tria().n_active_cells());
+ std::vector<typename DH::active_cell_iterator> ordered_cells;
+ ordered_cells.reserve (dof.get_tria().n_active_cells());
internal::ClockCells<DH::space_dimension> comparator(center, counter);
- typename DH::active_cell_iterator begin = dof.begin_active();
+ typename DH::active_cell_iterator p = dof.begin_active();
typename DH::active_cell_iterator end = dof.end();
- std::copy (begin, end, ordered_cells.begin());
+ while (p!=end)
+ {
+ ordered_cells.push_back(p);
+ ++p;
+ }
std::sort (ordered_cells.begin(), ordered_cells.end(), comparator);
std::vector<types::global_dof_index> reverse(new_indices.size());
const Point<DH::space_dimension> ¢er,
const bool counter)
{
- std::vector<typename DH::level_cell_iterator>
- ordered_cells(dof.get_tria().n_cells(level));
+ std::vector<typename DH::level_cell_iterator> ordered_cells;
+ ordered_cells.reserve(dof.get_tria().n_active_cells());
internal::ClockCells<DH::space_dimension> comparator(center, counter);
- typename DH::level_cell_iterator begin = dof.begin(level);
+ typename DH::level_cell_iterator p = dof.begin(level);
typename DH::level_cell_iterator end = dof.end(level);
- std::copy (begin, end, ordered_cells.begin());
+ while (p!=end)
+ {
+ ordered_cells.push_back(p);
+ ++p;
+ }
std::sort (ordered_cells.begin(), ordered_cells.end(), comparator);
cell_wise(dof, level, ordered_cells);
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
{
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
-
-#include <deal.II/base/multithread_info.h>
-#include <deal.II/base/thread_management.h>
-#include <deal.II/base/quadrature_lib.h>
-#include <deal.II/base/table.h>
-#include <deal.II/base/template_constraints.h>
-#include <deal.II/base/utilities.h>
-#include <deal.II/lac/sparsity_pattern.h>
-#include <deal.II/lac/compressed_sparsity_pattern.h>
-#include <deal.II/lac/compressed_set_sparsity_pattern.h>
-#include <deal.II/lac/compressed_simple_sparsity_pattern.h>
-#include <deal.II/lac/trilinos_sparsity_pattern.h>
-#include <deal.II/lac/block_sparsity_pattern.h>
-#include <deal.II/lac/vector.h>
-#include <deal.II/lac/constraint_matrix.h>
-#include <deal.II/grid/tria.h>
-#include <deal.II/grid/tria_iterator.h>
-#include <deal.II/grid/intergrid_map.h>
-#include <deal.II/grid/grid_tools.h>
-#include <deal.II/dofs/dof_handler.h>
-#include <deal.II/dofs/dof_accessor.h>
-#include <deal.II/fe/fe.h>
-#include <deal.II/fe/fe_values.h>
-#include <deal.II/fe/fe_tools.h>
-#include <deal.II/hp/fe_collection.h>
-#include <deal.II/hp/q_collection.h>
-#include <deal.II/hp/fe_values.h>
-#include <deal.II/dofs/dof_tools.h>
-#include <deal.II/numerics/vector_tools.h>
-
-#include <deal.II/multigrid/mg_dof_handler.h>
-
-#include <algorithm>
-#include <numeric>
-
-DEAL_II_NAMESPACE_OPEN
-
-
-
-namespace DoFTools
-{
-
- template <class DH, class SparsityPattern>
- void
- make_sparsity_pattern (const DH &dof,
- SparsityPattern &sparsity,
- const ConstraintMatrix &constraints,
- const bool keep_constrained_dofs,
- const types::subdomain_id subdomain_id)
- {
- const types::global_dof_index n_dofs = dof.n_dofs();
-
- Assert (sparsity.n_rows() == n_dofs,
- ExcDimensionMismatch (sparsity.n_rows(), n_dofs));
- Assert (sparsity.n_cols() == n_dofs,
- ExcDimensionMismatch (sparsity.n_cols(), n_dofs));
-
- // If we have a distributed::Triangulation only allow locally_owned
- // subdomain. Not setting a subdomain is also okay, because we skip
- // ghost cells in the loop below.
- Assert (
- (dof.get_tria().locally_owned_subdomain() == numbers::invalid_subdomain_id)
- ||
- (subdomain_id == numbers::invalid_subdomain_id)
- ||
- (subdomain_id == dof.get_tria().locally_owned_subdomain()),
- ExcMessage ("For parallel::distributed::Triangulation objects and "
- "associated DoF handler objects, asking for any subdomain other "
- "than the locally owned one does not make sense."));
-
- std::vector<types::global_dof_index> dofs_on_this_cell;
- dofs_on_this_cell.reserve (max_dofs_per_cell(dof));
- typename DH::active_cell_iterator cell = dof.begin_active(),
- endc = dof.end();
-
- // In case we work with a distributed sparsity pattern of Trilinos
- // type, we only have to do the work if the current cell is owned by
- // the calling processor. Otherwise, just continue.
- for (; cell!=endc; ++cell)
- if (((subdomain_id == numbers::invalid_subdomain_id)
- ||
- (subdomain_id == cell->subdomain_id()))
- &&
- cell->is_locally_owned())
- {
- const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell;
- dofs_on_this_cell.resize (dofs_per_cell);
- cell->get_dof_indices (dofs_on_this_cell);
-
- // make sparsity pattern for this cell. if no constraints pattern
- // was given, then the following call acts as if simply no
- // constraints existed
- constraints.add_entries_local_to_global (dofs_on_this_cell,
- sparsity,
- keep_constrained_dofs);
- }
- }
-
-
-
- template <class DH, class SparsityPattern>
- void
- make_sparsity_pattern (const DH &dof,
- const Table<2,Coupling> &couplings,
- SparsityPattern &sparsity,
- const ConstraintMatrix &constraints,
- const bool keep_constrained_dofs,
- const types::subdomain_id subdomain_id)
- {
- const types::global_dof_index n_dofs = dof.n_dofs();
-
- Assert (sparsity.n_rows() == n_dofs,
- ExcDimensionMismatch (sparsity.n_rows(), n_dofs));
- Assert (sparsity.n_cols() == n_dofs,
- ExcDimensionMismatch (sparsity.n_cols(), n_dofs));
- Assert (couplings.n_rows() == dof.get_fe().n_components(),
- ExcDimensionMismatch(couplings.n_rows(), dof.get_fe().n_components()));
- Assert (couplings.n_cols() == dof.get_fe().n_components(),
- ExcDimensionMismatch(couplings.n_cols(), dof.get_fe().n_components()));
-
- // If we have a distributed::Triangulation only allow locally_owned
- // subdomain. Not setting a subdomain is also okay, because we skip
- // ghost cells in the loop below.
- Assert (
- (dof.get_tria().locally_owned_subdomain() == numbers::invalid_subdomain_id)
- ||
- (subdomain_id == numbers::invalid_subdomain_id)
- ||
- (subdomain_id == dof.get_tria().locally_owned_subdomain()),
- ExcMessage ("For parallel::distributed::Triangulation objects and "
- "associated DoF handler objects, asking for any subdomain other "
- "than the locally owned one does not make sense."));
-
- const hp::FECollection<DH::dimension,DH::space_dimension> fe_collection (dof.get_fe());
-
- // first, for each finite element, build a mask for each dof, not like
- // the one given which represents components. make sure we do the right
- // thing also with respect to non-primitive shape functions, which
- // takes some additional thought
- std::vector<Table<2,bool> > dof_mask(fe_collection.size());
-
- // check whether the table of couplings contains only true arguments,
- // i.e., we do not exclude any index. that is the easy case, since we
- // don't have to set up the tables
- bool need_dof_mask = false;
- for (unsigned int i=0; i<couplings.n_rows(); ++i)
- for (unsigned int j=0; j<couplings.n_cols(); ++j)
- if (couplings(i,j) == none)
- need_dof_mask = true;
-
- if (need_dof_mask == true)
- for (unsigned int f=0; f<fe_collection.size(); ++f)
- {
- const unsigned int dofs_per_cell = fe_collection[f].dofs_per_cell;
-
- dof_mask[f].reinit (dofs_per_cell, dofs_per_cell);
-
- for (unsigned int i=0; i<dofs_per_cell; ++i)
- for (unsigned int j=0; j<dofs_per_cell; ++j)
- if (fe_collection[f].is_primitive(i) &&
- fe_collection[f].is_primitive(j))
- dof_mask[f](i,j)
- = (couplings(fe_collection[f].system_to_component_index(i).first,
- fe_collection[f].system_to_component_index(j).first) != none);
- else
- {
- const unsigned int first_nonzero_comp_i
- = fe_collection[f].get_nonzero_components(i).first_selected_component();
- const unsigned int first_nonzero_comp_j
- = fe_collection[f].get_nonzero_components(j).first_selected_component();
- Assert (first_nonzero_comp_i < fe_collection[f].n_components(),
- ExcInternalError());
- Assert (first_nonzero_comp_j < fe_collection[f].n_components(),
- ExcInternalError());
-
- dof_mask[f](i,j)
- = (couplings(first_nonzero_comp_i,first_nonzero_comp_j) != none);
- }
- }
-
-
- std::vector<types::global_dof_index> dofs_on_this_cell(fe_collection.max_dofs_per_cell());
- typename DH::active_cell_iterator cell = dof.begin_active(),
- endc = dof.end();
-
- // In case we work with a distributed sparsity pattern of Trilinos
- // type, we only have to do the work if the current cell is owned by
- // the calling processor. Otherwise, just continue.
- for (; cell!=endc; ++cell)
- if (((subdomain_id == numbers::invalid_subdomain_id)
- ||
- (subdomain_id == cell->subdomain_id()))
- &&
- cell->is_locally_owned())
- {
- const unsigned int fe_index = cell->active_fe_index();
- const unsigned int dofs_per_cell =fe_collection[fe_index].dofs_per_cell;
-
- dofs_on_this_cell.resize (dofs_per_cell);
- cell->get_dof_indices (dofs_on_this_cell);
-
-
- // make sparsity pattern for this cell. if no constraints pattern
- // was given, then the following call acts as if simply no
- // constraints existed
- constraints.add_entries_local_to_global (dofs_on_this_cell,
- sparsity,
- keep_constrained_dofs,
- dof_mask[fe_index]);
- }
- }
-
-
-
- template <class DH, class SparsityPattern>
- void
- make_sparsity_pattern (
- const DH &dof_row,
- const DH &dof_col,
- SparsityPattern &sparsity)
- {
- const types::global_dof_index n_dofs_row = dof_row.n_dofs();
- const types::global_dof_index n_dofs_col = dof_col.n_dofs();
-
- Assert (sparsity.n_rows() == n_dofs_row,
- ExcDimensionMismatch (sparsity.n_rows(), n_dofs_row));
- Assert (sparsity.n_cols() == n_dofs_col,
- ExcDimensionMismatch (sparsity.n_cols(), n_dofs_col));
-
-//TODO: Looks like wasteful memory management here
-
- const std::list<std::pair<typename DH::cell_iterator,
- typename DH::cell_iterator> >
- cell_list
- = GridTools::get_finest_common_cells (dof_row, dof_col);
-
-
- typename std::list<std::pair<typename DH::cell_iterator,
- typename DH::cell_iterator> >::const_iterator
- cell_iter = cell_list.begin();
-
- for (; cell_iter!=cell_list.end(); ++cell_iter)
- {
- const typename DH::cell_iterator cell_row = cell_iter->first;
- const typename DH::cell_iterator cell_col = cell_iter->second;
-
- if (!cell_row->has_children() && !cell_col->has_children())
- {
- const unsigned int dofs_per_cell_row =
- cell_row->get_fe().dofs_per_cell;
- const unsigned int dofs_per_cell_col =
- cell_col->get_fe().dofs_per_cell;
- std::vector<types::global_dof_index>
- local_dof_indices_row(dofs_per_cell_row);
- std::vector<types::global_dof_index>
- local_dof_indices_col(dofs_per_cell_col);
- cell_row->get_dof_indices (local_dof_indices_row);
- cell_col->get_dof_indices (local_dof_indices_col);
- for (unsigned int i=0; i<dofs_per_cell_row; ++i)
- sparsity.add_entries (local_dof_indices_row[i],
- local_dof_indices_col.begin(),
- local_dof_indices_col.end());
- }
- else if (cell_row->has_children())
- {
- const std::vector<typename DH::active_cell_iterator >
- child_cells = GridTools::get_active_child_cells<DH> (cell_row);
- for (unsigned int i=0; i<child_cells.size(); i++)
- {
- const typename DH::cell_iterator
- cell_row_child = child_cells[i];
- const unsigned int dofs_per_cell_row =
- cell_row_child->get_fe().dofs_per_cell;
- const unsigned int dofs_per_cell_col =
- cell_col->get_fe().dofs_per_cell;
- std::vector<types::global_dof_index>
- local_dof_indices_row(dofs_per_cell_row);
- std::vector<types::global_dof_index>
- local_dof_indices_col(dofs_per_cell_col);
- cell_row_child->get_dof_indices (local_dof_indices_row);
- cell_col->get_dof_indices (local_dof_indices_col);
- for (unsigned int i=0; i<dofs_per_cell_row; ++i)
- sparsity.add_entries (local_dof_indices_row[i],
- local_dof_indices_col.begin(),
- local_dof_indices_col.end());
- }
- }
- else
- {
- std::vector<typename DH::active_cell_iterator>
- child_cells = GridTools::get_active_child_cells<DH> (cell_col);
- for (unsigned int i=0; i<child_cells.size(); i++)
- {
- const typename DH::active_cell_iterator
- cell_col_child = child_cells[i];
- const unsigned int dofs_per_cell_row =
- cell_row->get_fe().dofs_per_cell;
- const unsigned int dofs_per_cell_col =
- cell_col_child->get_fe().dofs_per_cell;
- std::vector<types::global_dof_index>
- local_dof_indices_row(dofs_per_cell_row);
- std::vector<types::global_dof_index>
- local_dof_indices_col(dofs_per_cell_col);
- cell_row->get_dof_indices (local_dof_indices_row);
- cell_col_child->get_dof_indices (local_dof_indices_col);
- for (unsigned int i=0; i<dofs_per_cell_row; ++i)
- sparsity.add_entries (local_dof_indices_row[i],
- local_dof_indices_col.begin(),
- local_dof_indices_col.end());
- }
- }
- }
- }
-
-
-
- template <class DH, class SparsityPattern>
- void
- make_boundary_sparsity_pattern (
- const DH &dof,
- const std::vector<types::global_dof_index> &dof_to_boundary_mapping,
- SparsityPattern &sparsity)
- {
- if (DH::dimension == 1)
- {
- // there are only 2 boundary indicators in 1d, so it is no
- // performance problem to call the other function
- typename DH::FunctionMap boundary_indicators;
- boundary_indicators[0] = 0;
- boundary_indicators[1] = 0;
- make_boundary_sparsity_pattern<DH, SparsityPattern> (dof,
- boundary_indicators,
- dof_to_boundary_mapping,
- sparsity);
- return;
- }
-
- const types::global_dof_index n_dofs = dof.n_dofs();
-
- AssertDimension (dof_to_boundary_mapping.size(), n_dofs);
- AssertDimension (sparsity.n_rows(), dof.n_boundary_dofs());
- AssertDimension (sparsity.n_cols(), dof.n_boundary_dofs());
-#ifdef DEBUG
- if (sparsity.n_rows() != 0)
- {
- types::global_dof_index max_element = 0;
- for (std::vector<types::global_dof_index>::const_iterator i=dof_to_boundary_mapping.begin();
- i!=dof_to_boundary_mapping.end(); ++i)
- if ((*i != DH::invalid_dof_index) &&
- (*i > max_element))
- max_element = *i;
- AssertDimension (max_element, sparsity.n_rows()-1);
- };
-#endif
-
- std::vector<types::global_dof_index> dofs_on_this_face;
- dofs_on_this_face.reserve (max_dofs_per_face(dof));
-
- // loop over all faces to check whether they are at a boundary. note
- // that we need not take special care of single lines (using
- // @p{cell->has_boundary_lines}), since we do not support boundaries of
- // dimension dim-2, and so every boundary line is also part of a
- // boundary face.
- typename DH::active_cell_iterator cell = dof.begin_active(),
- endc = dof.end();
- for (; cell!=endc; ++cell)
- for (unsigned int f=0; f<GeometryInfo<DH::dimension>::faces_per_cell; ++f)
- if (cell->at_boundary(f))
- {
- const unsigned int dofs_per_face = cell->get_fe().dofs_per_face;
- dofs_on_this_face.resize (dofs_per_face);
- cell->face(f)->get_dof_indices (dofs_on_this_face,
- cell->active_fe_index());
-
- // make sparsity pattern for this cell
- for (unsigned int i=0; i<dofs_per_face; ++i)
- for (unsigned int j=0; j<dofs_per_face; ++j)
- sparsity.add (dof_to_boundary_mapping[dofs_on_this_face[i]],
- dof_to_boundary_mapping[dofs_on_this_face[j]]);
- }
- }
-
-
-
- template <class DH, class SparsityPattern>
- void make_boundary_sparsity_pattern (
- const DH &dof,
- const typename FunctionMap<DH::space_dimension>::type &boundary_indicators,
- const std::vector<types::global_dof_index> &dof_to_boundary_mapping,
- SparsityPattern &sparsity)
- {
- if (DH::dimension == 1)
- {
- // first check left, then right boundary point
- for (unsigned int direction=0; direction<2; ++direction)
- {
- // if this boundary is not requested, then go on with next one
- if (boundary_indicators.find(direction) ==
- boundary_indicators.end())
- continue;
-
- // find active cell at that boundary: first go to left/right,
- // then to children
- typename DH::level_cell_iterator cell = dof.begin(0);
- while (!cell->at_boundary(direction))
- cell = cell->neighbor(direction);
- while (!cell->active())
- cell = cell->child(direction);
-
- const unsigned int dofs_per_vertex = cell->get_fe().dofs_per_vertex;
- std::vector<types::global_dof_index> boundary_dof_boundary_indices (dofs_per_vertex);
-
- // next get boundary mapped dof indices of boundary dofs
- for (unsigned int i=0; i<dofs_per_vertex; ++i)
- boundary_dof_boundary_indices[i]
- = dof_to_boundary_mapping[cell->vertex_dof_index(direction,i)];
-
- for (unsigned int i=0; i<dofs_per_vertex; ++i)
- sparsity.add_entries (boundary_dof_boundary_indices[i],
- boundary_dof_boundary_indices.begin(),
- boundary_dof_boundary_indices.end());
- };
- return;
- }
-
- const types::global_dof_index n_dofs = dof.n_dofs();
-
- AssertDimension (dof_to_boundary_mapping.size(), n_dofs);
- Assert (boundary_indicators.find(numbers::internal_face_boundary_id) == boundary_indicators.end(),
- typename DH::ExcInvalidBoundaryIndicator());
- Assert (sparsity.n_rows() == dof.n_boundary_dofs (boundary_indicators),
- ExcDimensionMismatch (sparsity.n_rows(), dof.n_boundary_dofs (boundary_indicators)));
- Assert (sparsity.n_cols() == dof.n_boundary_dofs (boundary_indicators),
- ExcDimensionMismatch (sparsity.n_cols(), dof.n_boundary_dofs (boundary_indicators)));
-#ifdef DEBUG
- if (sparsity.n_rows() != 0)
- {
- types::global_dof_index max_element = 0;
- for (std::vector<types::global_dof_index>::const_iterator i=dof_to_boundary_mapping.begin();
- i!=dof_to_boundary_mapping.end(); ++i)
- if ((*i != DH::invalid_dof_index) &&
- (*i > max_element))
- max_element = *i;
- AssertDimension (max_element, sparsity.n_rows()-1);
- };
-#endif
-
- std::vector<types::global_dof_index> dofs_on_this_face;
- dofs_on_this_face.reserve (max_dofs_per_face(dof));
- typename DH::active_cell_iterator cell = dof.begin_active(),
- endc = dof.end();
- for (; cell!=endc; ++cell)
- for (unsigned int f=0; f<GeometryInfo<DH::dimension>::faces_per_cell; ++f)
- if (boundary_indicators.find(cell->face(f)->boundary_indicator()) !=
- boundary_indicators.end())
- {
- const unsigned int dofs_per_face = cell->get_fe().dofs_per_face;
- dofs_on_this_face.resize (dofs_per_face);
- cell->face(f)->get_dof_indices (dofs_on_this_face,
- cell->active_fe_index());
-
- // make sparsity pattern for this cell
- for (unsigned int i=0; i<dofs_per_face; ++i)
- for (unsigned int j=0; j<dofs_per_face; ++j)
- sparsity.add (dof_to_boundary_mapping[dofs_on_this_face[i]],
- dof_to_boundary_mapping[dofs_on_this_face[j]]);
- }
- }
-
-
-
- template <class DH, class SparsityPattern>
- void
- make_flux_sparsity_pattern (const DH &dof,
- SparsityPattern &sparsity,
- const ConstraintMatrix &constraints,
- const bool keep_constrained_dofs,
- const types::subdomain_id subdomain_id)
-
- // TODO: QA: reduce the indentation level of this method..., Maier 2012
-
- {
- const types::global_dof_index n_dofs = dof.n_dofs();
-
- AssertDimension (sparsity.n_rows(), n_dofs);
- AssertDimension (sparsity.n_cols(), n_dofs);
-
- // If we have a distributed::Triangulation only allow locally_owned
- // subdomain. Not setting a subdomain is also okay, because we skip
- // ghost cells in the loop below.
- Assert (
- (dof.get_tria().locally_owned_subdomain() == numbers::invalid_subdomain_id)
- ||
- (subdomain_id == numbers::invalid_subdomain_id)
- ||
- (subdomain_id == dof.get_tria().locally_owned_subdomain()),
- ExcMessage ("For parallel::distributed::Triangulation objects and "
- "associated DoF handler objects, asking for any subdomain other "
- "than the locally owned one does not make sense."));
-
- std::vector<types::global_dof_index> dofs_on_this_cell;
- std::vector<types::global_dof_index> dofs_on_other_cell;
- dofs_on_this_cell.reserve (max_dofs_per_cell(dof));
- dofs_on_other_cell.reserve (max_dofs_per_cell(dof));
- typename DH::active_cell_iterator cell = dof.begin_active(),
- endc = dof.end();
-
- // TODO: in an old implementation, we used user flags before to tag
- // faces that were already touched. this way, we could reduce the work
- // a little bit. now, we instead add only data from one side. this
- // should be OK, but we need to actually verify it.
-
- // In case we work with a distributed sparsity pattern of Trilinos
- // type, we only have to do the work if the current cell is owned by
- // the calling processor. Otherwise, just continue.
- for (; cell!=endc; ++cell)
- if (((subdomain_id == numbers::invalid_subdomain_id)
- ||
- (subdomain_id == cell->subdomain_id()))
- &&
- cell->is_locally_owned())
- {
- const unsigned int n_dofs_on_this_cell = cell->get_fe().dofs_per_cell;
- dofs_on_this_cell.resize (n_dofs_on_this_cell);
- cell->get_dof_indices (dofs_on_this_cell);
-
- // make sparsity pattern for this cell. if no constraints pattern
- // was given, then the following call acts as if simply no
- // constraints existed
- constraints.add_entries_local_to_global (dofs_on_this_cell,
- sparsity,
- keep_constrained_dofs);
-
- for (unsigned int face = 0;
- face < GeometryInfo<DH::dimension>::faces_per_cell;
- ++face)
- {
- typename DH::face_iterator cell_face = cell->face(face);
- if (! cell->at_boundary(face) )
- {
- typename DH::level_cell_iterator neighbor = cell->neighbor(face);
-
- // in 1d, we do not need to worry whether the neighbor
- // might have children and then loop over those children.
- // rather, we may as well go straight to to cell behind
- // this particular cell's most terminal child
- if (DH::dimension==1)
- while (neighbor->has_children())
- neighbor = neighbor->child(face==0 ? 1 : 0);
-
- if (neighbor->has_children())
- {
- for (unsigned int sub_nr = 0;
- sub_nr != cell_face->number_of_children();
- ++sub_nr)
- {
- const typename DH::level_cell_iterator
- sub_neighbor
- = cell->neighbor_child_on_subface (face, sub_nr);
-
- const unsigned int n_dofs_on_neighbor
- = sub_neighbor->get_fe().dofs_per_cell;
- dofs_on_other_cell.resize (n_dofs_on_neighbor);
- sub_neighbor->get_dof_indices (dofs_on_other_cell);
-
- constraints.add_entries_local_to_global
- (dofs_on_this_cell, dofs_on_other_cell,
- sparsity, keep_constrained_dofs);
- constraints.add_entries_local_to_global
- (dofs_on_other_cell, dofs_on_this_cell,
- sparsity, keep_constrained_dofs);
- }
- }
- else
- {
- // Refinement edges are taken care of by coarser
- // cells
-
- // TODO: in the distributed case, we miss out the
- // constraints when the neighbor cell is coarser, but
- // only the current cell is owned locally!
- if (cell->neighbor_is_coarser(face))
- continue;
-
- const unsigned int n_dofs_on_neighbor
- = neighbor->get_fe().dofs_per_cell;
- dofs_on_other_cell.resize (n_dofs_on_neighbor);
-
- neighbor->get_dof_indices (dofs_on_other_cell);
-
- constraints.add_entries_local_to_global
- (dofs_on_this_cell, dofs_on_other_cell,
- sparsity, keep_constrained_dofs);
-
- // only need to add these in case the neighbor cell
- // is not locally owned - otherwise, we touch each
- // face twice and hence put the indices the other way
- // around
- if (!cell->neighbor(face)->active()
- ||
- (cell->neighbor(face)->subdomain_id() !=
- cell->subdomain_id()))
- constraints.add_entries_local_to_global
- (dofs_on_other_cell, dofs_on_this_cell,
- sparsity, keep_constrained_dofs);
- }
- }
- }
- }
- }
-
-
-
- template <class DH, class SparsityPattern>
- void
- make_flux_sparsity_pattern (const DH &dof,
- SparsityPattern &sparsity)
- {
- ConstraintMatrix constraints;
- make_flux_sparsity_pattern (dof, sparsity, constraints);
- }
-
-
-
- template <int dim, int spacedim>
- Table<2,Coupling>
- dof_couplings_from_component_couplings (const FiniteElement<dim,spacedim> &fe,
- const Table<2,Coupling> &component_couplings)
- {
- Assert(component_couplings.n_rows() == fe.n_components(),
- ExcDimensionMismatch(component_couplings.n_rows(),
- fe.n_components()));
- Assert(component_couplings.n_cols() == fe.n_components(),
- ExcDimensionMismatch(component_couplings.n_cols(),
- fe.n_components()));
-
- const unsigned int n_dofs = fe.dofs_per_cell;
-
- Table<2,Coupling> dof_couplings (n_dofs, n_dofs);
-
- for (unsigned int i=0; i<n_dofs; ++i)
- {
- const unsigned int ii
- = (fe.is_primitive(i) ?
- fe.system_to_component_index(i).first
- :
- fe.get_nonzero_components(i).first_selected_component()
- );
- Assert (ii < fe.n_components(), ExcInternalError());
-
- for (unsigned int j=0; j<n_dofs; ++j)
- {
- const unsigned int jj
- = (fe.is_primitive(j) ?
- fe.system_to_component_index(j).first
- :
- fe.get_nonzero_components(j).first_selected_component()
- );
- Assert (jj < fe.n_components(), ExcInternalError());
-
- dof_couplings(i,j) = component_couplings(ii,jj);
- }
- }
- return dof_couplings;
- }
-
-
-
- template <int dim, int spacedim>
- std::vector<Table<2,Coupling> >
- dof_couplings_from_component_couplings
- (const hp::FECollection<dim,spacedim> &fe,
- const Table<2,Coupling> &component_couplings)
- {
- std::vector<Table<2,Coupling> > return_value (fe.size());
- for (unsigned int i=0; i<fe.size(); ++i)
- return_value[i]
- = dof_couplings_from_component_couplings(fe[i], component_couplings);
-
- return return_value;
- }
-
-
-
- namespace internal
- {
- namespace
- {
-
- // implementation of the same function in namespace DoFTools for
- // non-hp DoFHandlers
- template <class DH, class SparsityPattern>
- void
- make_flux_sparsity_pattern (const DH &dof,
- SparsityPattern &sparsity,
- const Table<2,Coupling> &int_mask,
- const Table<2,Coupling> &flux_mask)
- {
- const FiniteElement<DH::dimension,DH::space_dimension> &fe = dof.get_fe();
-
- std::vector<types::global_dof_index> dofs_on_this_cell(fe.dofs_per_cell);
- std::vector<types::global_dof_index> dofs_on_other_cell(fe.dofs_per_cell);
-
- const Table<2,Coupling>
- int_dof_mask = dof_couplings_from_component_couplings(fe, int_mask),
- flux_dof_mask = dof_couplings_from_component_couplings(fe, flux_mask);
-
- Table<2,bool> support_on_face(fe.dofs_per_cell,
- GeometryInfo<DH::dimension>::faces_per_cell);
- for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
- for (unsigned int f=0; f<GeometryInfo<DH::dimension>::faces_per_cell; ++f)
- support_on_face(i,f) = fe.has_support_on_face(i,f);
-
- typename DH::active_cell_iterator cell = dof.begin_active(),
- endc = dof.end();
- for (; cell!=endc; ++cell)
- if (cell->is_locally_owned())
- {
- cell->get_dof_indices (dofs_on_this_cell);
- // make sparsity pattern for this cell
- for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
- for (unsigned int j=0; j<fe.dofs_per_cell; ++j)
- if (int_dof_mask(i,j) != none)
- sparsity.add (dofs_on_this_cell[i],
- dofs_on_this_cell[j]);
-
- // Loop over all interior neighbors
- for (unsigned int face = 0;
- face < GeometryInfo<DH::dimension>::faces_per_cell;
- ++face)
- {
- const typename DH::face_iterator
- cell_face = cell->face(face);
- if (cell_face->user_flag_set ())
- continue;
-
- if (cell->at_boundary (face) )
- {
- for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
- {
- const bool i_non_zero_i = support_on_face (i, face);
- for (unsigned int j=0; j<fe.dofs_per_cell; ++j)
- {
- const bool j_non_zero_i = support_on_face (j, face);
-
- if ((flux_dof_mask(i,j) == always)
- ||
- (flux_dof_mask(i,j) == nonzero
- &&
- i_non_zero_i
- &&
- j_non_zero_i))
- sparsity.add (dofs_on_this_cell[i],
- dofs_on_this_cell[j]);
- }
- }
- }
- else
- {
- typename DH::level_cell_iterator
- neighbor = cell->neighbor(face);
- // Refinement edges are taken care of by coarser
- // cells
- if (cell->neighbor_is_coarser(face))
- continue;
-
- typename DH::face_iterator cell_face = cell->face(face);
- const unsigned int
- neighbor_face = cell->neighbor_of_neighbor(face);
-
- if (cell_face->has_children())
- {
- for (unsigned int sub_nr = 0;
- sub_nr != cell_face->n_children();
- ++sub_nr)
- {
- const typename DH::level_cell_iterator
- sub_neighbor
- = cell->neighbor_child_on_subface (face, sub_nr);
-
- sub_neighbor->get_dof_indices (dofs_on_other_cell);
- for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
- {
- const bool i_non_zero_i = support_on_face (i, face);
- const bool i_non_zero_e = support_on_face (i, neighbor_face);
- for (unsigned int j=0; j<fe.dofs_per_cell; ++j)
- {
- const bool j_non_zero_i = support_on_face (j, face);
- const bool j_non_zero_e = support_on_face (j, neighbor_face);
-
- if (flux_dof_mask(i,j) == always)
- {
- sparsity.add (dofs_on_this_cell[i],
- dofs_on_other_cell[j]);
- sparsity.add (dofs_on_other_cell[i],
- dofs_on_this_cell[j]);
- sparsity.add (dofs_on_this_cell[i],
- dofs_on_this_cell[j]);
- sparsity.add (dofs_on_other_cell[i],
- dofs_on_other_cell[j]);
- }
- else if (flux_dof_mask(i,j) == nonzero)
- {
- if (i_non_zero_i && j_non_zero_e)
- sparsity.add (dofs_on_this_cell[i],
- dofs_on_other_cell[j]);
- if (i_non_zero_e && j_non_zero_i)
- sparsity.add (dofs_on_other_cell[i],
- dofs_on_this_cell[j]);
- if (i_non_zero_i && j_non_zero_i)
- sparsity.add (dofs_on_this_cell[i],
- dofs_on_this_cell[j]);
- if (i_non_zero_e && j_non_zero_e)
- sparsity.add (dofs_on_other_cell[i],
- dofs_on_other_cell[j]);
- }
-
- if (flux_dof_mask(j,i) == always)
- {
- sparsity.add (dofs_on_this_cell[j],
- dofs_on_other_cell[i]);
- sparsity.add (dofs_on_other_cell[j],
- dofs_on_this_cell[i]);
- sparsity.add (dofs_on_this_cell[j],
- dofs_on_this_cell[i]);
- sparsity.add (dofs_on_other_cell[j],
- dofs_on_other_cell[i]);
- }
- else if (flux_dof_mask(j,i) == nonzero)
- {
- if (j_non_zero_i && i_non_zero_e)
- sparsity.add (dofs_on_this_cell[j],
- dofs_on_other_cell[i]);
- if (j_non_zero_e && i_non_zero_i)
- sparsity.add (dofs_on_other_cell[j],
- dofs_on_this_cell[i]);
- if (j_non_zero_i && i_non_zero_i)
- sparsity.add (dofs_on_this_cell[j],
- dofs_on_this_cell[i]);
- if (j_non_zero_e && i_non_zero_e)
- sparsity.add (dofs_on_other_cell[j],
- dofs_on_other_cell[i]);
- }
- }
- }
- sub_neighbor->face(neighbor_face)->set_user_flag ();
- }
- }
- else
- {
- neighbor->get_dof_indices (dofs_on_other_cell);
- for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
- {
- const bool i_non_zero_i = support_on_face (i, face);
- const bool i_non_zero_e = support_on_face (i, neighbor_face);
- for (unsigned int j=0; j<fe.dofs_per_cell; ++j)
- {
- const bool j_non_zero_i = support_on_face (j, face);
- const bool j_non_zero_e = support_on_face (j, neighbor_face);
- if (flux_dof_mask(i,j) == always)
- {
- sparsity.add (dofs_on_this_cell[i],
- dofs_on_other_cell[j]);
- sparsity.add (dofs_on_other_cell[i],
- dofs_on_this_cell[j]);
- sparsity.add (dofs_on_this_cell[i],
- dofs_on_this_cell[j]);
- sparsity.add (dofs_on_other_cell[i],
- dofs_on_other_cell[j]);
- }
- if (flux_dof_mask(i,j) == nonzero)
- {
- if (i_non_zero_i && j_non_zero_e)
- sparsity.add (dofs_on_this_cell[i],
- dofs_on_other_cell[j]);
- if (i_non_zero_e && j_non_zero_i)
- sparsity.add (dofs_on_other_cell[i],
- dofs_on_this_cell[j]);
- if (i_non_zero_i && j_non_zero_i)
- sparsity.add (dofs_on_this_cell[i],
- dofs_on_this_cell[j]);
- if (i_non_zero_e && j_non_zero_e)
- sparsity.add (dofs_on_other_cell[i],
- dofs_on_other_cell[j]);
- }
-
- if (flux_dof_mask(j,i) == always)
- {
- sparsity.add (dofs_on_this_cell[j],
- dofs_on_other_cell[i]);
- sparsity.add (dofs_on_other_cell[j],
- dofs_on_this_cell[i]);
- sparsity.add (dofs_on_this_cell[j],
- dofs_on_this_cell[i]);
- sparsity.add (dofs_on_other_cell[j],
- dofs_on_other_cell[i]);
- }
- if (flux_dof_mask(j,i) == nonzero)
- {
- if (j_non_zero_i && i_non_zero_e)
- sparsity.add (dofs_on_this_cell[j],
- dofs_on_other_cell[i]);
- if (j_non_zero_e && i_non_zero_i)
- sparsity.add (dofs_on_other_cell[j],
- dofs_on_this_cell[i]);
- if (j_non_zero_i && i_non_zero_i)
- sparsity.add (dofs_on_this_cell[j],
- dofs_on_this_cell[i]);
- if (j_non_zero_e && i_non_zero_e)
- sparsity.add (dofs_on_other_cell[j],
- dofs_on_other_cell[i]);
- }
- }
- }
- neighbor->face(neighbor_face)->set_user_flag ();
- }
- }
- }
- }
- }
-
-
- // implementation of the same function in namespace DoFTools for
- // non-hp DoFHandlers
- template <int dim, int spacedim, class SparsityPattern>
- void
- make_flux_sparsity_pattern (const dealii::hp::DoFHandler<dim,spacedim> &dof,
- SparsityPattern &sparsity,
- const Table<2,Coupling> &int_mask,
- const Table<2,Coupling> &flux_mask)
- {
- // while the implementation above is quite optimized and caches a
- // lot of data (see e.g. the int/flux_dof_mask tables), this is no
- // longer practical for the hp version since we would have to have
- // it for all combinations of elements in the hp::FECollection.
- // consequently, the implementation here is simpler and probably
- // less efficient but at least readable...
-
- const dealii::hp::FECollection<dim,spacedim> &fe = dof.get_fe();
-
- std::vector<types::global_dof_index> dofs_on_this_cell(DoFTools::max_dofs_per_cell(dof));
- std::vector<types::global_dof_index> dofs_on_other_cell(DoFTools::max_dofs_per_cell(dof));
-
- const std::vector<Table<2,Coupling> >
- int_dof_mask
- = dof_couplings_from_component_couplings(fe, int_mask);
-
- typename dealii::hp::DoFHandler<dim,spacedim>::active_cell_iterator
- cell = dof.begin_active(),
- endc = dof.end();
- for (; cell!=endc; ++cell)
- {
- dofs_on_this_cell.resize (cell->get_fe().dofs_per_cell);
- cell->get_dof_indices (dofs_on_this_cell);
-
- // make sparsity pattern for this cell
- for (unsigned int i=0; i<cell->get_fe().dofs_per_cell; ++i)
- for (unsigned int j=0; j<cell->get_fe().dofs_per_cell; ++j)
- if (int_dof_mask[cell->active_fe_index()](i,j) != none)
- sparsity.add (dofs_on_this_cell[i],
- dofs_on_this_cell[j]);
-
- // Loop over all interior neighbors
- for (unsigned int face = 0;
- face < GeometryInfo<dim>::faces_per_cell;
- ++face)
- {
- const typename dealii::hp::DoFHandler<dim,spacedim>::face_iterator
- cell_face = cell->face(face);
- if (cell_face->user_flag_set ())
- continue;
-
- if (cell->at_boundary (face) )
- {
- for (unsigned int i=0; i<cell->get_fe().dofs_per_cell; ++i)
- for (unsigned int j=0; j<cell->get_fe().dofs_per_cell; ++j)
- if ((flux_mask(cell->get_fe().system_to_component_index(i).first,
- cell->get_fe().system_to_component_index(j).first)
- == always)
- ||
- (flux_mask(cell->get_fe().system_to_component_index(i).first,
- cell->get_fe().system_to_component_index(j).first)
- == nonzero))
- sparsity.add (dofs_on_this_cell[i],
- dofs_on_this_cell[j]);
- }
- else
- {
- typename dealii::hp::DoFHandler<dim,spacedim>::level_cell_iterator
- neighbor = cell->neighbor(face);
-
- // Refinement edges are taken care of by coarser cells
- if (cell->neighbor_is_coarser(face))
- continue;
-
- typename dealii::hp::DoFHandler<dim,spacedim>::face_iterator
- cell_face = cell->face(face);
- const unsigned int
- neighbor_face = cell->neighbor_of_neighbor(face);
-
- if (cell_face->has_children())
- {
- for (unsigned int sub_nr = 0;
- sub_nr != cell_face->n_children();
- ++sub_nr)
- {
- const typename dealii::hp::DoFHandler<dim,spacedim>::level_cell_iterator
- sub_neighbor
- = cell->neighbor_child_on_subface (face, sub_nr);
-
- dofs_on_other_cell.resize (sub_neighbor->get_fe().dofs_per_cell);
- sub_neighbor->get_dof_indices (dofs_on_other_cell);
- for (unsigned int i=0; i<cell->get_fe().dofs_per_cell; ++i)
- {
- for (unsigned int j=0; j<sub_neighbor->get_fe().dofs_per_cell;
- ++j)
- {
- if ((flux_mask(cell->get_fe().system_to_component_index(i).first,
- sub_neighbor->get_fe().system_to_component_index(j).first)
- == always)
- ||
- (flux_mask(cell->get_fe().system_to_component_index(i).first,
- sub_neighbor->get_fe().system_to_component_index(j).first)
- == nonzero))
- {
- sparsity.add (dofs_on_this_cell[i],
- dofs_on_other_cell[j]);
- sparsity.add (dofs_on_other_cell[i],
- dofs_on_this_cell[j]);
- sparsity.add (dofs_on_this_cell[i],
- dofs_on_this_cell[j]);
- sparsity.add (dofs_on_other_cell[i],
- dofs_on_other_cell[j]);
- }
-
- if ((flux_mask(sub_neighbor->get_fe().system_to_component_index(j).first,
- cell->get_fe().system_to_component_index(i).first)
- == always)
- ||
- (flux_mask(sub_neighbor->get_fe().system_to_component_index(j).first,
- cell->get_fe().system_to_component_index(i).first)
- == nonzero))
- {
- sparsity.add (dofs_on_this_cell[j],
- dofs_on_other_cell[i]);
- sparsity.add (dofs_on_other_cell[j],
- dofs_on_this_cell[i]);
- sparsity.add (dofs_on_this_cell[j],
- dofs_on_this_cell[i]);
- sparsity.add (dofs_on_other_cell[j],
- dofs_on_other_cell[i]);
- }
- }
- }
- sub_neighbor->face(neighbor_face)->set_user_flag ();
- }
- }
- else
- {
- dofs_on_other_cell.resize (neighbor->get_fe().dofs_per_cell);
- neighbor->get_dof_indices (dofs_on_other_cell);
- for (unsigned int i=0; i<cell->get_fe().dofs_per_cell; ++i)
- {
- for (unsigned int j=0; j<neighbor->get_fe().dofs_per_cell; ++j)
- {
- if ((flux_mask(cell->get_fe().system_to_component_index(i).first,
- neighbor->get_fe().system_to_component_index(j).first)
- == always)
- ||
- (flux_mask(cell->get_fe().system_to_component_index(i).first,
- neighbor->get_fe().system_to_component_index(j).first)
- == nonzero))
- {
- sparsity.add (dofs_on_this_cell[i],
- dofs_on_other_cell[j]);
- sparsity.add (dofs_on_other_cell[i],
- dofs_on_this_cell[j]);
- sparsity.add (dofs_on_this_cell[i],
- dofs_on_this_cell[j]);
- sparsity.add (dofs_on_other_cell[i],
- dofs_on_other_cell[j]);
- }
-
- if ((flux_mask(neighbor->get_fe().system_to_component_index(j).first,
- cell->get_fe().system_to_component_index(i).first)
- == always)
- ||
- (flux_mask(neighbor->get_fe().system_to_component_index(j).first,
- cell->get_fe().system_to_component_index(i).first)
- == nonzero))
- {
- sparsity.add (dofs_on_this_cell[j],
- dofs_on_other_cell[i]);
- sparsity.add (dofs_on_other_cell[j],
- dofs_on_this_cell[i]);
- sparsity.add (dofs_on_this_cell[j],
- dofs_on_this_cell[i]);
- sparsity.add (dofs_on_other_cell[j],
- dofs_on_other_cell[i]);
- }
- }
- }
- neighbor->face(neighbor_face)->set_user_flag ();
- }
- }
- }
- }
- }
- }
-
- }
-
-
-
-
- template <class DH, class SparsityPattern>
- void
- make_flux_sparsity_pattern (const DH &dof,
- SparsityPattern &sparsity,
- const Table<2,Coupling> &int_mask,
- const Table<2,Coupling> &flux_mask)
- {
- // do the error checking and frame code here, and then pass on to more
- // specialized functions in the internal namespace
- const types::global_dof_index n_dofs = dof.n_dofs();
- const unsigned int n_comp = dof.get_fe().n_components();
-
- Assert (sparsity.n_rows() == n_dofs,
- ExcDimensionMismatch (sparsity.n_rows(), n_dofs));
- Assert (sparsity.n_cols() == n_dofs,
- ExcDimensionMismatch (sparsity.n_cols(), n_dofs));
- Assert (int_mask.n_rows() == n_comp,
- ExcDimensionMismatch (int_mask.n_rows(), n_comp));
- Assert (int_mask.n_cols() == n_comp,
- ExcDimensionMismatch (int_mask.n_cols(), n_comp));
- Assert (flux_mask.n_rows() == n_comp,
- ExcDimensionMismatch (flux_mask.n_rows(), n_comp));
- Assert (flux_mask.n_cols() == n_comp,
- ExcDimensionMismatch (flux_mask.n_cols(), n_comp));
-
- // Clear user flags because we will need them. But first we save them
- // and make sure that we restore them later such that at the end of
- // this function the Triangulation will be in the same state as it was
- // at the beginning of this function.
- std::vector<bool> user_flags;
- dof.get_tria().save_user_flags(user_flags);
- const_cast<Triangulation<DH::dimension,DH::space_dimension> &>(dof.get_tria()).clear_user_flags ();
-
- internal::make_flux_sparsity_pattern (dof, sparsity,
- int_mask, flux_mask);
-
- // finally restore the user flags
- const_cast<Triangulation<DH::dimension,DH::space_dimension> &>(dof.get_tria()).load_user_flags(user_flags);
- }
-
-
-
-
- namespace internal
- {
- namespace
- {
- inline bool
- check_master_dof_list (const FullMatrix<double> &face_interpolation_matrix,
- const std::vector<types::global_dof_index> &master_dof_list)
- {
- const unsigned int N = master_dof_list.size();
-
- FullMatrix<double> tmp (N,N);
- for (unsigned int i=0; i<N; ++i)
- for (unsigned int j=0; j<N; ++j)
- tmp(i,j) = face_interpolation_matrix (master_dof_list[i], j);
-
- // then use the algorithm from FullMatrix::gauss_jordan on this
- // matrix to find out whether it is singular. the algorithm there
- // does piviting and at the end swaps rows back into their proper
- // order -- we omit this step here, since we don't care about the
- // inverse matrix, all we care about is whether the matrix is
- // regular or singular
-
- // first get an estimate of the size of the elements of this
- // matrix, for later checks whether the pivot element is large
- // enough, or whether we have to fear that the matrix is not
- // regular
- double diagonal_sum = 0;
- for (unsigned int i=0; i<N; ++i)
- diagonal_sum += std::fabs(tmp(i,i));
- const double typical_diagonal_element = diagonal_sum/N;
-
- // initialize the array that holds the permutations that we find
- // during pivot search
- std::vector<unsigned int> p(N);
- for (unsigned int i=0; i<N; ++i)
- p[i] = i;
-
- for (unsigned int j=0; j<N; ++j)
- {
- // pivot search: search that part of the line on and right of
- // the diagonal for the largest element
- double max = std::fabs(tmp(j,j));
- unsigned int r = j;
- for (unsigned int i=j+1; i<N; ++i)
- {
- if (std::fabs(tmp(i,j)) > max)
- {
- max = std::fabs(tmp(i,j));
- r = i;
- }
- }
- // check whether the pivot is too small. if that is the case,
- // then the matrix is singular and we shouldn't use this set of
- // master dofs
- if (max < 1.e-12*typical_diagonal_element)
- return false;
-
- // row interchange
- if (r>j)
- {
- for (unsigned int k=0; k<N; ++k)
- std::swap (tmp(j,k), tmp(r,k));
-
- std::swap (p[j], p[r]);
- }
-
- // transformation
- const double hr = 1./tmp(j,j);
- tmp(j,j) = hr;
- for (unsigned int k=0; k<N; ++k)
- {
- if (k==j) continue;
- for (unsigned int i=0; i<N; ++i)
- {
- if (i==j) continue;
- tmp(i,k) -= tmp(i,j)*tmp(j,k)*hr;
- }
- }
- for (unsigned int i=0; i<N; ++i)
- {
- tmp(i,j) *= hr;
- tmp(j,i) *= -hr;
- }
- tmp(j,j) = hr;
- }
-
- // everything went fine, so we can accept this set of master dofs
- // (at least as far as they have already been collected)
- return true;
- }
-
-
-
- /**
- * When restricting, on a face, the degrees of freedom of fe1 to the
- * space described by fe2 (for example for the complex case described
- * in the @ref hp_paper "hp paper"), we have to select
- * fe2.dofs_per_face out of the fe1.dofs_per_face face DoFs as the
- * master DoFs, and the rest become slave dofs. This function selects
- * which ones will be masters, and which ones will be slaves.
- *
- * The function assumes that master_dofs already has size
- * fe1.dofs_per_face. After the function, exactly fe2.dofs_per_face
- * entries will be true.
- *
- * The function is a bit complicated since it has to figure out a set
- * a DoFs so that the corresponding rows in the face interpolation
- * matrix are all linearly independent. we have a good heuristic (see
- * the function body) for selecting these rows, but there are cases
- * where this fails and we have to pick them differently. what we do
- * is to run the heuristic and then go back to determine whether we
- * have a set of rows with full row rank. if this isn't the case, go
- * back and select dofs differently
- */
- template <int dim, int spacedim>
- void
- select_master_dofs_for_face_restriction (const FiniteElement<dim,spacedim> &fe1,
- const FiniteElement<dim,spacedim> &fe2,
- const FullMatrix<double> &face_interpolation_matrix,
- std::vector<bool> &master_dof_mask)
- {
- Assert (fe1.dofs_per_face >= fe2.dofs_per_face,
- ExcInternalError());
- AssertDimension (master_dof_mask.size(), fe1.dofs_per_face);
-
- Assert (fe2.dofs_per_vertex <= fe1.dofs_per_vertex,
- ExcInternalError());
- Assert (fe2.dofs_per_line <= fe1.dofs_per_line,
- ExcInternalError());
- Assert ((dim < 3)
- ||
- (fe2.dofs_per_quad <= fe1.dofs_per_quad),
- ExcInternalError());
-
- // the idea here is to designate as many DoFs in fe1 per object
- // (vertex, line, quad) as master as there are such dofs in fe2
- // (indices are int, because we want to avoid the 'unsigned int < 0
- // is always false warning for the cases at the bottom in 1d and
- // 2d)
- //
- // as mentioned in the paper, it is not always easy to find a set
- // of master dofs that produces an invertible matrix. to this end,
- // we check in each step whether the matrix is still invertible and
- // simply discard this dof if the matrix is not invertible anymore.
- //
- // the cases where we did have trouble in the past were with adding
- // more quad dofs when Q3 and Q4 elements meet at a refined face in
- // 3d (see the hp/crash_12 test that tests that we can do exactly
- // this, and failed before we had code to compensate for this
- // case). the other case are system elements: if we have say a Q1Q2
- // vs a Q2Q3 element, then we can't just take all master dofs on a
- // line from a single base element, since the shape functions of
- // that base element are independent of that of the other one. this
- // latter case shows up when running hp/hp_constraints_q_system_06
-
- std::vector<types::global_dof_index> master_dof_list;
- unsigned int index = 0;
- for (int v=0;
- v<static_cast<signed int>(GeometryInfo<dim>::vertices_per_face);
- ++v)
- {
- unsigned int dofs_added = 0;
- unsigned int i = 0;
- while (dofs_added < fe2.dofs_per_vertex)
- {
- // make sure that we were able to find a set of master dofs
- // and that the code down below didn't just reject all our
- // efforts
- Assert (i < fe1.dofs_per_vertex,
- ExcInternalError());
-
- // tentatively push this vertex dof
- master_dof_list.push_back (index+i);
-
- // then see what happens. if it succeeds, fine
- if (check_master_dof_list (face_interpolation_matrix,
- master_dof_list)
- == true)
- ++dofs_added;
- else
- // well, it didn't. simply pop that dof from the list
- // again and try with the next dof
- master_dof_list.pop_back ();
-
- // forward counter by one
- ++i;
- }
- index += fe1.dofs_per_vertex;
- }
-
- for (int l=0;
- l<static_cast<signed int>(GeometryInfo<dim>::lines_per_face);
- ++l)
- {
- // same algorithm as above
- unsigned int dofs_added = 0;
- unsigned int i = 0;
- while (dofs_added < fe2.dofs_per_line)
- {
- Assert (i < fe1.dofs_per_line,
- ExcInternalError());
-
- master_dof_list.push_back (index+i);
- if (check_master_dof_list (face_interpolation_matrix,
- master_dof_list)
- == true)
- ++dofs_added;
- else
- master_dof_list.pop_back ();
-
- ++i;
- }
- index += fe1.dofs_per_line;
- }
-
- for (int q=0;
- q<static_cast<signed int>(GeometryInfo<dim>::quads_per_face);
- ++q)
- {
- // same algorithm as above
- unsigned int dofs_added = 0;
- unsigned int i = 0;
- while (dofs_added < fe2.dofs_per_quad)
- {
- Assert (i < fe1.dofs_per_quad,
- ExcInternalError());
-
- master_dof_list.push_back (index+i);
- if (check_master_dof_list (face_interpolation_matrix,
- master_dof_list)
- == true)
- ++dofs_added;
- else
- master_dof_list.pop_back ();
-
- ++i;
- }
- index += fe1.dofs_per_quad;
- }
-
- AssertDimension (index, fe1.dofs_per_face);
- AssertDimension (master_dof_list.size(), fe2.dofs_per_face);
-
- // finally copy the list into the mask
- std::fill (master_dof_mask.begin(), master_dof_mask.end(), false);
- for (std::vector<types::global_dof_index>::const_iterator i=master_dof_list.begin();
- i!=master_dof_list.end(); ++i)
- master_dof_mask[*i] = true;
- }
-
-
-
- /**
- * Make sure that the mask exists that determines which dofs will be
- * the masters on refined faces where an fe1 and a fe2 meet.
- */
- template <int dim, int spacedim>
- void
- ensure_existence_of_master_dof_mask (const FiniteElement<dim,spacedim> &fe1,
- const FiniteElement<dim,spacedim> &fe2,
- const FullMatrix<double> &face_interpolation_matrix,
- std_cxx1x::shared_ptr<std::vector<bool> > &master_dof_mask)
- {
- if (master_dof_mask == std_cxx1x::shared_ptr<std::vector<bool> >())
- {
- master_dof_mask = std_cxx1x::shared_ptr<std::vector<bool> >
- (new std::vector<bool> (fe1.dofs_per_face));
- select_master_dofs_for_face_restriction (fe1,
- fe2,
- face_interpolation_matrix,
- *master_dof_mask);
- }
- }
-
-
-
- /**
- * Make sure that the given @p face_interpolation_matrix pointer
- * points to a valid matrix. If the pointer is zero beforehand,
- * create an entry with the correct data. If it is nonzero, don't
- * touch it.
- */
- template <int dim, int spacedim>
- void
- ensure_existence_of_face_matrix (const FiniteElement<dim,spacedim> &fe1,
- const FiniteElement<dim,spacedim> &fe2,
- std_cxx1x::shared_ptr<FullMatrix<double> > &matrix)
- {
- if (matrix == std_cxx1x::shared_ptr<FullMatrix<double> >())
- {
- matrix = std_cxx1x::shared_ptr<FullMatrix<double> >
- (new FullMatrix<double> (fe2.dofs_per_face,
- fe1.dofs_per_face));
- fe1.get_face_interpolation_matrix (fe2,
- *matrix);
- }
- }
-
-
-
- /**
- * Same, but for subface interpolation matrices.
- */
- template <int dim, int spacedim>
- void
- ensure_existence_of_subface_matrix (const FiniteElement<dim,spacedim> &fe1,
- const FiniteElement<dim,spacedim> &fe2,
- const unsigned int subface,
- std_cxx1x::shared_ptr<FullMatrix<double> > &matrix)
- {
- if (matrix == std_cxx1x::shared_ptr<FullMatrix<double> >())
- {
- matrix = std_cxx1x::shared_ptr<FullMatrix<double> >
- (new FullMatrix<double> (fe2.dofs_per_face,
- fe1.dofs_per_face));
- fe1.get_subface_interpolation_matrix (fe2,
- subface,
- *matrix);
- }
- }
-
-
-
- /**
- * Given the face interpolation matrix between two elements, split it
- * into its master and slave parts and invert the master part as
- * explained in the @ref hp_paper "hp paper".
- */
- void
- ensure_existence_of_split_face_matrix (const FullMatrix<double> &face_interpolation_matrix,
- const std::vector<bool> &master_dof_mask,
- std_cxx1x::shared_ptr<std::pair<FullMatrix<double>,FullMatrix<double> > > &split_matrix)
- {
- AssertDimension (master_dof_mask.size(), face_interpolation_matrix.m());
- Assert (std::count (master_dof_mask.begin(), master_dof_mask.end(), true) ==
- static_cast<signed int>(face_interpolation_matrix.n()),
- ExcInternalError());
-
- if (split_matrix ==
- std_cxx1x::shared_ptr<std::pair<FullMatrix<double>,FullMatrix<double> > >())
- {
- split_matrix
- = std_cxx1x::shared_ptr<std::pair<FullMatrix<double>,FullMatrix<double> > >
- (new std::pair<FullMatrix<double>,FullMatrix<double> >());
-
- const unsigned int n_master_dofs = face_interpolation_matrix.n();
- const unsigned int n_dofs = face_interpolation_matrix.m();
-
- Assert (n_master_dofs <= n_dofs, ExcInternalError());
-
- // copy and invert the master
- // component, copy the slave
- // component
- split_matrix->first.reinit (n_master_dofs, n_master_dofs);
- split_matrix->second.reinit (n_dofs-n_master_dofs, n_master_dofs);
-
- unsigned int nth_master_dof = 0,
- nth_slave_dof = 0;
-
- for (unsigned int i=0; i<n_dofs; ++i)
- if (master_dof_mask[i] == true)
- {
- for (unsigned int j=0; j<n_master_dofs; ++j)
- split_matrix->first(nth_master_dof,j)
- = face_interpolation_matrix(i,j);
- ++nth_master_dof;
- }
- else
- {
- for (unsigned int j=0; j<n_master_dofs; ++j)
- split_matrix->second(nth_slave_dof,j)
- = face_interpolation_matrix(i,j);
- ++nth_slave_dof;
- }
-
- AssertDimension (nth_master_dof, n_master_dofs);
- AssertDimension (nth_slave_dof, n_dofs-n_master_dofs);
-
- //TODO[WB]: We should make sure very small entries are removed after inversion
- split_matrix->first.gauss_jordan ();
- }
- }
-
-
- // a template that can determine statically whether a given
- // DoFHandler class supports different finite element elements
- template <typename>
- struct DoFHandlerSupportsDifferentFEs
- {
- static const bool value = true;
- };
-
-
- template <int dim, int spacedim>
- struct DoFHandlerSupportsDifferentFEs< dealii::DoFHandler<dim,spacedim> >
- {
- static const bool value = false;
- };
-
-
- template <int dim, int spacedim>
- struct DoFHandlerSupportsDifferentFEs< dealii::MGDoFHandler<dim,spacedim> >
- {
- static const bool value = false;
- };
-
-
- /**
- * A function that returns how many different finite elements a dof
- * handler uses. This is one for non-hp DoFHandlers and
- * dof_handler.get_fe().size() for the hp-versions.
- */
- template <int dim, int spacedim>
- unsigned int
- n_finite_elements (const dealii::hp::DoFHandler<dim,spacedim> &dof_handler)
- {
- return dof_handler.get_fe().size();
- }
-
-
- template <class DH>
- unsigned int
- n_finite_elements (const DH &)
- {
- return 1;
- }
-
-
- /**
- * For a given face belonging to an active cell that borders to a
- * more refined cell, return the fe_index of the most dominating
- * finite element used on any of the face's subfaces.
- */
- template <typename face_iterator>
- unsigned int
- get_most_dominating_subface_fe_index (const face_iterator &face)
- {
- const unsigned int dim
- = face_iterator::AccessorType::dimension;
- const unsigned int spacedim
- = face_iterator::AccessorType::space_dimension;
-
- unsigned int dominating_subface_no = 0;
- for (; dominating_subface_no<face->n_children();
- ++dominating_subface_no)
- {
- // each of the subfaces can have only a single fe_index
- // associated with them, since there is no cell on the other
- // side
- Assert (face->child(dominating_subface_no)
- ->n_active_fe_indices()
- == 1,
- ExcInternalError());
-
- const FiniteElement<dim,spacedim> &
- this_subface_fe = (face->child(dominating_subface_no)
- ->get_fe (face->child(dominating_subface_no)
- ->nth_active_fe_index(0)));
-
- FiniteElementDomination::Domination
- domination = FiniteElementDomination::either_element_can_dominate;
- for (unsigned int sf=0; sf<face->n_children(); ++sf)
- if (sf != dominating_subface_no)
- {
- const FiniteElement<dim,spacedim> &
- that_subface_fe = (face->child(sf)
- ->get_fe (face->child(sf)
- ->nth_active_fe_index(0)));
-
- domination = domination &
- this_subface_fe.compare_for_face_domination(that_subface_fe);
- }
-
- // see if the element on this subface is able to dominate the
- // ones on all other subfaces, and if so take it
- if ((domination == FiniteElementDomination::this_element_dominates)
- ||
- (domination == FiniteElementDomination::either_element_can_dominate))
- break;
- }
-
- // check that we have found one such subface
- Assert (dominating_subface_no < face->n_children(),
- ExcNotImplemented());
-
- // return the finite element index used on it. note that only a
- // single fe can be active on such subfaces
- return face->child (dominating_subface_no)->nth_active_fe_index(0);
- }
-
-
-
- /**
- * Copy constraints into a constraint matrix object.
- *
- * This function removes zero constraints and those, which constrain
- * a DoF which was already eliminated in one of the previous steps of
- * the hp hanging node procedure.
- *
- * It also suppresses very small entries in the constraint matrix to
- * avoid making the sparsity pattern fuller than necessary.
- */
- void
- filter_constraints (const std::vector<types::global_dof_index> &master_dofs,
- const std::vector<types::global_dof_index> &slave_dofs,
- const FullMatrix<double> &face_constraints,
- ConstraintMatrix &constraints)
- {
- Assert (face_constraints.n () == master_dofs.size (),
- ExcDimensionMismatch(master_dofs.size (),
- face_constraints.n()));
- Assert (face_constraints.m () == slave_dofs.size (),
- ExcDimensionMismatch(slave_dofs.size (),
- face_constraints.m()));
-
- const unsigned int n_master_dofs = master_dofs.size ();
- const unsigned int n_slave_dofs = slave_dofs.size ();
-
- // check for a couple conditions that happened in parallel
- // distributed mode
- for (unsigned int row=0; row!=n_slave_dofs; ++row)
- Assert (slave_dofs[row] != numbers::invalid_dof_index,
- ExcInternalError());
- for (unsigned int col=0; col!=n_master_dofs; ++col)
- Assert (master_dofs[col] != numbers::invalid_dof_index,
- ExcInternalError());
-
-
- for (unsigned int row=0; row!=n_slave_dofs; ++row)
- if (constraints.is_constrained (slave_dofs[row]) == false)
- {
- bool constraint_already_satisfied = false;
-
- // Check if we have an identity constraint, which is already
- // satisfied by unification of the corresponding global dof
- // indices
- for (unsigned int i=0; i<n_master_dofs; ++i)
- if (face_constraints (row,i) == 1.0)
- if (master_dofs[i] == slave_dofs[row])
- {
- constraint_already_satisfied = true;
- break;
- }
-
- if (constraint_already_satisfied == false)
- {
- // add up the absolute values of all constraints in this
- // line to get a measure of their absolute size
- double abs_sum = 0;
- for (unsigned int i=0; i<n_master_dofs; ++i)
- abs_sum += std::abs (face_constraints(row,i));
-
- // then enter those constraints that are larger than
- // 1e-14*abs_sum. everything else probably originated
- // from inexact inversion of matrices and similar
- // effects. having those constraints in here will only
- // lead to problems because it makes sparsity patterns
- // fuller than necessary without producing any
- // significant effect
- constraints.add_line (slave_dofs[row]);
- for (unsigned int i=0; i<n_master_dofs; ++i)
- if ((face_constraints(row,i) != 0)
- &&
- (std::fabs(face_constraints(row,i)) >= 1e-14*abs_sum))
- constraints.add_entry (slave_dofs[row],
- master_dofs[i],
- face_constraints (row,i));
- constraints.set_inhomogeneity (slave_dofs[row], 0.);
- }
- }
- }
-
- }
-
-
-
- void
- make_hp_hanging_node_constraints (const dealii::DoFHandler<1> &,
- ConstraintMatrix &)
- {
- // nothing to do for regular dof handlers in 1d
- }
-
-
-
- void
- make_oldstyle_hanging_node_constraints (const dealii::DoFHandler<1> &,
- ConstraintMatrix &,
- dealii::internal::int2type<1>)
- {
- // nothing to do for regular dof handlers in 1d
- }
-
-
- void
- make_hp_hanging_node_constraints (const dealii::MGDoFHandler<1> &,
- ConstraintMatrix &)
- {
- // nothing to do for regular dof handlers in 1d
- }
-
-
-
- void
- make_oldstyle_hanging_node_constraints (const dealii::MGDoFHandler<1> &,
- ConstraintMatrix &,
- dealii::internal::int2type<1>)
- {
- // nothing to do for regular dof handlers in 1d
- }
-
-
- void
- make_hp_hanging_node_constraints (const dealii::hp::DoFHandler<1> &/*dof_handler*/,
- ConstraintMatrix &/*constraints*/)
- {
- // we may have to compute constraints for vertices. gotta think about
- // that a bit more
-
- //TODO[WB]: think about what to do here...
- }
-
-
-
- void
- make_oldstyle_hanging_node_constraints (const dealii::hp::DoFHandler<1> &/*dof_handler*/,
- ConstraintMatrix &/*constraints*/,
- dealii::internal::int2type<1>)
- {
- // we may have to compute constraints for vertices. gotta think about
- // that a bit more
-
- //TODO[WB]: think about what to do here...
- }
-
-
- void
- make_hp_hanging_node_constraints (const dealii::DoFHandler<1,2> &,
- ConstraintMatrix &)
- {
- // nothing to do for regular dof handlers in 1d
- }
-
-
-
- void
- make_oldstyle_hanging_node_constraints (const dealii::DoFHandler<1,2> &,
- ConstraintMatrix &,
- dealii::internal::int2type<1>)
- {
- // nothing to do for regular dof handlers in 1d
- }
-
-
- void
- make_hp_hanging_node_constraints (const dealii::DoFHandler<1,3> &,
- ConstraintMatrix &)
- {
- // nothing to do for regular dof handlers in 1d
- }
-
- void
- make_oldstyle_hanging_node_constraints (const dealii::DoFHandler<1,3> &,
- ConstraintMatrix &,
- dealii::internal::int2type<1>)
- {
- // nothing to do for regular dof handlers in 1d
- }
-
-
-// currently not used but may be in the future:
-
-// void
-// make_hp_hanging_node_constraints (const dealii::MDoFHandler<1,2> &,
-// ConstraintMatrix &)
-// {
-// // nothing to do for regular
-// // dof handlers in 1d
-// }
-
-
-
-// void
-// make_oldstyle_hanging_node_constraints (const dealii::DoFHandler<1,2> &,
-// ConstraintMatrix &,
-// dealii::internal::int2type<1>)
-// {
-// // nothing to do for regular
-// // dof handlers in 1d
-// }
-
-
-// void
-// make_oldstyle_hanging_node_constraints (const dealii::hp::DoFHandler<1,2> &/*dof_handler*/,
-// ConstraintMatrix &/*constraints*/,
-// dealii::internal::int2type<1>)
-// {
-// // we may have to compute
-// // constraints for
-// // vertices. gotta think about
-// // that a bit more
-//
-// //TODO[WB]: think about what to do here...
-// }
-//#endif
-
-
-
- template <class DH>
- void
- make_oldstyle_hanging_node_constraints (const DH &dof_handler,
- ConstraintMatrix &constraints,
- dealii::internal::int2type<2>)
- {
- const unsigned int dim = 2;
-
- const unsigned int spacedim = DH::space_dimension;
-
- std::vector<types::global_dof_index> dofs_on_mother;
- std::vector<types::global_dof_index> dofs_on_children;
-
- // loop over all lines; only on lines there can be constraints. We do
- // so by looping over all active cells and checking whether any of
- // the faces are refined which can only be from the neighboring cell
- // because this one is active. In that case, the face is subject to
- // constraints
- //
- // note that even though we may visit a face twice if the neighboring
- // cells are equally refined, we can only visit each face with
- // hanging nodes once
- typename DH::active_cell_iterator cell = dof_handler.begin_active(),
- endc = dof_handler.end();
- for (; cell!=endc; ++cell)
- // artificial cells can at best neighbor ghost cells, but we're not
- // interested in these interfaces
- if (!cell->is_artificial ())
- for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
- if (cell->face(face)->has_children())
- {
- // in any case, faces can have at most two active fe
- // indices, but here the face can have only one (namely the
- // same as that from the cell we're sitting on), and each
- // of the children can have only one as well. check this
- Assert (cell->face(face)->n_active_fe_indices() == 1,
- ExcInternalError());
- Assert (cell->face(face)->fe_index_is_active(cell->active_fe_index())
- == true,
- ExcInternalError());
- for (unsigned int c=0; c<cell->face(face)->n_children(); ++c)
- if (!cell->neighbor_child_on_subface(face,c)->is_artificial())
- Assert (cell->face(face)->child(c)->n_active_fe_indices() == 1,
- ExcInternalError());
-
- // right now, all that is implemented is the case that both
- // sides use the same fe
- for (unsigned int c=0; c<cell->face(face)->n_children(); ++c)
- if (!cell->neighbor_child_on_subface(face,c)->is_artificial())
- Assert (cell->face(face)->child(c)
- ->fe_index_is_active(cell->active_fe_index()) == true,
- ExcNotImplemented());
-
- // ok, start up the work
- const FiniteElement<dim,spacedim> &fe = cell->get_fe();
- const unsigned int fe_index = cell->active_fe_index();
-
- const unsigned int
- n_dofs_on_mother = 2*fe.dofs_per_vertex + fe.dofs_per_line,
- n_dofs_on_children = fe.dofs_per_vertex + 2*fe.dofs_per_line;
-
- dofs_on_mother.resize (n_dofs_on_mother);
- dofs_on_children.resize (n_dofs_on_children);
-
- Assert(n_dofs_on_mother == fe.constraints().n(),
- ExcDimensionMismatch(n_dofs_on_mother,
- fe.constraints().n()));
- Assert(n_dofs_on_children == fe.constraints().m(),
- ExcDimensionMismatch(n_dofs_on_children,
- fe.constraints().m()));
-
- const typename DH::line_iterator this_face = cell->face(face);
-
- // fill the dofs indices. Use same enumeration scheme as in
- // @p{FiniteElement::constraints()}
- unsigned int next_index = 0;
- for (unsigned int vertex=0; vertex<2; ++vertex)
- for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
- dofs_on_mother[next_index++] = this_face->vertex_dof_index(vertex,dof,
- fe_index);
- for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof)
- dofs_on_mother[next_index++] = this_face->dof_index(dof, fe_index);
- AssertDimension (next_index, dofs_on_mother.size());
-
- next_index = 0;
- for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
- dofs_on_children[next_index++]
- = this_face->child(0)->vertex_dof_index(1,dof,fe_index);
- for (unsigned int child=0; child<2; ++child)
- for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof)
- dofs_on_children[next_index++]
- = this_face->child(child)->dof_index(dof, fe_index);
- AssertDimension (next_index, dofs_on_children.size());
-
- // for each row in the constraint matrix for this line:
- for (unsigned int row=0; row!=dofs_on_children.size(); ++row)
- {
- constraints.add_line (dofs_on_children[row]);
- for (unsigned int i=0; i!=dofs_on_mother.size(); ++i)
- constraints.add_entry (dofs_on_children[row],
- dofs_on_mother[i],
- fe.constraints()(row,i));
-
- constraints.set_inhomogeneity (dofs_on_children[row], 0.);
- }
- }
- else
- {
- // this face has no children, but it could still be that it
- // is shared by two cells that use a different fe index.
- // check a couple of things, but ignore the case that the
- // neighbor is an artificial cell
- if (!cell->at_boundary(face) &&
- !cell->neighbor(face)->is_artificial())
- {
- Assert (cell->face(face)->n_active_fe_indices() == 1,
- ExcNotImplemented());
- Assert (cell->face(face)
- ->fe_index_is_active(cell->active_fe_index()) == true,
- ExcInternalError());
- }
- }
- }
-
-
-
- template <class DH>
- void
- make_oldstyle_hanging_node_constraints (const DH &dof_handler,
- ConstraintMatrix &constraints,
- dealii::internal::int2type<3>)
- {
- const unsigned int dim = 3;
-
- std::vector<types::global_dof_index> dofs_on_mother;
- std::vector<types::global_dof_index> dofs_on_children;
-
- // loop over all quads; only on quads there can be constraints. We do
- // so by looping over all active cells and checking whether any of
- // the faces are refined which can only be from the neighboring cell
- // because this one is active. In that case, the face is subject to
- // constraints
- //
- // note that even though we may visit a face twice if the neighboring
- // cells are equally refined, we can only visit each face with
- // hanging nodes once
- typename DH::active_cell_iterator cell = dof_handler.begin_active(),
- endc = dof_handler.end();
- for (; cell!=endc; ++cell)
- // artificial cells can at best neighbor ghost cells, but we're not
- // interested in these interfaces
- if (!cell->is_artificial ())
- for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
- if (cell->face(face)->has_children())
- {
- // first of all, make sure that we treat a case which is
- // possible, i.e. either no dofs on the face at all or no
- // anisotropic refinement
- if (cell->get_fe().dofs_per_face == 0)
- continue;
-
- Assert(cell->face(face)->refinement_case()==RefinementCase<dim-1>::isotropic_refinement,
- ExcNotImplemented());
-
- // in any case, faces can have at most two active fe
- // indices, but here the face can have only one (namely the
- // same as that from the cell we're sitting on), and each
- // of the children can have only one as well. check this
- AssertDimension (cell->face(face)->n_active_fe_indices(), 1);
- Assert (cell->face(face)->fe_index_is_active(cell->active_fe_index())
- == true,
- ExcInternalError());
- for (unsigned int c=0; c<cell->face(face)->n_children(); ++c)
- AssertDimension (cell->face(face)->child(c)->n_active_fe_indices(), 1);
-
- // right now, all that is implemented is the case that both
- // sides use the same fe, and not only that but also that
- // all lines bounding this face and the children have the
- // same fe
- for (unsigned int c=0; c<cell->face(face)->n_children(); ++c)
- if (!cell->neighbor_child_on_subface(face,c)->is_artificial())
- {
- Assert (cell->face(face)->child(c)
- ->fe_index_is_active(cell->active_fe_index()) == true,
- ExcNotImplemented());
- for (unsigned int e=0; e<4; ++e)
- {
- Assert (cell->face(face)->child(c)->line(e)
- ->n_active_fe_indices() == 1,
- ExcNotImplemented());
- Assert (cell->face(face)->child(c)->line(e)
- ->fe_index_is_active(cell->active_fe_index()) == true,
- ExcNotImplemented());
- }
- }
- for (unsigned int e=0; e<4; ++e)
- {
- Assert (cell->face(face)->line(e)
- ->n_active_fe_indices() == 1,
- ExcNotImplemented());
- Assert (cell->face(face)->line(e)
- ->fe_index_is_active(cell->active_fe_index()) == true,
- ExcNotImplemented());
- }
-
- // ok, start up the work
- const FiniteElement<dim> &fe = cell->get_fe();
- const unsigned int fe_index = cell->active_fe_index();
-
- const unsigned int n_dofs_on_mother = fe.dofs_per_face;
- const unsigned int n_dofs_on_children = (5*fe.dofs_per_vertex+
- 12*fe.dofs_per_line+
- 4*fe.dofs_per_quad);
-
- //TODO[TL]: think about this and the following in case of anisotropic refinement
-
- dofs_on_mother.resize (n_dofs_on_mother);
- dofs_on_children.resize (n_dofs_on_children);
-
- Assert(n_dofs_on_mother == fe.constraints().n(),
- ExcDimensionMismatch(n_dofs_on_mother,
- fe.constraints().n()));
- Assert(n_dofs_on_children == fe.constraints().m(),
- ExcDimensionMismatch(n_dofs_on_children,
- fe.constraints().m()));
-
- const typename DH::face_iterator this_face = cell->face(face);
-
- // fill the dofs indices. Use same enumeration scheme as in
- // @p{FiniteElement::constraints()}
- unsigned int next_index = 0;
- for (unsigned int vertex=0; vertex<4; ++vertex)
- for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
- dofs_on_mother[next_index++] = this_face->vertex_dof_index(vertex,dof,
- fe_index);
- for (unsigned int line=0; line<4; ++line)
- for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof)
- dofs_on_mother[next_index++]
- = this_face->line(line)->dof_index(dof, fe_index);
- for (unsigned int dof=0; dof!=fe.dofs_per_quad; ++dof)
- dofs_on_mother[next_index++] = this_face->dof_index(dof, fe_index);
- AssertDimension (next_index, dofs_on_mother.size());
-
- next_index = 0;
-
- // assert some consistency assumptions
-
- //TODO[TL]: think about this in case of anisotropic
- //refinement
-
- Assert (dof_handler.get_tria().get_anisotropic_refinement_flag() ||
- ((this_face->child(0)->vertex_index(3) ==
- this_face->child(1)->vertex_index(2)) &&
- (this_face->child(0)->vertex_index(3) ==
- this_face->child(2)->vertex_index(1)) &&
- (this_face->child(0)->vertex_index(3) ==
- this_face->child(3)->vertex_index(0))),
- ExcInternalError());
- for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
- dofs_on_children[next_index++]
- = this_face->child(0)->vertex_dof_index(3,dof);
-
- // dof numbers on the centers of the lines bounding this
- // face
- for (unsigned int line=0; line<4; ++line)
- for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
- dofs_on_children[next_index++]
- = this_face->line(line)->child(0)->vertex_dof_index(1,dof, fe_index);
-
- // next the dofs on the lines interior to the face; the
- // order of these lines is laid down in the FiniteElement
- // class documentation
- for (unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
- dofs_on_children[next_index++]
- = this_face->child(0)->line(1)->dof_index(dof, fe_index);
- for (unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
- dofs_on_children[next_index++]
- = this_face->child(2)->line(1)->dof_index(dof, fe_index);
- for (unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
- dofs_on_children[next_index++]
- = this_face->child(0)->line(3)->dof_index(dof, fe_index);
- for (unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
- dofs_on_children[next_index++]
- = this_face->child(1)->line(3)->dof_index(dof, fe_index);
-
- // dofs on the bordering lines
- for (unsigned int line=0; line<4; ++line)
- for (unsigned int child=0; child<2; ++child)
- for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof)
- dofs_on_children[next_index++]
- = this_face->line(line)->child(child)->dof_index(dof, fe_index);
-
- // finally, for the dofs interior to the four child faces
- for (unsigned int child=0; child<4; ++child)
- for (unsigned int dof=0; dof!=fe.dofs_per_quad; ++dof)
- dofs_on_children[next_index++]
- = this_face->child(child)->dof_index(dof, fe_index);
- AssertDimension (next_index, dofs_on_children.size());
-
- // for each row in the constraint matrix for this line:
- for (unsigned int row=0; row!=dofs_on_children.size(); ++row)
- {
- constraints.add_line (dofs_on_children[row]);
- for (unsigned int i=0; i!=dofs_on_mother.size(); ++i)
- constraints.add_entry (dofs_on_children[row],
- dofs_on_mother[i],
- fe.constraints()(row,i));
-
- constraints.set_inhomogeneity(dofs_on_children[row], 0.);
- }
- }
- else
- {
- // this face has no children, but it could still be that it
- // is shared by two cells that use a different fe index.
- // check a couple of things, but ignore the case that the
- // neighbor is an artificial cell
- if (!cell->at_boundary(face) &&
- !cell->neighbor(face)->is_artificial())
- {
- Assert (cell->face(face)->n_active_fe_indices() == 1,
- ExcNotImplemented());
- Assert (cell->face(face)
- ->fe_index_is_active(cell->active_fe_index()) == true,
- ExcInternalError());
- }
- }
- }
-
-
- template <class DH>
- void
- make_hp_hanging_node_constraints (const DH &dof_handler,
- ConstraintMatrix &constraints)
- {
- // note: this function is going to be hard to understand if you
- // haven't read the hp paper. however, we try to follow the notation
- // laid out there, so go read the paper before you try to understand
- // what is going on here
-
- const unsigned int dim = DH::dimension;
-
- const unsigned int spacedim = DH::space_dimension;
-
-
- // a matrix to be used for constraints below. declared here and
- // simply resized down below to avoid permanent re-allocation of
- // memory
- FullMatrix<double> constraint_matrix;
-
- // similarly have arrays that will hold master and slave dof numbers,
- // as well as a scratch array needed for the complicated case below
- std::vector<types::global_dof_index> master_dofs;
- std::vector<types::global_dof_index> slave_dofs;
- std::vector<types::global_dof_index> scratch_dofs;
-
- // caches for the face and subface interpolation matrices between
- // different (or the same) finite elements. we compute them only
- // once, namely the first time they are needed, and then just reuse
- // them
- Table<2,std_cxx1x::shared_ptr<FullMatrix<double> > >
- face_interpolation_matrices (n_finite_elements (dof_handler),
- n_finite_elements (dof_handler));
- Table<3,std_cxx1x::shared_ptr<FullMatrix<double> > >
- subface_interpolation_matrices (n_finite_elements (dof_handler),
- n_finite_elements (dof_handler),
- GeometryInfo<dim>::max_children_per_face);
-
- // similarly have a cache for the matrices that are split into their
- // master and slave parts, and for which the master part is inverted.
- // these two matrices are derived from the face interpolation matrix
- // as described in the @ref hp_paper "hp paper"
- Table<2,std_cxx1x::shared_ptr<std::pair<FullMatrix<double>,FullMatrix<double> > > >
- split_face_interpolation_matrices (n_finite_elements (dof_handler),
- n_finite_elements (dof_handler));
-
- // finally, for each pair of finite elements, have a mask that states
- // which of the degrees of freedom on the coarse side of a refined
- // face will act as master dofs.
- Table<2,std_cxx1x::shared_ptr<std::vector<bool> > >
- master_dof_masks (n_finite_elements (dof_handler),
- n_finite_elements (dof_handler));
-
- // loop over all faces
- //
- // note that even though we may visit a face twice if the neighboring
- // cells are equally refined, we can only visit each face with
- // hanging nodes once
- typename DH::active_cell_iterator cell = dof_handler.begin_active(),
- endc = dof_handler.end();
- for (; cell!=endc; ++cell)
- // artificial cells can at best neighbor ghost cells, but we're not
- // interested in these interfaces
- if (!cell->is_artificial ())
- for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
- if (cell->face(face)->has_children())
- {
- // first of all, make sure that we treat a case which is
- // possible, i.e. either no dofs on the face at all or no
- // anisotropic refinement
- if (cell->get_fe().dofs_per_face == 0)
- continue;
-
- Assert(cell->face(face)->refinement_case()==RefinementCase<dim-1>::isotropic_refinement,
- ExcNotImplemented());
-
- // so now we've found a face of an active cell that has
- // children. that means that there are hanging nodes here.
-
- // in any case, faces can have at most two sets of active
- // fe indices, but here the face can have only one (namely
- // the same as that from the cell we're sitting on), and
- // each of the children can have only one as well. check
- // this
- Assert (cell->face(face)->n_active_fe_indices() == 1,
- ExcInternalError());
- Assert (cell->face(face)->fe_index_is_active(cell->active_fe_index())
- == true,
- ExcInternalError());
- for (unsigned int c=0; c<cell->face(face)->n_children(); ++c)
- Assert (cell->face(face)->child(c)->n_active_fe_indices() == 1,
- ExcInternalError());
-
- // first find out whether we can constrain each of the
- // subfaces to the mother face. in the lingo of the hp
- // paper, this would be the simple case. note that we can
- // short-circuit this decision if the dof_handler doesn't
- // support hp at all
- //
- // ignore all interfaces with artificial cells
- FiniteElementDomination::Domination
- mother_face_dominates = FiniteElementDomination::either_element_can_dominate;
-
- if (DoFHandlerSupportsDifferentFEs<DH>::value == true)
- for (unsigned int c=0; c<cell->face(face)->number_of_children(); ++c)
- if (!cell->neighbor_child_on_subface (face, c)->is_artificial())
- mother_face_dominates = mother_face_dominates &
- (cell->get_fe().compare_for_face_domination
- (cell->neighbor_child_on_subface (face, c)->get_fe()));
-
- switch (mother_face_dominates)
- {
- case FiniteElementDomination::this_element_dominates:
- case FiniteElementDomination::either_element_can_dominate:
- {
- // Case 1 (the simple case and the only case that can
- // happen for non-hp DoFHandlers): The coarse element
- // dominates the elements on the subfaces (or they are
- // all the same)
- //
- // so we are going to constrain the DoFs on the face
- // children against the DoFs on the face itself
- master_dofs.resize (cell->get_fe().dofs_per_face);
-
- cell->face(face)->get_dof_indices (master_dofs,
- cell->active_fe_index ());
-
- // Now create constraint matrix for the subfaces and
- // assemble it. ignore all interfaces with artificial
- // cells because we can only get to such interfaces if
- // the current cell is a ghost cell
- for (unsigned int c=0; c<cell->face(face)->n_children(); ++c)
- {
- if (cell->neighbor_child_on_subface (face, c)->is_artificial())
- continue;
-
- const typename DH::active_face_iterator
- subface = cell->face(face)->child(c);
-
- Assert (subface->n_active_fe_indices() == 1,
- ExcInternalError());
-
- const unsigned int
- subface_fe_index = subface->nth_active_fe_index(0);
-
- // we sometime run into the situation where for
- // example on one big cell we have a FE_Q(1) and on
- // the subfaces we have a mixture of FE_Q(1) and
- // FE_Nothing. In that case, the face domination is
- // either_element_can_dominate for the whole
- // collection of subfaces, but on the particular
- // subface between FE_Q(1) and FE_Nothing, there
- // are no constraints that we need to take care of.
- // in that case, just continue
- if (cell->get_fe().compare_for_face_domination
- (subface->get_fe(subface_fe_index))
- ==
- FiniteElementDomination::no_requirements)
- continue;
-
- // Same procedure as for the mother cell. Extract
- // the face DoFs from the cell DoFs.
- slave_dofs.resize (subface->get_fe(subface_fe_index)
- .dofs_per_face);
- subface->get_dof_indices (slave_dofs, subface_fe_index);
-
- for (unsigned int i=0; i<slave_dofs.size(); ++i)
- Assert (slave_dofs[i] != numbers::invalid_dof_index,
- ExcInternalError());
-
- // Now create the element constraint for this
- // subface.
- //
- // As a side remark, one may wonder the following:
- // neighbor_child is clearly computed correctly,
- // i.e. taking into account face_orientation (just
- // look at the implementation of that function).
- // however, we don't care about this here, when we
- // ask for subface_interpolation on subface c. the
- // question rather is: do we have to translate 'c'
- // here as well?
- //
- // the answer is in fact 'no'. if one does that,
- // results are wrong: constraints are added twice
- // for the same pair of nodes but with differing
- // weights. in addition, one can look at the
- // deal.II/project_*_03 tests that look at exactly
- // this case: there, we have a mesh with at least
- // one face_orientation==false and hanging nodes,
- // and the results of those tests show that the
- // result of projection verifies the approximation
- // properties of a finite element onto that mesh
- ensure_existence_of_subface_matrix
- (cell->get_fe(),
- subface->get_fe(subface_fe_index),
- c,
- subface_interpolation_matrices
- [cell->active_fe_index()][subface_fe_index][c]);
-
- // Add constraints to global constraint matrix.
- filter_constraints (master_dofs,
- slave_dofs,
- *(subface_interpolation_matrices
- [cell->active_fe_index()][subface_fe_index][c]),
- constraints);
- }
-
- break;
- }
-
- case FiniteElementDomination::other_element_dominates:
- case FiniteElementDomination::neither_element_dominates:
- {
- // Case 2 (the "complex" case): at least one (the
- // neither_... case) of the finer elements or all of
- // them (the other_... case) is dominating. See the hp
- // paper for a way how to deal with this situation
- //
- // since this is something that can only happen for hp
- // dof handlers, add a check here...
- Assert (DoFHandlerSupportsDifferentFEs<DH>::value == true,
- ExcInternalError());
-
- // we first have to find the finite element that is
- // able to generate a space that all the other ones can
- // be constrained to
- const unsigned int dominating_fe_index
- = get_most_dominating_subface_fe_index (cell->face(face));
-
- const FiniteElement<dim,spacedim> &dominating_fe
- = dof_handler.get_fe()[dominating_fe_index];
-
- // check also that it is able to constrain the mother
- // face. it should be, or we wouldn't have gotten into
- // the branch for the 'complex' case
- Assert ((dominating_fe.compare_for_face_domination
- (cell->face(face)->get_fe(cell->face(face)->nth_active_fe_index(0)))
- == FiniteElementDomination::this_element_dominates)
- ||
- (dominating_fe.compare_for_face_domination
- (cell->face(face)->get_fe(cell->face(face)->nth_active_fe_index(0)))
- == FiniteElementDomination::either_element_can_dominate),
- ExcInternalError());
-
-
- // first get the interpolation matrix from the mother
- // to the virtual dofs
- Assert (dominating_fe.dofs_per_face <=
- cell->get_fe().dofs_per_face,
- ExcInternalError());
-
- ensure_existence_of_face_matrix
- (dominating_fe,
- cell->get_fe(),
- face_interpolation_matrices
- [dominating_fe_index][cell->active_fe_index()]);
-
- // split this matrix into master and slave components.
- // invert the master component
- ensure_existence_of_master_dof_mask
- (cell->get_fe(),
- dominating_fe,
- (*face_interpolation_matrices
- [dominating_fe_index]
- [cell->active_fe_index()]),
- master_dof_masks
- [dominating_fe_index]
- [cell->active_fe_index()]);
-
- ensure_existence_of_split_face_matrix
- (*face_interpolation_matrices
- [dominating_fe_index][cell->active_fe_index()],
- (*master_dof_masks
- [dominating_fe_index][cell->active_fe_index()]),
- split_face_interpolation_matrices
- [dominating_fe_index][cell->active_fe_index()]);
-
- const FullMatrix<double> &restrict_mother_to_virtual_master_inv
- = (split_face_interpolation_matrices
- [dominating_fe_index][cell->active_fe_index()]->first);
-
- const FullMatrix<double> &restrict_mother_to_virtual_slave
- = (split_face_interpolation_matrices
- [dominating_fe_index][cell->active_fe_index()]->second);
-
- // now compute the constraint matrix as the product
- // between the inverse matrix and the slave part
- constraint_matrix.reinit (cell->get_fe().dofs_per_face -
- dominating_fe.dofs_per_face,
- dominating_fe.dofs_per_face);
- restrict_mother_to_virtual_slave
- .mmult (constraint_matrix,
- restrict_mother_to_virtual_master_inv);
-
- // then figure out the global numbers of master and
- // slave dofs and apply constraints
- scratch_dofs.resize (cell->get_fe().dofs_per_face);
- cell->face(face)->get_dof_indices (scratch_dofs,
- cell->active_fe_index ());
-
- // split dofs into master and slave components
- master_dofs.clear ();
- slave_dofs.clear ();
- for (unsigned int i=0; i<cell->get_fe().dofs_per_face; ++i)
- if ((*master_dof_masks
- [dominating_fe_index][cell->active_fe_index()])[i] == true)
- master_dofs.push_back (scratch_dofs[i]);
- else
- slave_dofs.push_back (scratch_dofs[i]);
-
- AssertDimension (master_dofs.size(), dominating_fe.dofs_per_face);
- AssertDimension (slave_dofs.size(),
- cell->get_fe().dofs_per_face - dominating_fe.dofs_per_face);
-
- filter_constraints (master_dofs,
- slave_dofs,
- constraint_matrix,
- constraints);
-
-
-
- // next we have to deal with the subfaces. do as
- // discussed in the hp paper
- for (unsigned int sf=0;
- sf<cell->face(face)->n_children(); ++sf)
- {
- // ignore interfaces with artificial cells as well
- // as interfaces between ghost cells in 2d
- if (cell->neighbor_child_on_subface (face, sf)->is_artificial()
- ||
- (dim==2 && cell->is_ghost()
- &&
- cell->neighbor_child_on_subface (face, sf)->is_ghost()))
- continue;
-
- Assert (cell->face(face)->child(sf)
- ->n_active_fe_indices() == 1,
- ExcInternalError());
-
- const unsigned int subface_fe_index
- = cell->face(face)->child(sf)->nth_active_fe_index(0);
- const FiniteElement<dim,spacedim> &subface_fe
- = dof_handler.get_fe()[subface_fe_index];
-
- // first get the interpolation matrix from the
- // subface to the virtual dofs
- Assert (dominating_fe.dofs_per_face <=
- subface_fe.dofs_per_face,
- ExcInternalError());
- ensure_existence_of_subface_matrix
- (dominating_fe,
- subface_fe,
- sf,
- subface_interpolation_matrices
- [dominating_fe_index][subface_fe_index][sf]);
-
- const FullMatrix<double> &restrict_subface_to_virtual
- = *(subface_interpolation_matrices
- [dominating_fe_index][subface_fe_index][sf]);
-
- constraint_matrix.reinit (subface_fe.dofs_per_face,
- dominating_fe.dofs_per_face);
-
- restrict_subface_to_virtual
- .mmult (constraint_matrix,
- restrict_mother_to_virtual_master_inv);
-
- slave_dofs.resize (subface_fe.dofs_per_face);
- cell->face(face)->child(sf)->get_dof_indices (slave_dofs,
- subface_fe_index);
-
- filter_constraints (master_dofs,
- slave_dofs,
- constraint_matrix,
- constraints);
- }
-
- break;
- }
-
- case FiniteElementDomination::no_requirements:
- // there are no continuity requirements between the two
- // elements. record no constraints
- break;
-
- default:
- // we shouldn't get here
- Assert (false, ExcInternalError());
- }
- }
- else
- {
- // this face has no children, but it could still be that it
- // is shared by two cells that use a different fe index
- Assert (cell->face(face)
- ->fe_index_is_active(cell->active_fe_index()) == true,
- ExcInternalError());
-
- // see if there is a neighbor that is an artificial cell.
- // in that case, we're not interested in this interface. we
- // test this case first since artificial cells may not have
- // an active_fe_index set, etc
- if (!cell->at_boundary(face)
- &&
- cell->neighbor(face)->is_artificial())
- continue;
-
- // Only if there is a neighbor with a different
- // active_fe_index and the same h-level, some action has to
- // be taken.
- if ((DoFHandlerSupportsDifferentFEs<DH>::value == true)
- &&
- !cell->face(face)->at_boundary ()
- &&
- (cell->neighbor(face)->active_fe_index () !=
- cell->active_fe_index ())
- &&
- (!cell->face(face)->has_children() &&
- !cell->neighbor_is_coarser(face) ))
- {
- const typename DH::level_cell_iterator neighbor = cell->neighbor (face);
-
- // see which side of the face we have to constrain
- switch (cell->get_fe().compare_for_face_domination (neighbor->get_fe ()))
- {
- case FiniteElementDomination::this_element_dominates:
- {
- // Get DoFs on dominating and dominated side of the
- // face
- master_dofs.resize (cell->get_fe().dofs_per_face);
- cell->face(face)->get_dof_indices (master_dofs,
- cell->active_fe_index ());
-
- slave_dofs.resize (neighbor->get_fe().dofs_per_face);
- cell->face(face)->get_dof_indices (slave_dofs,
- neighbor->active_fe_index ());
-
- // break if the n_master_dofs == 0, because we are
- // attempting to constrain to an element that has
- // has no face dofs
- if (master_dofs.size() == 0) break;
-
- // make sure the element constraints for this face
- // are available
- ensure_existence_of_face_matrix
- (cell->get_fe(),
- neighbor->get_fe(),
- face_interpolation_matrices
- [cell->active_fe_index()][neighbor->active_fe_index()]);
-
- // Add constraints to global constraint matrix.
- filter_constraints (master_dofs,
- slave_dofs,
- *(face_interpolation_matrices
- [cell->active_fe_index()]
- [neighbor->active_fe_index()]),
- constraints);
-
- break;
- }
-
- case FiniteElementDomination::other_element_dominates:
- {
- // we don't do anything here since we will come
- // back to this face from the other cell, at which
- // time we will fall into the first case clause
- // above
- break;
- }
-
- case FiniteElementDomination::either_element_can_dominate:
- {
- // it appears as if neither element has any
- // constraints on its neighbor. this may be because
- // neither element has any DoFs on faces at all. or
- // that the two elements are actually the same,
- // although they happen to run under different
- // fe_indices (this is what happens in
- // hp/hp_hanging_nodes_01 for example).
- //
- // another possibility is what happens in crash_13.
- // there, we have FESystem(FE_Q(1),FE_DGQ(0)) vs.
- // FESystem(FE_Q(1),FE_DGQ(1)). neither of them
- // dominates the other. the point is that it
- // doesn't matter, since hopefully for this case,
- // both sides' dofs should have been unified.
- //
- // make sure this is actually true. this actually
- // only matters, of course, if either of the two
- // finite elements actually do have dofs on the
- // face
- if ((cell->get_fe().dofs_per_face != 0)
- ||
- (cell->neighbor(face)->get_fe().dofs_per_face != 0))
- {
- Assert (cell->get_fe().dofs_per_face
- ==
- cell->neighbor(face)->get_fe().dofs_per_face,
- ExcNotImplemented());
-
- // (ab)use the master and slave dofs arrays for
- // a moment here
- master_dofs.resize (cell->get_fe().dofs_per_face);
- cell->face(face)
- ->get_dof_indices (master_dofs,
- cell->active_fe_index ());
-
- slave_dofs.resize (cell->neighbor(face)->get_fe().dofs_per_face);
- cell->face(face)
- ->get_dof_indices (slave_dofs,
- cell->neighbor(face)->active_fe_index ());
-
- for (unsigned int i=0; i<cell->get_fe().dofs_per_face; ++i)
- AssertDimension (master_dofs[i], slave_dofs[i]);
- }
-
- break;
- }
-
- case FiniteElementDomination::neither_element_dominates:
- {
- // we don't presently know what exactly to do here.
- // it isn't quite clear what exactly we would have
- // to do here. sit tight until someone trips over
- // the following statement and see what exactly is
- // going on
- Assert (false, ExcNotImplemented());
- break;
- }
-
- case FiniteElementDomination::no_requirements:
- {
- // nothing to do here
- break;
- }
-
- default:
- // we shouldn't get here
- Assert (false, ExcInternalError());
- }
- }
- }
- }
- }
-
-
-
-
- template <class DH>
- void
- make_hanging_node_constraints (const DH &dof_handler,
- ConstraintMatrix &constraints)
- {
- // Decide whether to use the new or old make_hanging_node_constraints
- // function. If all the FiniteElement or all elements in a FECollection
- // support the new face constraint matrix, the new code will be used.
- // Otherwise, the old implementation is used for the moment.
- if (dof_handler.get_fe().hp_constraints_are_implemented ())
- internal::
- make_hp_hanging_node_constraints (dof_handler,
- constraints);
- else
- internal::
- make_oldstyle_hanging_node_constraints (dof_handler,
- constraints,
- dealii::internal::int2type<DH::dimension>());
- }
-
-
-
- namespace
- {
- // enter constraints for periodicity into the given ConstraintMatrix object.
- // this function is called when at least one of the two face iterators corresponds
- // to an active object without further children
- //
- // @param transformation A matrix that maps degrees of freedom from one face
- // to another. If the DoFs on the two faces are supposed to match exactly, then
- // the matrix so provided will be the identity matrix. if face 2 is once refined
- // from face 1, then the matrix needs to be the interpolation matrix from a face
- // to this particular child
- //
- // @precondition: face_1 is supposed to be active
- template <typename FaceIterator>
- void
- set_periodicity_constraints (const FaceIterator &face_1,
- const typename identity<FaceIterator>::type &face_2,
- const FullMatrix<double> &transformation,
- dealii::ConstraintMatrix &constraint_matrix,
- const ComponentMask &component_mask,
- const bool face_orientation,
- const bool face_flip,
- const bool face_rotation)
- {
- static const int dim = FaceIterator::AccessorType::dimension;
- static const int spacedim = FaceIterator::AccessorType::space_dimension;
-
- // we should be in the case where face_1 is active, i.e. has no children:
- Assert (!face_1->has_children(),
- ExcInternalError());
-
- Assert (face_1->n_active_fe_indices() == 1,
- ExcInternalError());
-
- // if face_2 does have children, then we need to iterate over them
- if (face_2->has_children())
- {
- Assert (face_2->n_children() == GeometryInfo<dim>::max_children_per_face,
- ExcNotImplemented());
- const unsigned int dofs_per_face
- = face_1->get_fe(face_1->nth_active_fe_index(0)).dofs_per_face;
- FullMatrix<double> child_transformation (dofs_per_face, dofs_per_face);
- FullMatrix<double> subface_interpolation (dofs_per_face, dofs_per_face);
- for (unsigned int c=0; c<face_2->n_children(); ++c)
- {
- // get the interpolation matrix recursively from the one that
- // interpolated from face_1 to face_2 by multiplying from the
- // left with the one that interpolates from face_2 to
- // its child
- face_1->get_fe(face_1->nth_active_fe_index(0))
- .get_subface_interpolation_matrix (face_1->get_fe(face_1->nth_active_fe_index(0)),
- c,
- subface_interpolation);
- subface_interpolation.mmult (child_transformation, transformation);
- set_periodicity_constraints(face_1, face_2->child(c),
- child_transformation,
- constraint_matrix, component_mask,
- face_orientation, face_flip, face_rotation);
- }
- }
- else
- // both faces are active. we need to match the corresponding DoFs of both faces
- {
- const unsigned int face_1_index = face_1->nth_active_fe_index(0);
- const unsigned int face_2_index = face_2->nth_active_fe_index(0);
- Assert(face_1->get_fe(face_1_index) == face_2->get_fe(face_1_index),
- ExcMessage ("Matching periodic cells need to use the same finite element"));
-
- const FiniteElement<dim, spacedim> &fe = face_1->get_fe(face_1_index);
-
- Assert(component_mask.represents_n_components(fe.n_components()),
- ExcMessage ("The number of components in the mask has to be either "
- "zero or equal to the number of components in the finite " "element."));
-
- const unsigned int dofs_per_face = fe.dofs_per_face;
-
- std::vector<types::global_dof_index> dofs_1(dofs_per_face);
- std::vector<types::global_dof_index> dofs_2(dofs_per_face);
-
- face_1->get_dof_indices(dofs_1, face_1_index);
- face_2->get_dof_indices(dofs_2, face_2_index);
-
- // Well, this is a hack:
- //
- // There is no
- // face_to_face_index(face_index,
- // face_orientation,
- // face_flip,
- // face_rotation)
- // function in FiniteElementData, so we have to use
- // face_to_cell_index(face_index, face
- // face_orientation,
- // face_flip,
- // face_rotation)
- // But this will give us an index on a cell - something we cannot work
- // with directly. But luckily we can match them back :-]
-
- std::map<unsigned int, unsigned int> cell_to_rotated_face_index;
-
- // Build up a cell to face index for face_2:
- for (unsigned int i = 0; i < dofs_per_face; ++i)
- {
- const unsigned int cell_index = fe.face_to_cell_index(i, 0, /* It doesn't really matter, just assume
- * we're on the first face...
- */
- true, false, false // default orientation
- );
- cell_to_rotated_face_index[cell_index] = i;
- }
-
- // loop over all dofs on face 2 and constrain them again the ones on face 1
- for (unsigned int i=0; i<dofs_per_face; ++i)
- if (!constraint_matrix.is_constrained(dofs_2[i]))
- if ((component_mask.n_selected_components(fe.n_components())
- == fe.n_components())
- ||
- component_mask[fe.face_system_to_component_index(i).first])
- {
- constraint_matrix.add_line(dofs_2[i]);
- for (unsigned int jj=0; jj<dofs_per_face; ++jj)
- {
- // Query the correct face_index on face_2 respecting the given
- // orientation:
- const unsigned int j =
- cell_to_rotated_face_index[fe.face_to_cell_index(jj, 0, /* It doesn't really matter, just assume
- * we're on the first face...
- */
- face_orientation, face_flip, face_rotation)];
-
- // And finally constrain the two DoFs respecting component_mask:
- if (transformation(i,j) != 0)
- constraint_matrix.add_entry(dofs_2[i], dofs_1[j],
- transformation(i,j));
- }
- }
- }
- }
- }
-
-
- template <typename FaceIterator>
- void
- make_periodicity_constraints (const FaceIterator &face_1,
- const typename identity<FaceIterator>::type &face_2,
- dealii::ConstraintMatrix &constraint_matrix,
- const ComponentMask &component_mask,
- const bool face_orientation,
- const bool face_flip,
- const bool face_rotation)
- {
- static const int dim = FaceIterator::AccessorType::dimension;
-
- Assert( (dim != 1) ||
- (face_orientation == true &&
- face_flip == false &&
- face_rotation == false),
- ExcMessage ("The supplied orientation "
- "(face_orientation, face_flip, face_rotation) "
- "is invalid for 1D"));
-
- Assert( (dim != 2) ||
- (face_orientation == true &&
- face_rotation == false),
- ExcMessage ("The supplied orientation "
- "(face_orientation, face_flip, face_rotation) "
- "is invalid for 2D"));
-
- Assert(face_1 != face_2,
- ExcMessage ("face_1 and face_2 are equal! Cannot constrain DoFs "
- "on the very same face"));
-
- Assert(face_1->at_boundary() && face_2->at_boundary(),
- ExcMessage ("Faces for periodicity constraints must be on the boundary"));
-
-
- // A lookup table on how to go through the child faces depending on the
- // orientation:
-
- static const int lookup_table_2d[2][2] =
- {
- // flip:
- {0, 1}, // false
- {1, 0}, // true
- };
-
- static const int lookup_table_3d[2][2][2][4] =
- {
- // orientation flip rotation
- { { {0, 2, 1, 3}, // false false false
- {2, 3, 0, 1}, // false false true
- },
- { {3, 1, 2, 0}, // false true false
- {1, 0, 3, 2}, // false true true
- },
- },
- { { {0, 1, 2, 3}, // true false false
- {1, 3, 0, 2}, // true false true
- },
- { {3, 2, 1, 0}, // true true false
- {2, 0, 3, 1}, // true true true
- },
- },
- };
-
- // In the case that both faces have children, we loop over all
- // children and apply make_periodicty_constrains recursively:
- if (face_1->has_children() && face_2->has_children())
- {
- Assert(face_1->n_children() == GeometryInfo<dim>::max_children_per_face &&
- face_2->n_children() == GeometryInfo<dim>::max_children_per_face,
- ExcNotImplemented());
-
- for (unsigned int i = 0; i < GeometryInfo<dim>::max_children_per_face; ++i)
- {
- // Lookup the index for the second face
- unsigned int j;
- switch (dim)
- {
- case 2:
- j = lookup_table_2d[face_flip][i];
- break;
- case 3:
- j = lookup_table_3d[face_orientation][face_flip][face_rotation][i];
- break;
- default:
- AssertThrow(false, ExcNotImplemented());
- }
-
- make_periodicity_constraints (face_1->child(i),
- face_2->child(j),
- constraint_matrix,
- component_mask,
- face_orientation,
- face_flip,
- face_rotation);
- }
- }
- else
- // otherwise at least one of the two faces is active and
- // we need to enter the constraints
- {
- if (face_2->has_children() == false)
- set_periodicity_constraints(face_2, face_1,
- FullMatrix<double>(IdentityMatrix(face_1->get_fe(face_1->nth_active_fe_index(0)).dofs_per_face)),
- constraint_matrix,
- component_mask,
- face_orientation, face_flip, face_rotation);
- else
- set_periodicity_constraints(face_1, face_2,
- FullMatrix<double>(IdentityMatrix(face_1->get_fe(face_1->nth_active_fe_index(0)).dofs_per_face)),
- constraint_matrix,
- component_mask,
- face_orientation, face_flip, face_rotation);
- }
- }
-
-
-
- template<typename DH>
- void
- make_periodicity_constraints (const DH &dof_handler,
- const types::boundary_id b_id1,
- const types::boundary_id b_id2,
- const int direction,
- dealii::ConstraintMatrix &constraint_matrix,
- const ComponentMask &component_mask)
- {
- Tensor<1,DH::space_dimension> dummy;
- make_periodicity_constraints (dof_handler,
- b_id1,
- b_id2,
- direction,
- dummy,
- constraint_matrix,
- component_mask);
- }
-
-
-
- template<typename DH>
- void
- make_periodicity_constraints (const DH &dof_handler,
- const types::boundary_id b_id1,
- const types::boundary_id b_id2,
- const int direction,
- dealii::Tensor<1,DH::space_dimension> &offset,
- dealii::ConstraintMatrix &constraint_matrix,
- const ComponentMask &component_mask)
- {
- static const int space_dim = DH::space_dimension;
- Assert (0<=direction && direction<space_dim,
- ExcIndexRange (direction, 0, space_dim));
-
-#if defined(DEBUG) && defined(DEAL_II_WITH_P4EST)
- // Check whether we run on a non parallel mesh or on a
- // parallel::distributed::Triangulation in serial
- {
- typedef parallel::distributed::Triangulation<DH::dimension,DH::space_dimension> PTRIA;
- const PTRIA *ptria_p = dynamic_cast<const PTRIA *> (&dof_handler.get_tria());
- Assert ((ptria_p == 0 || Utilities::MPI::n_mpi_processes(ptria_p->get_communicator()) == 1),
- ExcMessage ("This function can not be used with distributed triangulations."
- "See the documentation for more information."));
- }
-#endif
-
- Assert (b_id1 != b_id2,
- ExcMessage ("The boundary indicators b_id1 and b_id2 must be"
- "different to denote different boundaries."));
-
- typedef typename DH::face_iterator FaceIterator;
- typedef std::map<FaceIterator, std::pair<FaceIterator, std::bitset<3> > > FaceMap;
-
- // Collect matching periodic cells on the coarsest level:
- FaceMap matched_cells =
- GridTools::collect_periodic_face_pairs(dof_handler,
- b_id1, b_id2,
- direction, offset);
-
- // And apply the low level make_periodicity_constraints function to
- // every matching pair:
- for (typename FaceMap::iterator it = matched_cells.begin();
- it != matched_cells.end(); ++it)
- {
- typedef typename DH::face_iterator FaceIterator;
- const FaceIterator &face_1 = it->first;
- const FaceIterator &face_2 = it->second.first;
- const std::bitset<3> &orientation = it->second.second;
-
- Assert(face_1->at_boundary() && face_2->at_boundary(),
- ExcInternalError());
-
- Assert (face_1->boundary_indicator() == b_id1 &&
- face_2->boundary_indicator() == b_id2,
- ExcInternalError());
-
- Assert (face_1 != face_2,
- ExcInternalError());
-
- make_periodicity_constraints(face_1,
- face_2,
- constraint_matrix,
- component_mask,
- orientation[0],
- orientation[1],
- orientation[2]);
- }
- }
-
-
-
- template<typename DH>
- void
- make_periodicity_constraints (const DH &dof_handler,
- const types::boundary_id b_id,
- const int direction,
- dealii::ConstraintMatrix &constraint_matrix,
- const ComponentMask &component_mask)
- {
- Tensor<1,DH::space_dimension> dummy;
- make_periodicity_constraints (dof_handler,
- b_id,
- direction,
- dummy,
- constraint_matrix,
- component_mask);
- }
-
-
-
- template<typename DH>
- void
- make_periodicity_constraints (const DH &dof_handler,
- const types::boundary_id b_id,
- const int direction,
- dealii::Tensor<1,DH::space_dimension> &offset,
- dealii::ConstraintMatrix &constraint_matrix,
- const ComponentMask &component_mask)
- {
- static const int dim = DH::dimension;
- static const int space_dim = DH::space_dimension;
-
- Assert (0<=direction && direction<space_dim,
- ExcIndexRange (direction, 0, space_dim));
-
- Assert(dim == space_dim,
- ExcNotImplemented());
-
-#if defined(DEBUG) && defined(DEAL_II_WITH_P4EST)
- // Check whether we run on a non parallel mesh or on a
- // parallel::distributed::Triangulation in serial
- {
- typedef typename parallel::distributed::Triangulation<DH::dimension,DH::space_dimension> PTRIA;
- const PTRIA *ptria_p = dynamic_cast<const PTRIA *> (&dof_handler.get_tria());
- Assert ((ptria_p == 0 || Utilities::MPI::n_mpi_processes(ptria_p->get_communicator()) == 1),
- ExcMessage ("This function can not be used with distributed triangulations."
- "See the documentation for more information."));
- }
-#endif
-
- typedef typename DH::face_iterator FaceIterator;
- typedef std::map<FaceIterator, FaceIterator> FaceMap;
-
- // Collect matching periodic cells on the coarsest level:
- FaceMap matched_cells =
- GridTools::collect_periodic_face_pairs(dof_handler,
- b_id,
- direction, offset);
-
- // And apply the low level make_periodicity_constraints function to
- // every matching pair:
- for (typename FaceMap::iterator it = matched_cells.begin();
- it != matched_cells.end(); ++it)
- {
- typedef typename DH::face_iterator FaceIterator;
- const FaceIterator &face_1 = it->first;
- const FaceIterator &face_2 = it->second;
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
- Assert(face_1->at_boundary() && face_2->at_boundary(),
- ExcInternalError());
+#include <deal.II/base/multithread_info.h>
+#include <deal.II/base/thread_management.h>
+#include <deal.II/base/quadrature_lib.h>
+#include <deal.II/base/table.h>
+#include <deal.II/base/template_constraints.h>
+#include <deal.II/base/utilities.h>
+#include <deal.II/lac/sparsity_pattern.h>
+#include <deal.II/lac/compressed_sparsity_pattern.h>
+#include <deal.II/lac/compressed_set_sparsity_pattern.h>
+#include <deal.II/lac/compressed_simple_sparsity_pattern.h>
+#include <deal.II/lac/trilinos_sparsity_pattern.h>
+#include <deal.II/lac/block_sparsity_pattern.h>
+#include <deal.II/lac/vector.h>
+#include <deal.II/lac/constraint_matrix.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/intergrid_map.h>
+#include <deal.II/grid/grid_tools.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/dofs/dof_accessor.h>
+#include <deal.II/fe/fe.h>
+#include <deal.II/fe/fe_values.h>
+#include <deal.II/fe/fe_tools.h>
+#include <deal.II/hp/fe_collection.h>
+#include <deal.II/hp/q_collection.h>
+#include <deal.II/hp/fe_values.h>
+#include <deal.II/dofs/dof_tools.h>
- Assert (face_1->boundary_indicator() == b_id &&
- face_2->boundary_indicator() == b_id,
- ExcInternalError());
+#include <deal.II/multigrid/mg_dof_handler.h>
- Assert (face_1 != face_2,
- ExcInternalError());
+#include <algorithm>
+#include <numeric>
- make_periodicity_constraints(face_1,
- face_2,
- constraint_matrix,
- component_mask
- /* standard orientation */);
- }
- }
+DEAL_II_NAMESPACE_OPEN
+namespace DoFTools
+{
namespace internal
{
// return an array that for each dof on the reference cell
const unsigned int n_components = dof_handler.get_fe().n_components();
std::fill (dofs_per_component.begin(), dofs_per_component.end(),
- types::global_dof_index(0));
+ types::global_dof_index(0));
// If the empty vector was given as default argument, set up this
// vector as identity.
||
(std::accumulate (dofs_per_component.begin(),
dofs_per_component.end(),
- types::global_dof_index(0))
+ types::global_dof_index(0))
== dof_handler.n_locally_owned_dofs()),
ExcInternalError());
MPI_Allreduce ( &local_dof_count[0], &dofs_per_component[0], n_target_components,
DEAL_II_DOF_INDEX_MPI_TYPE,
- MPI_SUM, tria->get_communicator());
+ MPI_SUM, tria->get_communicator());
}
#endif
}
{
const FiniteElement<DH::dimension,DH::space_dimension> &fe = fe_collection[this_fe];
std::fill (dofs_per_block.begin(), dofs_per_block.end(),
- types::global_dof_index(0));
+ types::global_dof_index(0));
// If the empty vector was given as default argument, set up this
// vector as identity.
{
std::vector<types::global_dof_index> local_dof_count = dofs_per_block;
MPI_Allreduce ( &local_dof_count[0], &dofs_per_block[0],
- n_target_blocks,
+ n_target_blocks,
DEAL_II_DOF_INDEX_MPI_TYPE,
- MPI_SUM, tria->get_communicator());
+ MPI_SUM, tria->get_communicator());
}
#endif
#endif
-
- namespace internal
- {
- namespace
- {
- /**
- * This is a function that is called by the _2 function and that
- * operates on a range of cells only. It is used to split up the
- * whole range of cells into chunks which are then worked on in
- * parallel, if multithreading is available.
- */
- template <int dim, int spacedim>
- void
- compute_intergrid_weights_3 (
- const dealii::DoFHandler<dim,spacedim> &coarse_grid,
- const unsigned int coarse_component,
- const InterGridMap<dealii::DoFHandler<dim,spacedim> > &coarse_to_fine_grid_map,
- const std::vector<dealii::Vector<double> > ¶meter_dofs,
- const std::vector<types::global_dof_index> &weight_mapping,
- std::vector<std::map<types::global_dof_index, float> > &weights,
- const typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator &begin,
- const typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator &end)
- {
- // aliases to the finite elements used by the dof handlers:
- const FiniteElement<dim,spacedim> &coarse_fe = coarse_grid.get_fe();
-
- // for each cell on the parameter grid: find out which degrees of
- // freedom on the fine grid correspond in which way to the degrees
- // of freedom on the parameter grid
- //
- // since for continuous FEs some dofs exist on more than one cell,
- // we have to track which ones were already visited. the problem is
- // that if we visit a dof first on one cell and compute its weight
- // with respect to some global dofs to be non-zero, and later visit
- // the dof again on another cell and (since we are on another cell)
- // recompute the weights with respect to the same dofs as above to
- // be zero now, we have to preserve them. we therefore overwrite
- // all weights if they are nonzero and do not enforce zero weights
- // since that might be only due to the fact that we are on another
- // cell.
- //
- // example:
- // coarse grid
- // | | |
- // *-----*-----*
- // | cell|cell |
- // | 1 | 2 |
- // | | |
- // 0-----1-----*
- //
- // fine grid
- // | | | | |
- // *--*--*--*--*
- // | | | | |
- // *--*--*--*--*
- // | | | | |
- // *--x--y--*--*
- //
- // when on cell 1, we compute the weights of dof 'x' to be 1/2 from
- // parameter dofs 0 and 1, respectively. however, when later we are
- // on cell 2, we again compute the prolongation of shape function 1
- // restricted to cell 2 to the globla grid and find that the weight
- // of global dof 'x' now is zero. however, we should not overwrite
- // the old value.
- //
- // we therefore always only set nonzero values. why adding up is
- // not useful: dof 'y' would get weight 1 from parameter dof 1 on
- // both cells 1 and 2, but the correct weight is nevertheless only
- // 1.
-
- // vector to hold the representation of a single degree of freedom
- // on the coarse grid (for the selected fe) on the fine grid
- const types::global_dof_index n_fine_dofs = weight_mapping.size();
- dealii::Vector<double> global_parameter_representation (n_fine_dofs);
-
- typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator cell;
- std::vector<types::global_dof_index> parameter_dof_indices (coarse_fe.dofs_per_cell);
-
- for (cell=begin; cell!=end; ++cell)
- {
- // get the global indices of the parameter dofs on this
- // parameter grid cell
- cell->get_dof_indices (parameter_dof_indices);
-
- // loop over all dofs on this cell and check whether they are
- // interesting for us
- for (unsigned int local_dof=0;
- local_dof<coarse_fe.dofs_per_cell;
- ++local_dof)
- if (coarse_fe.system_to_component_index(local_dof).first
- ==
- coarse_component)
- {
- // the how-many-th parameter is this on this cell?
- const unsigned int local_parameter_dof
- = coarse_fe.system_to_component_index(local_dof).second;
-
- global_parameter_representation = 0;
-
- // distribute the representation of
- // @p{local_parameter_dof} on the parameter grid cell
- // @p{cell} to the global data space
- coarse_to_fine_grid_map[cell]->
- set_dof_values_by_interpolation (parameter_dofs[local_parameter_dof],
- global_parameter_representation);
- // now that we've got the global representation of each
- // parameter dof, we've only got to clobber the non-zero
- // entries in that vector and store the result
- //
- // what we have learned: if entry @p{i} of the global
- // vector holds the value @p{v[i]}, then this is the
- // weight with which the present dof contributes to
- // @p{i}. there may be several such @p{i}s and their
- // weights' sum should be one. Then, @p{v[i]} should be
- // equal to @p{\sum_j w_{ij} p[j]} with @p{p[j]} be the
- // values of the degrees of freedom on the coarse grid.
- // we can thus compute constraints which link the degrees
- // of freedom @p{v[i]} on the fine grid to those on the
- // coarse grid, @p{p[j]}. Now to use these as real
- // constraints, rather than as additional equations, we
- // have to identify representants among the @p{i} for
- // each @p{j}. this will be done by simply taking the
- // first @p{i} for which @p{w_{ij}==1}.
- //
- // guard modification of the weights array by a Mutex.
- // since it should happen rather rarely that there are
- // several threads operating on different intergrid
- // weights, have only one mutex for all of them
- static Threads::Mutex mutex;
- Threads::Mutex::ScopedLock lock (mutex);
- for (types::global_dof_index i=0; i<global_parameter_representation.size(); ++i)
- // set this weight if it belongs to a parameter dof.
- if (weight_mapping[i] != numbers::invalid_dof_index)
- {
- // only overwrite old value if not by zero
- if (global_parameter_representation(i) != 0)
- {
- const types::global_dof_index wi = parameter_dof_indices[local_dof],
- wj = weight_mapping[i];
- weights[wi][wj] = global_parameter_representation(i);
- };
- }
- else
- Assert (global_parameter_representation(i) == 0,
- ExcInternalError());
- }
- }
- }
-
-
- /**
- * This is a helper function that is used in the computation of
- * integrid constraints. See the function for a thorough description
- * of how it works.
- */
- template <int dim, int spacedim>
- void
- compute_intergrid_weights_2 (
- const dealii::DoFHandler<dim,spacedim> &coarse_grid,
- const unsigned int coarse_component,
- const InterGridMap<dealii::DoFHandler<dim,spacedim> > &coarse_to_fine_grid_map,
- const std::vector<dealii::Vector<double> > ¶meter_dofs,
- const std::vector<types::global_dof_index> &weight_mapping,
- std::vector<std::map<types::global_dof_index,float> > &weights)
- {
- // simply distribute the range of cells to different threads
- typedef typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator active_cell_iterator;
- std::vector<std::pair<active_cell_iterator,active_cell_iterator> >
- cell_intervals = Threads::split_range<active_cell_iterator> (coarse_grid.begin_active(),
- coarse_grid.end(),
- multithread_info.n_default_threads);
-
- // TODO: use WorkStream here
-
- Threads::TaskGroup<> tasks;
- void (*fun_ptr) (const dealii::DoFHandler<dim,spacedim> &,
- const unsigned int ,
- const InterGridMap<dealii::DoFHandler<dim,spacedim> > &,
- const std::vector<dealii::Vector<double> > &,
- const std::vector<types::global_dof_index> &,
- std::vector<std::map<types::global_dof_index, float> > &,
- const typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator &,
- const typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator &)
- = &compute_intergrid_weights_3<dim>;
- for (unsigned int i=0; i<multithread_info.n_default_threads; ++i)
- tasks += Threads::new_task (fun_ptr,
- coarse_grid, coarse_component,
- coarse_to_fine_grid_map, parameter_dofs,
- weight_mapping, weights,
- cell_intervals[i].first,
- cell_intervals[i].second);
-
- // wait for the tasks to finish
- tasks.join_all ();
- }
-
-
-
- /**
- * This is a helper function that is used in the computation of
- * integrid constraints. See the function for a thorough description
- * of how it works.
- */
- template <int dim, int spacedim>
- unsigned int
- compute_intergrid_weights_1 (
- const dealii::DoFHandler<dim,spacedim> &coarse_grid,
- const unsigned int coarse_component,
- const dealii::DoFHandler<dim,spacedim> &fine_grid,
- const unsigned int fine_component,
- const InterGridMap<dealii::DoFHandler<dim,spacedim> > &coarse_to_fine_grid_map,
- std::vector<std::map<types::global_dof_index, float> > &weights,
- std::vector<types::global_dof_index> &weight_mapping)
- {
- // aliases to the finite elements used by the dof handlers:
- const FiniteElement<dim,spacedim> &coarse_fe = coarse_grid.get_fe(),
- &fine_fe = fine_grid.get_fe();
-
- // global numbers of dofs
- const types::global_dof_index n_coarse_dofs = coarse_grid.n_dofs(),
- n_fine_dofs = fine_grid.n_dofs();
-
- // local numbers of dofs
- const unsigned int fine_dofs_per_cell = fine_fe.dofs_per_cell;
-
- // alias the number of dofs per cell belonging to the
- // coarse_component which is to be the restriction of the fine
- // grid:
- const unsigned int coarse_dofs_per_cell_component
- = coarse_fe.base_element(coarse_fe.component_to_base_index(coarse_component).first).dofs_per_cell;
-
-
- // Try to find out whether the grids stem from the same coarse
- // grid. This is a rather crude test, but better than nothing
- Assert (coarse_grid.get_tria().n_cells(0) == fine_grid.get_tria().n_cells(0),
- ExcGridsDontMatch());
-
- // check whether the map correlates the right objects
- Assert (&coarse_to_fine_grid_map.get_source_grid() == &coarse_grid,
- ExcGridsDontMatch ());
- Assert (&coarse_to_fine_grid_map.get_destination_grid() == &fine_grid,
- ExcGridsDontMatch ());
-
-
- // check whether component numbers are valid
- AssertIndexRange (coarse_component,coarse_fe.n_components());
- AssertIndexRange (fine_component, fine_fe.n_components());
-
- // check whether respective finite elements are equal
- Assert (coarse_fe.base_element (coarse_fe.component_to_base_index(coarse_component).first)
- ==
- fine_fe.base_element (fine_fe.component_to_base_index(fine_component).first),
- ExcFiniteElementsDontMatch());
-
-#ifdef DEBUG
- // if in debug mode, check whether the coarse grid is indeed
- // coarser everywhere than the fine grid
- for (typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator
- cell=coarse_grid.begin_active();
- cell != coarse_grid.end(); ++cell)
- Assert (cell->level() <= coarse_to_fine_grid_map[cell]->level(),
- ExcGridNotCoarser());
-#endif
-
- /*
- * From here on: the term `parameter' refers to the selected
- * component on the coarse grid and its analogon on the fine grid.
- * The naming of variables containing this term is due to the fact
- * that `selected_component' is longer, but also due to the fact
- * that the code of this function was initially written for a
- * program where the component which we wanted to match between
- * grids was actually the `parameter' variable.
- *
- * Likewise, the terms `parameter grid' and `state grid' refer to
- * the coarse and fine grids, respectively.
- *
- * Changing the names of variables would in principle be a good
- * idea, but would not make things simpler and would be another
- * source of errors. If anyone feels like doing so: patches would
- * be welcome!
- */
-
-
-
- // set up vectors of cell-local data; each vector represents one
- // degree of freedom of the coarse-grid variable in the fine-grid
- // element
- std::vector<dealii::Vector<double> >
- parameter_dofs (coarse_dofs_per_cell_component,
- dealii::Vector<double>(fine_dofs_per_cell));
- // for each coarse dof: find its position within the fine element
- // and set this value to one in the respective vector (all other
- // values are zero by construction)
- for (unsigned int local_coarse_dof=0;
- local_coarse_dof<coarse_dofs_per_cell_component;
- ++local_coarse_dof)
- for (unsigned int fine_dof=0; fine_dof<fine_fe.dofs_per_cell; ++fine_dof)
- if (fine_fe.system_to_component_index(fine_dof)
- ==
- std::make_pair (fine_component, local_coarse_dof))
- {
- parameter_dofs[local_coarse_dof](fine_dof) = 1.;
- break;
- };
-
-
- // find out how many DoFs there are on the grids belonging to the
- // components we want to match
- unsigned int n_parameters_on_fine_grid=0;
- if (true)
- {
- // have a flag for each dof on the fine grid and set it to true
- // if this is an interesting dof. finally count how many true's
- // there
- std::vector<bool> dof_is_interesting (fine_grid.n_dofs(), false);
- std::vector<types::global_dof_index> local_dof_indices (fine_fe.dofs_per_cell);
-
- for (typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator
- cell=fine_grid.begin_active();
- cell!=fine_grid.end(); ++cell)
- {
- cell->get_dof_indices (local_dof_indices);
- for (unsigned int i=0; i<fine_fe.dofs_per_cell; ++i)
- if (fine_fe.system_to_component_index(i).first == fine_component)
- dof_is_interesting[local_dof_indices[i]] = true;
- };
-
- n_parameters_on_fine_grid = std::count (dof_is_interesting.begin(),
- dof_is_interesting.end(),
- true);
- };
-
-
- // set up the weights mapping
- weights.clear ();
- weights.resize (n_coarse_dofs);
-
- weight_mapping.clear ();
- weight_mapping.resize (n_fine_dofs, numbers::invalid_dof_index);
-
- if (true)
- {
- std::vector<types::global_dof_index> local_dof_indices(fine_fe.dofs_per_cell);
- unsigned int next_free_index=0;
- for (typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator
- cell=fine_grid.begin_active();
- cell != fine_grid.end(); ++cell)
- {
- cell->get_dof_indices (local_dof_indices);
- for (unsigned int i=0; i<fine_fe.dofs_per_cell; ++i)
- // if this DoF is a parameter dof and has not yet been
- // numbered, then do so
- if ((fine_fe.system_to_component_index(i).first == fine_component) &&
- (weight_mapping[local_dof_indices[i]] == numbers::invalid_dof_index))
- {
- weight_mapping[local_dof_indices[i]] = next_free_index;
- ++next_free_index;
- };
- };
-
- Assert (next_free_index == n_parameters_on_fine_grid,
- ExcInternalError());
- };
-
-
- // for each cell on the parameter grid: find out which degrees of
- // freedom on the fine grid correspond in which way to the degrees
- // of freedom on the parameter grid
- //
- // do this in a separate function to allow for multithreading
- // there. see this function also if you want to read more
- // information on the algorithm used.
- compute_intergrid_weights_2 (coarse_grid, coarse_component,
- coarse_to_fine_grid_map, parameter_dofs,
- weight_mapping, weights);
-
-
- // ok, now we have all weights for each dof on the fine grid. if in
- // debug mode lets see if everything went smooth, i.e. each dof has
- // sum of weights one
- //
- // in other words this means that if the sum of all shape functions
- // on the parameter grid is one (which is always the case), then
- // the representation on the state grid should be as well (division
- // of unity)
- //
- // if the parameter grid has more than one component, then the
- // respective dofs of the other components have sum of weights
- // zero, of course. we do not explicitly ask which component a dof
- // belongs to, but this at least tests some errors
-#ifdef DEBUG
- for (unsigned int col=0; col<n_parameters_on_fine_grid; ++col)
- {
- double sum=0;
- for (types::global_dof_index row=0; row<n_coarse_dofs; ++row)
- if (weights[row].find(col) != weights[row].end())
- sum += weights[row][col];
- Assert ((std::fabs(sum-1) < 1.e-12) ||
- ((coarse_fe.n_components()>1) && (sum==0)), ExcInternalError());
- };
-#endif
-
-
- return n_parameters_on_fine_grid;
- }
-
-
- }
- }
-
-
-
- template <int dim, int spacedim>
- void
- compute_intergrid_constraints (
- const DoFHandler<dim,spacedim> &coarse_grid,
- const unsigned int coarse_component,
- const DoFHandler<dim,spacedim> &fine_grid,
- const unsigned int fine_component,
- const InterGridMap<DoFHandler<dim,spacedim> > &coarse_to_fine_grid_map,
- ConstraintMatrix &constraints)
- {
- // store the weights with which a dof on the parameter grid contributes
- // to a dof on the fine grid. see the long doc below for more info
- //
- // allocate as many rows as there are parameter dofs on the coarse grid
- // and as many columns as there are parameter dofs on the fine grid.
- //
- // weight_mapping is used to map the global (fine grid) parameter dof
- // indices to the columns
- //
- // in the original implementation, the weights array was actually of
- // FullMatrix<double> type. this wasted huge amounts of memory, but was
- // fast. nonetheless, since the memory consumption was quadratic in the
- // number of degrees of freedom, this was not very practical, so we now
- // use a vector of rows of the matrix, and in each row a vector of
- // pairs (colnum,value). this seems like the best tradeoff between
- // memory and speed, as it is now linear in memory and still fast
- // enough.
- //
- // to save some memory and since the weights are usually (negative)
- // powers of 2, we choose the value type of the matrix to be @p{float}
- // rather than @p{double}.
- std::vector<std::map<types::global_dof_index, float> > weights;
-
- // this is this mapping. there is one entry for each dof on the fine
- // grid; if it is a parameter dof, then its value is the column in
- // weights for that parameter dof, if it is any other dof, then its
- // value is -1, indicating an error
- std::vector<types::global_dof_index> weight_mapping;
-
- const unsigned int n_parameters_on_fine_grid
- = internal::compute_intergrid_weights_1 (coarse_grid, coarse_component,
- fine_grid, fine_component,
- coarse_to_fine_grid_map,
- weights, weight_mapping);
-
- // global numbers of dofs
- const types::global_dof_index n_coarse_dofs = coarse_grid.n_dofs(),
- n_fine_dofs = fine_grid.n_dofs();
-
-
- // get an array in which we store which dof on the coarse grid is a
- // parameter and which is not
- std::vector<bool> coarse_dof_is_parameter (coarse_grid.n_dofs());
- if (true)
- {
- std::vector<bool> mask (coarse_grid.get_fe().n_components(),
- false);
- mask[coarse_component] = true;
- extract_dofs (coarse_grid, ComponentMask(mask), coarse_dof_is_parameter);
- }
-
- // now we know that the weights in each row constitute a constraint.
- // enter this into the constraints object
- //
- // first task: for each parameter dof on the parameter grid, find a
- // representant on the fine, global grid. this is possible since we use
- // conforming finite element. we take this representant to be the first
- // element in this row with weight identical to one. the representant
- // will become an unconstrained degree of freedom, while all others
- // will be constrained to this dof (and possibly others)
- std::vector<types::global_dof_index> representants(n_coarse_dofs, numbers::invalid_dof_index);
- for (types::global_dof_index parameter_dof=0; parameter_dof<n_coarse_dofs;
- ++parameter_dof)
- if (coarse_dof_is_parameter[parameter_dof] == true)
- {
- // if this is the line of a parameter dof on the coarse grid,
- // then it should have at least one dependent node on the fine
- // grid
- Assert (weights[parameter_dof].size() > 0, ExcInternalError());
-
- // find the column where the representant is mentioned
- std::map<types::global_dof_index,float>::const_iterator i = weights[parameter_dof].begin();
- for (; i!=weights[parameter_dof].end(); ++i)
- if (i->second == 1)
- break;
- Assert (i!=weights[parameter_dof].end(), ExcInternalError());
- const types::global_dof_index column = i->first;
-
- // now we know in which column of weights the representant is,
- // but we don't know its global index. get it using the inverse
- // operation of the weight_mapping
- types::global_dof_index global_dof=0;
- for (; global_dof<weight_mapping.size(); ++global_dof)
- if (weight_mapping[global_dof] == static_cast<types::global_dof_index>(column))
- break;
- Assert (global_dof < weight_mapping.size(), ExcInternalError());
-
- // now enter the representants global index into our list
- representants[parameter_dof] = global_dof;
- }
- else
- {
- // consistency check: if this is no parameter dof on the coarse
- // grid, then the respective row must be empty!
- Assert (weights[parameter_dof].size() == 0, ExcInternalError());
- };
-
-
-
- // note for people that want to optimize this function: the largest
- // part of the computing time is spent in the following, rather
- // innocent block of code. basically, it must be the
- // ConstraintMatrix::add_entry call which takes the bulk of the time,
- // but it is not known to the author how to make it faster...
- std::vector<std::pair<types::global_dof_index,double> > constraint_line;
- for (types::global_dof_index global_dof=0; global_dof<n_fine_dofs; ++global_dof)
- if (weight_mapping[global_dof] != numbers::invalid_dof_index)
- // this global dof is a parameter dof, so it may carry a constraint
- // note that for each global dof, the sum of weights shall be one,
- // so we can find out whether this dof is constrained in the
- // following way: if the only weight in this row is a one, and the
- // representant for the parameter dof of the line in which this one
- // is is the present dof, then we consider this dof to be
- // unconstrained. otherwise, all other dofs are constrained
- {
- const types::global_dof_index col = weight_mapping[global_dof];
- Assert (col < n_parameters_on_fine_grid, ExcInternalError());
-
- types::global_dof_index first_used_row=0;
-
- {
- Assert (weights.size() > 0, ExcInternalError());
- std::map<types::global_dof_index,float>::const_iterator
- col_entry = weights[0].end();
- for (; first_used_row<n_coarse_dofs; ++first_used_row)
- {
- col_entry = weights[first_used_row].find(col);
- if (col_entry != weights[first_used_row].end())
- break;
- }
-
- Assert (col_entry != weights[first_used_row].end(), ExcInternalError());
-
- if ((col_entry->second == 1) &&
- (representants[first_used_row] == global_dof))
- // dof unconstrained or constrained to itself (in case this
- // cell is mapped to itself, rather than to children of
- // itself)
- continue;
- }
-
-
- // otherwise enter all constraints
- constraints.add_line (global_dof);
-
- constraint_line.clear ();
- for (types::global_dof_index row=first_used_row; row<n_coarse_dofs; ++row)
- {
- const std::map<types::global_dof_index,float>::const_iterator
- j = weights[row].find(col);
- if ((j != weights[row].end()) && (j->second != 0))
- constraint_line.push_back (std::pair<types::global_dof_index,double>(representants[row],
- j->second));
- };
-
- constraints.add_entries (global_dof, constraint_line);
- };
- }
-
-
-
- template <int dim, int spacedim>
- void
- compute_intergrid_transfer_representation (
- const DoFHandler<dim,spacedim> &coarse_grid,
- const unsigned int coarse_component,
- const DoFHandler<dim,spacedim> &fine_grid,
- const unsigned int fine_component,
- const InterGridMap<DoFHandler<dim,spacedim> > &coarse_to_fine_grid_map,
- std::vector<std::map<types::global_dof_index, float> > &transfer_representation)
- {
- // store the weights with which a dof on the parameter grid contributes
- // to a dof on the fine grid. see the long doc below for more info
- //
- // allocate as many rows as there are parameter dofs on the coarse grid
- // and as many columns as there are parameter dofs on the fine grid.
- //
- // weight_mapping is used to map the global (fine grid) parameter dof
- // indices to the columns
- //
- // in the original implementation, the weights array was actually of
- // FullMatrix<double> type. this wasted huge amounts of memory, but was
- // fast. nonetheless, since the memory consumption was quadratic in the
- // number of degrees of freedom, this was not very practical, so we now
- // use a vector of rows of the matrix, and in each row a vector of
- // pairs (colnum,value). this seems like the best tradeoff between
- // memory and speed, as it is now linear in memory and still fast
- // enough.
- //
- // to save some memory and since the weights are usually (negative)
- // powers of 2, we choose the value type of the matrix to be @p{float}
- // rather than @p{double}.
- std::vector<std::map<types::global_dof_index, float> > weights;
-
- // this is this mapping. there is one entry for each dof on the fine
- // grid; if it is a parameter dof, then its value is the column in
- // weights for that parameter dof, if it is any other dof, then its
- // value is -1, indicating an error
- std::vector<types::global_dof_index> weight_mapping;
-
- internal::compute_intergrid_weights_1 (coarse_grid, coarse_component,
- fine_grid, fine_component,
- coarse_to_fine_grid_map,
- weights, weight_mapping);
-
- // now compute the requested representation
- const types::global_dof_index n_global_parm_dofs
- = std::count_if (weight_mapping.begin(), weight_mapping.end(),
- std::bind2nd (std::not_equal_to<types::global_dof_index> (), numbers::invalid_dof_index));
-
- // first construct the inverse mapping of weight_mapping
- std::vector<types::global_dof_index> inverse_weight_mapping (n_global_parm_dofs,
- DoFHandler<dim,spacedim>::invalid_dof_index);
- for (types::global_dof_index i=0; i<weight_mapping.size(); ++i)
- {
- const types::global_dof_index parameter_dof = weight_mapping[i];
- // if this global dof is a parameter
- if (parameter_dof != numbers::invalid_dof_index)
- {
- Assert (parameter_dof < n_global_parm_dofs, ExcInternalError());
- Assert ((inverse_weight_mapping[parameter_dof] == DoFHandler<dim,spacedim>::invalid_dof_index),
- ExcInternalError());
-
- inverse_weight_mapping[parameter_dof] = i;
- };
- };
-
- // next copy over weights array and replace respective numbers
- const types::global_dof_index n_rows = weight_mapping.size();
-
- transfer_representation.clear ();
- transfer_representation.resize (n_rows);
-
- const types::global_dof_index n_coarse_dofs = coarse_grid.n_dofs();
- for (types::global_dof_index i=0; i<n_coarse_dofs; ++i)
- {
- std::map<types::global_dof_index, float>::const_iterator j = weights[i].begin();
- for (; j!=weights[i].end(); ++j)
- {
- const types::global_dof_index p = inverse_weight_mapping[j->first];
- Assert (p<n_rows, ExcInternalError());
-
- transfer_representation[p][i] = j->second;
- };
- };
- }
-
-
-
template <class DH>
void
map_dof_to_boundary_indices (const DH &dof_handler,
- template <int dim, int spacedim, template <int,int> class DH>
- void
- make_zero_boundary_constraints (const DH<dim, spacedim> &dof,
- const types::boundary_id boundary_indicator,
- ConstraintMatrix &zero_boundary_constraints,
- const ComponentMask &component_mask)
- {
- Assert (component_mask.represents_n_components(dof.get_fe().n_components()),
- ExcMessage ("The number of components in the mask has to be either "
- "zero or equal to the number of components in the finite "
- "element."));
-
- const unsigned int n_components = DoFTools::n_components (dof);
-
- Assert (component_mask.n_selected_components(n_components) > 0,
- VectorTools::ExcNoComponentSelected());
-
- // a field to store the indices
- std::vector<types::global_dof_index> face_dofs;
- face_dofs.reserve (max_dofs_per_face(dof));
-
- typename DH<dim,spacedim>::active_cell_iterator
- cell = dof.begin_active(),
- endc = dof.end();
- for (; cell!=endc; ++cell)
- if (!cell->is_artificial())
- for (unsigned int face_no = 0; face_no < GeometryInfo<dim>::faces_per_cell;
- ++face_no)
- {
- const FiniteElement<dim,spacedim> &fe = cell->get_fe();
-
- const typename DH<dim,spacedim>::face_iterator face = cell->face(face_no);
-
- // if face is on the boundary and satisfies the correct
- // boundary id property
- if (face->at_boundary ()
- &&
- ((boundary_indicator == numbers::invalid_boundary_id)
- ||
- (face->boundary_indicator() == boundary_indicator)))
- {
- // get indices and physical location on this face
- face_dofs.resize (fe.dofs_per_face);
- face->get_dof_indices (face_dofs, cell->active_fe_index());
-
- // enter those dofs into the list that match the component
- // signature.
- for (unsigned int i=0; i<face_dofs.size(); ++i)
- {
- // Find out if a dof has a contribution in this
- // component, and if so, add it to the list
- const ComponentMask &nonzero_component_array
- = cell->get_fe().get_nonzero_components (i);
- bool nonzero = false;
- for (unsigned int c=0; c<n_components; ++c)
- if (nonzero_component_array[c] && component_mask[c])
- {
- nonzero = true;
- break;
- }
-
- if (nonzero)
- zero_boundary_constraints.add_line (face_dofs[i]);
- }
- }
- }
- }
-
-
-
- template <int dim, int spacedim, template <int,int> class DH>
- void
- make_zero_boundary_constraints (const DH<dim, spacedim> &dof,
- ConstraintMatrix &zero_boundary_constraints,
- const ComponentMask &component_mask)
- {
- make_zero_boundary_constraints(dof, numbers::invalid_boundary_id,
- zero_boundary_constraints, component_mask);
- }
-
-
template <class DH, class Sparsity>
void make_cell_patches(
Sparsity &block_list,
}
}
}
-}
+
+
+} // end of namespace DoFTools
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
for (SP : SPARSITY_PATTERNS; deal_II_dimension : DIMENSIONS)
{
- template void
- DoFTools::make_sparsity_pattern<DoFHandler<deal_II_dimension,deal_II_dimension>, SP>
- (const DoFHandler<deal_II_dimension,deal_II_dimension> &dof,
- SP &sparsity,
- const ConstraintMatrix &,
- const bool,
- const unsigned int);
-
- template void
- DoFTools::make_sparsity_pattern<hp::DoFHandler<deal_II_dimension,deal_II_dimension>, SP>
- (const hp::DoFHandler<deal_II_dimension,deal_II_dimension> &dof,
- SP &sparsity,
- const ConstraintMatrix &,
- const bool,
- const unsigned int);
-
- template void
- DoFTools::make_sparsity_pattern<MGDoFHandler<deal_II_dimension,deal_II_dimension>, SP>
- (const MGDoFHandler<deal_II_dimension,deal_II_dimension> &dof,
- SP &sparsity,
- const ConstraintMatrix &,
- const bool,
- const unsigned int);
-
- template void
- DoFTools::make_sparsity_pattern<DoFHandler<deal_II_dimension,deal_II_dimension>, SP>
- (const DoFHandler<deal_II_dimension,deal_II_dimension>&,
- const Table<2,Coupling>&,
- SP &,
- const ConstraintMatrix &,
- const bool,
- const unsigned int);
-
- template void
- DoFTools::make_sparsity_pattern<hp::DoFHandler<deal_II_dimension,deal_II_dimension>, SP>
- (const hp::DoFHandler<deal_II_dimension,deal_II_dimension>&,
- const Table<2,Coupling>&,
- SP &,
- const ConstraintMatrix &,
- const bool,
- const unsigned int);
-
- template void
- DoFTools::make_sparsity_pattern<MGDoFHandler<deal_II_dimension,deal_II_dimension>, SP>
- (const MGDoFHandler<deal_II_dimension,deal_II_dimension>&,
- const Table<2,Coupling>&,
- SP &,
- const ConstraintMatrix &,
- const bool,
- const unsigned int);
-
- template void
- DoFTools::make_sparsity_pattern<DoFHandler<deal_II_dimension,deal_II_dimension>, SP>
- (const DoFHandler<deal_II_dimension,deal_II_dimension> &dof_row,
- const DoFHandler<deal_II_dimension,deal_II_dimension> &dof_col,
- SP &sparsity);
-
- template void
- DoFTools::make_sparsity_pattern<hp::DoFHandler<deal_II_dimension,deal_II_dimension>, SP>
- (const hp::DoFHandler<deal_II_dimension,deal_II_dimension> &dof_row,
- const hp::DoFHandler<deal_II_dimension,deal_II_dimension> &dof_col,
- SP &sparsity);
-
- // #if deal_II_dimension > 1
- template void
- DoFTools::make_boundary_sparsity_pattern<DoFHandler<deal_II_dimension>,SP>
- (const DoFHandler<deal_II_dimension>& dof,
- const std::vector<types::global_dof_index> &,
- SP &);
-
- template void
- DoFTools::make_boundary_sparsity_pattern<hp::DoFHandler<deal_II_dimension>,SP>
- (const hp::DoFHandler<deal_II_dimension>& dof,
- const std::vector<types::global_dof_index> &,
- SP &);
-
- template void
- DoFTools::make_boundary_sparsity_pattern<DoFHandler<deal_II_dimension>,SP>
- (const DoFHandler<deal_II_dimension>& dof,
- const FunctionMap<deal_II_dimension>::type &boundary_indicators,
- const std::vector<types::global_dof_index> &dof_to_boundary_mapping,
- SP &sparsity);
-
- template void
- DoFTools::make_boundary_sparsity_pattern<hp::DoFHandler<deal_II_dimension>,SP>
- (const hp::DoFHandler<deal_II_dimension>& dof,
- const FunctionMap<deal_II_dimension>::type &boundary_indicators,
- const std::vector<types::global_dof_index> &dof_to_boundary_mapping,
- SP &sparsity);
-
- template void
- DoFTools::make_flux_sparsity_pattern<DoFHandler<deal_II_dimension>,SP>
- (const DoFHandler<deal_II_dimension> &dof,
- SP &sparsity);
-
- template void
- DoFTools::make_flux_sparsity_pattern<hp::DoFHandler<deal_II_dimension>,SP>
- (const hp::DoFHandler<deal_II_dimension> &dof,
- SP &sparsity);
-
- template void
- DoFTools::make_cell_patches<DoFHandler<deal_II_dimension>,SP>
- (SP&, const DoFHandler<deal_II_dimension>&, const unsigned int, const std::vector<bool>&, types::global_dof_index);
-
- template void
- DoFTools::make_cell_patches<MGDoFHandler<deal_II_dimension>,SP>
- (SP&, const MGDoFHandler<deal_II_dimension>&, const unsigned int, const std::vector<bool>&, types::global_dof_index);
-
-#if deal_II_dimension > 1
-
- template void
- DoFTools::make_flux_sparsity_pattern<DoFHandler<deal_II_dimension>,SP>
- (const DoFHandler<deal_II_dimension> &dof,
- SP &,
- const Table<2,Coupling>&,
- const Table<2,Coupling>&);
-
- template void
- DoFTools::make_flux_sparsity_pattern<DoFHandler<deal_II_dimension>,SP>
- (const DoFHandler<deal_II_dimension> &dof,
- SP &sparsity,
- const ConstraintMatrix &constraints,
- const bool, const unsigned int);
-
- template void
- DoFTools::make_flux_sparsity_pattern<hp::DoFHandler<deal_II_dimension>,SP>
- (const hp::DoFHandler<deal_II_dimension> &dof,
- SP &sparsity,
- const ConstraintMatrix &constraints,
- const bool, const unsigned int);
-
- template void
- DoFTools::make_flux_sparsity_pattern<hp::DoFHandler<deal_II_dimension>,SP>
- (const hp::DoFHandler<deal_II_dimension> &dof,
- SP &,
- const Table<2,Coupling>&,
- const Table<2,Coupling>&);
-#endif
-
-#if deal_II_dimension < 3
-
- template void
- DoFTools::make_sparsity_pattern<DoFHandler<deal_II_dimension,deal_II_dimension+1>, SP>
- (const DoFHandler<deal_II_dimension,deal_II_dimension+1> &dof,
- SP &sparsity,
- const ConstraintMatrix &,
- const bool,
- const unsigned int);
-
- template void
- DoFTools::make_sparsity_pattern<hp::DoFHandler<deal_II_dimension,deal_II_dimension+1>, SP>
- (const hp::DoFHandler<deal_II_dimension,deal_II_dimension+1> &dof,
- SP &sparsity,
- const ConstraintMatrix &,
- const bool,
- const unsigned int);
-
- template void
- DoFTools::make_sparsity_pattern<DoFHandler<deal_II_dimension,deal_II_dimension+1>, SP>
- (const DoFHandler<deal_II_dimension,deal_II_dimension+1>&,
- const Table<2,Coupling>&,
- SP &,
- const ConstraintMatrix &,
- const bool,
- const unsigned int);
-
- template void
- DoFTools::make_sparsity_pattern<hp::DoFHandler<deal_II_dimension,deal_II_dimension+1>, SP>
- (const hp::DoFHandler<deal_II_dimension,deal_II_dimension+1>&,
- const Table<2,Coupling>&,
- SP &,
- const ConstraintMatrix &,
- const bool,
- const unsigned int);
-
- template void
- DoFTools::make_sparsity_pattern<DoFHandler<deal_II_dimension,deal_II_dimension+1>, SP>
- (const DoFHandler<deal_II_dimension,deal_II_dimension+1> &dof_row,
- const DoFHandler<deal_II_dimension,deal_II_dimension+1> &dof_col,
- SP &sparsity);
-
- template void
- DoFTools::make_sparsity_pattern<hp::DoFHandler<deal_II_dimension,deal_II_dimension+1>, SP>
- (const hp::DoFHandler<deal_II_dimension,deal_II_dimension+1> &dof_row,
- const hp::DoFHandler<deal_II_dimension,deal_II_dimension+1> &dof_col,
- SP &sparsity);
-
- template void
- DoFTools::make_boundary_sparsity_pattern<DoFHandler<deal_II_dimension,deal_II_dimension+1>,SP>
- (const DoFHandler<deal_II_dimension,deal_II_dimension+1>& dof,
- const std::vector<types::global_dof_index> &,
- SP &);
-
- //template void
- //DoFTools::make_boundary_sparsity_pattern<hp::DoFHandler<deal_II_dimension,deal_II_dimension+1>,SP>
- //(const hp::DoFHandler<deal_II_dimension,deal_II_dimension+1>& dof,
- // const std::vector<types::global_dof_index> &,
- // SP &);
-
- template void
- DoFTools::make_boundary_sparsity_pattern<DoFHandler<deal_II_dimension,deal_II_dimension+1>,SP>
- (const DoFHandler<deal_II_dimension,deal_II_dimension+1>& dof,
- const FunctionMap<deal_II_dimension+1>::type &boundary_indicators,
- const std::vector<types::global_dof_index> &dof_to_boundary_mapping,
- SP &sparsity);
-
- //template void
- //DoFTools::make_boundary_sparsity_pattern<hp::DoFHandler<deal_II_dimension,deal_II_dimension+1>,SP>
- //(const hp::DoFHandler<deal_II_dimension,deal_II_dimension+1>& dof,
- // const FunctionMap<deal_II_dimension+1>::type &boundary_indicators,
- // const std::vector<types::global_dof_index> &dof_to_boundary_mapping,
- // SP &sparsity);
-
-#endif
-
-
-#if deal_II_dimension == 3
+ template void
+ DoFTools::make_cell_patches<DoFHandler<deal_II_dimension>,SP>
+ (SP&, const DoFHandler<deal_II_dimension>&, const unsigned int, const std::vector<bool>&, types::global_dof_index);
- template void
- DoFTools::make_sparsity_pattern<DoFHandler<1,3>, SP>
- (const DoFHandler<1,3> &dof,
- SP &sparsity,
- const ConstraintMatrix &,
- const bool,
- const unsigned int);
-
- template void
- DoFTools::make_sparsity_pattern<hp::DoFHandler<1,3>, SP>
- (const hp::DoFHandler<1,3> &dof,
- SP &sparsity,
- const ConstraintMatrix &,
- const bool,
- const unsigned int);
-
- template void
- DoFTools::make_sparsity_pattern<DoFHandler<1,3>, SP>
- (const DoFHandler<1,3>&,
- const Table<2,Coupling>&,
- SP &,
- const ConstraintMatrix &,
- const bool,
- const unsigned int);
-
- template void
- DoFTools::make_sparsity_pattern<hp::DoFHandler<1,3>, SP>
- (const hp::DoFHandler<1,3>&,
- const Table<2,Coupling>&,
- SP &,
- const ConstraintMatrix &,
- const bool,
- const unsigned int);
-
- template void
- DoFTools::make_sparsity_pattern<DoFHandler<1,3>, SP>
- (const DoFHandler<1,3> &dof_row,
- const DoFHandler<1,3> &dof_col,
- SP &sparsity);
-
- template void
- DoFTools::make_sparsity_pattern<hp::DoFHandler<1,3>, SP>
- (const hp::DoFHandler<1,3> &dof_row,
- const hp::DoFHandler<1,3> &dof_col,
- SP &sparsity);
-
- template void
- DoFTools::make_boundary_sparsity_pattern<DoFHandler<1,3>,SP>
- (const DoFHandler<1,3>& dof,
- const std::vector<types::global_dof_index> &,
- SP &);
-
- //template void
- //DoFTools::make_boundary_sparsity_pattern<hp::DoFHandler<1,3>,SP>
- //(const hp::DoFHandler<1,3>& dof,
- // const std::vector<types::global_dof_index> &,
- // SP &);
-
- template void
- DoFTools::make_boundary_sparsity_pattern<DoFHandler<1,3>,SP>
- (const DoFHandler<1,3>& dof,
- const FunctionMap<3>::type &boundary_indicators,
- const std::vector<types::global_dof_index> &dof_to_boundary_mapping,
- SP &sparsity);
-
- //template void
- //DoFTools::make_boundary_sparsity_pattern<hp::DoFHandler<1,3>,SP>
- //(const hp::DoFHandler<1,3>& dof,
- // const FunctionMap<3>::type &boundary_indicators,
- // const std::vector<types::global_dof_index> &dof_to_boundary_mapping,
- // SP &sparsity);
-
-#endif
-
- }
-
-
-
-
-for (DH : DOFHANDLERS; deal_II_dimension : DIMENSIONS)
-{
- template
- void
- DoFTools::make_hanging_node_constraints (const DH &dof_handler,
- ConstraintMatrix &constraints);
+ template void
+ DoFTools::make_cell_patches<MGDoFHandler<deal_II_dimension>,SP>
+ (SP&, const MGDoFHandler<deal_II_dimension>&, const unsigned int, const std::vector<bool>&, types::global_dof_index);
}
-for (DH : DOFHANDLERS; deal_II_dimension : DIMENSIONS)
-{
-
-#if deal_II_dimension != 1
- template
- void
- DoFTools::make_periodicity_constraints (const DH::face_iterator &,
- const DH::face_iterator &,
- dealii::ConstraintMatrix &,
- const ComponentMask &,
- bool, bool, bool);
-
- template
- void
- DoFTools::make_periodicity_constraints(const DH &,
- const types::boundary_id,
- const types::boundary_id,
- const int,
- dealii::ConstraintMatrix &,
- const ComponentMask &);
-
- template
- void
- DoFTools::make_periodicity_constraints(const DH &,
- const types::boundary_id,
- const types::boundary_id,
- const int,
- dealii::Tensor<1,DH::space_dimension> &,
- dealii::ConstraintMatrix &,
- const ComponentMask &);
-
- template
- void
- DoFTools::make_periodicity_constraints(const DH &,
- const types::boundary_id,
- const int,
- dealii::ConstraintMatrix &,
- const ComponentMask &);
-
- template
- void
- DoFTools::make_periodicity_constraints(const DH &,
- const types::boundary_id,
- const int,
- dealii::Tensor<1,DH::space_dimension> &,
- dealii::ConstraintMatrix &,
- const ComponentMask &);
-#endif
-}
-
-for (deal_II_dimension : DIMENSIONS)
-{
-#if deal_II_dimension != 1
- template
- void
- DoFTools::make_hanging_node_constraints (const MGDoFHandler<deal_II_dimension> &dof_handler,
- ConstraintMatrix &constraints);
-
-#endif
- }
-
-
for (deal_II_dimension : DIMENSIONS)
{
- template
- Table<2,DoFTools::Coupling>
- DoFTools::dof_couplings_from_component_couplings
- (const FiniteElement<deal_II_dimension> &fe,
- const Table<2,DoFTools::Coupling> &component_couplings);
-
template
void DoFTools::make_vertex_patches (SparsityPattern&, const DoFHandler<deal_II_dimension>&,
unsigned int, bool, bool, bool, bool);
void DoFTools::make_child_patches(SparsityPattern&, const MGDoFHandler<deal_II_dimension>&,
unsigned int, bool, bool);
-#if deal_II_dimension < 3
-template
-void
-DoFTools::
-make_hanging_node_constraints (const DoFHandler<deal_II_dimension,deal_II_dimension+1> &dof_handler,
- ConstraintMatrix &constraints);
-#endif
-
-#if deal_II_dimension == 3
-template
-void
-DoFTools::
-make_hanging_node_constraints (const DoFHandler<1,3> &dof_handler,
- ConstraintMatrix &constraints);
-#endif
-
// TODO: can cleanup a bit more to fit into the scheme used above
(const DoFHandler<deal_II_dimension> & dof_handler,
IndexSet & dof_set);
+template
+void
+DoFTools::extract_locally_owned_dofs<hp::DoFHandler<deal_II_dimension> >
+(const hp::DoFHandler<deal_II_dimension> & dof_handler,
+ IndexSet & dof_set);
+
template
void
DoFTools::extract_locally_active_dofs<DoFHandler<deal_II_dimension> >
(const DoFHandler<deal_II_dimension> & dof_handler,
IndexSet & dof_set);
+template
+void
+DoFTools::extract_locally_active_dofs<hp::DoFHandler<deal_II_dimension> >
+(const hp::DoFHandler<deal_II_dimension> & dof_handler,
+ IndexSet & dof_set);
template
void
DoFTools::extract_locally_relevant_dofs<DoFHandler<deal_II_dimension> >
(const DoFHandler<deal_II_dimension> & dof_handler,
IndexSet & dof_set);
+
+template
+void
+DoFTools::extract_locally_relevant_dofs<hp::DoFHandler<deal_II_dimension> >
+(const hp::DoFHandler<deal_II_dimension> & dof_handler,
+ IndexSet & dof_set);
template
void
const DoFHandler<deal_II_dimension>&,
std::vector<types::global_dof_index>&, std::vector<unsigned int>);
-template
-void
-DoFTools::compute_intergrid_constraints<deal_II_dimension> (
- const DoFHandler<deal_II_dimension> &, const unsigned int,
- const DoFHandler<deal_II_dimension> &, const unsigned int,
- const InterGridMap<DoFHandler<deal_II_dimension> > &,
- ConstraintMatrix&);
-
-template
-void
-DoFTools::compute_intergrid_transfer_representation<deal_II_dimension>
-(const DoFHandler<deal_II_dimension> &, const unsigned int,
- const DoFHandler<deal_II_dimension> &, const unsigned int,
- const InterGridMap<DoFHandler<deal_II_dimension> > &,
- std::vector<std::map<types::global_dof_index, float> > &);
-
-
template
void
DoFTools::map_dof_to_boundary_indices<DoFHandler<deal_II_dimension> >
const hp::DoFHandler<deal_II_dimension>&, const Table<2, Coupling>&,
std::vector<Table<2,Coupling> >&);
-template
-void
-DoFTools::make_zero_boundary_constraints
-(const DoFHandler<deal_II_dimension> &,
- ConstraintMatrix &,
- const ComponentMask &);
-
-template
-void
-DoFTools::make_zero_boundary_constraints
-(const DoFHandler<deal_II_dimension> &,
- const types::boundary_id ,
- ConstraintMatrix &,
- const ComponentMask &);
-
-template
-void
-DoFTools::make_zero_boundary_constraints
-(const hp::DoFHandler<deal_II_dimension> &,
- ConstraintMatrix &,
- const ComponentMask &);
-
-template
-void
-DoFTools::make_zero_boundary_constraints
-(const hp::DoFHandler<deal_II_dimension> &,
- const types::boundary_id ,
- ConstraintMatrix &,
- const ComponentMask &);
-
#if deal_II_dimension < 3
(const DoFHandler<1,3> &dof_handler,
std::vector<bool> &selected_dofs);
-// template
-// void
-// DoFTools::map_dof_to_boundary_indices<hp::DoFHandler<1,3> >
-// (const hp::DoFHandler<1,3> &,
-// const std::set<unsigned char> &,
-// std::vector<types::global_dof_index> &);
-
-// template
-// void
-// DoFTools::map_dof_to_boundary_indices<hp::DoFHandler<1,3> >
-// (const hp::DoFHandler<1,3> &,
-// std::vector<types::global_dof_index> &);
+template
+void
+DoFTools::map_dof_to_boundary_indices<hp::DoFHandler<1,3> >
+(const hp::DoFHandler<1,3> &,
+ const std::set<unsigned char> &,
+ std::vector<types::global_dof_index> &);
+
+template
+void
+DoFTools::map_dof_to_boundary_indices<hp::DoFHandler<1,3> >
+(const hp::DoFHandler<1,3> &,
+ std::vector<types::global_dof_index> &);
#endif
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1999 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+#include <deal.II/base/multithread_info.h>
+#include <deal.II/base/thread_management.h>
+#include <deal.II/base/table.h>
+#include <deal.II/base/template_constraints.h>
+#include <deal.II/base/utilities.h>
+#include <deal.II/lac/vector.h>
+#include <deal.II/lac/constraint_matrix.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/intergrid_map.h>
+#include <deal.II/grid/grid_tools.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/dofs/dof_accessor.h>
+#include <deal.II/fe/fe.h>
+#include <deal.II/fe/fe_values.h>
+#include <deal.II/fe/fe_tools.h>
+#include <deal.II/hp/fe_collection.h>
+#include <deal.II/hp/fe_values.h>
+#include <deal.II/dofs/dof_tools.h>
+
+#include <deal.II/multigrid/mg_dof_handler.h>
+
+#include <algorithm>
+#include <numeric>
+
+DEAL_II_NAMESPACE_OPEN
+
+
+
+namespace DoFTools
+{
+ namespace internal
+ {
+ namespace
+ {
+ inline bool
+ check_master_dof_list (const FullMatrix<double> &face_interpolation_matrix,
+ const std::vector<types::global_dof_index> &master_dof_list)
+ {
+ const unsigned int N = master_dof_list.size();
+
+ FullMatrix<double> tmp (N,N);
+ for (unsigned int i=0; i<N; ++i)
+ for (unsigned int j=0; j<N; ++j)
+ tmp(i,j) = face_interpolation_matrix (master_dof_list[i], j);
+
+ // then use the algorithm from FullMatrix::gauss_jordan on this
+ // matrix to find out whether it is singular. the algorithm there
+ // does piviting and at the end swaps rows back into their proper
+ // order -- we omit this step here, since we don't care about the
+ // inverse matrix, all we care about is whether the matrix is
+ // regular or singular
+
+ // first get an estimate of the size of the elements of this
+ // matrix, for later checks whether the pivot element is large
+ // enough, or whether we have to fear that the matrix is not
+ // regular
+ double diagonal_sum = 0;
+ for (unsigned int i=0; i<N; ++i)
+ diagonal_sum += std::fabs(tmp(i,i));
+ const double typical_diagonal_element = diagonal_sum/N;
+
+ // initialize the array that holds the permutations that we find
+ // during pivot search
+ std::vector<unsigned int> p(N);
+ for (unsigned int i=0; i<N; ++i)
+ p[i] = i;
+
+ for (unsigned int j=0; j<N; ++j)
+ {
+ // pivot search: search that part of the line on and right of
+ // the diagonal for the largest element
+ double max = std::fabs(tmp(j,j));
+ unsigned int r = j;
+ for (unsigned int i=j+1; i<N; ++i)
+ {
+ if (std::fabs(tmp(i,j)) > max)
+ {
+ max = std::fabs(tmp(i,j));
+ r = i;
+ }
+ }
+ // check whether the pivot is too small. if that is the case,
+ // then the matrix is singular and we shouldn't use this set of
+ // master dofs
+ if (max < 1.e-12*typical_diagonal_element)
+ return false;
+
+ // row interchange
+ if (r>j)
+ {
+ for (unsigned int k=0; k<N; ++k)
+ std::swap (tmp(j,k), tmp(r,k));
+
+ std::swap (p[j], p[r]);
+ }
+
+ // transformation
+ const double hr = 1./tmp(j,j);
+ tmp(j,j) = hr;
+ for (unsigned int k=0; k<N; ++k)
+ {
+ if (k==j) continue;
+ for (unsigned int i=0; i<N; ++i)
+ {
+ if (i==j) continue;
+ tmp(i,k) -= tmp(i,j)*tmp(j,k)*hr;
+ }
+ }
+ for (unsigned int i=0; i<N; ++i)
+ {
+ tmp(i,j) *= hr;
+ tmp(j,i) *= -hr;
+ }
+ tmp(j,j) = hr;
+ }
+
+ // everything went fine, so we can accept this set of master dofs
+ // (at least as far as they have already been collected)
+ return true;
+ }
+
+
+
+ /**
+ * When restricting, on a face, the degrees of freedom of fe1 to the
+ * space described by fe2 (for example for the complex case described
+ * in the @ref hp_paper "hp paper"), we have to select
+ * fe2.dofs_per_face out of the fe1.dofs_per_face face DoFs as the
+ * master DoFs, and the rest become slave dofs. This function selects
+ * which ones will be masters, and which ones will be slaves.
+ *
+ * The function assumes that master_dofs already has size
+ * fe1.dofs_per_face. After the function, exactly fe2.dofs_per_face
+ * entries will be true.
+ *
+ * The function is a bit complicated since it has to figure out a set
+ * a DoFs so that the corresponding rows in the face interpolation
+ * matrix are all linearly independent. we have a good heuristic (see
+ * the function body) for selecting these rows, but there are cases
+ * where this fails and we have to pick them differently. what we do
+ * is to run the heuristic and then go back to determine whether we
+ * have a set of rows with full row rank. if this isn't the case, go
+ * back and select dofs differently
+ */
+ template <int dim, int spacedim>
+ void
+ select_master_dofs_for_face_restriction (const FiniteElement<dim,spacedim> &fe1,
+ const FiniteElement<dim,spacedim> &fe2,
+ const FullMatrix<double> &face_interpolation_matrix,
+ std::vector<bool> &master_dof_mask)
+ {
+ Assert (fe1.dofs_per_face >= fe2.dofs_per_face,
+ ExcInternalError());
+ AssertDimension (master_dof_mask.size(), fe1.dofs_per_face);
+
+ Assert (fe2.dofs_per_vertex <= fe1.dofs_per_vertex,
+ ExcInternalError());
+ Assert (fe2.dofs_per_line <= fe1.dofs_per_line,
+ ExcInternalError());
+ Assert ((dim < 3)
+ ||
+ (fe2.dofs_per_quad <= fe1.dofs_per_quad),
+ ExcInternalError());
+
+ // the idea here is to designate as many DoFs in fe1 per object
+ // (vertex, line, quad) as master as there are such dofs in fe2
+ // (indices are int, because we want to avoid the 'unsigned int < 0
+ // is always false warning for the cases at the bottom in 1d and
+ // 2d)
+ //
+ // as mentioned in the paper, it is not always easy to find a set
+ // of master dofs that produces an invertible matrix. to this end,
+ // we check in each step whether the matrix is still invertible and
+ // simply discard this dof if the matrix is not invertible anymore.
+ //
+ // the cases where we did have trouble in the past were with adding
+ // more quad dofs when Q3 and Q4 elements meet at a refined face in
+ // 3d (see the hp/crash_12 test that tests that we can do exactly
+ // this, and failed before we had code to compensate for this
+ // case). the other case are system elements: if we have say a Q1Q2
+ // vs a Q2Q3 element, then we can't just take all master dofs on a
+ // line from a single base element, since the shape functions of
+ // that base element are independent of that of the other one. this
+ // latter case shows up when running hp/hp_constraints_q_system_06
+
+ std::vector<types::global_dof_index> master_dof_list;
+ unsigned int index = 0;
+ for (int v=0;
+ v<static_cast<signed int>(GeometryInfo<dim>::vertices_per_face);
+ ++v)
+ {
+ unsigned int dofs_added = 0;
+ unsigned int i = 0;
+ while (dofs_added < fe2.dofs_per_vertex)
+ {
+ // make sure that we were able to find a set of master dofs
+ // and that the code down below didn't just reject all our
+ // efforts
+ Assert (i < fe1.dofs_per_vertex,
+ ExcInternalError());
+
+ // tentatively push this vertex dof
+ master_dof_list.push_back (index+i);
+
+ // then see what happens. if it succeeds, fine
+ if (check_master_dof_list (face_interpolation_matrix,
+ master_dof_list)
+ == true)
+ ++dofs_added;
+ else
+ // well, it didn't. simply pop that dof from the list
+ // again and try with the next dof
+ master_dof_list.pop_back ();
+
+ // forward counter by one
+ ++i;
+ }
+ index += fe1.dofs_per_vertex;
+ }
+
+ for (int l=0;
+ l<static_cast<signed int>(GeometryInfo<dim>::lines_per_face);
+ ++l)
+ {
+ // same algorithm as above
+ unsigned int dofs_added = 0;
+ unsigned int i = 0;
+ while (dofs_added < fe2.dofs_per_line)
+ {
+ Assert (i < fe1.dofs_per_line,
+ ExcInternalError());
+
+ master_dof_list.push_back (index+i);
+ if (check_master_dof_list (face_interpolation_matrix,
+ master_dof_list)
+ == true)
+ ++dofs_added;
+ else
+ master_dof_list.pop_back ();
+
+ ++i;
+ }
+ index += fe1.dofs_per_line;
+ }
+
+ for (int q=0;
+ q<static_cast<signed int>(GeometryInfo<dim>::quads_per_face);
+ ++q)
+ {
+ // same algorithm as above
+ unsigned int dofs_added = 0;
+ unsigned int i = 0;
+ while (dofs_added < fe2.dofs_per_quad)
+ {
+ Assert (i < fe1.dofs_per_quad,
+ ExcInternalError());
+
+ master_dof_list.push_back (index+i);
+ if (check_master_dof_list (face_interpolation_matrix,
+ master_dof_list)
+ == true)
+ ++dofs_added;
+ else
+ master_dof_list.pop_back ();
+
+ ++i;
+ }
+ index += fe1.dofs_per_quad;
+ }
+
+ AssertDimension (index, fe1.dofs_per_face);
+ AssertDimension (master_dof_list.size(), fe2.dofs_per_face);
+
+ // finally copy the list into the mask
+ std::fill (master_dof_mask.begin(), master_dof_mask.end(), false);
+ for (std::vector<types::global_dof_index>::const_iterator i=master_dof_list.begin();
+ i!=master_dof_list.end(); ++i)
+ master_dof_mask[*i] = true;
+ }
+
+
+
+ /**
+ * Make sure that the mask exists that determines which dofs will be
+ * the masters on refined faces where an fe1 and a fe2 meet.
+ */
+ template <int dim, int spacedim>
+ void
+ ensure_existence_of_master_dof_mask (const FiniteElement<dim,spacedim> &fe1,
+ const FiniteElement<dim,spacedim> &fe2,
+ const FullMatrix<double> &face_interpolation_matrix,
+ std_cxx1x::shared_ptr<std::vector<bool> > &master_dof_mask)
+ {
+ if (master_dof_mask == std_cxx1x::shared_ptr<std::vector<bool> >())
+ {
+ master_dof_mask = std_cxx1x::shared_ptr<std::vector<bool> >
+ (new std::vector<bool> (fe1.dofs_per_face));
+ select_master_dofs_for_face_restriction (fe1,
+ fe2,
+ face_interpolation_matrix,
+ *master_dof_mask);
+ }
+ }
+
+
+
+ /**
+ * Make sure that the given @p face_interpolation_matrix pointer
+ * points to a valid matrix. If the pointer is zero beforehand,
+ * create an entry with the correct data. If it is nonzero, don't
+ * touch it.
+ */
+ template <int dim, int spacedim>
+ void
+ ensure_existence_of_face_matrix (const FiniteElement<dim,spacedim> &fe1,
+ const FiniteElement<dim,spacedim> &fe2,
+ std_cxx1x::shared_ptr<FullMatrix<double> > &matrix)
+ {
+ if (matrix == std_cxx1x::shared_ptr<FullMatrix<double> >())
+ {
+ matrix = std_cxx1x::shared_ptr<FullMatrix<double> >
+ (new FullMatrix<double> (fe2.dofs_per_face,
+ fe1.dofs_per_face));
+ fe1.get_face_interpolation_matrix (fe2,
+ *matrix);
+ }
+ }
+
+
+
+ /**
+ * Same, but for subface interpolation matrices.
+ */
+ template <int dim, int spacedim>
+ void
+ ensure_existence_of_subface_matrix (const FiniteElement<dim,spacedim> &fe1,
+ const FiniteElement<dim,spacedim> &fe2,
+ const unsigned int subface,
+ std_cxx1x::shared_ptr<FullMatrix<double> > &matrix)
+ {
+ if (matrix == std_cxx1x::shared_ptr<FullMatrix<double> >())
+ {
+ matrix = std_cxx1x::shared_ptr<FullMatrix<double> >
+ (new FullMatrix<double> (fe2.dofs_per_face,
+ fe1.dofs_per_face));
+ fe1.get_subface_interpolation_matrix (fe2,
+ subface,
+ *matrix);
+ }
+ }
+
+
+
+ /**
+ * Given the face interpolation matrix between two elements, split it
+ * into its master and slave parts and invert the master part as
+ * explained in the @ref hp_paper "hp paper".
+ */
+ void
+ ensure_existence_of_split_face_matrix (const FullMatrix<double> &face_interpolation_matrix,
+ const std::vector<bool> &master_dof_mask,
+ std_cxx1x::shared_ptr<std::pair<FullMatrix<double>,FullMatrix<double> > > &split_matrix)
+ {
+ AssertDimension (master_dof_mask.size(), face_interpolation_matrix.m());
+ Assert (std::count (master_dof_mask.begin(), master_dof_mask.end(), true) ==
+ static_cast<signed int>(face_interpolation_matrix.n()),
+ ExcInternalError());
+
+ if (split_matrix ==
+ std_cxx1x::shared_ptr<std::pair<FullMatrix<double>,FullMatrix<double> > >())
+ {
+ split_matrix
+ = std_cxx1x::shared_ptr<std::pair<FullMatrix<double>,FullMatrix<double> > >
+ (new std::pair<FullMatrix<double>,FullMatrix<double> >());
+
+ const unsigned int n_master_dofs = face_interpolation_matrix.n();
+ const unsigned int n_dofs = face_interpolation_matrix.m();
+
+ Assert (n_master_dofs <= n_dofs, ExcInternalError());
+
+ // copy and invert the master
+ // component, copy the slave
+ // component
+ split_matrix->first.reinit (n_master_dofs, n_master_dofs);
+ split_matrix->second.reinit (n_dofs-n_master_dofs, n_master_dofs);
+
+ unsigned int nth_master_dof = 0,
+ nth_slave_dof = 0;
+
+ for (unsigned int i=0; i<n_dofs; ++i)
+ if (master_dof_mask[i] == true)
+ {
+ for (unsigned int j=0; j<n_master_dofs; ++j)
+ split_matrix->first(nth_master_dof,j)
+ = face_interpolation_matrix(i,j);
+ ++nth_master_dof;
+ }
+ else
+ {
+ for (unsigned int j=0; j<n_master_dofs; ++j)
+ split_matrix->second(nth_slave_dof,j)
+ = face_interpolation_matrix(i,j);
+ ++nth_slave_dof;
+ }
+
+ AssertDimension (nth_master_dof, n_master_dofs);
+ AssertDimension (nth_slave_dof, n_dofs-n_master_dofs);
+
+ //TODO[WB]: We should make sure very small entries are removed after inversion
+ split_matrix->first.gauss_jordan ();
+ }
+ }
+
+
+ // a template that can determine statically whether a given
+ // DoFHandler class supports different finite element elements
+ template <typename>
+ struct DoFHandlerSupportsDifferentFEs
+ {
+ static const bool value = true;
+ };
+
+
+ template <int dim, int spacedim>
+ struct DoFHandlerSupportsDifferentFEs< dealii::DoFHandler<dim,spacedim> >
+ {
+ static const bool value = false;
+ };
+
+
+ /**
+ * A function that returns how many different finite elements a dof
+ * handler uses. This is one for non-hp DoFHandlers and
+ * dof_handler.get_fe().size() for the hp-versions.
+ */
+ template <int dim, int spacedim>
+ unsigned int
+ n_finite_elements (const dealii::hp::DoFHandler<dim,spacedim> &dof_handler)
+ {
+ return dof_handler.get_fe().size();
+ }
+
+
+ template <class DH>
+ unsigned int
+ n_finite_elements (const DH &)
+ {
+ return 1;
+ }
+
+
+ /**
+ * For a given face belonging to an active cell that borders to a
+ * more refined cell, return the fe_index of the most dominating
+ * finite element used on any of the face's subfaces.
+ */
+ template <typename face_iterator>
+ unsigned int
+ get_most_dominating_subface_fe_index (const face_iterator &face)
+ {
+ const unsigned int dim
+ = face_iterator::AccessorType::dimension;
+ const unsigned int spacedim
+ = face_iterator::AccessorType::space_dimension;
+
+ unsigned int dominating_subface_no = 0;
+ for (; dominating_subface_no<face->n_children();
+ ++dominating_subface_no)
+ {
+ // each of the subfaces can have only a single fe_index
+ // associated with them, since there is no cell on the other
+ // side
+ Assert (face->child(dominating_subface_no)
+ ->n_active_fe_indices()
+ == 1,
+ ExcInternalError());
+
+ const FiniteElement<dim,spacedim> &
+ this_subface_fe = (face->child(dominating_subface_no)
+ ->get_fe (face->child(dominating_subface_no)
+ ->nth_active_fe_index(0)));
+
+ FiniteElementDomination::Domination
+ domination = FiniteElementDomination::either_element_can_dominate;
+ for (unsigned int sf=0; sf<face->n_children(); ++sf)
+ if (sf != dominating_subface_no)
+ {
+ const FiniteElement<dim,spacedim> &
+ that_subface_fe = (face->child(sf)
+ ->get_fe (face->child(sf)
+ ->nth_active_fe_index(0)));
+
+ domination = domination &
+ this_subface_fe.compare_for_face_domination(that_subface_fe);
+ }
+
+ // see if the element on this subface is able to dominate the
+ // ones on all other subfaces, and if so take it
+ if ((domination == FiniteElementDomination::this_element_dominates)
+ ||
+ (domination == FiniteElementDomination::either_element_can_dominate))
+ break;
+ }
+
+ // check that we have found one such subface
+ Assert (dominating_subface_no < face->n_children(),
+ ExcNotImplemented());
+
+ // return the finite element index used on it. note that only a
+ // single fe can be active on such subfaces
+ return face->child (dominating_subface_no)->nth_active_fe_index(0);
+ }
+
+
+
+ /**
+ * Copy constraints into a constraint matrix object.
+ *
+ * This function removes zero constraints and those, which constrain
+ * a DoF which was already eliminated in one of the previous steps of
+ * the hp hanging node procedure.
+ *
+ * It also suppresses very small entries in the constraint matrix to
+ * avoid making the sparsity pattern fuller than necessary.
+ */
+ void
+ filter_constraints (const std::vector<types::global_dof_index> &master_dofs,
+ const std::vector<types::global_dof_index> &slave_dofs,
+ const FullMatrix<double> &face_constraints,
+ ConstraintMatrix &constraints)
+ {
+ Assert (face_constraints.n () == master_dofs.size (),
+ ExcDimensionMismatch(master_dofs.size (),
+ face_constraints.n()));
+ Assert (face_constraints.m () == slave_dofs.size (),
+ ExcDimensionMismatch(slave_dofs.size (),
+ face_constraints.m()));
+
+ const unsigned int n_master_dofs = master_dofs.size ();
+ const unsigned int n_slave_dofs = slave_dofs.size ();
+
+ // check for a couple conditions that happened in parallel
+ // distributed mode
+ for (unsigned int row=0; row!=n_slave_dofs; ++row)
+ Assert (slave_dofs[row] != numbers::invalid_dof_index,
+ ExcInternalError());
+ for (unsigned int col=0; col!=n_master_dofs; ++col)
+ Assert (master_dofs[col] != numbers::invalid_dof_index,
+ ExcInternalError());
+
+
+ for (unsigned int row=0; row!=n_slave_dofs; ++row)
+ if (constraints.is_constrained (slave_dofs[row]) == false)
+ {
+ bool constraint_already_satisfied = false;
+
+ // Check if we have an identity constraint, which is already
+ // satisfied by unification of the corresponding global dof
+ // indices
+ for (unsigned int i=0; i<n_master_dofs; ++i)
+ if (face_constraints (row,i) == 1.0)
+ if (master_dofs[i] == slave_dofs[row])
+ {
+ constraint_already_satisfied = true;
+ break;
+ }
+
+ if (constraint_already_satisfied == false)
+ {
+ // add up the absolute values of all constraints in this
+ // line to get a measure of their absolute size
+ double abs_sum = 0;
+ for (unsigned int i=0; i<n_master_dofs; ++i)
+ abs_sum += std::abs (face_constraints(row,i));
+
+ // then enter those constraints that are larger than
+ // 1e-14*abs_sum. everything else probably originated
+ // from inexact inversion of matrices and similar
+ // effects. having those constraints in here will only
+ // lead to problems because it makes sparsity patterns
+ // fuller than necessary without producing any
+ // significant effect
+ constraints.add_line (slave_dofs[row]);
+ for (unsigned int i=0; i<n_master_dofs; ++i)
+ if ((face_constraints(row,i) != 0)
+ &&
+ (std::fabs(face_constraints(row,i)) >= 1e-14*abs_sum))
+ constraints.add_entry (slave_dofs[row],
+ master_dofs[i],
+ face_constraints (row,i));
+ constraints.set_inhomogeneity (slave_dofs[row], 0.);
+ }
+ }
+ }
+
+ }
+
+
+
+ void
+ make_hp_hanging_node_constraints (const dealii::DoFHandler<1> &,
+ ConstraintMatrix &)
+ {
+ // nothing to do for regular dof handlers in 1d
+ }
+
+
+
+ void
+ make_oldstyle_hanging_node_constraints (const dealii::DoFHandler<1> &,
+ ConstraintMatrix &,
+ dealii::internal::int2type<1>)
+ {
+ // nothing to do for regular dof handlers in 1d
+ }
+
+
+ void
+ make_hp_hanging_node_constraints (const dealii::MGDoFHandler<1> &,
+ ConstraintMatrix &)
+ {
+ // nothing to do for regular dof handlers in 1d
+ }
+
+
+
+ void
+ make_oldstyle_hanging_node_constraints (const dealii::MGDoFHandler<1> &,
+ ConstraintMatrix &,
+ dealii::internal::int2type<1>)
+ {
+ // nothing to do for regular dof handlers in 1d
+ }
+
+
+ void
+ make_hp_hanging_node_constraints (const dealii::hp::DoFHandler<1> &/*dof_handler*/,
+ ConstraintMatrix &/*constraints*/)
+ {
+ // we may have to compute constraints for vertices. gotta think about
+ // that a bit more
+
+ //TODO[WB]: think about what to do here...
+ }
+
+
+
+ void
+ make_oldstyle_hanging_node_constraints (const dealii::hp::DoFHandler<1> &/*dof_handler*/,
+ ConstraintMatrix &/*constraints*/,
+ dealii::internal::int2type<1>)
+ {
+ // we may have to compute constraints for vertices. gotta think about
+ // that a bit more
+
+ //TODO[WB]: think about what to do here...
+ }
+
+
+ void
+ make_hp_hanging_node_constraints (const dealii::DoFHandler<1,2> &,
+ ConstraintMatrix &)
+ {
+ // nothing to do for regular dof handlers in 1d
+ }
+
+
+
+ void
+ make_oldstyle_hanging_node_constraints (const dealii::DoFHandler<1,2> &,
+ ConstraintMatrix &,
+ dealii::internal::int2type<1>)
+ {
+ // nothing to do for regular dof handlers in 1d
+ }
+
+
+ void
+ make_hp_hanging_node_constraints (const dealii::DoFHandler<1,3> &,
+ ConstraintMatrix &)
+ {
+ // nothing to do for regular dof handlers in 1d
+ }
+
+ void
+ make_oldstyle_hanging_node_constraints (const dealii::DoFHandler<1,3> &,
+ ConstraintMatrix &,
+ dealii::internal::int2type<1>)
+ {
+ // nothing to do for regular dof handlers in 1d
+ }
+
+
+// currently not used but may be in the future:
+
+// void
+// make_hp_hanging_node_constraints (const dealii::MDoFHandler<1,2> &,
+// ConstraintMatrix &)
+// {
+// // nothing to do for regular
+// // dof handlers in 1d
+// }
+
+
+
+// void
+// make_oldstyle_hanging_node_constraints (const dealii::DoFHandler<1,2> &,
+// ConstraintMatrix &,
+// dealii::internal::int2type<1>)
+// {
+// // nothing to do for regular
+// // dof handlers in 1d
+// }
+
+
+// void
+// make_oldstyle_hanging_node_constraints (const dealii::hp::DoFHandler<1,2> &/*dof_handler*/,
+// ConstraintMatrix &/*constraints*/,
+// dealii::internal::int2type<1>)
+// {
+// // we may have to compute
+// // constraints for
+// // vertices. gotta think about
+// // that a bit more
+//
+// //TODO[WB]: think about what to do here...
+// }
+//#endif
+
+
+
+ template <class DH>
+ void
+ make_oldstyle_hanging_node_constraints (const DH &dof_handler,
+ ConstraintMatrix &constraints,
+ dealii::internal::int2type<2>)
+ {
+ const unsigned int dim = 2;
+
+ const unsigned int spacedim = DH::space_dimension;
+
+ std::vector<types::global_dof_index> dofs_on_mother;
+ std::vector<types::global_dof_index> dofs_on_children;
+
+ // loop over all lines; only on lines there can be constraints. We do
+ // so by looping over all active cells and checking whether any of
+ // the faces are refined which can only be from the neighboring cell
+ // because this one is active. In that case, the face is subject to
+ // constraints
+ //
+ // note that even though we may visit a face twice if the neighboring
+ // cells are equally refined, we can only visit each face with
+ // hanging nodes once
+ typename DH::active_cell_iterator cell = dof_handler.begin_active(),
+ endc = dof_handler.end();
+ for (; cell!=endc; ++cell)
+ // artificial cells can at best neighbor ghost cells, but we're not
+ // interested in these interfaces
+ if (!cell->is_artificial ())
+ for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
+ if (cell->face(face)->has_children())
+ {
+ // in any case, faces can have at most two active fe
+ // indices, but here the face can have only one (namely the
+ // same as that from the cell we're sitting on), and each
+ // of the children can have only one as well. check this
+ Assert (cell->face(face)->n_active_fe_indices() == 1,
+ ExcInternalError());
+ Assert (cell->face(face)->fe_index_is_active(cell->active_fe_index())
+ == true,
+ ExcInternalError());
+ for (unsigned int c=0; c<cell->face(face)->n_children(); ++c)
+ if (!cell->neighbor_child_on_subface(face,c)->is_artificial())
+ Assert (cell->face(face)->child(c)->n_active_fe_indices() == 1,
+ ExcInternalError());
+
+ // right now, all that is implemented is the case that both
+ // sides use the same fe
+ for (unsigned int c=0; c<cell->face(face)->n_children(); ++c)
+ if (!cell->neighbor_child_on_subface(face,c)->is_artificial())
+ Assert (cell->face(face)->child(c)
+ ->fe_index_is_active(cell->active_fe_index()) == true,
+ ExcNotImplemented());
+
+ // ok, start up the work
+ const FiniteElement<dim,spacedim> &fe = cell->get_fe();
+ const unsigned int fe_index = cell->active_fe_index();
+
+ const unsigned int
+ n_dofs_on_mother = 2*fe.dofs_per_vertex + fe.dofs_per_line,
+ n_dofs_on_children = fe.dofs_per_vertex + 2*fe.dofs_per_line;
+
+ dofs_on_mother.resize (n_dofs_on_mother);
+ dofs_on_children.resize (n_dofs_on_children);
+
+ Assert(n_dofs_on_mother == fe.constraints().n(),
+ ExcDimensionMismatch(n_dofs_on_mother,
+ fe.constraints().n()));
+ Assert(n_dofs_on_children == fe.constraints().m(),
+ ExcDimensionMismatch(n_dofs_on_children,
+ fe.constraints().m()));
+
+ const typename DH::line_iterator this_face = cell->face(face);
+
+ // fill the dofs indices. Use same enumeration scheme as in
+ // @p{FiniteElement::constraints()}
+ unsigned int next_index = 0;
+ for (unsigned int vertex=0; vertex<2; ++vertex)
+ for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
+ dofs_on_mother[next_index++] = this_face->vertex_dof_index(vertex,dof,
+ fe_index);
+ for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof)
+ dofs_on_mother[next_index++] = this_face->dof_index(dof, fe_index);
+ AssertDimension (next_index, dofs_on_mother.size());
+
+ next_index = 0;
+ for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
+ dofs_on_children[next_index++]
+ = this_face->child(0)->vertex_dof_index(1,dof,fe_index);
+ for (unsigned int child=0; child<2; ++child)
+ for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof)
+ dofs_on_children[next_index++]
+ = this_face->child(child)->dof_index(dof, fe_index);
+ AssertDimension (next_index, dofs_on_children.size());
+
+ // for each row in the constraint matrix for this line:
+ for (unsigned int row=0; row!=dofs_on_children.size(); ++row)
+ {
+ constraints.add_line (dofs_on_children[row]);
+ for (unsigned int i=0; i!=dofs_on_mother.size(); ++i)
+ constraints.add_entry (dofs_on_children[row],
+ dofs_on_mother[i],
+ fe.constraints()(row,i));
+
+ constraints.set_inhomogeneity (dofs_on_children[row], 0.);
+ }
+ }
+ else
+ {
+ // this face has no children, but it could still be that it
+ // is shared by two cells that use a different fe index.
+ // check a couple of things, but ignore the case that the
+ // neighbor is an artificial cell
+ if (!cell->at_boundary(face) &&
+ !cell->neighbor(face)->is_artificial())
+ {
+ Assert (cell->face(face)->n_active_fe_indices() == 1,
+ ExcNotImplemented());
+ Assert (cell->face(face)
+ ->fe_index_is_active(cell->active_fe_index()) == true,
+ ExcInternalError());
+ }
+ }
+ }
+
+
+
+ template <class DH>
+ void
+ make_oldstyle_hanging_node_constraints (const DH &dof_handler,
+ ConstraintMatrix &constraints,
+ dealii::internal::int2type<3>)
+ {
+ const unsigned int dim = 3;
+
+ std::vector<types::global_dof_index> dofs_on_mother;
+ std::vector<types::global_dof_index> dofs_on_children;
+
+ // loop over all quads; only on quads there can be constraints. We do
+ // so by looping over all active cells and checking whether any of
+ // the faces are refined which can only be from the neighboring cell
+ // because this one is active. In that case, the face is subject to
+ // constraints
+ //
+ // note that even though we may visit a face twice if the neighboring
+ // cells are equally refined, we can only visit each face with
+ // hanging nodes once
+ typename DH::active_cell_iterator cell = dof_handler.begin_active(),
+ endc = dof_handler.end();
+ for (; cell!=endc; ++cell)
+ // artificial cells can at best neighbor ghost cells, but we're not
+ // interested in these interfaces
+ if (!cell->is_artificial ())
+ for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
+ if (cell->face(face)->has_children())
+ {
+ // first of all, make sure that we treat a case which is
+ // possible, i.e. either no dofs on the face at all or no
+ // anisotropic refinement
+ if (cell->get_fe().dofs_per_face == 0)
+ continue;
+
+ Assert(cell->face(face)->refinement_case()==RefinementCase<dim-1>::isotropic_refinement,
+ ExcNotImplemented());
+
+ // in any case, faces can have at most two active fe
+ // indices, but here the face can have only one (namely the
+ // same as that from the cell we're sitting on), and each
+ // of the children can have only one as well. check this
+ AssertDimension (cell->face(face)->n_active_fe_indices(), 1);
+ Assert (cell->face(face)->fe_index_is_active(cell->active_fe_index())
+ == true,
+ ExcInternalError());
+ for (unsigned int c=0; c<cell->face(face)->n_children(); ++c)
+ AssertDimension (cell->face(face)->child(c)->n_active_fe_indices(), 1);
+
+ // right now, all that is implemented is the case that both
+ // sides use the same fe, and not only that but also that
+ // all lines bounding this face and the children have the
+ // same fe
+ for (unsigned int c=0; c<cell->face(face)->n_children(); ++c)
+ if (!cell->neighbor_child_on_subface(face,c)->is_artificial())
+ {
+ Assert (cell->face(face)->child(c)
+ ->fe_index_is_active(cell->active_fe_index()) == true,
+ ExcNotImplemented());
+ for (unsigned int e=0; e<4; ++e)
+ {
+ Assert (cell->face(face)->child(c)->line(e)
+ ->n_active_fe_indices() == 1,
+ ExcNotImplemented());
+ Assert (cell->face(face)->child(c)->line(e)
+ ->fe_index_is_active(cell->active_fe_index()) == true,
+ ExcNotImplemented());
+ }
+ }
+ for (unsigned int e=0; e<4; ++e)
+ {
+ Assert (cell->face(face)->line(e)
+ ->n_active_fe_indices() == 1,
+ ExcNotImplemented());
+ Assert (cell->face(face)->line(e)
+ ->fe_index_is_active(cell->active_fe_index()) == true,
+ ExcNotImplemented());
+ }
+
+ // ok, start up the work
+ const FiniteElement<dim> &fe = cell->get_fe();
+ const unsigned int fe_index = cell->active_fe_index();
+
+ const unsigned int n_dofs_on_mother = fe.dofs_per_face;
+ const unsigned int n_dofs_on_children = (5*fe.dofs_per_vertex+
+ 12*fe.dofs_per_line+
+ 4*fe.dofs_per_quad);
+
+ //TODO[TL]: think about this and the following in case of anisotropic refinement
+
+ dofs_on_mother.resize (n_dofs_on_mother);
+ dofs_on_children.resize (n_dofs_on_children);
+
+ Assert(n_dofs_on_mother == fe.constraints().n(),
+ ExcDimensionMismatch(n_dofs_on_mother,
+ fe.constraints().n()));
+ Assert(n_dofs_on_children == fe.constraints().m(),
+ ExcDimensionMismatch(n_dofs_on_children,
+ fe.constraints().m()));
+
+ const typename DH::face_iterator this_face = cell->face(face);
+
+ // fill the dofs indices. Use same enumeration scheme as in
+ // @p{FiniteElement::constraints()}
+ unsigned int next_index = 0;
+ for (unsigned int vertex=0; vertex<4; ++vertex)
+ for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
+ dofs_on_mother[next_index++] = this_face->vertex_dof_index(vertex,dof,
+ fe_index);
+ for (unsigned int line=0; line<4; ++line)
+ for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof)
+ dofs_on_mother[next_index++]
+ = this_face->line(line)->dof_index(dof, fe_index);
+ for (unsigned int dof=0; dof!=fe.dofs_per_quad; ++dof)
+ dofs_on_mother[next_index++] = this_face->dof_index(dof, fe_index);
+ AssertDimension (next_index, dofs_on_mother.size());
+
+ next_index = 0;
+
+ // assert some consistency assumptions
+
+ //TODO[TL]: think about this in case of anisotropic
+ //refinement
+
+ Assert (dof_handler.get_tria().get_anisotropic_refinement_flag() ||
+ ((this_face->child(0)->vertex_index(3) ==
+ this_face->child(1)->vertex_index(2)) &&
+ (this_face->child(0)->vertex_index(3) ==
+ this_face->child(2)->vertex_index(1)) &&
+ (this_face->child(0)->vertex_index(3) ==
+ this_face->child(3)->vertex_index(0))),
+ ExcInternalError());
+ for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
+ dofs_on_children[next_index++]
+ = this_face->child(0)->vertex_dof_index(3,dof);
+
+ // dof numbers on the centers of the lines bounding this
+ // face
+ for (unsigned int line=0; line<4; ++line)
+ for (unsigned int dof=0; dof!=fe.dofs_per_vertex; ++dof)
+ dofs_on_children[next_index++]
+ = this_face->line(line)->child(0)->vertex_dof_index(1,dof, fe_index);
+
+ // next the dofs on the lines interior to the face; the
+ // order of these lines is laid down in the FiniteElement
+ // class documentation
+ for (unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
+ dofs_on_children[next_index++]
+ = this_face->child(0)->line(1)->dof_index(dof, fe_index);
+ for (unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
+ dofs_on_children[next_index++]
+ = this_face->child(2)->line(1)->dof_index(dof, fe_index);
+ for (unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
+ dofs_on_children[next_index++]
+ = this_face->child(0)->line(3)->dof_index(dof, fe_index);
+ for (unsigned int dof=0; dof<fe.dofs_per_line; ++dof)
+ dofs_on_children[next_index++]
+ = this_face->child(1)->line(3)->dof_index(dof, fe_index);
+
+ // dofs on the bordering lines
+ for (unsigned int line=0; line<4; ++line)
+ for (unsigned int child=0; child<2; ++child)
+ for (unsigned int dof=0; dof!=fe.dofs_per_line; ++dof)
+ dofs_on_children[next_index++]
+ = this_face->line(line)->child(child)->dof_index(dof, fe_index);
+
+ // finally, for the dofs interior to the four child faces
+ for (unsigned int child=0; child<4; ++child)
+ for (unsigned int dof=0; dof!=fe.dofs_per_quad; ++dof)
+ dofs_on_children[next_index++]
+ = this_face->child(child)->dof_index(dof, fe_index);
+ AssertDimension (next_index, dofs_on_children.size());
+
+ // for each row in the constraint matrix for this line:
+ for (unsigned int row=0; row!=dofs_on_children.size(); ++row)
+ {
+ constraints.add_line (dofs_on_children[row]);
+ for (unsigned int i=0; i!=dofs_on_mother.size(); ++i)
+ constraints.add_entry (dofs_on_children[row],
+ dofs_on_mother[i],
+ fe.constraints()(row,i));
+
+ constraints.set_inhomogeneity(dofs_on_children[row], 0.);
+ }
+ }
+ else
+ {
+ // this face has no children, but it could still be that it
+ // is shared by two cells that use a different fe index.
+ // check a couple of things, but ignore the case that the
+ // neighbor is an artificial cell
+ if (!cell->at_boundary(face) &&
+ !cell->neighbor(face)->is_artificial())
+ {
+ Assert (cell->face(face)->n_active_fe_indices() == 1,
+ ExcNotImplemented());
+ Assert (cell->face(face)
+ ->fe_index_is_active(cell->active_fe_index()) == true,
+ ExcInternalError());
+ }
+ }
+ }
+
+
+ template <class DH>
+ void
+ make_hp_hanging_node_constraints (const DH &dof_handler,
+ ConstraintMatrix &constraints)
+ {
+ // note: this function is going to be hard to understand if you
+ // haven't read the hp paper. however, we try to follow the notation
+ // laid out there, so go read the paper before you try to understand
+ // what is going on here
+
+ const unsigned int dim = DH::dimension;
+
+ const unsigned int spacedim = DH::space_dimension;
+
+
+ // a matrix to be used for constraints below. declared here and
+ // simply resized down below to avoid permanent re-allocation of
+ // memory
+ FullMatrix<double> constraint_matrix;
+
+ // similarly have arrays that will hold master and slave dof numbers,
+ // as well as a scratch array needed for the complicated case below
+ std::vector<types::global_dof_index> master_dofs;
+ std::vector<types::global_dof_index> slave_dofs;
+ std::vector<types::global_dof_index> scratch_dofs;
+
+ // caches for the face and subface interpolation matrices between
+ // different (or the same) finite elements. we compute them only
+ // once, namely the first time they are needed, and then just reuse
+ // them
+ Table<2,std_cxx1x::shared_ptr<FullMatrix<double> > >
+ face_interpolation_matrices (n_finite_elements (dof_handler),
+ n_finite_elements (dof_handler));
+ Table<3,std_cxx1x::shared_ptr<FullMatrix<double> > >
+ subface_interpolation_matrices (n_finite_elements (dof_handler),
+ n_finite_elements (dof_handler),
+ GeometryInfo<dim>::max_children_per_face);
+
+ // similarly have a cache for the matrices that are split into their
+ // master and slave parts, and for which the master part is inverted.
+ // these two matrices are derived from the face interpolation matrix
+ // as described in the @ref hp_paper "hp paper"
+ Table<2,std_cxx1x::shared_ptr<std::pair<FullMatrix<double>,FullMatrix<double> > > >
+ split_face_interpolation_matrices (n_finite_elements (dof_handler),
+ n_finite_elements (dof_handler));
+
+ // finally, for each pair of finite elements, have a mask that states
+ // which of the degrees of freedom on the coarse side of a refined
+ // face will act as master dofs.
+ Table<2,std_cxx1x::shared_ptr<std::vector<bool> > >
+ master_dof_masks (n_finite_elements (dof_handler),
+ n_finite_elements (dof_handler));
+
+ // loop over all faces
+ //
+ // note that even though we may visit a face twice if the neighboring
+ // cells are equally refined, we can only visit each face with
+ // hanging nodes once
+ typename DH::active_cell_iterator cell = dof_handler.begin_active(),
+ endc = dof_handler.end();
+ for (; cell!=endc; ++cell)
+ // artificial cells can at best neighbor ghost cells, but we're not
+ // interested in these interfaces
+ if (!cell->is_artificial ())
+ for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
+ if (cell->face(face)->has_children())
+ {
+ // first of all, make sure that we treat a case which is
+ // possible, i.e. either no dofs on the face at all or no
+ // anisotropic refinement
+ if (cell->get_fe().dofs_per_face == 0)
+ continue;
+
+ Assert(cell->face(face)->refinement_case()==RefinementCase<dim-1>::isotropic_refinement,
+ ExcNotImplemented());
+
+ // so now we've found a face of an active cell that has
+ // children. that means that there are hanging nodes here.
+
+ // in any case, faces can have at most two sets of active
+ // fe indices, but here the face can have only one (namely
+ // the same as that from the cell we're sitting on), and
+ // each of the children can have only one as well. check
+ // this
+ Assert (cell->face(face)->n_active_fe_indices() == 1,
+ ExcInternalError());
+ Assert (cell->face(face)->fe_index_is_active(cell->active_fe_index())
+ == true,
+ ExcInternalError());
+ for (unsigned int c=0; c<cell->face(face)->n_children(); ++c)
+ Assert (cell->face(face)->child(c)->n_active_fe_indices() == 1,
+ ExcInternalError());
+
+ // first find out whether we can constrain each of the
+ // subfaces to the mother face. in the lingo of the hp
+ // paper, this would be the simple case. note that we can
+ // short-circuit this decision if the dof_handler doesn't
+ // support hp at all
+ //
+ // ignore all interfaces with artificial cells
+ FiniteElementDomination::Domination
+ mother_face_dominates = FiniteElementDomination::either_element_can_dominate;
+
+ if (DoFHandlerSupportsDifferentFEs<DH>::value == true)
+ for (unsigned int c=0; c<cell->face(face)->number_of_children(); ++c)
+ if (!cell->neighbor_child_on_subface (face, c)->is_artificial())
+ mother_face_dominates = mother_face_dominates &
+ (cell->get_fe().compare_for_face_domination
+ (cell->neighbor_child_on_subface (face, c)->get_fe()));
+
+ switch (mother_face_dominates)
+ {
+ case FiniteElementDomination::this_element_dominates:
+ case FiniteElementDomination::either_element_can_dominate:
+ {
+ // Case 1 (the simple case and the only case that can
+ // happen for non-hp DoFHandlers): The coarse element
+ // dominates the elements on the subfaces (or they are
+ // all the same)
+ //
+ // so we are going to constrain the DoFs on the face
+ // children against the DoFs on the face itself
+ master_dofs.resize (cell->get_fe().dofs_per_face);
+
+ cell->face(face)->get_dof_indices (master_dofs,
+ cell->active_fe_index ());
+
+ // Now create constraint matrix for the subfaces and
+ // assemble it. ignore all interfaces with artificial
+ // cells because we can only get to such interfaces if
+ // the current cell is a ghost cell
+ for (unsigned int c=0; c<cell->face(face)->n_children(); ++c)
+ {
+ if (cell->neighbor_child_on_subface (face, c)->is_artificial())
+ continue;
+
+ const typename DH::active_face_iterator
+ subface = cell->face(face)->child(c);
+
+ Assert (subface->n_active_fe_indices() == 1,
+ ExcInternalError());
+
+ const unsigned int
+ subface_fe_index = subface->nth_active_fe_index(0);
+
+ // we sometime run into the situation where for
+ // example on one big cell we have a FE_Q(1) and on
+ // the subfaces we have a mixture of FE_Q(1) and
+ // FE_Nothing. In that case, the face domination is
+ // either_element_can_dominate for the whole
+ // collection of subfaces, but on the particular
+ // subface between FE_Q(1) and FE_Nothing, there
+ // are no constraints that we need to take care of.
+ // in that case, just continue
+ if (cell->get_fe().compare_for_face_domination
+ (subface->get_fe(subface_fe_index))
+ ==
+ FiniteElementDomination::no_requirements)
+ continue;
+
+ // Same procedure as for the mother cell. Extract
+ // the face DoFs from the cell DoFs.
+ slave_dofs.resize (subface->get_fe(subface_fe_index)
+ .dofs_per_face);
+ subface->get_dof_indices (slave_dofs, subface_fe_index);
+
+ for (unsigned int i=0; i<slave_dofs.size(); ++i)
+ Assert (slave_dofs[i] != numbers::invalid_dof_index,
+ ExcInternalError());
+
+ // Now create the element constraint for this
+ // subface.
+ //
+ // As a side remark, one may wonder the following:
+ // neighbor_child is clearly computed correctly,
+ // i.e. taking into account face_orientation (just
+ // look at the implementation of that function).
+ // however, we don't care about this here, when we
+ // ask for subface_interpolation on subface c. the
+ // question rather is: do we have to translate 'c'
+ // here as well?
+ //
+ // the answer is in fact 'no'. if one does that,
+ // results are wrong: constraints are added twice
+ // for the same pair of nodes but with differing
+ // weights. in addition, one can look at the
+ // deal.II/project_*_03 tests that look at exactly
+ // this case: there, we have a mesh with at least
+ // one face_orientation==false and hanging nodes,
+ // and the results of those tests show that the
+ // result of projection verifies the approximation
+ // properties of a finite element onto that mesh
+ ensure_existence_of_subface_matrix
+ (cell->get_fe(),
+ subface->get_fe(subface_fe_index),
+ c,
+ subface_interpolation_matrices
+ [cell->active_fe_index()][subface_fe_index][c]);
+
+ // Add constraints to global constraint matrix.
+ filter_constraints (master_dofs,
+ slave_dofs,
+ *(subface_interpolation_matrices
+ [cell->active_fe_index()][subface_fe_index][c]),
+ constraints);
+ }
+
+ break;
+ }
+
+ case FiniteElementDomination::other_element_dominates:
+ case FiniteElementDomination::neither_element_dominates:
+ {
+ // Case 2 (the "complex" case): at least one (the
+ // neither_... case) of the finer elements or all of
+ // them (the other_... case) is dominating. See the hp
+ // paper for a way how to deal with this situation
+ //
+ // since this is something that can only happen for hp
+ // dof handlers, add a check here...
+ Assert (DoFHandlerSupportsDifferentFEs<DH>::value == true,
+ ExcInternalError());
+
+ // we first have to find the finite element that is
+ // able to generate a space that all the other ones can
+ // be constrained to
+ const unsigned int dominating_fe_index
+ = get_most_dominating_subface_fe_index (cell->face(face));
+
+ const FiniteElement<dim,spacedim> &dominating_fe
+ = dof_handler.get_fe()[dominating_fe_index];
+
+ // check also that it is able to constrain the mother
+ // face. it should be, or we wouldn't have gotten into
+ // the branch for the 'complex' case
+ Assert ((dominating_fe.compare_for_face_domination
+ (cell->face(face)->get_fe(cell->face(face)->nth_active_fe_index(0)))
+ == FiniteElementDomination::this_element_dominates)
+ ||
+ (dominating_fe.compare_for_face_domination
+ (cell->face(face)->get_fe(cell->face(face)->nth_active_fe_index(0)))
+ == FiniteElementDomination::either_element_can_dominate),
+ ExcInternalError());
+
+
+ // first get the interpolation matrix from the mother
+ // to the virtual dofs
+ Assert (dominating_fe.dofs_per_face <=
+ cell->get_fe().dofs_per_face,
+ ExcInternalError());
+
+ ensure_existence_of_face_matrix
+ (dominating_fe,
+ cell->get_fe(),
+ face_interpolation_matrices
+ [dominating_fe_index][cell->active_fe_index()]);
+
+ // split this matrix into master and slave components.
+ // invert the master component
+ ensure_existence_of_master_dof_mask
+ (cell->get_fe(),
+ dominating_fe,
+ (*face_interpolation_matrices
+ [dominating_fe_index]
+ [cell->active_fe_index()]),
+ master_dof_masks
+ [dominating_fe_index]
+ [cell->active_fe_index()]);
+
+ ensure_existence_of_split_face_matrix
+ (*face_interpolation_matrices
+ [dominating_fe_index][cell->active_fe_index()],
+ (*master_dof_masks
+ [dominating_fe_index][cell->active_fe_index()]),
+ split_face_interpolation_matrices
+ [dominating_fe_index][cell->active_fe_index()]);
+
+ const FullMatrix<double> &restrict_mother_to_virtual_master_inv
+ = (split_face_interpolation_matrices
+ [dominating_fe_index][cell->active_fe_index()]->first);
+
+ const FullMatrix<double> &restrict_mother_to_virtual_slave
+ = (split_face_interpolation_matrices
+ [dominating_fe_index][cell->active_fe_index()]->second);
+
+ // now compute the constraint matrix as the product
+ // between the inverse matrix and the slave part
+ constraint_matrix.reinit (cell->get_fe().dofs_per_face -
+ dominating_fe.dofs_per_face,
+ dominating_fe.dofs_per_face);
+ restrict_mother_to_virtual_slave
+ .mmult (constraint_matrix,
+ restrict_mother_to_virtual_master_inv);
+
+ // then figure out the global numbers of master and
+ // slave dofs and apply constraints
+ scratch_dofs.resize (cell->get_fe().dofs_per_face);
+ cell->face(face)->get_dof_indices (scratch_dofs,
+ cell->active_fe_index ());
+
+ // split dofs into master and slave components
+ master_dofs.clear ();
+ slave_dofs.clear ();
+ for (unsigned int i=0; i<cell->get_fe().dofs_per_face; ++i)
+ if ((*master_dof_masks
+ [dominating_fe_index][cell->active_fe_index()])[i] == true)
+ master_dofs.push_back (scratch_dofs[i]);
+ else
+ slave_dofs.push_back (scratch_dofs[i]);
+
+ AssertDimension (master_dofs.size(), dominating_fe.dofs_per_face);
+ AssertDimension (slave_dofs.size(),
+ cell->get_fe().dofs_per_face - dominating_fe.dofs_per_face);
+
+ filter_constraints (master_dofs,
+ slave_dofs,
+ constraint_matrix,
+ constraints);
+
+
+
+ // next we have to deal with the subfaces. do as
+ // discussed in the hp paper
+ for (unsigned int sf=0;
+ sf<cell->face(face)->n_children(); ++sf)
+ {
+ // ignore interfaces with artificial cells as well
+ // as interfaces between ghost cells in 2d
+ if (cell->neighbor_child_on_subface (face, sf)->is_artificial()
+ ||
+ (dim==2 && cell->is_ghost()
+ &&
+ cell->neighbor_child_on_subface (face, sf)->is_ghost()))
+ continue;
+
+ Assert (cell->face(face)->child(sf)
+ ->n_active_fe_indices() == 1,
+ ExcInternalError());
+
+ const unsigned int subface_fe_index
+ = cell->face(face)->child(sf)->nth_active_fe_index(0);
+ const FiniteElement<dim,spacedim> &subface_fe
+ = dof_handler.get_fe()[subface_fe_index];
+
+ // first get the interpolation matrix from the
+ // subface to the virtual dofs
+ Assert (dominating_fe.dofs_per_face <=
+ subface_fe.dofs_per_face,
+ ExcInternalError());
+ ensure_existence_of_subface_matrix
+ (dominating_fe,
+ subface_fe,
+ sf,
+ subface_interpolation_matrices
+ [dominating_fe_index][subface_fe_index][sf]);
+
+ const FullMatrix<double> &restrict_subface_to_virtual
+ = *(subface_interpolation_matrices
+ [dominating_fe_index][subface_fe_index][sf]);
+
+ constraint_matrix.reinit (subface_fe.dofs_per_face,
+ dominating_fe.dofs_per_face);
+
+ restrict_subface_to_virtual
+ .mmult (constraint_matrix,
+ restrict_mother_to_virtual_master_inv);
+
+ slave_dofs.resize (subface_fe.dofs_per_face);
+ cell->face(face)->child(sf)->get_dof_indices (slave_dofs,
+ subface_fe_index);
+
+ filter_constraints (master_dofs,
+ slave_dofs,
+ constraint_matrix,
+ constraints);
+ }
+
+ break;
+ }
+
+ case FiniteElementDomination::no_requirements:
+ // there are no continuity requirements between the two
+ // elements. record no constraints
+ break;
+
+ default:
+ // we shouldn't get here
+ Assert (false, ExcInternalError());
+ }
+ }
+ else
+ {
+ // this face has no children, but it could still be that it
+ // is shared by two cells that use a different fe index
+ Assert (cell->face(face)
+ ->fe_index_is_active(cell->active_fe_index()) == true,
+ ExcInternalError());
+
+ // see if there is a neighbor that is an artificial cell.
+ // in that case, we're not interested in this interface. we
+ // test this case first since artificial cells may not have
+ // an active_fe_index set, etc
+ if (!cell->at_boundary(face)
+ &&
+ cell->neighbor(face)->is_artificial())
+ continue;
+
+ // Only if there is a neighbor with a different
+ // active_fe_index and the same h-level, some action has to
+ // be taken.
+ if ((DoFHandlerSupportsDifferentFEs<DH>::value == true)
+ &&
+ !cell->face(face)->at_boundary ()
+ &&
+ (cell->neighbor(face)->active_fe_index () !=
+ cell->active_fe_index ())
+ &&
+ (!cell->face(face)->has_children() &&
+ !cell->neighbor_is_coarser(face) ))
+ {
+ const typename DH::level_cell_iterator neighbor = cell->neighbor (face);
+
+ // see which side of the face we have to constrain
+ switch (cell->get_fe().compare_for_face_domination (neighbor->get_fe ()))
+ {
+ case FiniteElementDomination::this_element_dominates:
+ {
+ // Get DoFs on dominating and dominated side of the
+ // face
+ master_dofs.resize (cell->get_fe().dofs_per_face);
+ cell->face(face)->get_dof_indices (master_dofs,
+ cell->active_fe_index ());
+
+ slave_dofs.resize (neighbor->get_fe().dofs_per_face);
+ cell->face(face)->get_dof_indices (slave_dofs,
+ neighbor->active_fe_index ());
+
+ // break if the n_master_dofs == 0, because we are
+ // attempting to constrain to an element that has
+ // no face dofs
+ if (master_dofs.size() == 0) break;
+
+ // make sure the element constraints for this face
+ // are available
+ ensure_existence_of_face_matrix
+ (cell->get_fe(),
+ neighbor->get_fe(),
+ face_interpolation_matrices
+ [cell->active_fe_index()][neighbor->active_fe_index()]);
+
+ // Add constraints to global constraint matrix.
+ filter_constraints (master_dofs,
+ slave_dofs,
+ *(face_interpolation_matrices
+ [cell->active_fe_index()]
+ [neighbor->active_fe_index()]),
+ constraints);
+
+ break;
+ }
+
+ case FiniteElementDomination::other_element_dominates:
+ {
+ // we don't do anything here since we will come
+ // back to this face from the other cell, at which
+ // time we will fall into the first case clause
+ // above
+ break;
+ }
+
+ case FiniteElementDomination::either_element_can_dominate:
+ {
+ // it appears as if neither element has any
+ // constraints on its neighbor. this may be because
+ // neither element has any DoFs on faces at all. or
+ // that the two elements are actually the same,
+ // although they happen to run under different
+ // fe_indices (this is what happens in
+ // hp/hp_hanging_nodes_01 for example).
+ //
+ // another possibility is what happens in crash_13.
+ // there, we have FESystem(FE_Q(1),FE_DGQ(0)) vs.
+ // FESystem(FE_Q(1),FE_DGQ(1)). neither of them
+ // dominates the other.
+ //
+ // a final possibility is that we have something like
+ // FESystem(FE_Q(1),FE_Q(1)) vs
+ // FESystem(FE_Q(1),FE_Nothing()), see
+ // hp/fe_nothing_18/19.
+ //
+ // in any case, the point is that it doesn't
+ // matter. there is nothing to do here.
+ break;
+ }
+
+ case FiniteElementDomination::neither_element_dominates:
+ {
+ // we don't presently know what exactly to do here.
+ // it isn't quite clear what exactly we would have
+ // to do here. sit tight until someone trips over
+ // the following statement and see what exactly is
+ // going on
+ Assert (false, ExcNotImplemented());
+ break;
+ }
+
+ case FiniteElementDomination::no_requirements:
+ {
+ // nothing to do here
+ break;
+ }
+
+ default:
+ // we shouldn't get here
+ Assert (false, ExcInternalError());
+ }
+ }
+ }
+ }
+ }
+
+
+
+
+ template <class DH>
+ void
+ make_hanging_node_constraints (const DH &dof_handler,
+ ConstraintMatrix &constraints)
+ {
+ // Decide whether to use the new or old make_hanging_node_constraints
+ // function. If all the FiniteElement or all elements in a FECollection
+ // support the new face constraint matrix, the new code will be used.
+ // Otherwise, the old implementation is used for the moment.
+ if (dof_handler.get_fe().hp_constraints_are_implemented ())
+ internal::
+ make_hp_hanging_node_constraints (dof_handler,
+ constraints);
+ else
+ internal::
+ make_oldstyle_hanging_node_constraints (dof_handler,
+ constraints,
+ dealii::internal::int2type<DH::dimension>());
+ }
+
+
+
+ namespace
+ {
+ // enter constraints for periodicity into the given ConstraintMatrix object.
+ // this function is called when at least one of the two face iterators corresponds
+ // to an active object without further children
+ //
+ // @param transformation A matrix that maps degrees of freedom from one face
+ // to another. If the DoFs on the two faces are supposed to match exactly, then
+ // the matrix so provided will be the identity matrix. if face 2 is once refined
+ // from face 1, then the matrix needs to be the interpolation matrix from a face
+ // to this particular child
+ //
+ // @precondition: face_1 is supposed to be active
+ //
+ // @note As bug #82 ((http://code.google.com/p/dealii/issues/detail?id=82) and the
+ // corresponding testcase bits/periodicity_05 demonstrate, we can occasionally
+ // get into trouble if we already have the constraint x1=x2 and want to insert
+ // x2=x1. we avoid this by skipping an identity constraint if the opposite
+ // constraint already exists
+ template <typename FaceIterator>
+ void
+ set_periodicity_constraints (const FaceIterator &face_1,
+ const typename identity<FaceIterator>::type &face_2,
+ const FullMatrix<double> &transformation,
+ dealii::ConstraintMatrix &constraint_matrix,
+ const ComponentMask &component_mask,
+ const bool face_orientation,
+ const bool face_flip,
+ const bool face_rotation)
+ {
+ static const int dim = FaceIterator::AccessorType::dimension;
+ static const int spacedim = FaceIterator::AccessorType::space_dimension;
+
+ // we should be in the case where face_1 is active, i.e. has no children:
+ Assert (!face_1->has_children(),
+ ExcInternalError());
+
+ Assert (face_1->n_active_fe_indices() == 1,
+ ExcInternalError());
+
+ // if face_2 does have children, then we need to iterate over them
+ if (face_2->has_children())
+ {
+ Assert (face_2->n_children() == GeometryInfo<dim>::max_children_per_face,
+ ExcNotImplemented());
+ const unsigned int dofs_per_face
+ = face_1->get_fe(face_1->nth_active_fe_index(0)).dofs_per_face;
+ FullMatrix<double> child_transformation (dofs_per_face, dofs_per_face);
+ FullMatrix<double> subface_interpolation (dofs_per_face, dofs_per_face);
+ for (unsigned int c=0; c<face_2->n_children(); ++c)
+ {
+ // get the interpolation matrix recursively from the one that
+ // interpolated from face_1 to face_2 by multiplying from the
+ // left with the one that interpolates from face_2 to
+ // its child
+ face_1->get_fe(face_1->nth_active_fe_index(0))
+ .get_subface_interpolation_matrix (face_1->get_fe(face_1->nth_active_fe_index(0)),
+ c,
+ subface_interpolation);
+ subface_interpolation.mmult (child_transformation, transformation);
+ set_periodicity_constraints(face_1, face_2->child(c),
+ child_transformation,
+ constraint_matrix, component_mask,
+ face_orientation, face_flip, face_rotation);
+ }
+ }
+ else
+ // both faces are active. we need to match the corresponding DoFs of both faces
+ {
+ const unsigned int face_1_index = face_1->nth_active_fe_index(0);
+ const unsigned int face_2_index = face_2->nth_active_fe_index(0);
+ Assert(face_1->get_fe(face_1_index) == face_2->get_fe(face_1_index),
+ ExcMessage ("Matching periodic cells need to use the same finite element"));
+
+ const FiniteElement<dim, spacedim> &fe = face_1->get_fe(face_1_index);
+
+ Assert(component_mask.represents_n_components(fe.n_components()),
+ ExcMessage ("The number of components in the mask has to be either "
+ "zero or equal to the number of components in the finite " "element."));
+
+ const unsigned int dofs_per_face = fe.dofs_per_face;
+
+ std::vector<types::global_dof_index> dofs_1(dofs_per_face);
+ std::vector<types::global_dof_index> dofs_2(dofs_per_face);
+
+ face_1->get_dof_indices(dofs_1, face_1_index);
+ face_2->get_dof_indices(dofs_2, face_2_index);
+
+ for (unsigned int i=0; i < dofs_per_face; i++) {
+ if (dofs_1[i] == numbers::invalid_dof_index ||
+ dofs_2[i] == numbers::invalid_dof_index) {
+ /* If either of these faces have no indices, stop. This is so
+ * that there is no attempt to match artificial cells of
+ * parallel distributed triangulations.
+ *
+ * While it seems like we ought to be able to avoid even calling
+ * set_periodicity_constraints for artificial faces, this
+ * situation can arise when a face that is being made periodic
+ * is only partially touched by the local subdomain.
+ * make_periodicity_constraints will be called recursively even
+ * for the section of the face that is not touched by the local
+ * subdomain.
+ *
+ * Until there is a better way to determine if the cells that
+ * neighbor a face are artificial, we simply test to see if the
+ * face does not have a valid dof initialization.
+ */
+ return;
+ }
+ }
+
+ // Well, this is a hack:
+ //
+ // There is no
+ // face_to_face_index(face_index,
+ // face_orientation,
+ // face_flip,
+ // face_rotation)
+ // function in FiniteElementData, so we have to use
+ // face_to_cell_index(face_index, face
+ // face_orientation,
+ // face_flip,
+ // face_rotation)
+ // But this will give us an index on a cell - something we cannot work
+ // with directly. But luckily we can match them back :-]
+
+ std::map<unsigned int, unsigned int> cell_to_rotated_face_index;
+
+ // Build up a cell to face index for face_2:
+ for (unsigned int i = 0; i < dofs_per_face; ++i)
+ {
+ const unsigned int cell_index = fe.face_to_cell_index(i, 0, /* It doesn't really matter, just assume
+ * we're on the first face...
+ */
+ true, false, false // default orientation
+ );
+ cell_to_rotated_face_index[cell_index] = i;
+ }
+
+ // loop over all dofs on face 2 and constrain them again the ones on face 1
+ for (unsigned int i=0; i<dofs_per_face; ++i)
+ if (!constraint_matrix.is_constrained(dofs_2[i]))
+ if ((component_mask.n_selected_components(fe.n_components())
+ == fe.n_components())
+ ||
+ component_mask[fe.face_system_to_component_index(i).first])
+ {
+ // as mentioned in the comment above this function, we need
+ // to be careful about treating identity constraints differently.
+ // consequently, find out whether this dof 'i' will be
+ // identity constrained
+ //
+ // to check whether this is the case, first see whether there are
+ // any weights other than 0 and 1, then in a first stage make sure
+ // that if so there is only one weight equal to 1
+ bool is_identity_constrained = true;
+ for (unsigned int jj=0; jj<dofs_per_face; ++jj)
+ if (((transformation(i,jj) == 0) || (transformation(i,jj) == 1)) == false)
+ {
+ is_identity_constrained = false;
+ break;
+ }
+ unsigned int identity_constraint_target = numbers::invalid_unsigned_int;
+ if (is_identity_constrained == true)
+ {
+ bool one_identity_found = false;
+ for (unsigned int jj=0; jj<dofs_per_face; ++jj)
+ if (transformation(i,jj) == 1)
+ {
+ if (one_identity_found == false)
+ {
+ one_identity_found = true;
+ identity_constraint_target = jj;
+ }
+ else
+ {
+ is_identity_constrained = false;
+ identity_constraint_target = numbers::invalid_unsigned_int;
+ break;
+ }
+ }
+ }
+
+ // now treat constraints, either as an equality constraint or
+ // as a sequence of constraints
+ if (is_identity_constrained == true)
+ {
+ // Query the correct face_index on face_2 respecting the given
+ // orientation:
+ const unsigned int j =
+ cell_to_rotated_face_index[fe.face_to_cell_index(identity_constraint_target,
+ 0, /* It doesn't really matter, just assume
+ * we're on the first face...
+ */
+ face_orientation, face_flip, face_rotation)];
+
+ // if the two aren't already identity constrained (whichever way
+ // around, then enter the constraint. otherwise there is nothing
+ // for us still to do
+ if (constraint_matrix.are_identity_constrained(dofs_2[i], dofs_1[i]) == false)
+ {
+ constraint_matrix.add_line(dofs_2[i]);
+ constraint_matrix.add_entry(dofs_2[i], dofs_1[j], 1);
+ }
+ }
+ else
+ {
+ // this is just a regular constraint. enter it piece by piece
+ constraint_matrix.add_line(dofs_2[i]);
+ for (unsigned int jj=0; jj<dofs_per_face; ++jj)
+ {
+ // Query the correct face_index on face_2 respecting the given
+ // orientation:
+ const unsigned int j =
+ cell_to_rotated_face_index[fe.face_to_cell_index(jj, 0, /* It doesn't really matter, just assume
+ * we're on the first face...
+ */
+ face_orientation, face_flip, face_rotation)];
+
+ // And finally constrain the two DoFs respecting component_mask:
+ if (transformation(i,jj) != 0)
+ constraint_matrix.add_entry(dofs_2[i], dofs_1[j],
+ transformation(i,jj));
+ }
+ }
+ }
+ }
+ }
+ }
+
+
+ template <typename FaceIterator>
+ void
+ make_periodicity_constraints (const FaceIterator &face_1,
+ const typename identity<FaceIterator>::type &face_2,
+ dealii::ConstraintMatrix &constraint_matrix,
+ const ComponentMask &component_mask,
+ const bool face_orientation,
+ const bool face_flip,
+ const bool face_rotation)
+ {
+ static const int dim = FaceIterator::AccessorType::dimension;
+
+ Assert( (dim != 1) ||
+ (face_orientation == true &&
+ face_flip == false &&
+ face_rotation == false),
+ ExcMessage ("The supplied orientation "
+ "(face_orientation, face_flip, face_rotation) "
+ "is invalid for 1D"));
+
+ Assert( (dim != 2) ||
+ (face_orientation == true &&
+ face_rotation == false),
+ ExcMessage ("The supplied orientation "
+ "(face_orientation, face_flip, face_rotation) "
+ "is invalid for 2D"));
+
+ Assert(face_1 != face_2,
+ ExcMessage ("face_1 and face_2 are equal! Cannot constrain DoFs "
+ "on the very same face"));
+
+ Assert(face_1->at_boundary() && face_2->at_boundary(),
+ ExcMessage ("Faces for periodicity constraints must be on the boundary"));
+
+
+ // A lookup table on how to go through the child faces depending on the
+ // orientation:
+
+ static const int lookup_table_2d[2][2] =
+ {
+ // flip:
+ {0, 1}, // false
+ {1, 0}, // true
+ };
+
+ static const int lookup_table_3d[2][2][2][4] =
+ {
+ // orientation flip rotation
+ { { {0, 2, 1, 3}, // false false false
+ {2, 3, 0, 1}, // false false true
+ },
+ { {3, 1, 2, 0}, // false true false
+ {1, 0, 3, 2}, // false true true
+ },
+ },
+ { { {0, 1, 2, 3}, // true false false
+ {1, 3, 0, 2}, // true false true
+ },
+ { {3, 2, 1, 0}, // true true false
+ {2, 0, 3, 1}, // true true true
+ },
+ },
+ };
+
+ // In the case that both faces have children, we loop over all
+ // children and apply make_periodicty_constrains recursively:
+ if (face_1->has_children() && face_2->has_children())
+ {
+ Assert(face_1->n_children() == GeometryInfo<dim>::max_children_per_face &&
+ face_2->n_children() == GeometryInfo<dim>::max_children_per_face,
+ ExcNotImplemented());
+
+ for (unsigned int i = 0; i < GeometryInfo<dim>::max_children_per_face; ++i)
+ {
+ // Lookup the index for the second face
+ unsigned int j;
+ switch (dim)
+ {
+ case 2:
+ j = lookup_table_2d[face_flip][i];
+ break;
+ case 3:
+ j = lookup_table_3d[face_orientation][face_flip][face_rotation][i];
+ break;
+ default:
+ AssertThrow(false, ExcNotImplemented());
+ }
+
+ make_periodicity_constraints (face_1->child(i),
+ face_2->child(j),
+ constraint_matrix,
+ component_mask,
+ face_orientation,
+ face_flip,
+ face_rotation);
+ }
+ }
+ else
+ // otherwise at least one of the two faces is active and
+ // we need to enter the constraints
+ {
+ if (face_2->has_children() == false)
+ set_periodicity_constraints(face_2, face_1,
+ FullMatrix<double>(IdentityMatrix(face_1->get_fe(face_1->nth_active_fe_index(0)).dofs_per_face)),
+ constraint_matrix,
+ component_mask,
+ face_orientation, face_flip, face_rotation);
+ else
+ set_periodicity_constraints(face_1, face_2,
+ FullMatrix<double>(IdentityMatrix(face_1->get_fe(face_1->nth_active_fe_index(0)).dofs_per_face)),
+ constraint_matrix,
+ component_mask,
+ face_orientation, face_flip, face_rotation);
+ }
+ }
+
+
+
+ template<typename DH>
+ void
+ make_periodicity_constraints (const DH &dof_handler,
+ const types::boundary_id b_id1,
+ const types::boundary_id b_id2,
+ const int direction,
+ dealii::ConstraintMatrix &constraint_matrix,
+ const ComponentMask &component_mask)
+ {
+ Tensor<1,DH::space_dimension> dummy;
+ make_periodicity_constraints (dof_handler,
+ b_id1,
+ b_id2,
+ direction,
+ dummy,
+ constraint_matrix,
+ component_mask);
+ }
+
+
+
+ template<typename DH>
+ void
+ make_periodicity_constraints (const DH &dof_handler,
+ const types::boundary_id b_id1,
+ const types::boundary_id b_id2,
+ const int direction,
+ dealii::Tensor<1,DH::space_dimension> &offset,
+ dealii::ConstraintMatrix &constraint_matrix,
+ const ComponentMask &component_mask)
+ {
+ static const int space_dim = DH::space_dimension;
+ Assert (0<=direction && direction<space_dim,
+ ExcIndexRange (direction, 0, space_dim));
+
+ Assert (b_id1 != b_id2,
+ ExcMessage ("The boundary indicators b_id1 and b_id2 must be"
+ "different to denote different boundaries."));
+
+ typedef std::vector<GridTools::PeriodicFacePair
+ <typename DH::cell_iterator> > FaceVector;
+
+ // Collect matching periodic cells on the coarsest level:
+ FaceVector matched_faces =
+ GridTools::collect_periodic_faces(dof_handler, b_id1, b_id2,
+ direction, offset);
+
+ make_periodicity_constraints<DH>
+ (matched_faces, constraint_matrix, component_mask);
+ }
+
+
+
+ template<typename DH>
+ void
+ make_periodicity_constraints (const DH &dof_handler,
+ const types::boundary_id b_id,
+ const int direction,
+ dealii::ConstraintMatrix &constraint_matrix,
+ const ComponentMask &component_mask)
+ {
+ Tensor<1,DH::space_dimension> dummy;
+ make_periodicity_constraints (dof_handler,
+ b_id,
+ direction,
+ dummy,
+ constraint_matrix,
+ component_mask);
+ }
+
+
+
+ template<typename DH>
+ void
+ make_periodicity_constraints (const DH &dof_handler,
+ const types::boundary_id b_id,
+ const int direction,
+ dealii::Tensor<1,DH::space_dimension> &offset,
+ dealii::ConstraintMatrix &constraint_matrix,
+ const ComponentMask &component_mask)
+ {
+ static const int dim = DH::dimension;
+ static const int space_dim = DH::space_dimension;
+
+ Assert (0<=direction && direction<space_dim,
+ ExcIndexRange (direction, 0, space_dim));
+
+ Assert(dim == space_dim,
+ ExcNotImplemented());
+
+ typedef std::vector<GridTools::PeriodicFacePair
+ <typename DH::cell_iterator> > FaceVector;
+
+ // Collect matching periodic cells on the coarsest level:
+ const FaceVector matched_faces =
+ GridTools::collect_periodic_faces(dof_handler, b_id,
+ direction, offset);
+
+ make_periodicity_constraints<DH>
+ (matched_faces, constraint_matrix, component_mask);
+ }
+
+
+
+ template<typename DH>
+ void
+ make_periodicity_constraints
+ (const std::vector<GridTools::PeriodicFacePair<typename DH::cell_iterator> >
+ &periodic_faces,
+ dealii::ConstraintMatrix &constraint_matrix,
+ const ComponentMask &component_mask)
+ {
+ typedef std::vector<GridTools::PeriodicFacePair<typename DH::cell_iterator> >
+ FaceVector;
+ typename FaceVector::const_iterator it, end_periodic;
+ it = periodic_faces.begin();
+ end_periodic = periodic_faces.end();
+
+
+ // And apply the low level make_periodicity_constraints function to
+ // every matching pair:
+ for(; it!=end_periodic; ++it)
+ {
+ typedef typename DH::face_iterator FaceIterator;
+ const FaceIterator face_1 = it->cell[0]->face(it->face_idx[0]);
+ const FaceIterator face_2 = it->cell[1]->face(it->face_idx[1]);
+
+ Assert(face_1->at_boundary() && face_2->at_boundary(),
+ ExcInternalError());
+
+ Assert (face_1 != face_2,
+ ExcInternalError());
+
+ make_periodicity_constraints(face_1,
+ face_2,
+ constraint_matrix,
+ component_mask,
+ it->orientation[0],
+ it->orientation[1],
+ it->orientation[2]);
+ }
+ }
+
+
+
+ namespace internal
+ {
+ namespace
+ {
+ /**
+ * This is a function that is called by the _2 function and that
+ * operates on a range of cells only. It is used to split up the
+ * whole range of cells into chunks which are then worked on in
+ * parallel, if multithreading is available.
+ */
+ template <int dim, int spacedim>
+ void
+ compute_intergrid_weights_3 (
+ const dealii::DoFHandler<dim,spacedim> &coarse_grid,
+ const unsigned int coarse_component,
+ const InterGridMap<dealii::DoFHandler<dim,spacedim> > &coarse_to_fine_grid_map,
+ const std::vector<dealii::Vector<double> > ¶meter_dofs,
+ const std::vector<types::global_dof_index> &weight_mapping,
+ std::vector<std::map<types::global_dof_index, float> > &weights,
+ const typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator &begin,
+ const typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator &end)
+ {
+ // aliases to the finite elements used by the dof handlers:
+ const FiniteElement<dim,spacedim> &coarse_fe = coarse_grid.get_fe();
+
+ // for each cell on the parameter grid: find out which degrees of
+ // freedom on the fine grid correspond in which way to the degrees
+ // of freedom on the parameter grid
+ //
+ // since for continuous FEs some dofs exist on more than one cell,
+ // we have to track which ones were already visited. the problem is
+ // that if we visit a dof first on one cell and compute its weight
+ // with respect to some global dofs to be non-zero, and later visit
+ // the dof again on another cell and (since we are on another cell)
+ // recompute the weights with respect to the same dofs as above to
+ // be zero now, we have to preserve them. we therefore overwrite
+ // all weights if they are nonzero and do not enforce zero weights
+ // since that might be only due to the fact that we are on another
+ // cell.
+ //
+ // example:
+ // coarse grid
+ // | | |
+ // *-----*-----*
+ // | cell|cell |
+ // | 1 | 2 |
+ // | | |
+ // 0-----1-----*
+ //
+ // fine grid
+ // | | | | |
+ // *--*--*--*--*
+ // | | | | |
+ // *--*--*--*--*
+ // | | | | |
+ // *--x--y--*--*
+ //
+ // when on cell 1, we compute the weights of dof 'x' to be 1/2 from
+ // parameter dofs 0 and 1, respectively. however, when later we are
+ // on cell 2, we again compute the prolongation of shape function 1
+ // restricted to cell 2 to the globla grid and find that the weight
+ // of global dof 'x' now is zero. however, we should not overwrite
+ // the old value.
+ //
+ // we therefore always only set nonzero values. why adding up is
+ // not useful: dof 'y' would get weight 1 from parameter dof 1 on
+ // both cells 1 and 2, but the correct weight is nevertheless only
+ // 1.
+
+ // vector to hold the representation of a single degree of freedom
+ // on the coarse grid (for the selected fe) on the fine grid
+ const types::global_dof_index n_fine_dofs = weight_mapping.size();
+ dealii::Vector<double> global_parameter_representation (n_fine_dofs);
+
+ typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator cell;
+ std::vector<types::global_dof_index> parameter_dof_indices (coarse_fe.dofs_per_cell);
+
+ for (cell=begin; cell!=end; ++cell)
+ {
+ // get the global indices of the parameter dofs on this
+ // parameter grid cell
+ cell->get_dof_indices (parameter_dof_indices);
+
+ // loop over all dofs on this cell and check whether they are
+ // interesting for us
+ for (unsigned int local_dof=0;
+ local_dof<coarse_fe.dofs_per_cell;
+ ++local_dof)
+ if (coarse_fe.system_to_component_index(local_dof).first
+ ==
+ coarse_component)
+ {
+ // the how-many-th parameter is this on this cell?
+ const unsigned int local_parameter_dof
+ = coarse_fe.system_to_component_index(local_dof).second;
+
+ global_parameter_representation = 0;
+
+ // distribute the representation of
+ // @p{local_parameter_dof} on the parameter grid cell
+ // @p{cell} to the global data space
+ coarse_to_fine_grid_map[cell]->
+ set_dof_values_by_interpolation (parameter_dofs[local_parameter_dof],
+ global_parameter_representation);
+ // now that we've got the global representation of each
+ // parameter dof, we've only got to clobber the non-zero
+ // entries in that vector and store the result
+ //
+ // what we have learned: if entry @p{i} of the global
+ // vector holds the value @p{v[i]}, then this is the
+ // weight with which the present dof contributes to
+ // @p{i}. there may be several such @p{i}s and their
+ // weights' sum should be one. Then, @p{v[i]} should be
+ // equal to @p{\sum_j w_{ij} p[j]} with @p{p[j]} be the
+ // values of the degrees of freedom on the coarse grid.
+ // we can thus compute constraints which link the degrees
+ // of freedom @p{v[i]} on the fine grid to those on the
+ // coarse grid, @p{p[j]}. Now to use these as real
+ // constraints, rather than as additional equations, we
+ // have to identify representants among the @p{i} for
+ // each @p{j}. this will be done by simply taking the
+ // first @p{i} for which @p{w_{ij}==1}.
+ //
+ // guard modification of the weights array by a Mutex.
+ // since it should happen rather rarely that there are
+ // several threads operating on different intergrid
+ // weights, have only one mutex for all of them
+ static Threads::Mutex mutex;
+ Threads::Mutex::ScopedLock lock (mutex);
+ for (types::global_dof_index i=0; i<global_parameter_representation.size(); ++i)
+ // set this weight if it belongs to a parameter dof.
+ if (weight_mapping[i] != numbers::invalid_dof_index)
+ {
+ // only overwrite old value if not by zero
+ if (global_parameter_representation(i) != 0)
+ {
+ const types::global_dof_index wi = parameter_dof_indices[local_dof],
+ wj = weight_mapping[i];
+ weights[wi][wj] = global_parameter_representation(i);
+ };
+ }
+ else
+ Assert (global_parameter_representation(i) == 0,
+ ExcInternalError());
+ }
+ }
+ }
+
+
+ /**
+ * This is a helper function that is used in the computation of
+ * integrid constraints. See the function for a thorough description
+ * of how it works.
+ */
+ template <int dim, int spacedim>
+ void
+ compute_intergrid_weights_2 (
+ const dealii::DoFHandler<dim,spacedim> &coarse_grid,
+ const unsigned int coarse_component,
+ const InterGridMap<dealii::DoFHandler<dim,spacedim> > &coarse_to_fine_grid_map,
+ const std::vector<dealii::Vector<double> > ¶meter_dofs,
+ const std::vector<types::global_dof_index> &weight_mapping,
+ std::vector<std::map<types::global_dof_index,float> > &weights)
+ {
+ // simply distribute the range of cells to different threads
+ typedef typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator active_cell_iterator;
+ std::vector<std::pair<active_cell_iterator,active_cell_iterator> >
+ cell_intervals = Threads::split_range<active_cell_iterator> (coarse_grid.begin_active(),
+ coarse_grid.end(),
+ multithread_info.n_default_threads);
+
+ // TODO: use WorkStream here
+
+ Threads::TaskGroup<> tasks;
+ void (*fun_ptr) (const dealii::DoFHandler<dim,spacedim> &,
+ const unsigned int ,
+ const InterGridMap<dealii::DoFHandler<dim,spacedim> > &,
+ const std::vector<dealii::Vector<double> > &,
+ const std::vector<types::global_dof_index> &,
+ std::vector<std::map<types::global_dof_index, float> > &,
+ const typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator &,
+ const typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator &)
+ = &compute_intergrid_weights_3<dim>;
+ for (unsigned int i=0; i<multithread_info.n_default_threads; ++i)
+ tasks += Threads::new_task (fun_ptr,
+ coarse_grid, coarse_component,
+ coarse_to_fine_grid_map, parameter_dofs,
+ weight_mapping, weights,
+ cell_intervals[i].first,
+ cell_intervals[i].second);
+
+ // wait for the tasks to finish
+ tasks.join_all ();
+ }
+
+
+
+ /**
+ * This is a helper function that is used in the computation of
+ * integrid constraints. See the function for a thorough description
+ * of how it works.
+ */
+ template <int dim, int spacedim>
+ unsigned int
+ compute_intergrid_weights_1 (
+ const dealii::DoFHandler<dim,spacedim> &coarse_grid,
+ const unsigned int coarse_component,
+ const dealii::DoFHandler<dim,spacedim> &fine_grid,
+ const unsigned int fine_component,
+ const InterGridMap<dealii::DoFHandler<dim,spacedim> > &coarse_to_fine_grid_map,
+ std::vector<std::map<types::global_dof_index, float> > &weights,
+ std::vector<types::global_dof_index> &weight_mapping)
+ {
+ // aliases to the finite elements used by the dof handlers:
+ const FiniteElement<dim,spacedim> &coarse_fe = coarse_grid.get_fe(),
+ &fine_fe = fine_grid.get_fe();
+
+ // global numbers of dofs
+ const types::global_dof_index n_coarse_dofs = coarse_grid.n_dofs(),
+ n_fine_dofs = fine_grid.n_dofs();
+
+ // local numbers of dofs
+ const unsigned int fine_dofs_per_cell = fine_fe.dofs_per_cell;
+
+ // alias the number of dofs per cell belonging to the
+ // coarse_component which is to be the restriction of the fine
+ // grid:
+ const unsigned int coarse_dofs_per_cell_component
+ = coarse_fe.base_element(coarse_fe.component_to_base_index(coarse_component).first).dofs_per_cell;
+
+
+ // Try to find out whether the grids stem from the same coarse
+ // grid. This is a rather crude test, but better than nothing
+ Assert (coarse_grid.get_tria().n_cells(0) == fine_grid.get_tria().n_cells(0),
+ ExcGridsDontMatch());
+
+ // check whether the map correlates the right objects
+ Assert (&coarse_to_fine_grid_map.get_source_grid() == &coarse_grid,
+ ExcGridsDontMatch ());
+ Assert (&coarse_to_fine_grid_map.get_destination_grid() == &fine_grid,
+ ExcGridsDontMatch ());
+
+
+ // check whether component numbers are valid
+ AssertIndexRange (coarse_component,coarse_fe.n_components());
+ AssertIndexRange (fine_component, fine_fe.n_components());
+
+ // check whether respective finite elements are equal
+ Assert (coarse_fe.base_element (coarse_fe.component_to_base_index(coarse_component).first)
+ ==
+ fine_fe.base_element (fine_fe.component_to_base_index(fine_component).first),
+ ExcFiniteElementsDontMatch());
+
+#ifdef DEBUG
+ // if in debug mode, check whether the coarse grid is indeed
+ // coarser everywhere than the fine grid
+ for (typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator
+ cell=coarse_grid.begin_active();
+ cell != coarse_grid.end(); ++cell)
+ Assert (cell->level() <= coarse_to_fine_grid_map[cell]->level(),
+ ExcGridNotCoarser());
+#endif
+
+ /*
+ * From here on: the term `parameter' refers to the selected
+ * component on the coarse grid and its analogon on the fine grid.
+ * The naming of variables containing this term is due to the fact
+ * that `selected_component' is longer, but also due to the fact
+ * that the code of this function was initially written for a
+ * program where the component which we wanted to match between
+ * grids was actually the `parameter' variable.
+ *
+ * Likewise, the terms `parameter grid' and `state grid' refer to
+ * the coarse and fine grids, respectively.
+ *
+ * Changing the names of variables would in principle be a good
+ * idea, but would not make things simpler and would be another
+ * source of errors. If anyone feels like doing so: patches would
+ * be welcome!
+ */
+
+
+
+ // set up vectors of cell-local data; each vector represents one
+ // degree of freedom of the coarse-grid variable in the fine-grid
+ // element
+ std::vector<dealii::Vector<double> >
+ parameter_dofs (coarse_dofs_per_cell_component,
+ dealii::Vector<double>(fine_dofs_per_cell));
+ // for each coarse dof: find its position within the fine element
+ // and set this value to one in the respective vector (all other
+ // values are zero by construction)
+ for (unsigned int local_coarse_dof=0;
+ local_coarse_dof<coarse_dofs_per_cell_component;
+ ++local_coarse_dof)
+ for (unsigned int fine_dof=0; fine_dof<fine_fe.dofs_per_cell; ++fine_dof)
+ if (fine_fe.system_to_component_index(fine_dof)
+ ==
+ std::make_pair (fine_component, local_coarse_dof))
+ {
+ parameter_dofs[local_coarse_dof](fine_dof) = 1.;
+ break;
+ };
+
+
+ // find out how many DoFs there are on the grids belonging to the
+ // components we want to match
+ unsigned int n_parameters_on_fine_grid=0;
+ if (true)
+ {
+ // have a flag for each dof on the fine grid and set it to true
+ // if this is an interesting dof. finally count how many true's
+ // there
+ std::vector<bool> dof_is_interesting (fine_grid.n_dofs(), false);
+ std::vector<types::global_dof_index> local_dof_indices (fine_fe.dofs_per_cell);
+
+ for (typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator
+ cell=fine_grid.begin_active();
+ cell!=fine_grid.end(); ++cell)
+ {
+ cell->get_dof_indices (local_dof_indices);
+ for (unsigned int i=0; i<fine_fe.dofs_per_cell; ++i)
+ if (fine_fe.system_to_component_index(i).first == fine_component)
+ dof_is_interesting[local_dof_indices[i]] = true;
+ };
+
+ n_parameters_on_fine_grid = std::count (dof_is_interesting.begin(),
+ dof_is_interesting.end(),
+ true);
+ };
+
+
+ // set up the weights mapping
+ weights.clear ();
+ weights.resize (n_coarse_dofs);
+
+ weight_mapping.clear ();
+ weight_mapping.resize (n_fine_dofs, numbers::invalid_dof_index);
+
+ if (true)
+ {
+ std::vector<types::global_dof_index> local_dof_indices(fine_fe.dofs_per_cell);
+ unsigned int next_free_index=0;
+ for (typename dealii::DoFHandler<dim,spacedim>::active_cell_iterator
+ cell=fine_grid.begin_active();
+ cell != fine_grid.end(); ++cell)
+ {
+ cell->get_dof_indices (local_dof_indices);
+ for (unsigned int i=0; i<fine_fe.dofs_per_cell; ++i)
+ // if this DoF is a parameter dof and has not yet been
+ // numbered, then do so
+ if ((fine_fe.system_to_component_index(i).first == fine_component) &&
+ (weight_mapping[local_dof_indices[i]] == numbers::invalid_dof_index))
+ {
+ weight_mapping[local_dof_indices[i]] = next_free_index;
+ ++next_free_index;
+ };
+ };
+
+ Assert (next_free_index == n_parameters_on_fine_grid,
+ ExcInternalError());
+ };
+
+
+ // for each cell on the parameter grid: find out which degrees of
+ // freedom on the fine grid correspond in which way to the degrees
+ // of freedom on the parameter grid
+ //
+ // do this in a separate function to allow for multithreading
+ // there. see this function also if you want to read more
+ // information on the algorithm used.
+ compute_intergrid_weights_2 (coarse_grid, coarse_component,
+ coarse_to_fine_grid_map, parameter_dofs,
+ weight_mapping, weights);
+
+
+ // ok, now we have all weights for each dof on the fine grid. if in
+ // debug mode lets see if everything went smooth, i.e. each dof has
+ // sum of weights one
+ //
+ // in other words this means that if the sum of all shape functions
+ // on the parameter grid is one (which is always the case), then
+ // the representation on the state grid should be as well (division
+ // of unity)
+ //
+ // if the parameter grid has more than one component, then the
+ // respective dofs of the other components have sum of weights
+ // zero, of course. we do not explicitly ask which component a dof
+ // belongs to, but this at least tests some errors
+#ifdef DEBUG
+ for (unsigned int col=0; col<n_parameters_on_fine_grid; ++col)
+ {
+ double sum=0;
+ for (types::global_dof_index row=0; row<n_coarse_dofs; ++row)
+ if (weights[row].find(col) != weights[row].end())
+ sum += weights[row][col];
+ Assert ((std::fabs(sum-1) < 1.e-12) ||
+ ((coarse_fe.n_components()>1) && (sum==0)), ExcInternalError());
+ };
+#endif
+
+
+ return n_parameters_on_fine_grid;
+ }
+
+
+ }
+ }
+
+
+
+ template <int dim, int spacedim>
+ void
+ compute_intergrid_constraints (
+ const DoFHandler<dim,spacedim> &coarse_grid,
+ const unsigned int coarse_component,
+ const DoFHandler<dim,spacedim> &fine_grid,
+ const unsigned int fine_component,
+ const InterGridMap<DoFHandler<dim,spacedim> > &coarse_to_fine_grid_map,
+ ConstraintMatrix &constraints)
+ {
+ // store the weights with which a dof on the parameter grid contributes
+ // to a dof on the fine grid. see the long doc below for more info
+ //
+ // allocate as many rows as there are parameter dofs on the coarse grid
+ // and as many columns as there are parameter dofs on the fine grid.
+ //
+ // weight_mapping is used to map the global (fine grid) parameter dof
+ // indices to the columns
+ //
+ // in the original implementation, the weights array was actually of
+ // FullMatrix<double> type. this wasted huge amounts of memory, but was
+ // fast. nonetheless, since the memory consumption was quadratic in the
+ // number of degrees of freedom, this was not very practical, so we now
+ // use a vector of rows of the matrix, and in each row a vector of
+ // pairs (colnum,value). this seems like the best tradeoff between
+ // memory and speed, as it is now linear in memory and still fast
+ // enough.
+ //
+ // to save some memory and since the weights are usually (negative)
+ // powers of 2, we choose the value type of the matrix to be @p{float}
+ // rather than @p{double}.
+ std::vector<std::map<types::global_dof_index, float> > weights;
+
+ // this is this mapping. there is one entry for each dof on the fine
+ // grid; if it is a parameter dof, then its value is the column in
+ // weights for that parameter dof, if it is any other dof, then its
+ // value is -1, indicating an error
+ std::vector<types::global_dof_index> weight_mapping;
+
+ const unsigned int n_parameters_on_fine_grid
+ = internal::compute_intergrid_weights_1 (coarse_grid, coarse_component,
+ fine_grid, fine_component,
+ coarse_to_fine_grid_map,
+ weights, weight_mapping);
+
+ // global numbers of dofs
+ const types::global_dof_index n_coarse_dofs = coarse_grid.n_dofs(),
+ n_fine_dofs = fine_grid.n_dofs();
+
+
+ // get an array in which we store which dof on the coarse grid is a
+ // parameter and which is not
+ std::vector<bool> coarse_dof_is_parameter (coarse_grid.n_dofs());
+ if (true)
+ {
+ std::vector<bool> mask (coarse_grid.get_fe().n_components(),
+ false);
+ mask[coarse_component] = true;
+ extract_dofs (coarse_grid, ComponentMask(mask), coarse_dof_is_parameter);
+ }
+
+ // now we know that the weights in each row constitute a constraint.
+ // enter this into the constraints object
+ //
+ // first task: for each parameter dof on the parameter grid, find a
+ // representant on the fine, global grid. this is possible since we use
+ // conforming finite element. we take this representant to be the first
+ // element in this row with weight identical to one. the representant
+ // will become an unconstrained degree of freedom, while all others
+ // will be constrained to this dof (and possibly others)
+ std::vector<types::global_dof_index> representants(n_coarse_dofs, numbers::invalid_dof_index);
+ for (types::global_dof_index parameter_dof=0; parameter_dof<n_coarse_dofs;
+ ++parameter_dof)
+ if (coarse_dof_is_parameter[parameter_dof] == true)
+ {
+ // if this is the line of a parameter dof on the coarse grid,
+ // then it should have at least one dependent node on the fine
+ // grid
+ Assert (weights[parameter_dof].size() > 0, ExcInternalError());
+
+ // find the column where the representant is mentioned
+ std::map<types::global_dof_index,float>::const_iterator i = weights[parameter_dof].begin();
+ for (; i!=weights[parameter_dof].end(); ++i)
+ if (i->second == 1)
+ break;
+ Assert (i!=weights[parameter_dof].end(), ExcInternalError());
+ const types::global_dof_index column = i->first;
+
+ // now we know in which column of weights the representant is,
+ // but we don't know its global index. get it using the inverse
+ // operation of the weight_mapping
+ types::global_dof_index global_dof=0;
+ for (; global_dof<weight_mapping.size(); ++global_dof)
+ if (weight_mapping[global_dof] == static_cast<types::global_dof_index>(column))
+ break;
+ Assert (global_dof < weight_mapping.size(), ExcInternalError());
+
+ // now enter the representants global index into our list
+ representants[parameter_dof] = global_dof;
+ }
+ else
+ {
+ // consistency check: if this is no parameter dof on the coarse
+ // grid, then the respective row must be empty!
+ Assert (weights[parameter_dof].size() == 0, ExcInternalError());
+ };
+
+
+
+ // note for people that want to optimize this function: the largest
+ // part of the computing time is spent in the following, rather
+ // innocent block of code. basically, it must be the
+ // ConstraintMatrix::add_entry call which takes the bulk of the time,
+ // but it is not known to the author how to make it faster...
+ std::vector<std::pair<types::global_dof_index,double> > constraint_line;
+ for (types::global_dof_index global_dof=0; global_dof<n_fine_dofs; ++global_dof)
+ if (weight_mapping[global_dof] != numbers::invalid_dof_index)
+ // this global dof is a parameter dof, so it may carry a constraint
+ // note that for each global dof, the sum of weights shall be one,
+ // so we can find out whether this dof is constrained in the
+ // following way: if the only weight in this row is a one, and the
+ // representant for the parameter dof of the line in which this one
+ // is is the present dof, then we consider this dof to be
+ // unconstrained. otherwise, all other dofs are constrained
+ {
+ const types::global_dof_index col = weight_mapping[global_dof];
+ Assert (col < n_parameters_on_fine_grid, ExcInternalError());
+
+ types::global_dof_index first_used_row=0;
+
+ {
+ Assert (weights.size() > 0, ExcInternalError());
+ std::map<types::global_dof_index,float>::const_iterator
+ col_entry = weights[0].end();
+ for (; first_used_row<n_coarse_dofs; ++first_used_row)
+ {
+ col_entry = weights[first_used_row].find(col);
+ if (col_entry != weights[first_used_row].end())
+ break;
+ }
+
+ Assert (col_entry != weights[first_used_row].end(), ExcInternalError());
+
+ if ((col_entry->second == 1) &&
+ (representants[first_used_row] == global_dof))
+ // dof unconstrained or constrained to itself (in case this
+ // cell is mapped to itself, rather than to children of
+ // itself)
+ continue;
+ }
+
+
+ // otherwise enter all constraints
+ constraints.add_line (global_dof);
+
+ constraint_line.clear ();
+ for (types::global_dof_index row=first_used_row; row<n_coarse_dofs; ++row)
+ {
+ const std::map<types::global_dof_index,float>::const_iterator
+ j = weights[row].find(col);
+ if ((j != weights[row].end()) && (j->second != 0))
+ constraint_line.push_back (std::pair<types::global_dof_index,double>(representants[row],
+ j->second));
+ };
+
+ constraints.add_entries (global_dof, constraint_line);
+ };
+ }
+
+
+
+ template <int dim, int spacedim>
+ void
+ compute_intergrid_transfer_representation (
+ const DoFHandler<dim,spacedim> &coarse_grid,
+ const unsigned int coarse_component,
+ const DoFHandler<dim,spacedim> &fine_grid,
+ const unsigned int fine_component,
+ const InterGridMap<DoFHandler<dim,spacedim> > &coarse_to_fine_grid_map,
+ std::vector<std::map<types::global_dof_index, float> > &transfer_representation)
+ {
+ // store the weights with which a dof on the parameter grid contributes
+ // to a dof on the fine grid. see the long doc below for more info
+ //
+ // allocate as many rows as there are parameter dofs on the coarse grid
+ // and as many columns as there are parameter dofs on the fine grid.
+ //
+ // weight_mapping is used to map the global (fine grid) parameter dof
+ // indices to the columns
+ //
+ // in the original implementation, the weights array was actually of
+ // FullMatrix<double> type. this wasted huge amounts of memory, but was
+ // fast. nonetheless, since the memory consumption was quadratic in the
+ // number of degrees of freedom, this was not very practical, so we now
+ // use a vector of rows of the matrix, and in each row a vector of
+ // pairs (colnum,value). this seems like the best tradeoff between
+ // memory and speed, as it is now linear in memory and still fast
+ // enough.
+ //
+ // to save some memory and since the weights are usually (negative)
+ // powers of 2, we choose the value type of the matrix to be @p{float}
+ // rather than @p{double}.
+ std::vector<std::map<types::global_dof_index, float> > weights;
+
+ // this is this mapping. there is one entry for each dof on the fine
+ // grid; if it is a parameter dof, then its value is the column in
+ // weights for that parameter dof, if it is any other dof, then its
+ // value is -1, indicating an error
+ std::vector<types::global_dof_index> weight_mapping;
+
+ internal::compute_intergrid_weights_1 (coarse_grid, coarse_component,
+ fine_grid, fine_component,
+ coarse_to_fine_grid_map,
+ weights, weight_mapping);
+
+ // now compute the requested representation
+ const types::global_dof_index n_global_parm_dofs
+ = std::count_if (weight_mapping.begin(), weight_mapping.end(),
+ std::bind2nd (std::not_equal_to<types::global_dof_index> (), numbers::invalid_dof_index));
+
+ // first construct the inverse mapping of weight_mapping
+ std::vector<types::global_dof_index> inverse_weight_mapping (n_global_parm_dofs,
+ DoFHandler<dim,spacedim>::invalid_dof_index);
+ for (types::global_dof_index i=0; i<weight_mapping.size(); ++i)
+ {
+ const types::global_dof_index parameter_dof = weight_mapping[i];
+ // if this global dof is a parameter
+ if (parameter_dof != numbers::invalid_dof_index)
+ {
+ Assert (parameter_dof < n_global_parm_dofs, ExcInternalError());
+ Assert ((inverse_weight_mapping[parameter_dof] == DoFHandler<dim,spacedim>::invalid_dof_index),
+ ExcInternalError());
+
+ inverse_weight_mapping[parameter_dof] = i;
+ };
+ };
+
+ // next copy over weights array and replace respective numbers
+ const types::global_dof_index n_rows = weight_mapping.size();
+
+ transfer_representation.clear ();
+ transfer_representation.resize (n_rows);
+
+ const types::global_dof_index n_coarse_dofs = coarse_grid.n_dofs();
+ for (types::global_dof_index i=0; i<n_coarse_dofs; ++i)
+ {
+ std::map<types::global_dof_index, float>::const_iterator j = weights[i].begin();
+ for (; j!=weights[i].end(); ++j)
+ {
+ const types::global_dof_index p = inverse_weight_mapping[j->first];
+ Assert (p<n_rows, ExcInternalError());
+
+ transfer_representation[p][i] = j->second;
+ };
+ };
+ }
+
+
+
+ template <int dim, int spacedim, template <int,int> class DH>
+ void
+ make_zero_boundary_constraints (const DH<dim, spacedim> &dof,
+ const types::boundary_id boundary_indicator,
+ ConstraintMatrix &zero_boundary_constraints,
+ const ComponentMask &component_mask)
+ {
+ Assert (component_mask.represents_n_components(dof.get_fe().n_components()),
+ ExcMessage ("The number of components in the mask has to be either "
+ "zero or equal to the number of components in the finite "
+ "element."));
+
+ const unsigned int n_components = DoFTools::n_components (dof);
+
+ Assert (component_mask.n_selected_components(n_components) > 0,
+ ComponentMask::ExcNoComponentSelected());
+
+ // a field to store the indices
+ std::vector<types::global_dof_index> face_dofs;
+ face_dofs.reserve (max_dofs_per_face(dof));
+
+ typename DH<dim,spacedim>::active_cell_iterator
+ cell = dof.begin_active(),
+ endc = dof.end();
+ for (; cell!=endc; ++cell)
+ if (!cell->is_artificial())
+ for (unsigned int face_no = 0; face_no < GeometryInfo<dim>::faces_per_cell;
+ ++face_no)
+ {
+ const FiniteElement<dim,spacedim> &fe = cell->get_fe();
+
+ const typename DH<dim,spacedim>::face_iterator face = cell->face(face_no);
+
+ // if face is on the boundary and satisfies the correct
+ // boundary id property
+ if (face->at_boundary ()
+ &&
+ ((boundary_indicator == numbers::invalid_boundary_id)
+ ||
+ (face->boundary_indicator() == boundary_indicator)))
+ {
+ // get indices and physical location on this face
+ face_dofs.resize (fe.dofs_per_face);
+ face->get_dof_indices (face_dofs, cell->active_fe_index());
+
+ // enter those dofs into the list that match the component
+ // signature.
+ for (unsigned int i=0; i<face_dofs.size(); ++i)
+ {
+ // Find out if a dof has a contribution in this
+ // component, and if so, add it to the list
+ const ComponentMask &nonzero_component_array
+ = cell->get_fe().get_nonzero_components (i);
+ bool nonzero = false;
+ for (unsigned int c=0; c<n_components; ++c)
+ if (nonzero_component_array[c] && component_mask[c])
+ {
+ nonzero = true;
+ break;
+ }
+
+ if (nonzero)
+ zero_boundary_constraints.add_line (face_dofs[i]);
+ }
+ }
+ }
+ }
+
+
+
+ template <int dim, int spacedim, template <int,int> class DH>
+ void
+ make_zero_boundary_constraints (const DH<dim, spacedim> &dof,
+ ConstraintMatrix &zero_boundary_constraints,
+ const ComponentMask &component_mask)
+ {
+ make_zero_boundary_constraints(dof, numbers::invalid_boundary_id,
+ zero_boundary_constraints, component_mask);
+ }
+
+
+} // end of namespace DoFTools
+
+
+
+// explicit instantiations
+
+#include "dof_tools_constraints.inst"
+
+
+
+DEAL_II_NAMESPACE_CLOSE
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 2009 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+
+
+for (DH : DOFHANDLERS; deal_II_dimension : DIMENSIONS)
+{
+ template
+ void
+ DoFTools::make_hanging_node_constraints (const DH &dof_handler,
+ ConstraintMatrix &constraints);
+
+#if deal_II_dimension != 1
+ template
+ void
+ DoFTools::make_periodicity_constraints (const DH::face_iterator &,
+ const DH::face_iterator &,
+ dealii::ConstraintMatrix &,
+ const ComponentMask &,
+ bool, bool, bool);
+
+ template
+ void
+ DoFTools::make_periodicity_constraints(const DH &,
+ const types::boundary_id,
+ const types::boundary_id,
+ const int,
+ dealii::ConstraintMatrix &,
+ const ComponentMask &);
+
+ template
+ void
+ DoFTools::make_periodicity_constraints(const DH &,
+ const types::boundary_id,
+ const types::boundary_id,
+ const int,
+ dealii::Tensor<1,DH::space_dimension> &,
+ dealii::ConstraintMatrix &,
+ const ComponentMask &);
+
+ template
+ void
+ DoFTools::make_periodicity_constraints(const DH &,
+ const types::boundary_id,
+ const int,
+ dealii::ConstraintMatrix &,
+ const ComponentMask &);
+
+ template
+ void
+ DoFTools::make_periodicity_constraints(const DH &,
+ const types::boundary_id,
+ const int,
+ dealii::Tensor<1,DH::space_dimension> &,
+ dealii::ConstraintMatrix &,
+ const ComponentMask &);
+
+ template
+ void
+ DoFTools::make_periodicity_constraints<DH>
+ (const std::vector<GridTools::PeriodicFacePair<DH::cell_iterator> > &,
+ dealii::ConstraintMatrix &,
+ const ComponentMask &);
+
+#endif
+}
+
+for (deal_II_dimension : DIMENSIONS)
+{
+#if deal_II_dimension != 1
+ template
+ void
+ DoFTools::make_hanging_node_constraints (const MGDoFHandler<deal_II_dimension> &dof_handler,
+ ConstraintMatrix &constraints);
+
+#endif
+
+#if deal_II_dimension < 3
+
+template
+void
+DoFTools::
+make_hanging_node_constraints (const DoFHandler<deal_II_dimension,deal_II_dimension+1> &dof_handler,
+ ConstraintMatrix &constraints);
+#endif
+
+#if deal_II_dimension == 3
+template
+void
+DoFTools::
+make_hanging_node_constraints (const DoFHandler<1,3> &dof_handler,
+ ConstraintMatrix &constraints);
+#endif
+
+template
+void
+DoFTools::make_zero_boundary_constraints
+(const DoFHandler<deal_II_dimension> &,
+ ConstraintMatrix &,
+ const ComponentMask &);
+
+template
+void
+DoFTools::make_zero_boundary_constraints
+(const DoFHandler<deal_II_dimension> &,
+ const types::boundary_id ,
+ ConstraintMatrix &,
+ const ComponentMask &);
+
+template
+void
+DoFTools::make_zero_boundary_constraints
+(const hp::DoFHandler<deal_II_dimension> &,
+ ConstraintMatrix &,
+ const ComponentMask &);
+
+template
+void
+DoFTools::make_zero_boundary_constraints
+(const hp::DoFHandler<deal_II_dimension> &,
+ const types::boundary_id ,
+ ConstraintMatrix &,
+ const ComponentMask &);
+
+template
+void
+DoFTools::compute_intergrid_constraints<deal_II_dimension> (
+ const DoFHandler<deal_II_dimension> &, const unsigned int,
+ const DoFHandler<deal_II_dimension> &, const unsigned int,
+ const InterGridMap<DoFHandler<deal_II_dimension> > &,
+ ConstraintMatrix&);
+
+template
+void
+DoFTools::compute_intergrid_transfer_representation<deal_II_dimension>
+(const DoFHandler<deal_II_dimension> &, const unsigned int,
+ const DoFHandler<deal_II_dimension> &, const unsigned int,
+ const InterGridMap<DoFHandler<deal_II_dimension> > &,
+ std::vector<std::map<types::global_dof_index, float> > &);
+
+}
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1999 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+#include <deal.II/base/multithread_info.h>
+#include <deal.II/base/thread_management.h>
+#include <deal.II/base/quadrature_lib.h>
+#include <deal.II/base/table.h>
+#include <deal.II/base/template_constraints.h>
+#include <deal.II/base/utilities.h>
+#include <deal.II/lac/sparsity_pattern.h>
+#include <deal.II/lac/compressed_sparsity_pattern.h>
+#include <deal.II/lac/compressed_set_sparsity_pattern.h>
+#include <deal.II/lac/compressed_simple_sparsity_pattern.h>
+#include <deal.II/lac/trilinos_sparsity_pattern.h>
+#include <deal.II/lac/block_sparsity_pattern.h>
+#include <deal.II/lac/vector.h>
+#include <deal.II/lac/constraint_matrix.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/intergrid_map.h>
+#include <deal.II/grid/grid_tools.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/dofs/dof_accessor.h>
+#include <deal.II/fe/fe.h>
+#include <deal.II/fe/fe_values.h>
+#include <deal.II/fe/fe_tools.h>
+#include <deal.II/hp/fe_collection.h>
+#include <deal.II/hp/q_collection.h>
+#include <deal.II/hp/fe_values.h>
+#include <deal.II/dofs/dof_tools.h>
+#include <deal.II/numerics/vector_tools.h>
+
+#include <deal.II/multigrid/mg_dof_handler.h>
+
+#include <algorithm>
+#include <numeric>
+
+DEAL_II_NAMESPACE_OPEN
+
+
+
+namespace DoFTools
+{
+
+ template <class DH, class SparsityPattern>
+ void
+ make_sparsity_pattern (const DH &dof,
+ SparsityPattern &sparsity,
+ const ConstraintMatrix &constraints,
+ const bool keep_constrained_dofs,
+ const types::subdomain_id subdomain_id)
+ {
+ const types::global_dof_index n_dofs = dof.n_dofs();
+
+ Assert (sparsity.n_rows() == n_dofs,
+ ExcDimensionMismatch (sparsity.n_rows(), n_dofs));
+ Assert (sparsity.n_cols() == n_dofs,
+ ExcDimensionMismatch (sparsity.n_cols(), n_dofs));
+
+ // If we have a distributed::Triangulation only allow locally_owned
+ // subdomain. Not setting a subdomain is also okay, because we skip
+ // ghost cells in the loop below.
+ Assert (
+ (dof.get_tria().locally_owned_subdomain() == numbers::invalid_subdomain_id)
+ ||
+ (subdomain_id == numbers::invalid_subdomain_id)
+ ||
+ (subdomain_id == dof.get_tria().locally_owned_subdomain()),
+ ExcMessage ("For parallel::distributed::Triangulation objects and "
+ "associated DoF handler objects, asking for any subdomain other "
+ "than the locally owned one does not make sense."));
+
+ std::vector<types::global_dof_index> dofs_on_this_cell;
+ dofs_on_this_cell.reserve (max_dofs_per_cell(dof));
+ typename DH::active_cell_iterator cell = dof.begin_active(),
+ endc = dof.end();
+
+ // In case we work with a distributed sparsity pattern of Trilinos
+ // type, we only have to do the work if the current cell is owned by
+ // the calling processor. Otherwise, just continue.
+ for (; cell!=endc; ++cell)
+ if (((subdomain_id == numbers::invalid_subdomain_id)
+ ||
+ (subdomain_id == cell->subdomain_id()))
+ &&
+ cell->is_locally_owned())
+ {
+ const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell;
+ dofs_on_this_cell.resize (dofs_per_cell);
+ cell->get_dof_indices (dofs_on_this_cell);
+
+ // make sparsity pattern for this cell. if no constraints pattern
+ // was given, then the following call acts as if simply no
+ // constraints existed
+ constraints.add_entries_local_to_global (dofs_on_this_cell,
+ sparsity,
+ keep_constrained_dofs);
+ }
+ }
+
+
+
+ template <class DH, class SparsityPattern>
+ void
+ make_sparsity_pattern (const DH &dof,
+ const Table<2,Coupling> &couplings,
+ SparsityPattern &sparsity,
+ const ConstraintMatrix &constraints,
+ const bool keep_constrained_dofs,
+ const types::subdomain_id subdomain_id)
+ {
+ const types::global_dof_index n_dofs = dof.n_dofs();
+
+ Assert (sparsity.n_rows() == n_dofs,
+ ExcDimensionMismatch (sparsity.n_rows(), n_dofs));
+ Assert (sparsity.n_cols() == n_dofs,
+ ExcDimensionMismatch (sparsity.n_cols(), n_dofs));
+ Assert (couplings.n_rows() == dof.get_fe().n_components(),
+ ExcDimensionMismatch(couplings.n_rows(), dof.get_fe().n_components()));
+ Assert (couplings.n_cols() == dof.get_fe().n_components(),
+ ExcDimensionMismatch(couplings.n_cols(), dof.get_fe().n_components()));
+
+ // If we have a distributed::Triangulation only allow locally_owned
+ // subdomain. Not setting a subdomain is also okay, because we skip
+ // ghost cells in the loop below.
+ Assert (
+ (dof.get_tria().locally_owned_subdomain() == numbers::invalid_subdomain_id)
+ ||
+ (subdomain_id == numbers::invalid_subdomain_id)
+ ||
+ (subdomain_id == dof.get_tria().locally_owned_subdomain()),
+ ExcMessage ("For parallel::distributed::Triangulation objects and "
+ "associated DoF handler objects, asking for any subdomain other "
+ "than the locally owned one does not make sense."));
+
+ const hp::FECollection<DH::dimension,DH::space_dimension> fe_collection (dof.get_fe());
+
+ // first, for each finite element, build a mask for each dof, not like
+ // the one given which represents components. make sure we do the right
+ // thing also with respect to non-primitive shape functions, which
+ // takes some additional thought
+ std::vector<Table<2,bool> > dof_mask(fe_collection.size());
+
+ // check whether the table of couplings contains only true arguments,
+ // i.e., we do not exclude any index. that is the easy case, since we
+ // don't have to set up the tables
+ bool need_dof_mask = false;
+ for (unsigned int i=0; i<couplings.n_rows(); ++i)
+ for (unsigned int j=0; j<couplings.n_cols(); ++j)
+ if (couplings(i,j) == none)
+ need_dof_mask = true;
+
+ if (need_dof_mask == true)
+ for (unsigned int f=0; f<fe_collection.size(); ++f)
+ {
+ const unsigned int dofs_per_cell = fe_collection[f].dofs_per_cell;
+
+ dof_mask[f].reinit (dofs_per_cell, dofs_per_cell);
+
+ for (unsigned int i=0; i<dofs_per_cell; ++i)
+ for (unsigned int j=0; j<dofs_per_cell; ++j)
+ if (fe_collection[f].is_primitive(i) &&
+ fe_collection[f].is_primitive(j))
+ dof_mask[f](i,j)
+ = (couplings(fe_collection[f].system_to_component_index(i).first,
+ fe_collection[f].system_to_component_index(j).first) != none);
+ else
+ {
+ const unsigned int first_nonzero_comp_i
+ = fe_collection[f].get_nonzero_components(i).first_selected_component();
+ const unsigned int first_nonzero_comp_j
+ = fe_collection[f].get_nonzero_components(j).first_selected_component();
+ Assert (first_nonzero_comp_i < fe_collection[f].n_components(),
+ ExcInternalError());
+ Assert (first_nonzero_comp_j < fe_collection[f].n_components(),
+ ExcInternalError());
+
+ dof_mask[f](i,j)
+ = (couplings(first_nonzero_comp_i,first_nonzero_comp_j) != none);
+ }
+ }
+
+
+ std::vector<types::global_dof_index> dofs_on_this_cell(fe_collection.max_dofs_per_cell());
+ typename DH::active_cell_iterator cell = dof.begin_active(),
+ endc = dof.end();
+
+ // In case we work with a distributed sparsity pattern of Trilinos
+ // type, we only have to do the work if the current cell is owned by
+ // the calling processor. Otherwise, just continue.
+ for (; cell!=endc; ++cell)
+ if (((subdomain_id == numbers::invalid_subdomain_id)
+ ||
+ (subdomain_id == cell->subdomain_id()))
+ &&
+ cell->is_locally_owned())
+ {
+ const unsigned int fe_index = cell->active_fe_index();
+ const unsigned int dofs_per_cell =fe_collection[fe_index].dofs_per_cell;
+
+ dofs_on_this_cell.resize (dofs_per_cell);
+ cell->get_dof_indices (dofs_on_this_cell);
+
+
+ // make sparsity pattern for this cell. if no constraints pattern
+ // was given, then the following call acts as if simply no
+ // constraints existed
+ constraints.add_entries_local_to_global (dofs_on_this_cell,
+ sparsity,
+ keep_constrained_dofs,
+ dof_mask[fe_index]);
+ }
+ }
+
+
+
+ template <class DH, class SparsityPattern>
+ void
+ make_sparsity_pattern (
+ const DH &dof_row,
+ const DH &dof_col,
+ SparsityPattern &sparsity)
+ {
+ const types::global_dof_index n_dofs_row = dof_row.n_dofs();
+ const types::global_dof_index n_dofs_col = dof_col.n_dofs();
+
+ Assert (sparsity.n_rows() == n_dofs_row,
+ ExcDimensionMismatch (sparsity.n_rows(), n_dofs_row));
+ Assert (sparsity.n_cols() == n_dofs_col,
+ ExcDimensionMismatch (sparsity.n_cols(), n_dofs_col));
+
+//TODO: Looks like wasteful memory management here
+
+ const std::list<std::pair<typename DH::cell_iterator,
+ typename DH::cell_iterator> >
+ cell_list
+ = GridTools::get_finest_common_cells (dof_row, dof_col);
+
+
+ typename std::list<std::pair<typename DH::cell_iterator,
+ typename DH::cell_iterator> >::const_iterator
+ cell_iter = cell_list.begin();
+
+ for (; cell_iter!=cell_list.end(); ++cell_iter)
+ {
+ const typename DH::cell_iterator cell_row = cell_iter->first;
+ const typename DH::cell_iterator cell_col = cell_iter->second;
+
+ if (!cell_row->has_children() && !cell_col->has_children())
+ {
+ const unsigned int dofs_per_cell_row =
+ cell_row->get_fe().dofs_per_cell;
+ const unsigned int dofs_per_cell_col =
+ cell_col->get_fe().dofs_per_cell;
+ std::vector<types::global_dof_index>
+ local_dof_indices_row(dofs_per_cell_row);
+ std::vector<types::global_dof_index>
+ local_dof_indices_col(dofs_per_cell_col);
+ cell_row->get_dof_indices (local_dof_indices_row);
+ cell_col->get_dof_indices (local_dof_indices_col);
+ for (unsigned int i=0; i<dofs_per_cell_row; ++i)
+ sparsity.add_entries (local_dof_indices_row[i],
+ local_dof_indices_col.begin(),
+ local_dof_indices_col.end());
+ }
+ else if (cell_row->has_children())
+ {
+ const std::vector<typename DH::active_cell_iterator >
+ child_cells = GridTools::get_active_child_cells<DH> (cell_row);
+ for (unsigned int i=0; i<child_cells.size(); i++)
+ {
+ const typename DH::cell_iterator
+ cell_row_child = child_cells[i];
+ const unsigned int dofs_per_cell_row =
+ cell_row_child->get_fe().dofs_per_cell;
+ const unsigned int dofs_per_cell_col =
+ cell_col->get_fe().dofs_per_cell;
+ std::vector<types::global_dof_index>
+ local_dof_indices_row(dofs_per_cell_row);
+ std::vector<types::global_dof_index>
+ local_dof_indices_col(dofs_per_cell_col);
+ cell_row_child->get_dof_indices (local_dof_indices_row);
+ cell_col->get_dof_indices (local_dof_indices_col);
+ for (unsigned int i=0; i<dofs_per_cell_row; ++i)
+ sparsity.add_entries (local_dof_indices_row[i],
+ local_dof_indices_col.begin(),
+ local_dof_indices_col.end());
+ }
+ }
+ else
+ {
+ std::vector<typename DH::active_cell_iterator>
+ child_cells = GridTools::get_active_child_cells<DH> (cell_col);
+ for (unsigned int i=0; i<child_cells.size(); i++)
+ {
+ const typename DH::active_cell_iterator
+ cell_col_child = child_cells[i];
+ const unsigned int dofs_per_cell_row =
+ cell_row->get_fe().dofs_per_cell;
+ const unsigned int dofs_per_cell_col =
+ cell_col_child->get_fe().dofs_per_cell;
+ std::vector<types::global_dof_index>
+ local_dof_indices_row(dofs_per_cell_row);
+ std::vector<types::global_dof_index>
+ local_dof_indices_col(dofs_per_cell_col);
+ cell_row->get_dof_indices (local_dof_indices_row);
+ cell_col_child->get_dof_indices (local_dof_indices_col);
+ for (unsigned int i=0; i<dofs_per_cell_row; ++i)
+ sparsity.add_entries (local_dof_indices_row[i],
+ local_dof_indices_col.begin(),
+ local_dof_indices_col.end());
+ }
+ }
+ }
+ }
+
+
+
+ template <class DH, class SparsityPattern>
+ void
+ make_boundary_sparsity_pattern (
+ const DH &dof,
+ const std::vector<types::global_dof_index> &dof_to_boundary_mapping,
+ SparsityPattern &sparsity)
+ {
+ if (DH::dimension == 1)
+ {
+ // there are only 2 boundary indicators in 1d, so it is no
+ // performance problem to call the other function
+ typename DH::FunctionMap boundary_indicators;
+ boundary_indicators[0] = 0;
+ boundary_indicators[1] = 0;
+ make_boundary_sparsity_pattern<DH, SparsityPattern> (dof,
+ boundary_indicators,
+ dof_to_boundary_mapping,
+ sparsity);
+ return;
+ }
+
+ const types::global_dof_index n_dofs = dof.n_dofs();
+
+ AssertDimension (dof_to_boundary_mapping.size(), n_dofs);
+ AssertDimension (sparsity.n_rows(), dof.n_boundary_dofs());
+ AssertDimension (sparsity.n_cols(), dof.n_boundary_dofs());
+#ifdef DEBUG
+ if (sparsity.n_rows() != 0)
+ {
+ types::global_dof_index max_element = 0;
+ for (std::vector<types::global_dof_index>::const_iterator i=dof_to_boundary_mapping.begin();
+ i!=dof_to_boundary_mapping.end(); ++i)
+ if ((*i != DH::invalid_dof_index) &&
+ (*i > max_element))
+ max_element = *i;
+ AssertDimension (max_element, sparsity.n_rows()-1);
+ };
+#endif
+
+ std::vector<types::global_dof_index> dofs_on_this_face;
+ dofs_on_this_face.reserve (max_dofs_per_face(dof));
+
+ // loop over all faces to check whether they are at a boundary. note
+ // that we need not take special care of single lines (using
+ // @p{cell->has_boundary_lines}), since we do not support boundaries of
+ // dimension dim-2, and so every boundary line is also part of a
+ // boundary face.
+ typename DH::active_cell_iterator cell = dof.begin_active(),
+ endc = dof.end();
+ for (; cell!=endc; ++cell)
+ for (unsigned int f=0; f<GeometryInfo<DH::dimension>::faces_per_cell; ++f)
+ if (cell->at_boundary(f))
+ {
+ const unsigned int dofs_per_face = cell->get_fe().dofs_per_face;
+ dofs_on_this_face.resize (dofs_per_face);
+ cell->face(f)->get_dof_indices (dofs_on_this_face,
+ cell->active_fe_index());
+
+ // make sparsity pattern for this cell
+ for (unsigned int i=0; i<dofs_per_face; ++i)
+ for (unsigned int j=0; j<dofs_per_face; ++j)
+ sparsity.add (dof_to_boundary_mapping[dofs_on_this_face[i]],
+ dof_to_boundary_mapping[dofs_on_this_face[j]]);
+ }
+ }
+
+
+
+ template <class DH, class SparsityPattern>
+ void make_boundary_sparsity_pattern (
+ const DH &dof,
+ const typename FunctionMap<DH::space_dimension>::type &boundary_indicators,
+ const std::vector<types::global_dof_index> &dof_to_boundary_mapping,
+ SparsityPattern &sparsity)
+ {
+ if (DH::dimension == 1)
+ {
+ // first check left, then right boundary point
+ for (unsigned int direction=0; direction<2; ++direction)
+ {
+ // if this boundary is not requested, then go on with next one
+ if (boundary_indicators.find(direction) ==
+ boundary_indicators.end())
+ continue;
+
+ // find active cell at that boundary: first go to left/right,
+ // then to children
+ typename DH::level_cell_iterator cell = dof.begin(0);
+ while (!cell->at_boundary(direction))
+ cell = cell->neighbor(direction);
+ while (!cell->active())
+ cell = cell->child(direction);
+
+ const unsigned int dofs_per_vertex = cell->get_fe().dofs_per_vertex;
+ std::vector<types::global_dof_index> boundary_dof_boundary_indices (dofs_per_vertex);
+
+ // next get boundary mapped dof indices of boundary dofs
+ for (unsigned int i=0; i<dofs_per_vertex; ++i)
+ boundary_dof_boundary_indices[i]
+ = dof_to_boundary_mapping[cell->vertex_dof_index(direction,i)];
+
+ for (unsigned int i=0; i<dofs_per_vertex; ++i)
+ sparsity.add_entries (boundary_dof_boundary_indices[i],
+ boundary_dof_boundary_indices.begin(),
+ boundary_dof_boundary_indices.end());
+ };
+ return;
+ }
+
+ const types::global_dof_index n_dofs = dof.n_dofs();
+
+ AssertDimension (dof_to_boundary_mapping.size(), n_dofs);
+ Assert (boundary_indicators.find(numbers::internal_face_boundary_id) == boundary_indicators.end(),
+ typename DH::ExcInvalidBoundaryIndicator());
+ Assert (sparsity.n_rows() == dof.n_boundary_dofs (boundary_indicators),
+ ExcDimensionMismatch (sparsity.n_rows(), dof.n_boundary_dofs (boundary_indicators)));
+ Assert (sparsity.n_cols() == dof.n_boundary_dofs (boundary_indicators),
+ ExcDimensionMismatch (sparsity.n_cols(), dof.n_boundary_dofs (boundary_indicators)));
+#ifdef DEBUG
+ if (sparsity.n_rows() != 0)
+ {
+ types::global_dof_index max_element = 0;
+ for (std::vector<types::global_dof_index>::const_iterator i=dof_to_boundary_mapping.begin();
+ i!=dof_to_boundary_mapping.end(); ++i)
+ if ((*i != DH::invalid_dof_index) &&
+ (*i > max_element))
+ max_element = *i;
+ AssertDimension (max_element, sparsity.n_rows()-1);
+ };
+#endif
+
+ std::vector<types::global_dof_index> dofs_on_this_face;
+ dofs_on_this_face.reserve (max_dofs_per_face(dof));
+ typename DH::active_cell_iterator cell = dof.begin_active(),
+ endc = dof.end();
+ for (; cell!=endc; ++cell)
+ for (unsigned int f=0; f<GeometryInfo<DH::dimension>::faces_per_cell; ++f)
+ if (boundary_indicators.find(cell->face(f)->boundary_indicator()) !=
+ boundary_indicators.end())
+ {
+ const unsigned int dofs_per_face = cell->get_fe().dofs_per_face;
+ dofs_on_this_face.resize (dofs_per_face);
+ cell->face(f)->get_dof_indices (dofs_on_this_face,
+ cell->active_fe_index());
+
+ // make sparsity pattern for this cell
+ for (unsigned int i=0; i<dofs_per_face; ++i)
+ for (unsigned int j=0; j<dofs_per_face; ++j)
+ sparsity.add (dof_to_boundary_mapping[dofs_on_this_face[i]],
+ dof_to_boundary_mapping[dofs_on_this_face[j]]);
+ }
+ }
+
+
+
+ template <class DH, class SparsityPattern>
+ void
+ make_flux_sparsity_pattern (const DH &dof,
+ SparsityPattern &sparsity,
+ const ConstraintMatrix &constraints,
+ const bool keep_constrained_dofs,
+ const types::subdomain_id subdomain_id)
+
+ // TODO: QA: reduce the indentation level of this method..., Maier 2012
+
+ {
+ const types::global_dof_index n_dofs = dof.n_dofs();
+
+ AssertDimension (sparsity.n_rows(), n_dofs);
+ AssertDimension (sparsity.n_cols(), n_dofs);
+
+ // If we have a distributed::Triangulation only allow locally_owned
+ // subdomain. Not setting a subdomain is also okay, because we skip
+ // ghost cells in the loop below.
+ Assert (
+ (dof.get_tria().locally_owned_subdomain() == numbers::invalid_subdomain_id)
+ ||
+ (subdomain_id == numbers::invalid_subdomain_id)
+ ||
+ (subdomain_id == dof.get_tria().locally_owned_subdomain()),
+ ExcMessage ("For parallel::distributed::Triangulation objects and "
+ "associated DoF handler objects, asking for any subdomain other "
+ "than the locally owned one does not make sense."));
+
+ std::vector<types::global_dof_index> dofs_on_this_cell;
+ std::vector<types::global_dof_index> dofs_on_other_cell;
+ dofs_on_this_cell.reserve (max_dofs_per_cell(dof));
+ dofs_on_other_cell.reserve (max_dofs_per_cell(dof));
+ typename DH::active_cell_iterator cell = dof.begin_active(),
+ endc = dof.end();
+
+ // TODO: in an old implementation, we used user flags before to tag
+ // faces that were already touched. this way, we could reduce the work
+ // a little bit. now, we instead add only data from one side. this
+ // should be OK, but we need to actually verify it.
+
+ // In case we work with a distributed sparsity pattern of Trilinos
+ // type, we only have to do the work if the current cell is owned by
+ // the calling processor. Otherwise, just continue.
+ for (; cell!=endc; ++cell)
+ if (((subdomain_id == numbers::invalid_subdomain_id)
+ ||
+ (subdomain_id == cell->subdomain_id()))
+ &&
+ cell->is_locally_owned())
+ {
+ const unsigned int n_dofs_on_this_cell = cell->get_fe().dofs_per_cell;
+ dofs_on_this_cell.resize (n_dofs_on_this_cell);
+ cell->get_dof_indices (dofs_on_this_cell);
+
+ // make sparsity pattern for this cell. if no constraints pattern
+ // was given, then the following call acts as if simply no
+ // constraints existed
+ constraints.add_entries_local_to_global (dofs_on_this_cell,
+ sparsity,
+ keep_constrained_dofs);
+
+ for (unsigned int face = 0;
+ face < GeometryInfo<DH::dimension>::faces_per_cell;
+ ++face)
+ {
+ typename DH::face_iterator cell_face = cell->face(face);
+ if (! cell->at_boundary(face) )
+ {
+ typename DH::level_cell_iterator neighbor = cell->neighbor(face);
+
+ // in 1d, we do not need to worry whether the neighbor
+ // might have children and then loop over those children.
+ // rather, we may as well go straight to to cell behind
+ // this particular cell's most terminal child
+ if (DH::dimension==1)
+ while (neighbor->has_children())
+ neighbor = neighbor->child(face==0 ? 1 : 0);
+
+ if (neighbor->has_children())
+ {
+ for (unsigned int sub_nr = 0;
+ sub_nr != cell_face->number_of_children();
+ ++sub_nr)
+ {
+ const typename DH::level_cell_iterator
+ sub_neighbor
+ = cell->neighbor_child_on_subface (face, sub_nr);
+
+ const unsigned int n_dofs_on_neighbor
+ = sub_neighbor->get_fe().dofs_per_cell;
+ dofs_on_other_cell.resize (n_dofs_on_neighbor);
+ sub_neighbor->get_dof_indices (dofs_on_other_cell);
+
+ constraints.add_entries_local_to_global
+ (dofs_on_this_cell, dofs_on_other_cell,
+ sparsity, keep_constrained_dofs);
+ constraints.add_entries_local_to_global
+ (dofs_on_other_cell, dofs_on_this_cell,
+ sparsity, keep_constrained_dofs);
+ }
+ }
+ else
+ {
+ // Refinement edges are taken care of by coarser
+ // cells
+
+ // TODO: in the distributed case, we miss out the
+ // constraints when the neighbor cell is coarser, but
+ // only the current cell is owned locally!
+ if (cell->neighbor_is_coarser(face))
+ continue;
+
+ const unsigned int n_dofs_on_neighbor
+ = neighbor->get_fe().dofs_per_cell;
+ dofs_on_other_cell.resize (n_dofs_on_neighbor);
+
+ neighbor->get_dof_indices (dofs_on_other_cell);
+
+ constraints.add_entries_local_to_global
+ (dofs_on_this_cell, dofs_on_other_cell,
+ sparsity, keep_constrained_dofs);
+
+ // only need to add these in case the neighbor cell
+ // is not locally owned - otherwise, we touch each
+ // face twice and hence put the indices the other way
+ // around
+ if (!cell->neighbor(face)->active()
+ ||
+ (cell->neighbor(face)->subdomain_id() !=
+ cell->subdomain_id()))
+ constraints.add_entries_local_to_global
+ (dofs_on_other_cell, dofs_on_this_cell,
+ sparsity, keep_constrained_dofs);
+ }
+ }
+ }
+ }
+ }
+
+
+
+ template <class DH, class SparsityPattern>
+ void
+ make_flux_sparsity_pattern (const DH &dof,
+ SparsityPattern &sparsity)
+ {
+ ConstraintMatrix constraints;
+ make_flux_sparsity_pattern (dof, sparsity, constraints);
+ }
+
+ template <int dim, int spacedim>
+ Table<2,Coupling>
+ dof_couplings_from_component_couplings (const FiniteElement<dim,spacedim> &fe,
+ const Table<2,Coupling> &component_couplings)
+ {
+ Assert(component_couplings.n_rows() == fe.n_components(),
+ ExcDimensionMismatch(component_couplings.n_rows(),
+ fe.n_components()));
+ Assert(component_couplings.n_cols() == fe.n_components(),
+ ExcDimensionMismatch(component_couplings.n_cols(),
+ fe.n_components()));
+
+ const unsigned int n_dofs = fe.dofs_per_cell;
+
+ Table<2,Coupling> dof_couplings (n_dofs, n_dofs);
+
+ for (unsigned int i=0; i<n_dofs; ++i)
+ {
+ const unsigned int ii
+ = (fe.is_primitive(i) ?
+ fe.system_to_component_index(i).first
+ :
+ fe.get_nonzero_components(i).first_selected_component()
+ );
+ Assert (ii < fe.n_components(), ExcInternalError());
+
+ for (unsigned int j=0; j<n_dofs; ++j)
+ {
+ const unsigned int jj
+ = (fe.is_primitive(j) ?
+ fe.system_to_component_index(j).first
+ :
+ fe.get_nonzero_components(j).first_selected_component()
+ );
+ Assert (jj < fe.n_components(), ExcInternalError());
+
+ dof_couplings(i,j) = component_couplings(ii,jj);
+ }
+ }
+ return dof_couplings;
+ }
+
+
+
+ template <int dim, int spacedim>
+ std::vector<Table<2,Coupling> >
+ dof_couplings_from_component_couplings
+ (const hp::FECollection<dim,spacedim> &fe,
+ const Table<2,Coupling> &component_couplings)
+ {
+ std::vector<Table<2,Coupling> > return_value (fe.size());
+ for (unsigned int i=0; i<fe.size(); ++i)
+ return_value[i]
+ = dof_couplings_from_component_couplings(fe[i], component_couplings);
+
+ return return_value;
+ }
+
+
+
+ namespace internal
+ {
+ namespace
+ {
+
+ // implementation of the same function in namespace DoFTools for
+ // non-hp DoFHandlers
+ template <class DH, class SparsityPattern>
+ void
+ make_flux_sparsity_pattern (const DH &dof,
+ SparsityPattern &sparsity,
+ const Table<2,Coupling> &int_mask,
+ const Table<2,Coupling> &flux_mask)
+ {
+ const FiniteElement<DH::dimension,DH::space_dimension> &fe = dof.get_fe();
+
+ std::vector<types::global_dof_index> dofs_on_this_cell(fe.dofs_per_cell);
+ std::vector<types::global_dof_index> dofs_on_other_cell(fe.dofs_per_cell);
+
+ const Table<2,Coupling>
+ int_dof_mask = dof_couplings_from_component_couplings(fe, int_mask),
+ flux_dof_mask = dof_couplings_from_component_couplings(fe, flux_mask);
+
+ Table<2,bool> support_on_face(fe.dofs_per_cell,
+ GeometryInfo<DH::dimension>::faces_per_cell);
+ for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
+ for (unsigned int f=0; f<GeometryInfo<DH::dimension>::faces_per_cell; ++f)
+ support_on_face(i,f) = fe.has_support_on_face(i,f);
+
+ typename DH::active_cell_iterator cell = dof.begin_active(),
+ endc = dof.end();
+ for (; cell!=endc; ++cell)
+ if (cell->is_locally_owned())
+ {
+ cell->get_dof_indices (dofs_on_this_cell);
+ // make sparsity pattern for this cell
+ for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
+ for (unsigned int j=0; j<fe.dofs_per_cell; ++j)
+ if (int_dof_mask(i,j) != none)
+ sparsity.add (dofs_on_this_cell[i],
+ dofs_on_this_cell[j]);
+
+ // Loop over all interior neighbors
+ for (unsigned int face = 0;
+ face < GeometryInfo<DH::dimension>::faces_per_cell;
+ ++face)
+ {
+ const typename DH::face_iterator
+ cell_face = cell->face(face);
+ if (cell_face->user_flag_set ())
+ continue;
+
+ if (cell->at_boundary (face) )
+ {
+ for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
+ {
+ const bool i_non_zero_i = support_on_face (i, face);
+ for (unsigned int j=0; j<fe.dofs_per_cell; ++j)
+ {
+ const bool j_non_zero_i = support_on_face (j, face);
+
+ if ((flux_dof_mask(i,j) == always)
+ ||
+ (flux_dof_mask(i,j) == nonzero
+ &&
+ i_non_zero_i
+ &&
+ j_non_zero_i))
+ sparsity.add (dofs_on_this_cell[i],
+ dofs_on_this_cell[j]);
+ }
+ }
+ }
+ else
+ {
+ typename DH::level_cell_iterator
+ neighbor = cell->neighbor(face);
+ // Refinement edges are taken care of by coarser
+ // cells
+ if (cell->neighbor_is_coarser(face))
+ continue;
+
+ typename DH::face_iterator cell_face = cell->face(face);
+ const unsigned int
+ neighbor_face = cell->neighbor_of_neighbor(face);
+
+ if (cell_face->has_children())
+ {
+ for (unsigned int sub_nr = 0;
+ sub_nr != cell_face->n_children();
+ ++sub_nr)
+ {
+ const typename DH::level_cell_iterator
+ sub_neighbor
+ = cell->neighbor_child_on_subface (face, sub_nr);
+
+ sub_neighbor->get_dof_indices (dofs_on_other_cell);
+ for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
+ {
+ const bool i_non_zero_i = support_on_face (i, face);
+ const bool i_non_zero_e = support_on_face (i, neighbor_face);
+ for (unsigned int j=0; j<fe.dofs_per_cell; ++j)
+ {
+ const bool j_non_zero_i = support_on_face (j, face);
+ const bool j_non_zero_e = support_on_face (j, neighbor_face);
+
+ if (flux_dof_mask(i,j) == always)
+ {
+ sparsity.add (dofs_on_this_cell[i],
+ dofs_on_other_cell[j]);
+ sparsity.add (dofs_on_other_cell[i],
+ dofs_on_this_cell[j]);
+ sparsity.add (dofs_on_this_cell[i],
+ dofs_on_this_cell[j]);
+ sparsity.add (dofs_on_other_cell[i],
+ dofs_on_other_cell[j]);
+ }
+ else if (flux_dof_mask(i,j) == nonzero)
+ {
+ if (i_non_zero_i && j_non_zero_e)
+ sparsity.add (dofs_on_this_cell[i],
+ dofs_on_other_cell[j]);
+ if (i_non_zero_e && j_non_zero_i)
+ sparsity.add (dofs_on_other_cell[i],
+ dofs_on_this_cell[j]);
+ if (i_non_zero_i && j_non_zero_i)
+ sparsity.add (dofs_on_this_cell[i],
+ dofs_on_this_cell[j]);
+ if (i_non_zero_e && j_non_zero_e)
+ sparsity.add (dofs_on_other_cell[i],
+ dofs_on_other_cell[j]);
+ }
+
+ if (flux_dof_mask(j,i) == always)
+ {
+ sparsity.add (dofs_on_this_cell[j],
+ dofs_on_other_cell[i]);
+ sparsity.add (dofs_on_other_cell[j],
+ dofs_on_this_cell[i]);
+ sparsity.add (dofs_on_this_cell[j],
+ dofs_on_this_cell[i]);
+ sparsity.add (dofs_on_other_cell[j],
+ dofs_on_other_cell[i]);
+ }
+ else if (flux_dof_mask(j,i) == nonzero)
+ {
+ if (j_non_zero_i && i_non_zero_e)
+ sparsity.add (dofs_on_this_cell[j],
+ dofs_on_other_cell[i]);
+ if (j_non_zero_e && i_non_zero_i)
+ sparsity.add (dofs_on_other_cell[j],
+ dofs_on_this_cell[i]);
+ if (j_non_zero_i && i_non_zero_i)
+ sparsity.add (dofs_on_this_cell[j],
+ dofs_on_this_cell[i]);
+ if (j_non_zero_e && i_non_zero_e)
+ sparsity.add (dofs_on_other_cell[j],
+ dofs_on_other_cell[i]);
+ }
+ }
+ }
+ sub_neighbor->face(neighbor_face)->set_user_flag ();
+ }
+ }
+ else
+ {
+ neighbor->get_dof_indices (dofs_on_other_cell);
+ for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
+ {
+ const bool i_non_zero_i = support_on_face (i, face);
+ const bool i_non_zero_e = support_on_face (i, neighbor_face);
+ for (unsigned int j=0; j<fe.dofs_per_cell; ++j)
+ {
+ const bool j_non_zero_i = support_on_face (j, face);
+ const bool j_non_zero_e = support_on_face (j, neighbor_face);
+ if (flux_dof_mask(i,j) == always)
+ {
+ sparsity.add (dofs_on_this_cell[i],
+ dofs_on_other_cell[j]);
+ sparsity.add (dofs_on_other_cell[i],
+ dofs_on_this_cell[j]);
+ sparsity.add (dofs_on_this_cell[i],
+ dofs_on_this_cell[j]);
+ sparsity.add (dofs_on_other_cell[i],
+ dofs_on_other_cell[j]);
+ }
+ if (flux_dof_mask(i,j) == nonzero)
+ {
+ if (i_non_zero_i && j_non_zero_e)
+ sparsity.add (dofs_on_this_cell[i],
+ dofs_on_other_cell[j]);
+ if (i_non_zero_e && j_non_zero_i)
+ sparsity.add (dofs_on_other_cell[i],
+ dofs_on_this_cell[j]);
+ if (i_non_zero_i && j_non_zero_i)
+ sparsity.add (dofs_on_this_cell[i],
+ dofs_on_this_cell[j]);
+ if (i_non_zero_e && j_non_zero_e)
+ sparsity.add (dofs_on_other_cell[i],
+ dofs_on_other_cell[j]);
+ }
+
+ if (flux_dof_mask(j,i) == always)
+ {
+ sparsity.add (dofs_on_this_cell[j],
+ dofs_on_other_cell[i]);
+ sparsity.add (dofs_on_other_cell[j],
+ dofs_on_this_cell[i]);
+ sparsity.add (dofs_on_this_cell[j],
+ dofs_on_this_cell[i]);
+ sparsity.add (dofs_on_other_cell[j],
+ dofs_on_other_cell[i]);
+ }
+ if (flux_dof_mask(j,i) == nonzero)
+ {
+ if (j_non_zero_i && i_non_zero_e)
+ sparsity.add (dofs_on_this_cell[j],
+ dofs_on_other_cell[i]);
+ if (j_non_zero_e && i_non_zero_i)
+ sparsity.add (dofs_on_other_cell[j],
+ dofs_on_this_cell[i]);
+ if (j_non_zero_i && i_non_zero_i)
+ sparsity.add (dofs_on_this_cell[j],
+ dofs_on_this_cell[i]);
+ if (j_non_zero_e && i_non_zero_e)
+ sparsity.add (dofs_on_other_cell[j],
+ dofs_on_other_cell[i]);
+ }
+ }
+ }
+ neighbor->face(neighbor_face)->set_user_flag ();
+ }
+ }
+ }
+ }
+ }
+
+
+ // implementation of the same function in namespace DoFTools for
+ // non-hp DoFHandlers
+ template <int dim, int spacedim, class SparsityPattern>
+ void
+ make_flux_sparsity_pattern (const dealii::hp::DoFHandler<dim,spacedim> &dof,
+ SparsityPattern &sparsity,
+ const Table<2,Coupling> &int_mask,
+ const Table<2,Coupling> &flux_mask)
+ {
+ // while the implementation above is quite optimized and caches a
+ // lot of data (see e.g. the int/flux_dof_mask tables), this is no
+ // longer practical for the hp version since we would have to have
+ // it for all combinations of elements in the hp::FECollection.
+ // consequently, the implementation here is simpler and probably
+ // less efficient but at least readable...
+
+ const dealii::hp::FECollection<dim,spacedim> &fe = dof.get_fe();
+
+ std::vector<types::global_dof_index> dofs_on_this_cell(DoFTools::max_dofs_per_cell(dof));
+ std::vector<types::global_dof_index> dofs_on_other_cell(DoFTools::max_dofs_per_cell(dof));
+
+ const std::vector<Table<2,Coupling> >
+ int_dof_mask
+ = dof_couplings_from_component_couplings(fe, int_mask);
+
+ typename dealii::hp::DoFHandler<dim,spacedim>::active_cell_iterator
+ cell = dof.begin_active(),
+ endc = dof.end();
+ for (; cell!=endc; ++cell)
+ {
+ dofs_on_this_cell.resize (cell->get_fe().dofs_per_cell);
+ cell->get_dof_indices (dofs_on_this_cell);
+
+ // make sparsity pattern for this cell
+ for (unsigned int i=0; i<cell->get_fe().dofs_per_cell; ++i)
+ for (unsigned int j=0; j<cell->get_fe().dofs_per_cell; ++j)
+ if (int_dof_mask[cell->active_fe_index()](i,j) != none)
+ sparsity.add (dofs_on_this_cell[i],
+ dofs_on_this_cell[j]);
+
+ // Loop over all interior neighbors
+ for (unsigned int face = 0;
+ face < GeometryInfo<dim>::faces_per_cell;
+ ++face)
+ {
+ const typename dealii::hp::DoFHandler<dim,spacedim>::face_iterator
+ cell_face = cell->face(face);
+ if (cell_face->user_flag_set ())
+ continue;
+
+ if (cell->at_boundary (face) )
+ {
+ for (unsigned int i=0; i<cell->get_fe().dofs_per_cell; ++i)
+ for (unsigned int j=0; j<cell->get_fe().dofs_per_cell; ++j)
+ if ((flux_mask(cell->get_fe().system_to_component_index(i).first,
+ cell->get_fe().system_to_component_index(j).first)
+ == always)
+ ||
+ (flux_mask(cell->get_fe().system_to_component_index(i).first,
+ cell->get_fe().system_to_component_index(j).first)
+ == nonzero))
+ sparsity.add (dofs_on_this_cell[i],
+ dofs_on_this_cell[j]);
+ }
+ else
+ {
+ typename dealii::hp::DoFHandler<dim,spacedim>::level_cell_iterator
+ neighbor = cell->neighbor(face);
+
+ // Refinement edges are taken care of by coarser cells
+ if (cell->neighbor_is_coarser(face))
+ continue;
+
+ typename dealii::hp::DoFHandler<dim,spacedim>::face_iterator
+ cell_face = cell->face(face);
+ const unsigned int
+ neighbor_face = cell->neighbor_of_neighbor(face);
+
+ if (cell_face->has_children())
+ {
+ for (unsigned int sub_nr = 0;
+ sub_nr != cell_face->n_children();
+ ++sub_nr)
+ {
+ const typename dealii::hp::DoFHandler<dim,spacedim>::level_cell_iterator
+ sub_neighbor
+ = cell->neighbor_child_on_subface (face, sub_nr);
+
+ dofs_on_other_cell.resize (sub_neighbor->get_fe().dofs_per_cell);
+ sub_neighbor->get_dof_indices (dofs_on_other_cell);
+ for (unsigned int i=0; i<cell->get_fe().dofs_per_cell; ++i)
+ {
+ for (unsigned int j=0; j<sub_neighbor->get_fe().dofs_per_cell;
+ ++j)
+ {
+ if ((flux_mask(cell->get_fe().system_to_component_index(i).first,
+ sub_neighbor->get_fe().system_to_component_index(j).first)
+ == always)
+ ||
+ (flux_mask(cell->get_fe().system_to_component_index(i).first,
+ sub_neighbor->get_fe().system_to_component_index(j).first)
+ == nonzero))
+ {
+ sparsity.add (dofs_on_this_cell[i],
+ dofs_on_other_cell[j]);
+ sparsity.add (dofs_on_other_cell[i],
+ dofs_on_this_cell[j]);
+ sparsity.add (dofs_on_this_cell[i],
+ dofs_on_this_cell[j]);
+ sparsity.add (dofs_on_other_cell[i],
+ dofs_on_other_cell[j]);
+ }
+
+ if ((flux_mask(sub_neighbor->get_fe().system_to_component_index(j).first,
+ cell->get_fe().system_to_component_index(i).first)
+ == always)
+ ||
+ (flux_mask(sub_neighbor->get_fe().system_to_component_index(j).first,
+ cell->get_fe().system_to_component_index(i).first)
+ == nonzero))
+ {
+ sparsity.add (dofs_on_this_cell[j],
+ dofs_on_other_cell[i]);
+ sparsity.add (dofs_on_other_cell[j],
+ dofs_on_this_cell[i]);
+ sparsity.add (dofs_on_this_cell[j],
+ dofs_on_this_cell[i]);
+ sparsity.add (dofs_on_other_cell[j],
+ dofs_on_other_cell[i]);
+ }
+ }
+ }
+ sub_neighbor->face(neighbor_face)->set_user_flag ();
+ }
+ }
+ else
+ {
+ dofs_on_other_cell.resize (neighbor->get_fe().dofs_per_cell);
+ neighbor->get_dof_indices (dofs_on_other_cell);
+ for (unsigned int i=0; i<cell->get_fe().dofs_per_cell; ++i)
+ {
+ for (unsigned int j=0; j<neighbor->get_fe().dofs_per_cell; ++j)
+ {
+ if ((flux_mask(cell->get_fe().system_to_component_index(i).first,
+ neighbor->get_fe().system_to_component_index(j).first)
+ == always)
+ ||
+ (flux_mask(cell->get_fe().system_to_component_index(i).first,
+ neighbor->get_fe().system_to_component_index(j).first)
+ == nonzero))
+ {
+ sparsity.add (dofs_on_this_cell[i],
+ dofs_on_other_cell[j]);
+ sparsity.add (dofs_on_other_cell[i],
+ dofs_on_this_cell[j]);
+ sparsity.add (dofs_on_this_cell[i],
+ dofs_on_this_cell[j]);
+ sparsity.add (dofs_on_other_cell[i],
+ dofs_on_other_cell[j]);
+ }
+
+ if ((flux_mask(neighbor->get_fe().system_to_component_index(j).first,
+ cell->get_fe().system_to_component_index(i).first)
+ == always)
+ ||
+ (flux_mask(neighbor->get_fe().system_to_component_index(j).first,
+ cell->get_fe().system_to_component_index(i).first)
+ == nonzero))
+ {
+ sparsity.add (dofs_on_this_cell[j],
+ dofs_on_other_cell[i]);
+ sparsity.add (dofs_on_other_cell[j],
+ dofs_on_this_cell[i]);
+ sparsity.add (dofs_on_this_cell[j],
+ dofs_on_this_cell[i]);
+ sparsity.add (dofs_on_other_cell[j],
+ dofs_on_other_cell[i]);
+ }
+ }
+ }
+ neighbor->face(neighbor_face)->set_user_flag ();
+ }
+ }
+ }
+ }
+ }
+ }
+
+ }
+
+
+
+
+ template <class DH, class SparsityPattern>
+ void
+ make_flux_sparsity_pattern (const DH &dof,
+ SparsityPattern &sparsity,
+ const Table<2,Coupling> &int_mask,
+ const Table<2,Coupling> &flux_mask)
+ {
+ // do the error checking and frame code here, and then pass on to more
+ // specialized functions in the internal namespace
+ const types::global_dof_index n_dofs = dof.n_dofs();
+ const unsigned int n_comp = dof.get_fe().n_components();
+
+ Assert (sparsity.n_rows() == n_dofs,
+ ExcDimensionMismatch (sparsity.n_rows(), n_dofs));
+ Assert (sparsity.n_cols() == n_dofs,
+ ExcDimensionMismatch (sparsity.n_cols(), n_dofs));
+ Assert (int_mask.n_rows() == n_comp,
+ ExcDimensionMismatch (int_mask.n_rows(), n_comp));
+ Assert (int_mask.n_cols() == n_comp,
+ ExcDimensionMismatch (int_mask.n_cols(), n_comp));
+ Assert (flux_mask.n_rows() == n_comp,
+ ExcDimensionMismatch (flux_mask.n_rows(), n_comp));
+ Assert (flux_mask.n_cols() == n_comp,
+ ExcDimensionMismatch (flux_mask.n_cols(), n_comp));
+
+ // Clear user flags because we will need them. But first we save them
+ // and make sure that we restore them later such that at the end of
+ // this function the Triangulation will be in the same state as it was
+ // at the beginning of this function.
+ std::vector<bool> user_flags;
+ dof.get_tria().save_user_flags(user_flags);
+ const_cast<Triangulation<DH::dimension,DH::space_dimension> &>(dof.get_tria()).clear_user_flags ();
+
+ internal::make_flux_sparsity_pattern (dof, sparsity,
+ int_mask, flux_mask);
+
+ // finally restore the user flags
+ const_cast<Triangulation<DH::dimension,DH::space_dimension> &>(dof.get_tria()).load_user_flags(user_flags);
+ }
+
+
+} // end of namespace DoFTools
+
+
+// --------------------------------------------------- explicit instantiations
+
+#include "dof_tools_sparsity.inst"
+
+
+
+DEAL_II_NAMESPACE_CLOSE
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 2009 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+
+for (SP : SPARSITY_PATTERNS; deal_II_dimension : DIMENSIONS)
+ {
+ template void
+ DoFTools::make_sparsity_pattern<DoFHandler<deal_II_dimension,deal_II_dimension>, SP>
+ (const DoFHandler<deal_II_dimension,deal_II_dimension> &dof,
+ SP &sparsity,
+ const ConstraintMatrix &,
+ const bool,
+ const unsigned int);
+
+ template void
+ DoFTools::make_sparsity_pattern<hp::DoFHandler<deal_II_dimension,deal_II_dimension>, SP>
+ (const hp::DoFHandler<deal_II_dimension,deal_II_dimension> &dof,
+ SP &sparsity,
+ const ConstraintMatrix &,
+ const bool,
+ const unsigned int);
+
+ template void
+ DoFTools::make_sparsity_pattern<MGDoFHandler<deal_II_dimension,deal_II_dimension>, SP>
+ (const MGDoFHandler<deal_II_dimension,deal_II_dimension> &dof,
+ SP &sparsity,
+ const ConstraintMatrix &,
+ const bool,
+ const unsigned int);
+
+ template void
+ DoFTools::make_sparsity_pattern<DoFHandler<deal_II_dimension,deal_II_dimension>, SP>
+ (const DoFHandler<deal_II_dimension,deal_II_dimension>&,
+ const Table<2,Coupling>&,
+ SP &,
+ const ConstraintMatrix &,
+ const bool,
+ const unsigned int);
+
+ template void
+ DoFTools::make_sparsity_pattern<hp::DoFHandler<deal_II_dimension,deal_II_dimension>, SP>
+ (const hp::DoFHandler<deal_II_dimension,deal_II_dimension>&,
+ const Table<2,Coupling>&,
+ SP &,
+ const ConstraintMatrix &,
+ const bool,
+ const unsigned int);
+
+ template void
+ DoFTools::make_sparsity_pattern<MGDoFHandler<deal_II_dimension,deal_II_dimension>, SP>
+ (const MGDoFHandler<deal_II_dimension,deal_II_dimension>&,
+ const Table<2,Coupling>&,
+ SP &,
+ const ConstraintMatrix &,
+ const bool,
+ const unsigned int);
+
+ template void
+ DoFTools::make_sparsity_pattern<DoFHandler<deal_II_dimension,deal_II_dimension>, SP>
+ (const DoFHandler<deal_II_dimension,deal_II_dimension> &dof_row,
+ const DoFHandler<deal_II_dimension,deal_II_dimension> &dof_col,
+ SP &sparsity);
+
+ template void
+ DoFTools::make_sparsity_pattern<hp::DoFHandler<deal_II_dimension,deal_II_dimension>, SP>
+ (const hp::DoFHandler<deal_II_dimension,deal_II_dimension> &dof_row,
+ const hp::DoFHandler<deal_II_dimension,deal_II_dimension> &dof_col,
+ SP &sparsity);
+
+ template void
+ DoFTools::make_boundary_sparsity_pattern<DoFHandler<deal_II_dimension>,SP>
+ (const DoFHandler<deal_II_dimension>& dof,
+ const std::vector<types::global_dof_index> &,
+ SP &);
+
+ template void
+ DoFTools::make_boundary_sparsity_pattern<hp::DoFHandler<deal_II_dimension>,SP>
+ (const hp::DoFHandler<deal_II_dimension>& dof,
+ const std::vector<types::global_dof_index> &,
+ SP &);
+
+ template void
+ DoFTools::make_boundary_sparsity_pattern<DoFHandler<deal_II_dimension>,SP>
+ (const DoFHandler<deal_II_dimension>& dof,
+ const FunctionMap<deal_II_dimension>::type &boundary_indicators,
+ const std::vector<types::global_dof_index> &dof_to_boundary_mapping,
+ SP &sparsity);
+
+ template void
+ DoFTools::make_boundary_sparsity_pattern<hp::DoFHandler<deal_II_dimension>,SP>
+ (const hp::DoFHandler<deal_II_dimension>& dof,
+ const FunctionMap<deal_II_dimension>::type &boundary_indicators,
+ const std::vector<types::global_dof_index> &dof_to_boundary_mapping,
+ SP &sparsity);
+
+#if deal_II_dimension < 3
+ template void
+ DoFTools::make_boundary_sparsity_pattern<hp::DoFHandler<deal_II_dimension,deal_II_dimension+1>,SP>
+ (const hp::DoFHandler<deal_II_dimension,deal_II_dimension+1>& dof,
+ const FunctionMap<deal_II_dimension+1>::type &boundary_indicators,
+ const std::vector<types::global_dof_index> &dof_to_boundary_mapping,
+ SP &sparsity);
+ #endif
+
+ template void
+ DoFTools::make_flux_sparsity_pattern<DoFHandler<deal_II_dimension>,SP>
+ (const DoFHandler<deal_II_dimension> &dof,
+ SP &sparsity);
+
+ template void
+ DoFTools::make_flux_sparsity_pattern<hp::DoFHandler<deal_II_dimension>,SP>
+ (const hp::DoFHandler<deal_II_dimension> &dof,
+ SP &sparsity);
+
+#if deal_II_dimension > 1
+
+ template void
+ DoFTools::make_flux_sparsity_pattern<DoFHandler<deal_II_dimension>,SP>
+ (const DoFHandler<deal_II_dimension> &dof,
+ SP &,
+ const Table<2,Coupling>&,
+ const Table<2,Coupling>&);
+
+ template void
+ DoFTools::make_flux_sparsity_pattern<DoFHandler<deal_II_dimension>,SP>
+ (const DoFHandler<deal_II_dimension> &dof,
+ SP &sparsity,
+ const ConstraintMatrix &constraints,
+ const bool, const unsigned int);
+
+ template void
+ DoFTools::make_flux_sparsity_pattern<hp::DoFHandler<deal_II_dimension>,SP>
+ (const hp::DoFHandler<deal_II_dimension> &dof,
+ SP &sparsity,
+ const ConstraintMatrix &constraints,
+ const bool, const unsigned int);
+
+ template void
+ DoFTools::make_flux_sparsity_pattern<hp::DoFHandler<deal_II_dimension>,SP>
+ (const hp::DoFHandler<deal_II_dimension> &dof,
+ SP &,
+ const Table<2,Coupling>&,
+ const Table<2,Coupling>&);
+#endif
+
+#if deal_II_dimension < 3
+
+ template void
+ DoFTools::make_sparsity_pattern<DoFHandler<deal_II_dimension,deal_II_dimension+1>, SP>
+ (const DoFHandler<deal_II_dimension,deal_II_dimension+1> &dof,
+ SP &sparsity,
+ const ConstraintMatrix &,
+ const bool,
+ const unsigned int);
+
+ template void
+ DoFTools::make_sparsity_pattern<hp::DoFHandler<deal_II_dimension,deal_II_dimension+1>, SP>
+ (const hp::DoFHandler<deal_II_dimension,deal_II_dimension+1> &dof,
+ SP &sparsity,
+ const ConstraintMatrix &,
+ const bool,
+ const unsigned int);
+
+ template void
+ DoFTools::make_sparsity_pattern<DoFHandler<deal_II_dimension,deal_II_dimension+1>, SP>
+ (const DoFHandler<deal_II_dimension,deal_II_dimension+1>&,
+ const Table<2,Coupling>&,
+ SP &,
+ const ConstraintMatrix &,
+ const bool,
+ const unsigned int);
+
+ template void
+ DoFTools::make_sparsity_pattern<hp::DoFHandler<deal_II_dimension,deal_II_dimension+1>, SP>
+ (const hp::DoFHandler<deal_II_dimension,deal_II_dimension+1>&,
+ const Table<2,Coupling>&,
+ SP &,
+ const ConstraintMatrix &,
+ const bool,
+ const unsigned int);
+
+ template void
+ DoFTools::make_sparsity_pattern<DoFHandler<deal_II_dimension,deal_II_dimension+1>, SP>
+ (const DoFHandler<deal_II_dimension,deal_II_dimension+1> &dof_row,
+ const DoFHandler<deal_II_dimension,deal_II_dimension+1> &dof_col,
+ SP &sparsity);
+
+ template void
+ DoFTools::make_sparsity_pattern<hp::DoFHandler<deal_II_dimension,deal_II_dimension+1>, SP>
+ (const hp::DoFHandler<deal_II_dimension,deal_II_dimension+1> &dof_row,
+ const hp::DoFHandler<deal_II_dimension,deal_II_dimension+1> &dof_col,
+ SP &sparsity);
+
+ template void
+ DoFTools::make_boundary_sparsity_pattern<DoFHandler<deal_II_dimension,deal_II_dimension+1>,SP>
+ (const DoFHandler<deal_II_dimension,deal_II_dimension+1>& dof,
+ const std::vector<types::global_dof_index> &,
+ SP &);
+
+ //template void
+ //DoFTools::make_boundary_sparsity_pattern<hp::DoFHandler<deal_II_dimension,deal_II_dimension+1>,SP>
+ //(const hp::DoFHandler<deal_II_dimension,deal_II_dimension+1>& dof,
+ // const std::vector<types::global_dof_index> &,
+ // SP &);
+
+ template void
+ DoFTools::make_boundary_sparsity_pattern<DoFHandler<deal_II_dimension,deal_II_dimension+1>,SP>
+ (const DoFHandler<deal_II_dimension,deal_II_dimension+1>& dof,
+ const FunctionMap<deal_II_dimension+1>::type &boundary_indicators,
+ const std::vector<types::global_dof_index> &dof_to_boundary_mapping,
+ SP &sparsity);
+
+ //template void
+ //DoFTools::make_boundary_sparsity_pattern<hp::DoFHandler<deal_II_dimension,deal_II_dimension+1>,SP>
+ //(const hp::DoFHandler<deal_II_dimension,deal_II_dimension+1>& dof,
+ // const FunctionMap<deal_II_dimension+1>::type &boundary_indicators,
+ // const std::vector<types::global_dof_index> &dof_to_boundary_mapping,
+ // SP &sparsity);
+
+#endif
+
+
+#if deal_II_dimension == 3
+
+ template void
+ DoFTools::make_sparsity_pattern<DoFHandler<1,3>, SP>
+ (const DoFHandler<1,3> &dof,
+ SP &sparsity,
+ const ConstraintMatrix &,
+ const bool,
+ const unsigned int);
+
+ template void
+ DoFTools::make_sparsity_pattern<hp::DoFHandler<1,3>, SP>
+ (const hp::DoFHandler<1,3> &dof,
+ SP &sparsity,
+ const ConstraintMatrix &,
+ const bool,
+ const unsigned int);
+
+ template void
+ DoFTools::make_sparsity_pattern<DoFHandler<1,3>, SP>
+ (const DoFHandler<1,3>&,
+ const Table<2,Coupling>&,
+ SP &,
+ const ConstraintMatrix &,
+ const bool,
+ const unsigned int);
+
+ template void
+ DoFTools::make_sparsity_pattern<hp::DoFHandler<1,3>, SP>
+ (const hp::DoFHandler<1,3>&,
+ const Table<2,Coupling>&,
+ SP &,
+ const ConstraintMatrix &,
+ const bool,
+ const unsigned int);
+
+ template void
+ DoFTools::make_sparsity_pattern<DoFHandler<1,3>, SP>
+ (const DoFHandler<1,3> &dof_row,
+ const DoFHandler<1,3> &dof_col,
+ SP &sparsity);
+
+ template void
+ DoFTools::make_sparsity_pattern<hp::DoFHandler<1,3>, SP>
+ (const hp::DoFHandler<1,3> &dof_row,
+ const hp::DoFHandler<1,3> &dof_col,
+ SP &sparsity);
+
+ template void
+ DoFTools::make_boundary_sparsity_pattern<DoFHandler<1,3>,SP>
+ (const DoFHandler<1,3>& dof,
+ const std::vector<types::global_dof_index> &,
+ SP &);
+
+ template void
+ DoFTools::make_boundary_sparsity_pattern<hp::DoFHandler<1,3>,SP>
+ (const hp::DoFHandler<1,3>& dof,
+ const std::vector<types::global_dof_index> &,
+ SP &);
+
+ template void
+ DoFTools::make_boundary_sparsity_pattern<DoFHandler<1,3>,SP>
+ (const DoFHandler<1,3>& dof,
+ const FunctionMap<3>::type &boundary_indicators,
+ const std::vector<types::global_dof_index> &dof_to_boundary_mapping,
+ SP &sparsity);
+
+ template void
+ DoFTools::make_boundary_sparsity_pattern<hp::DoFHandler<1,3>,SP>
+ (const hp::DoFHandler<1,3>& dof,
+ const FunctionMap<3>::type &boundary_indicators,
+ const std::vector<types::global_dof_index> &dof_to_boundary_mapping,
+ SP &sparsity);
+
+#endif
+
+ }
+
+
+for (deal_II_dimension : DIMENSIONS)
+{
+ template
+ Table<2,DoFTools::Coupling>
+ DoFTools::dof_couplings_from_component_couplings
+ (const FiniteElement<deal_II_dimension> &fe,
+ const Table<2,DoFTools::Coupling> &component_couplings);
+}
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/memory_consumption.h>
#include <deal.II/dofs/number_cache.h>
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+/*
+ * Workaround for a bug in the Xcode generator.
+ *
+ * This file contains a dummy global symbol to trigger the link phase in
+ * the generated Xcode project.
+ */
+
+const int _global_symbol_42 = 42;
+
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
-FILE(GLOB _header
- ${CMAKE_SOURCE_DIR}/include/deal.II/fe/*.h
- )
-
SET(_src
block_mask.cc
component_mask.cc
fe_nothing.cc
fe_poly.cc
fe_poly_tensor.cc
- fe_q.cc
fe_q_base.cc
+ fe_q.cc
fe_q_dg0.cc
fe_q_hierarchical.cc
fe_q_iso_q1.cc
fe_raviart_thomas_nodal.cc
fe_system.cc
fe_tools.cc
+ fe_tools_interpolate.cc
fe_values.cc
fe_values_inst2.cc
mapping_c1.cc
fe_nothing.inst.in
fe_poly.inst.in
fe_poly_tensor.inst.in
- fe_q_base.inst.in
+ fe_q_base.inst.in
fe_q_dg0.inst.in
fe_q_hierarchical.inst.in
fe_q.inst.in
fe_raviart_thomas_nodal.inst.in
fe_system.inst.in
fe_tools.inst.in
+ fe_tools_interpolate.inst.in
fe_values.decl.1.inst.in
fe_values.decl.2.inst.in
fe_values.impl.1.inst.in
mapping_q.inst.in
)
+FILE(GLOB _header
+ ${CMAKE_SOURCE_DIR}/include/deal.II/fe/*.h
+ )
+
DEAL_II_ADD_LIBRARY(obj_fe OBJECT ${_src} ${_header} ${_inst})
EXPAND_INSTANTIATIONS(obj_fe "${_inst}")
-
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2012 by the deal.II authors
+// Copyright (C) 2012 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/fe/block_mask.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2012 by the deal.II authors
+// Copyright (C) 2012 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/fe/component_mask.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/memory_consumption.h>
#include <deal.II/fe/mapping.h>
system_to_component_table.resize(this->dofs_per_cell);
face_system_to_component_table.resize(this->dofs_per_face);
for (unsigned int j=0 ; j<this->dofs_per_cell ; ++j)
- {
- system_to_component_table[j] = std::pair<unsigned,unsigned>(0,j);
- system_to_base_table[j] = std::make_pair(std::make_pair(0U,0U),j);
- }
+ system_to_component_table[j] = std::pair<unsigned,unsigned>(0,j);
for (unsigned int j=0 ; j<this->dofs_per_face ; ++j)
- {
- face_system_to_component_table[j] = std::pair<unsigned,unsigned>(0,j);
- face_system_to_base_table[j] = std::make_pair(std::make_pair(0U,0U),j);
- }
+ face_system_to_component_table[j] = std::pair<unsigned,unsigned>(0,j);
}
+
+ for (unsigned int j=0 ; j<this->dofs_per_cell ; ++j)
+ system_to_base_table[j] = std::make_pair(std::make_pair(0U,0U),j);
+ for (unsigned int j=0 ; j<this->dofs_per_face ; ++j)
+ face_system_to_base_table[j] = std::make_pair(std::make_pair(0U,0U),j);
+
// Fill with default value; may be changed by constructor of derived class.
base_to_block_indices.reinit(1,1);
+template <int dim, int spacedim>
+unsigned int
+FiniteElement<dim,spacedim>::
+face_to_cell_index (const unsigned int face_index,
+ const unsigned int face,
+ const bool face_orientation,
+ const bool face_flip,
+ const bool face_rotation) const
+{
+ Assert (face_index < this->dofs_per_face,
+ ExcIndexRange(face_index, 0, this->dofs_per_face));
+ Assert (face < GeometryInfo<dim>::faces_per_cell,
+ ExcIndexRange(face, 0, GeometryInfo<dim>::faces_per_cell));
+
+//TODO: we could presumably solve the 3d case below using the
+// adjust_quad_dof_index_for_face_orientation_table field. for the
+// 2d case, we can't use adjust_line_dof_index_for_line_orientation_table
+// since that array is empty (presumably because we thought that
+// there are no flipped edges in 2d, but these can happen in
+// DoFTools::make_periodicity_constraints, for example). so we
+// would need to either fill this field, or rely on derived classes
+// implementing this function, as we currently do
+
+ // see the function's documentation for an explanation of this
+ // assertion -- in essence, derived classes have to implement
+ // an overloaded version of this function if we are to use any
+ // other than standard orientation
+ if ((face_orientation != true) || (face_flip != false) || (face_rotation != false))
+ Assert ((this->dofs_per_line <= 1) && (this->dofs_per_quad <= 1),
+ ExcMessage ("The function in this base class can not handle this case. "
+ "Rather, the derived class you are using must provide "
+ "an overloaded version but apparently hasn't done so. See "
+ "the documentation of this function for more information."));
+
+ // we need to distinguish between DoFs on vertices, lines and in 3d quads.
+ // do so in a sequence of if-else statements
+ if (face_index < this->first_face_line_index)
+ // DoF is on a vertex
+ {
+ // get the number of the vertex on the face that corresponds to this DoF,
+ // along with the number of the DoF on this vertex
+ const unsigned int face_vertex = face_index / this->dofs_per_vertex;
+ const unsigned int dof_index_on_vertex = face_index % this->dofs_per_vertex;
+
+ // then get the number of this vertex on the cell and translate
+ // this to a DoF number on the cell
+ return (GeometryInfo<dim>::face_to_cell_vertices(face, face_vertex,
+ face_orientation,
+ face_flip,
+ face_rotation)
+ * this->dofs_per_vertex
+ +
+ dof_index_on_vertex);
+ }
+ else if (face_index < this->first_face_quad_index)
+ // DoF is on a face
+ {
+ // do the same kind of translation as before. we need to only consider
+ // DoFs on the lines, i.e., ignoring those on the vertices
+ const unsigned int index = face_index - this->first_face_line_index;
+
+ const unsigned int face_line = index / this->dofs_per_line;
+ const unsigned int dof_index_on_line = index % this->dofs_per_line;
+
+ return (this->first_line_index
+ + GeometryInfo<dim>::face_to_cell_lines(face, face_line,
+ face_orientation,
+ face_flip,
+ face_rotation)
+ * this->dofs_per_line
+ +
+ dof_index_on_line);
+ }
+ else
+ // DoF is on a quad
+ {
+ Assert (dim >= 3, ExcInternalError());
+
+ // ignore vertex and line dofs
+ const unsigned int index = face_index - this->first_face_quad_index;
+
+ return (this->first_quad_index
+ + face * this->dofs_per_quad
+ + index);
+ }
+}
+
+
+
+
template <int dim, int spacedim>
unsigned int
FiniteElement<dim,spacedim>::adjust_quad_dof_index_for_face_orientation (const unsigned int index,
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/utilities.h>
#include <deal.II/base/quadrature.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/quadrature_lib.h>
#include <deal.II/base/qprojector.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/geometry_info.h>
#include <deal.II/fe/fe.h>
(conforming_space == f.conforming_space));
}
-template<int dim>
-unsigned int
-FiniteElementData<dim>::
-face_to_cell_index (const unsigned int face_index,
- const unsigned int face,
- const bool face_orientation,
- const bool face_flip,
- const bool face_rotation) const
-{
- Assert (face_index < this->dofs_per_face,
- ExcIndexRange(face_index, 0, this->dofs_per_face));
- Assert (face < GeometryInfo<dim>::faces_per_cell,
- ExcIndexRange(face, 0, GeometryInfo<dim>::faces_per_cell));
-
- // DoF on a vertex
- if (face_index < this->first_face_line_index)
- {
- // Vertex number on the face
- const unsigned int face_vertex = face_index / this->dofs_per_vertex;
- return face_index % this->dofs_per_vertex
- + GeometryInfo<dim>::face_to_cell_vertices(face, face_vertex,
- face_orientation,
- face_flip,
- face_rotation)
- * this->dofs_per_vertex;
- }
- // Else, DoF on a line?
- if (face_index < this->first_face_quad_index)
- {
- // Ignore vertex dofs
- const unsigned int index = face_index - this->first_face_line_index;
- // Line number on the face
- const unsigned int face_line = index / this->dofs_per_line;
- return this->first_line_index + index % this->dofs_per_line
- + GeometryInfo<dim>::face_to_cell_lines(face, face_line,
- face_orientation,
- face_flip,
- face_rotation)
- * this->dofs_per_line;
- }
- // Else, DoF is on a quad
-
- // Ignore vertex and line dofs
- const unsigned int index = face_index - this->first_face_quad_index;
- return this->first_quad_index + index
- + face * this->dofs_per_quad;
-}
-
template class FiniteElementData<1>;
template class FiniteElementData<2>;
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/fe/fe_dg_vector.templates.h>
#include <deal.II/base/polynomials_abf.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2011, 2012 by the deal.II authors
+// Copyright (C) 2002 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/fe/fe_dgp.h>
#include <deal.II/fe/fe_tools.h>
std::vector<ComponentMask>(FiniteElementData<dim>(
get_dpo_vector(degree), 1, degree).dofs_per_cell, std::vector<bool>(1,true)))
{
- // Reinit the vectors of
- // restriction and prolongation
- // matrices to the right sizes
+ // Reinit the vectors of restriction and prolongation matrices to the right
+ // sizes
this->reinit_restriction_and_prolongation_matrices();
// Fill prolongation matrices with embedding operators
if (dim == spacedim)
std::string
FE_DGP<dim,spacedim>::get_name () const
{
- // note that the
- // FETools::get_fe_from_name
- // function depends on the
- // particular format of the string
- // this function returns, so they
- // have to be kept in synch
+ // note that the FETools::get_fe_from_name function depends on the
+ // particular format of the string this function returns, so they have to be
+ // kept in synch
std::ostringstream namebuf;
namebuf << "FE_DGP<" << dim << ">(" << this->degree << ")";
get_face_interpolation_matrix (const FiniteElement<dim,spacedim> &x_source_fe,
FullMatrix<double> &interpolation_matrix) const
{
- // this is only implemented, if the source
- // FE is also a DGP element. in that case,
- // both elements have no dofs on their
- // faces and the face interpolation matrix
- // is necessarily empty -- i.e. there isn't
- // much we need to do here.
+ // this is only implemented, if the source FE is also a DGP element. in that
+ // case, both elements have no dofs on their faces and the face
+ // interpolation matrix is necessarily empty -- i.e. there isn't much we
+ // need to do here.
typedef FiniteElement<dim,spacedim> FE;
typedef FE_DGP<dim,spacedim> FEDGP;
AssertThrow ((x_source_fe.get_name().find ("FE_DGP<") == 0)
const unsigned int ,
FullMatrix<double> &interpolation_matrix) const
{
- // this is only implemented, if the source
- // FE is also a DGP element. in that case,
- // both elements have no dofs on their
- // faces and the face interpolation matrix
- // is necessarily empty -- i.e. there isn't
- // much we need to do here.
+ // this is only implemented, if the source FE is also a DGP element. in that
+ // case, both elements have no dofs on their faces and the face
+ // interpolation matrix is necessarily empty -- i.e. there isn't much we
+ // need to do here.
typedef FiniteElement<dim,spacedim> FE;
typedef FE_DGP<dim,spacedim> FEDGP;
AssertThrow ((x_source_fe.get_name().find ("FE_DGP<") == 0)
FE_DGP<dim,spacedim>::
hp_vertex_dof_identities (const FiniteElement<dim,spacedim> &fe_other) const
{
- // there are no such constraints for DGP
- // elements at all
+ // there are no such constraints for DGP elements at all
if (dynamic_cast<const FE_DGP<dim,spacedim>*>(&fe_other) != 0)
return
std::vector<std::pair<unsigned int, unsigned int> > ();
FE_DGP<dim,spacedim>::
hp_line_dof_identities (const FiniteElement<dim,spacedim> &fe_other) const
{
- // there are no such constraints for DGP
- // elements at all
+ // there are no such constraints for DGP elements at all
if (dynamic_cast<const FE_DGP<dim,spacedim>*>(&fe_other) != 0)
return
std::vector<std::pair<unsigned int, unsigned int> > ();
FE_DGP<dim,spacedim>::
hp_quad_dof_identities (const FiniteElement<dim,spacedim> &fe_other) const
{
- // there are no such constraints for DGP
- // elements at all
+ // there are no such constraints for DGP elements at all
if (dynamic_cast<const FE_DGP<dim,spacedim>*>(&fe_other) != 0)
return
std::vector<std::pair<unsigned int, unsigned int> > ();
FiniteElementDomination::Domination
FE_DGP<dim,spacedim>::compare_for_face_domination (const FiniteElement<dim,spacedim> &fe_other) const
{
- // check whether both are discontinuous
- // elements, see the description of
+ // check whether both are discontinuous elements, see the description of
// FiniteElementDomination::Domination
if (dynamic_cast<const FE_DGP<dim,spacedim>*>(&fe_other) != 0)
return FiniteElementDomination::no_requirements;
FE_DGP<dim,spacedim>::has_support_on_face (const unsigned int,
const unsigned int) const
{
- // all shape functions have support on all
- // faces
+ // all shape functions have support on all faces
return true;
}
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/fe/fe_dgp_monomial.h>
#include <deal.II/fe/fe_tools.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 by the deal.II authors
+// Copyright (C) 2002 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/quadrature.h>
#include <deal.II/grid/tria.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/quadrature.h>
#include <deal.II/base/quadrature_lib.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2011, 2012 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/fe/fe_face.h>
#include <deal.II/fe/fe_poly_face.templates.h>
+#include <deal.II/fe/fe_nothing.h>
+#include <deal.II/fe/fe_tools.h>
+#include <deal.II/base/quadrature_lib.h>
+#include <deal.II/lac/householder.h>
#include <sstream>
DEAL_II_NAMESPACE_OPEN
+
+namespace
+{
+ std::vector<Point<1> >
+ get_QGaussLobatto_points (const unsigned int degree)
+ {
+ if (degree > 0)
+ return QGaussLobatto<1>(degree+1).get_points();
+ else
+ return std::vector<Point<1> >(1, Point<1>(0.5));
+ }
+}
+
template <int dim, int spacedim>
FE_FaceQ<dim,spacedim>::FE_FaceQ (const unsigned int degree)
:
FE_PolyFace<TensorProductPolynomials<dim-1>, dim, spacedim> (
- TensorProductPolynomials<dim-1>(Polynomials::LagrangeEquidistant::generate_complete_basis(degree)),
+ TensorProductPolynomials<dim-1>(Polynomials::generate_complete_Lagrange_basis(get_QGaussLobatto_points(degree))),
FiniteElementData<dim>(get_dpo_vector(degree), 1, degree, FiniteElementData<dim>::L2),
std::vector<bool>(1,true))
{
this->unit_face_support_points[0][d] = 0.5;
else
{
- const double step = 1./this->degree;
- Point<codim> p;
+ std::vector<Point<1> > points = get_QGaussLobatto_points(degree);
unsigned int k=0;
for (unsigned int iz=0; iz <= ((codim>2) ? this->degree : 0) ; ++iz)
for (unsigned int iy=0; iy <= ((codim>1) ? this->degree : 0) ; ++iy)
for (unsigned int ix=0; ix<=this->degree; ++ix)
{
- p(0) = ix * step;
+ Point<codim> p;
+
+ p(0) = points[ix][0];
if (codim>1)
- p(1) = iy * step;
+ p(1) = points[iy][0];
if (codim>2)
- p(2) = iz * step;
+ p(2) = points[iz][0];
this->unit_face_support_points[k++] = p;
}
AssertDimension (k, this->unit_face_support_points.size());
}
+
+ // initialize unit support points (this makes it possible to assign initial
+ // values to FE_FaceQ)
+ this->unit_support_points.resize(GeometryInfo<dim>::faces_per_cell*
+ this->unit_face_support_points.size());
+ const unsigned int n_face_dofs = this->unit_face_support_points.size();
+ for (unsigned int i=0; i<n_face_dofs; ++i)
+ for (unsigned int d=0; d<dim; ++d)
+ {
+ for (unsigned int e=0, c=0; e<dim; ++e)
+ if (d!=e)
+ {
+ this->unit_support_points[n_face_dofs*2*d+i][e] =
+ this->unit_face_support_points[i][c];
+ this->unit_support_points[n_face_dofs*(2*d+1)+i][e] =
+ this->unit_face_support_points[i][c];
+ this->unit_support_points[n_face_dofs*(2*d+1)+i][d] = 1;
+ ++c;
+ }
+ }
}
+
template <int dim, int spacedim>
FiniteElement<dim,spacedim> *
FE_FaceQ<dim,spacedim>::clone() const
}
+
template <int dim, int spacedim>
std::string
FE_FaceQ<dim,spacedim>::get_name () const
{
- // note that the
- // FETools::get_fe_from_name
- // function depends on the
- // particular format of the string
- // this function returns, so they
- // have to be kept in synch
-
+ // note that the FETools::get_fe_from_name function depends on the
+ // particular format of the string this function returns, so they have to be
+ // kept in synch
std::ostringstream namebuf;
namebuf << "FE_FaceQ<" << dim << ">(" << this->degree << ")";
+template <int dim, int spacedim>
+void
+FE_FaceQ<dim,spacedim>::
+get_face_interpolation_matrix (const FiniteElement<dim,spacedim> &source_fe,
+ FullMatrix<double> &interpolation_matrix) const
+{
+ get_subface_interpolation_matrix (source_fe, numbers::invalid_unsigned_int,
+ interpolation_matrix);
+}
+
+
+
+template <int dim, int spacedim>
+void
+FE_FaceQ<dim,spacedim>::
+get_subface_interpolation_matrix (const FiniteElement<dim,spacedim> &x_source_fe,
+ const unsigned int subface,
+ FullMatrix<double> &interpolation_matrix) const
+{
+ // this function is similar to the respective method in FE_Q
+
+ Assert (interpolation_matrix.n() == this->dofs_per_face,
+ ExcDimensionMismatch (interpolation_matrix.n(),
+ this->dofs_per_face));
+ Assert (interpolation_matrix.m() == x_source_fe.dofs_per_face,
+ ExcDimensionMismatch (interpolation_matrix.m(),
+ x_source_fe.dofs_per_face));
+
+ // see if source is a FaceQ element
+ if (const FE_FaceQ<dim,spacedim> *source_fe
+ = dynamic_cast<const FE_FaceQ<dim,spacedim> *>(&x_source_fe))
+ {
+
+ // Make sure that the element for which the DoFs should be constrained
+ // is the one with the higher polynomial degree. Actually the procedure
+ // will work also if this assertion is not satisfied. But the matrices
+ // produced in that case might lead to problems in the hp procedures,
+ // which use this method.
+ Assert (this->dofs_per_face <= source_fe->dofs_per_face,
+ (typename FiniteElement<dim,spacedim>::
+ ExcInterpolationNotImplemented ()));
+
+ // generate a quadrature with the unit face support points.
+ const Quadrature<dim-1> face_quadrature (source_fe->get_unit_face_support_points ());
+
+ // Rule of thumb for FP accuracy, that can be expected for a given
+ // polynomial degree. This value is used to cut off values close to
+ // zero.
+ const double eps = 2e-13*(this->degree+1)*(dim-1);
+
+ // compute the interpolation matrix by simply taking the value at the
+ // support points.
+ for (unsigned int i=0; i<source_fe->dofs_per_face; ++i)
+ {
+ const Point<dim-1> p =
+ subface == numbers::invalid_unsigned_int
+ ?
+ face_quadrature.point(i)
+ :
+ GeometryInfo<dim-1>::child_to_cell_coordinates (face_quadrature.point(i),
+ subface);
+
+ for (unsigned int j=0; j<this->dofs_per_face; ++j)
+ {
+ double matrix_entry = this->poly_space.compute_value (j, p);
+
+ // Correct the interpolated value. I.e. if it is close to 1 or 0,
+ // make it exactly 1 or 0. Unfortunately, this is required to avoid
+ // problems with higher order elements.
+ if (std::fabs (matrix_entry - 1.0) < eps)
+ matrix_entry = 1.0;
+ if (std::fabs (matrix_entry) < eps)
+ matrix_entry = 0.0;
+
+ interpolation_matrix(i,j) = matrix_entry;
+ }
+ }
+
+ // make sure that the row sum of each of the matrices is 1 at this
+ // point. this must be so since the shape functions sum up to 1
+ for (unsigned int j=0; j<source_fe->dofs_per_face; ++j)
+ {
+ double sum = 0.;
+
+ for (unsigned int i=0; i<this->dofs_per_face; ++i)
+ sum += interpolation_matrix(j,i);
+
+ Assert (std::fabs(sum-1) < eps, ExcInternalError());
+ }
+ }
+ else if (dynamic_cast<const FE_Nothing<dim> *>(&x_source_fe) != 0)
+ {
+ // nothing to do here, the FE_Nothing has no degrees of freedom anyway
+ }
+ else
+ AssertThrow (false,(typename FiniteElement<dim,spacedim>::
+ ExcInterpolationNotImplemented()));
+}
+
+
+
template <int dim, int spacedim>
bool
FE_FaceQ<dim,spacedim>::has_support_on_face (
}
+
template <int dim, int spacedim>
std::vector<unsigned int>
FE_FaceQ<dim,spacedim>::get_dpo_vector (const unsigned int deg)
+template <int dim, int spacedim>
+bool
+FE_FaceQ<dim,spacedim>::hp_constraints_are_implemented () const
+{
+ return true;
+}
+
+
+
+template <int dim, int spacedim>
+FiniteElementDomination::Domination
+FE_FaceQ<dim,spacedim>::
+compare_for_face_domination (const FiniteElement<dim,spacedim> &fe_other) const
+{
+ if (const FE_FaceQ<dim,spacedim> *fe_q_other
+ = dynamic_cast<const FE_FaceQ<dim,spacedim>*>(&fe_other))
+ {
+ if (this->degree < fe_q_other->degree)
+ return FiniteElementDomination::this_element_dominates;
+ else if (this->degree == fe_q_other->degree)
+ return FiniteElementDomination::either_element_can_dominate;
+ else
+ return FiniteElementDomination::other_element_dominates;
+ }
+ else if (dynamic_cast<const FE_Nothing<dim>*>(&fe_other) != 0)
+ {
+ // the FE_Nothing has no degrees of freedom and it is typically used in
+ // a context where we don't require any continuity along the interface
+ return FiniteElementDomination::no_requirements;
+ }
+
+ Assert (false, ExcNotImplemented());
+ return FiniteElementDomination::neither_element_dominates;
+}
+
+
+
+// --------------------------------------- FE_FaceP --------------------------
+
+template <int dim, int spacedim>
+FE_FaceP<dim,spacedim>::FE_FaceP (const unsigned int degree)
+ :
+ FE_PolyFace<PolynomialSpace<dim-1>, dim, spacedim>
+ (PolynomialSpace<dim-1>(Polynomials::Legendre::generate_complete_basis(degree)),
+ FiniteElementData<dim>(get_dpo_vector(degree), 1, degree, FiniteElementData<dim>::L2),
+ std::vector<bool>(1,true))
+{}
+
+
+template <int dim, int spacedim>
+FiniteElement<dim,spacedim> *
+FE_FaceP<dim,spacedim>::clone() const
+{
+ return new FE_FaceP<dim,spacedim>(this->degree);
+}
+
+
+template <int dim, int spacedim>
+std::string
+FE_FaceP<dim,spacedim>::get_name () const
+{
+ // note that the FETools::get_fe_from_name function depends on the
+ // particular format of the string this function returns, so they have to be
+ // kept in synch
+ std::ostringstream namebuf;
+ namebuf << "FE_FaceP<" << dim << ">(" << this->degree << ")";
+
+ return namebuf.str();
+}
+
+
+
+template <int dim, int spacedim>
+bool
+FE_FaceP<dim,spacedim>::has_support_on_face (
+ const unsigned int shape_index,
+ const unsigned int face_index) const
+{
+ return (face_index == (shape_index/this->dofs_per_face));
+}
+
+
+
+template <int dim, int spacedim>
+std::vector<unsigned int>
+FE_FaceP<dim,spacedim>::get_dpo_vector (const unsigned int deg)
+{
+ std::vector<unsigned int> dpo(dim+1, 0U);
+ dpo[dim-1] = deg+1;
+ for (unsigned int i=1; i<dim-1; ++i)
+ {
+ dpo[dim-1] *= deg+1+i;
+ dpo[dim-1] /= i+1;
+ }
+ return dpo;
+}
+
+
+
+
+template <int dim, int spacedim>
+bool
+FE_FaceP<dim,spacedim>::hp_constraints_are_implemented () const
+{
+ return true;
+}
+
+
+
+template <int dim, int spacedim>
+FiniteElementDomination::Domination
+FE_FaceP<dim,spacedim>::
+compare_for_face_domination (const FiniteElement<dim,spacedim> &fe_other) const
+{
+ if (const FE_FaceP<dim,spacedim> *fe_q_other
+ = dynamic_cast<const FE_FaceP<dim,spacedim>*>(&fe_other))
+ {
+ if (this->degree < fe_q_other->degree)
+ return FiniteElementDomination::this_element_dominates;
+ else if (this->degree == fe_q_other->degree)
+ return FiniteElementDomination::either_element_can_dominate;
+ else
+ return FiniteElementDomination::other_element_dominates;
+ }
+ else if (dynamic_cast<const FE_Nothing<dim>*>(&fe_other) != 0)
+ {
+ // the FE_Nothing has no degrees of freedom and it is typically used in
+ // a context where we don't require any continuity along the interface
+ return FiniteElementDomination::no_requirements;
+ }
+
+ Assert (false, ExcNotImplemented());
+ return FiniteElementDomination::neither_element_dominates;
+}
+
+
+
+
+template <int dim, int spacedim>
+void
+FE_FaceP<dim,spacedim>::
+get_face_interpolation_matrix (const FiniteElement<dim,spacedim> &source_fe,
+ FullMatrix<double> &interpolation_matrix) const
+{
+ get_subface_interpolation_matrix (source_fe, numbers::invalid_unsigned_int,
+ interpolation_matrix);
+}
+
+
+
+template <int dim, int spacedim>
+void
+FE_FaceP<dim,spacedim>::
+get_subface_interpolation_matrix (const FiniteElement<dim,spacedim> &x_source_fe,
+ const unsigned int subface,
+ FullMatrix<double> &interpolation_matrix) const
+{
+ // this function is similar to the respective method in FE_Q
+
+ Assert (interpolation_matrix.n() == this->dofs_per_face,
+ ExcDimensionMismatch (interpolation_matrix.n(),
+ this->dofs_per_face));
+ Assert (interpolation_matrix.m() == x_source_fe.dofs_per_face,
+ ExcDimensionMismatch (interpolation_matrix.m(),
+ x_source_fe.dofs_per_face));
+
+ // see if source is a FaceP element
+ if (const FE_FaceP<dim,spacedim> *source_fe
+ = dynamic_cast<const FE_FaceP<dim,spacedim> *>(&x_source_fe))
+ {
+ // Make sure that the element for which the DoFs should be constrained
+ // is the one with the higher polynomial degree. Actually the procedure
+ // will work also if this assertion is not satisfied. But the matrices
+ // produced in that case might lead to problems in the hp procedures,
+ // which use this method.
+ Assert (this->dofs_per_face <= source_fe->dofs_per_face,
+ (typename FiniteElement<dim,spacedim>::
+ ExcInterpolationNotImplemented ()));
+
+ // do this as in FETools by solving a least squares problem where we
+ // force the source FE polynomial to be equal the given FE on all
+ // quadrature points
+ const QGauss<dim-1> face_quadrature (source_fe->degree+1);
+
+ // Rule of thumb for FP accuracy, that can be expected for a given
+ // polynomial degree. This value is used to cut off values close to
+ // zero.
+ const double eps = 2e-13*(this->degree+1)*(dim-1);
+
+ FullMatrix<double> mass (face_quadrature.size(), source_fe->dofs_per_face);
+
+ for (unsigned int k = 0; k < face_quadrature.size(); ++k)
+ {
+ const Point<dim-1> p =
+ subface == numbers::invalid_unsigned_int ?
+ face_quadrature.point(k) :
+ GeometryInfo<dim-1>::child_to_cell_coordinates (face_quadrature.point(k),
+ subface);
+
+ for (unsigned int j = 0; j < source_fe->dofs_per_face; ++j)
+ mass (k , j) = source_fe->poly_space.compute_value(j, p);
+ }
+
+ Householder<double> H(mass);
+ Vector<double> v_in(face_quadrature.size());
+ Vector<double> v_out(source_fe->dofs_per_face);
+
+
+ // compute the interpolation matrix by evaluating on the fine side and
+ // then solving the least squares problem
+ for (unsigned int i=0; i<this->dofs_per_face; ++i)
+ {
+ for (unsigned int k = 0; k < face_quadrature.size(); ++k)
+ {
+ const Point<dim-1> p = numbers::invalid_unsigned_int ?
+ face_quadrature.point(k) :
+ GeometryInfo<dim-1>::child_to_cell_coordinates (face_quadrature.point(k),
+ subface);
+ v_in(k) = this->poly_space.compute_value(i, p);
+ }
+ const double result = H.least_squares(v_out, v_in);
+ Assert(result < 1e-12, FETools::ExcLeastSquaresError (result));
+
+ for (unsigned int j = 0; j < source_fe->dofs_per_face; ++j)
+ {
+ double matrix_entry = v_out(j);
+
+ // Correct the interpolated value. I.e. if it is close to 1 or 0,
+ // make it exactly 1 or 0. Unfortunately, this is required to avoid
+ // problems with higher order elements.
+ if (std::fabs (matrix_entry - 1.0) < eps)
+ matrix_entry = 1.0;
+ if (std::fabs (matrix_entry) < eps)
+ matrix_entry = 0.0;
+
+ interpolation_matrix(j,i) = matrix_entry;
+ }
+ }
+ }
+ else if (dynamic_cast<const FE_Nothing<dim> *>(&x_source_fe) != 0)
+ {
+ // nothing to do here, the FE_Nothing has no degrees of freedom anyway
+ }
+ else
+ AssertThrow (false,(typename FiniteElement<dim,spacedim>::
+ ExcInterpolationNotImplemented()));
+}
+
+
// explicit instantiations
#include "fe_face.inst"
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
{
#if deal_II_dimension > 1
template class FE_PolyFace<TensorProductPolynomials<deal_II_dimension-1> >;
- //template class FE_PolyFace<PolynomialSpace<deal_II_dimension>, deal_II_dimension>;
+ template class FE_PolyFace<PolynomialSpace<deal_II_dimension-1>, deal_II_dimension>;
//template class FE_PolyFace<PolynomialsP<deal_II_dimension>, deal_II_dimension>;
template class FE_FaceQ<deal_II_dimension>;
+ template class FE_FaceP<deal_II_dimension>;
#endif
}
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/logstream.h>
#include <deal.II/base/utilities.h>
#include <deal.II/base/quadrature.h>
// Initialize quadratures to obtain
// quadrature points later on.
const QGauss<dim - 1> reference_edge_quadrature (degree + 1);
- const unsigned int&
+ const unsigned int &
n_edge_points = reference_edge_quadrature.size ();
const unsigned int n_boundary_points
= GeometryInfo<dim>::lines_per_cell * n_edge_points;
const QGauss<1> edge_quadrature (2 * this->degree);
const std::vector<Point<1> > &edge_quadrature_points
= edge_quadrature.get_points ();
- const unsigned int&
+ const unsigned int &
n_edge_quadrature_points = edge_quadrature.size ();
const unsigned int
index = RefinementCase<dim>::isotropic_refinement - 1;
{
const QGauss<1>
reference_edge_quadrature (this->degree);
- const unsigned int&
+ const unsigned int &
n_edge_points = reference_edge_quadrature.size ();
// Let us begin with the
// the interior shape
// functions.
const QGauss<dim> reference_quadrature (this->degree);
- const unsigned int&
+ const unsigned int &
n_interior_points = reference_quadrature.size ();
// We create the
// Let us begin with the
// interpolation part.
const QGauss<dim - 1> reference_edge_quadrature (this->degree);
- const unsigned int&
+ const unsigned int &
n_edge_points = reference_edge_quadrature.size ();
for (unsigned int i = 0; i < 2; ++i)
// vertical, interior
// shape functions.
const QGauss<dim> reference_quadrature (this->degree);
- const unsigned int&
+ const unsigned int &
n_interior_points = reference_quadrature.size ();
const std::vector<Polynomials::Polynomial<double> > &
legendre_polynomials
// Let us begin with the
// interpolation part.
const QGauss<1> reference_edge_quadrature (this->degree);
- const unsigned int&
+ const unsigned int &
n_edge_points = reference_edge_quadrature.size ();
for (unsigned int q_point = 0; q_point < n_edge_points; ++q_point)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2011, 2012 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/fe/fe_nothing.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/qprojector.h>
#include <deal.II/base/tensor_product_polynomials.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/derivative_form.h>
#include <deal.II/base/qprojector.h>
* given cell.
*/
void
- get_face_sign_change (const Triangulation<1>::cell_iterator &,
- const unsigned int ,
- std::vector<double> &face_sign)
+ get_face_sign_change_rt (const Triangulation<1>::cell_iterator &,
+ const unsigned int ,
+ std::vector<double> &face_sign)
{
// nothing to do in 1d
std::fill (face_sign.begin (), face_sign.end (), 1.0);
void
- get_face_sign_change (const Triangulation<2>::cell_iterator &cell,
- const unsigned int dofs_per_face,
- std::vector<double> &face_sign)
+ get_face_sign_change_rt (const Triangulation<2>::cell_iterator &cell,
+ const unsigned int dofs_per_face,
+ std::vector<double> &face_sign)
{
const unsigned int dim = 2;
const unsigned int spacedim = 2;
void
- get_face_sign_change (const Triangulation<3>::cell_iterator &/*cell*/,
- const unsigned int /*dofs_per_face*/,
- std::vector<double> &face_sign)
+ get_face_sign_change_rt (const Triangulation<3>::cell_iterator &cell,
+ const unsigned int dofs_per_face,
+ std::vector<double> &face_sign)
+ {
+ std::fill (face_sign.begin (), face_sign.end (), 1.0);
+//TODO: think about what it would take here
+ }
+
+ void
+ get_face_sign_change_nedelec (const Triangulation<1>::cell_iterator &,
+ const unsigned int ,
+ std::vector<double> &face_sign)
+ {
+ // nothing to do in 1d
+ std::fill (face_sign.begin (), face_sign.end (), 1.0);
+ }
+
+
+
+ void
+ get_face_sign_change_nedelec (const Triangulation<2>::cell_iterator &cell,
+ const unsigned int dofs_per_face,
+ std::vector<double> &face_sign)
{
std::fill (face_sign.begin (), face_sign.end (), 1.0);
//TODO: think about what it would take here
}
+
+
+ void
+ get_face_sign_change_nedelec (const Triangulation<3>::cell_iterator &cell,
+ const unsigned int dofs_per_face,
+ std::vector<double> &face_sign)
+ {
+ const unsigned int dim = 3;
+ std::fill (face_sign.begin (), face_sign.end (), 1.0);
+//TODO: This is probably only going to work for those elements for which all dofs are face dofs
+ for (unsigned int l = 0; l < GeometryInfo<dim>::lines_per_cell; ++l)
+ if (!(cell->line_orientation (l)))
+ face_sign[l] = -1.0;
+ }
}
// Compute eventual sign changes depending on the neighborhood
// between two faces.
std::vector<double> sign_change (this->dofs_per_cell, 1.0);
- get_face_sign_change (cell, this->dofs_per_face, sign_change);
+ if (mapping_type == mapping_raviart_thomas)
+ get_face_sign_change_rt (cell, this->dofs_per_face, sign_change);
+
+ else if (mapping_type == mapping_nedelec)
+ get_face_sign_change_nedelec (cell, this->dofs_per_face, sign_change);
// for Piola mapping, the similarity
// concept cannot be used because of
// possible sign changes from one cell to
// the next.
- if ( (mapping_type == mapping_piola) || (mapping_type == mapping_raviart_thomas) )
+ if ( (mapping_type == mapping_piola) || (mapping_type == mapping_raviart_thomas)
+ || (mapping_type == mapping_nedelec))
if (cell_similarity == CellSimilarity::translation)
cell_similarity = CellSimilarity::none;
for (unsigned int k = 0; k < n_q_points; ++k)
for (unsigned int d = 0; d < dim; ++d)
- data.shape_values(first+d,k) = shape_values[k][d];
+ data.shape_values(first+d,k) = sign_change[i] * shape_values[k][d];
break;
}
for (unsigned int k = 0; k < n_q_points; ++k)
for (unsigned int d = 0; d < dim; ++d)
- data.shape_gradients[first + d][k] = shape_grads1[k][d];
- // then copy over to target:
+ data.shape_gradients[first + d][k] = sign_change[i] * shape_grads1[k][d];
break;
}
// Compute eventual sign changes depending
// on the neighborhood between two faces.
std::vector<double> sign_change (this->dofs_per_cell, 1.0);
- get_face_sign_change (cell, this->dofs_per_face, sign_change);
+
+ if (mapping_type == mapping_raviart_thomas)
+ get_face_sign_change_rt (cell, this->dofs_per_face, sign_change);
+
+ else if (mapping_type == mapping_nedelec)
+ get_face_sign_change_nedelec (cell, this->dofs_per_face, sign_change);
for (unsigned int i=0; i<this->dofs_per_cell; ++i)
{
for (unsigned int k = 0; k < n_q_points; ++k)
for (unsigned int d = 0; d < dim; ++d)
- data.shape_values(first+d,k) = shape_values[k][d];
+ data.shape_values(first+d,k) = sign_change[i] * shape_values[k][d];
break;
}
for (unsigned int k = 0; k < n_q_points; ++k)
for (unsigned int d = 0; d < dim; ++d)
- data.shape_gradients[first + d][k] = shape_grads1[k][d];
- // then copy over to target:
+ data.shape_gradients[first + d][k] = sign_change[i] * shape_grads1[k][d];
+
break;
}
// Compute eventual sign changes depending
// on the neighborhood between two faces.
std::vector<double> sign_change (this->dofs_per_cell, 1.0);
- get_face_sign_change (cell, this->dofs_per_face, sign_change);
+
+ if (mapping_type == mapping_raviart_thomas)
+ get_face_sign_change_rt (cell, this->dofs_per_face, sign_change);
+
+ else if (mapping_type == mapping_nedelec)
+ get_face_sign_change_nedelec (cell, this->dofs_per_face, sign_change);
for (unsigned int i=0; i<this->dofs_per_cell; ++i)
{
for (unsigned int k = 0; k < n_q_points; ++k)
for (unsigned int d = 0; d < dim; ++d)
- data.shape_values(first+d,k) = shape_values[k][d];
+ data.shape_values(first+d,k) = sign_change[i] * shape_values[k][d];
break;
}
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/quadrature_lib.h>
#include <deal.II/fe/fe_q.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/quadrature.h>
#include <deal.II/base/qprojector.h>
get_interpolation_matrix (const FiniteElement<dim,spacedim> &x_source_fe,
FullMatrix<double> &interpolation_matrix) const
{
- // this is only implemented, if the source FE is also a Q element
- AssertThrow ((dynamic_cast<const FE_Q_Base<POLY,dim,spacedim> *>(&x_source_fe) != 0),
- (typename FiniteElement<dim,spacedim>::ExcInterpolationNotImplemented()));
+ // go through the list of elements we can interpolate from
+ if (const FE_Q_Base<POLY,dim,spacedim> *source_fe
+ = dynamic_cast<const FE_Q_Base<POLY,dim,spacedim>*>(&x_source_fe))
+ {
+ // ok, source is a Q element, so we will be able to do the work
+ Assert (interpolation_matrix.m() == this->dofs_per_cell,
+ ExcDimensionMismatch (interpolation_matrix.m(),
+ this->dofs_per_cell));
+ Assert (interpolation_matrix.n() == x_source_fe.dofs_per_cell,
+ ExcDimensionMismatch (interpolation_matrix.m(),
+ x_source_fe.dofs_per_cell));
+
+ // only evaluate Q dofs
+ const unsigned int q_dofs_per_cell = Utilities::fixed_power<dim>(this->degree+1);
+ const unsigned int source_q_dofs_per_cell = Utilities::fixed_power<dim>(source_fe->degree+1);
- Assert (interpolation_matrix.m() == this->dofs_per_cell,
- ExcDimensionMismatch (interpolation_matrix.m(),
- this->dofs_per_cell));
- Assert (interpolation_matrix.n() == x_source_fe.dofs_per_cell,
- ExcDimensionMismatch (interpolation_matrix.m(),
- x_source_fe.dofs_per_cell));
+ // evaluation is simply done by evaluating the other FE's basis functions on
+ // the unit support points (FE_Q has the property that the cell
+ // interpolation matrix is a unit matrix, so no need to evaluate it and
+ // invert it)
+ for (unsigned int j=0; j<q_dofs_per_cell; ++j)
+ {
+ // read in a point on this cell and evaluate the shape functions there
+ const Point<dim> p = this->unit_support_points[j];
- // ok, source is a Q element, so we will be able to do the work
- const FE_Q_Base<POLY,dim,spacedim> &source_fe
- = dynamic_cast<const FE_Q_Base<POLY,dim,spacedim>&>(x_source_fe);
+ // FE_Q element evaluates to 1 in unit support point and to zero in all
+ // other points by construction
+ Assert(std::abs(this->poly_space.compute_value (j, p)-1.)<1e-13,
+ ExcInternalError());
- // only evaluate Q dofs
- const unsigned int q_dofs_per_cell = Utilities::fixed_power<dim>(this->degree+1);
- const unsigned int source_q_dofs_per_cell = Utilities::fixed_power<dim>(source_fe.degree+1);
+ for (unsigned int i=0; i<source_q_dofs_per_cell; ++i)
+ interpolation_matrix(j,i) = source_fe->poly_space.compute_value (i, p);
+ }
- // evaluation is simply done by evaluating the other FE's basis functions on
- // the unit support points (FE_Q has the property that the cell
- // interpolation matrix is a unit matrix, so no need to evaluate it and
- // invert it)
- for (unsigned int j=0; j<q_dofs_per_cell; ++j)
- {
- // read in a point on this cell and evaluate the shape functions there
- const Point<dim> p = this->unit_support_points[j];
+ // for FE_Q_DG0, add one last row of identity
+ if (q_dofs_per_cell < this->dofs_per_cell)
+ {
+ AssertDimension(source_q_dofs_per_cell+1, source_fe->dofs_per_cell);
+ for (unsigned int i=0; i<source_q_dofs_per_cell; ++i)
+ interpolation_matrix(q_dofs_per_cell, i) = 0.;
+ for (unsigned int j=0; j<q_dofs_per_cell; ++j)
+ interpolation_matrix(j, source_q_dofs_per_cell) = 0.;
+ interpolation_matrix(q_dofs_per_cell, source_q_dofs_per_cell) = 1.;
+ }
- // FE_Q element evaluates to 1 in unit support point and to zero in all
- // other points by construction
- Assert(std::abs(this->poly_space.compute_value (j, p)-1.)<1e-13,
- ExcInternalError());
+ // cut off very small values
+ const double eps = 2e-13*this->degree*dim;
+ for (unsigned int i=0; i<this->dofs_per_cell; ++i)
+ for (unsigned int j=0; j<source_fe->dofs_per_cell; ++j)
+ if (std::fabs(interpolation_matrix(i,j)) < eps)
+ interpolation_matrix(i,j) = 0.;
- for (unsigned int i=0; i<source_q_dofs_per_cell; ++i)
- interpolation_matrix(j,i) = source_fe.poly_space.compute_value (i, p);
- }
+ // make sure that the row sum of each of the matrices is 1 at this
+ // point. this must be so since the shape functions sum up to 1
+ for (unsigned int i=0; i<this->dofs_per_cell; ++i)
+ {
+ double sum = 0.;
+ for (unsigned int j=0; j<source_fe->dofs_per_cell; ++j)
+ sum += interpolation_matrix(i,j);
- // for FE_Q_DG0, add one last row of identity
- if (q_dofs_per_cell < this->dofs_per_cell)
- {
- AssertDimension(source_q_dofs_per_cell+1, source_fe.dofs_per_cell);
- for (unsigned int i=0; i<source_q_dofs_per_cell; ++i)
- interpolation_matrix(q_dofs_per_cell, i) = 0.;
- for (unsigned int j=0; j<q_dofs_per_cell; ++j)
- interpolation_matrix(j, source_q_dofs_per_cell) = 0.;
- interpolation_matrix(q_dofs_per_cell, source_q_dofs_per_cell) = 1.;
+ Assert (std::fabs(sum-1) < eps, ExcInternalError());
+ }
}
-
- // cut off very small values
- const double eps = 2e-13*this->degree*dim;
- for (unsigned int i=0; i<this->dofs_per_cell; ++i)
- for (unsigned int j=0; j<source_fe.dofs_per_cell; ++j)
- if (std::fabs(interpolation_matrix(i,j)) < eps)
- interpolation_matrix(i,j) = 0.;
-
- // make sure that the row sum of each of the matrices is 1 at this
- // point. this must be so since the shape functions sum up to 1
- for (unsigned int i=0; i<this->dofs_per_cell; ++i)
+ else if (dynamic_cast<const FE_Nothing<dim>*>(&x_source_fe))
{
- double sum = 0.;
- for (unsigned int j=0; j<source_fe.dofs_per_cell; ++j)
- sum += interpolation_matrix(i,j);
+ // the element we want to interpolate from is an FE_Nothing. this
+ // element represents a function that is constant zero and has no
+ // degrees of freedom, so the interpolation is simply a multiplication
+ // with a n_dofs x 0 matrix. there is nothing to do here
+
+ // we would like to verify that the number of rows and columns of
+ // the matrix equals this->dofs_per_cell and zero. unfortunately,
+ // whenever we do FullMatrix::reinit(m,0), it sets both rows and
+ // columns to zero, instead of m and zero. thus, only test the
+ // number of columns
+ Assert (interpolation_matrix.n() == x_source_fe.dofs_per_cell,
+ ExcDimensionMismatch (interpolation_matrix.m(),
+ x_source_fe.dofs_per_cell));
- Assert (std::fabs(sum-1) < eps, ExcInternalError());
}
+ else
+ AssertThrow (false,
+ (typename FiniteElement<dim,spacedim>::ExcInterpolationNotImplemented()));
+
}
template <class POLY, int dim, int spacedim>
void
FE_Q_Base<POLY,dim,spacedim>::
-get_face_interpolation_matrix (const FiniteElement<dim,spacedim> &x_source_fe,
+get_face_interpolation_matrix (const FiniteElement<dim,spacedim> &source_fe,
FullMatrix<double> &interpolation_matrix) const
{
Assert (dim > 1, ExcImpossibleInDim(1));
-
- // this is only implemented, if the source FE is also a Q element
- AssertThrow ((dynamic_cast<const FE_Q_Base<POLY,dim,spacedim> *>(&x_source_fe) != 0),
- (typename FiniteElement<dim,spacedim>::
- ExcInterpolationNotImplemented()));
-
- Assert (interpolation_matrix.n() == this->dofs_per_face,
- ExcDimensionMismatch (interpolation_matrix.n(),
- this->dofs_per_face));
- Assert (interpolation_matrix.m() == x_source_fe.dofs_per_face,
- ExcDimensionMismatch (interpolation_matrix.m(),
- x_source_fe.dofs_per_face));
-
- // ok, source is a Q element, so we will be able to do the work
- const FE_Q_Base<POLY,dim,spacedim> &source_fe
- = dynamic_cast<const FE_Q_Base<POLY,dim,spacedim>&>(x_source_fe);
-
- // Make sure that the element for which the DoFs should be constrained is
- // the one with the higher polynomial degree. Actually the procedure will
- // work also if this assertion is not satisfied. But the matrices produced
- // in that case might lead to problems in the hp procedures, which use this
- // method.
- Assert (this->dofs_per_face <= source_fe.dofs_per_face,
- (typename FiniteElement<dim,spacedim>::
- ExcInterpolationNotImplemented ()));
-
- // generate a quadrature with the unit support points. This is later based
- // as a basis for the QProjector, which returns the support points on the
- // face.
- Quadrature<dim-1> quad_face_support (source_fe.get_unit_face_support_points ());
-
- // Rule of thumb for FP accuracy, that can be expected for a given
- // polynomial degree. This value is used to cut off values close to zero.
- const double eps = 2e-13*this->degree*(dim-1);
-
- // compute the interpolation matrix by simply taking the value at the
- // support points.
-//TODO: Verify that all faces are the same with respect to
-// these support points. Furthermore, check if something has to
-// be done for the face orientation flag in 3D.
- const Quadrature<dim> face_quadrature
- = QProjector<dim>::project_to_face (quad_face_support, 0);
- for (unsigned int i=0; i<source_fe.dofs_per_face; ++i)
- {
- const Point<dim> &p = face_quadrature.point (i);
-
- for (unsigned int j=0; j<this->dofs_per_face; ++j)
- {
- double matrix_entry = this->poly_space.compute_value (this->face_to_cell_index(j, 0), p);
-
- // Correct the interpolated value. I.e. if it is close to 1 or 0,
- // make it exactly 1 or 0. Unfortunately, this is required to avoid
- // problems with higher order elements.
- if (std::fabs (matrix_entry - 1.0) < eps)
- matrix_entry = 1.0;
- if (std::fabs (matrix_entry) < eps)
- matrix_entry = 0.0;
-
- interpolation_matrix(i,j) = matrix_entry;
- }
- }
-
- // make sure that the row sum of each of the matrices is 1 at this
- // point. this must be so since the shape functions sum up to 1
- for (unsigned int j=0; j<source_fe.dofs_per_face; ++j)
- {
- double sum = 0.;
-
- for (unsigned int i=0; i<this->dofs_per_face; ++i)
- sum += interpolation_matrix(j,i);
-
- Assert (std::fabs(sum-1) < 2e-13*this->degree*(dim-1),
- ExcInternalError());
- }
+ get_subface_interpolation_matrix (source_fe, numbers::invalid_unsigned_int,
+ interpolation_matrix);
}
// these support points. Furthermore, check if something has to
// be done for the face orientation flag in 3D.
const Quadrature<dim> subface_quadrature
- = QProjector<dim>::project_to_subface (quad_face_support, 0, subface);
+ = subface == numbers::invalid_unsigned_int
+ ?
+ QProjector<dim>::project_to_face (quad_face_support, 0)
+ :
+ QProjector<dim>::project_to_subface (quad_face_support, 0, subface);
for (unsigned int i=0; i<source_fe->dofs_per_face; ++i)
{
const Point<dim> &p = subface_quadrature.point (i);
for (unsigned int i=0; i<this->dofs_per_face; ++i)
sum += interpolation_matrix(j,i);
- Assert (std::fabs(sum-1) < 2e-13*this->degree*dim,
- ExcInternalError());
+ Assert (std::fabs(sum-1) < eps, ExcInternalError());
}
}
else if (dynamic_cast<const FE_Nothing<dim> *>(&x_source_fe) != 0)
{
// dofs are located along lines, so two dofs are identical if they are
// located at identical positions. if we had only equidistant points, we
- // could simple check for similarity like (i+1)*q == (j+1)*p, but we
+ // could simply check for similarity like (i+1)*q == (j+1)*p, but we
// might have other support points (e.g. Gauss-Lobatto
// points). Therefore, read the points in unit_support_points for the
// first coordinate direction. We take the lexicographic ordering of the
+template <class POLY, int dim, int spacedim>
+unsigned int
+FE_Q_Base<POLY,dim,spacedim>::
+face_to_cell_index (const unsigned int face_index,
+ const unsigned int face,
+ const bool face_orientation,
+ const bool face_flip,
+ const bool face_rotation) const
+{
+ Assert (face_index < this->dofs_per_face,
+ ExcIndexRange(face_index, 0, this->dofs_per_face));
+ Assert (face < GeometryInfo<dim>::faces_per_cell,
+ ExcIndexRange(face, 0, GeometryInfo<dim>::faces_per_cell));
+
+//TODO: we could presumably solve the 3d case below using the
+// adjust_quad_dof_index_for_face_orientation_table field. for the
+// 2d case, we can't use adjust_line_dof_index_for_line_orientation_table
+// since that array is empty (presumably because we thought that
+// there are no flipped edges in 2d, but these can happen in
+// DoFTools::make_periodicity_constraints, for example). so we
+// would need to either fill this field, or rely on derived classes
+// implementing this function, as we currently do
+
+ // we need to distinguish between DoFs on vertices, lines and in 3d quads.
+ // do so in a sequence of if-else statements
+ if (face_index < this->first_face_line_index)
+ // DoF is on a vertex
+ {
+ // get the number of the vertex on the face that corresponds to this DoF,
+ // along with the number of the DoF on this vertex
+ const unsigned int face_vertex = face_index / this->dofs_per_vertex;
+ const unsigned int dof_index_on_vertex = face_index % this->dofs_per_vertex;
+
+ // then get the number of this vertex on the cell and translate
+ // this to a DoF number on the cell
+ return (GeometryInfo<dim>::face_to_cell_vertices(face, face_vertex,
+ face_orientation,
+ face_flip,
+ face_rotation)
+ * this->dofs_per_vertex
+ +
+ dof_index_on_vertex);
+ }
+ else if (face_index < this->first_face_quad_index)
+ // DoF is on a face
+ {
+ // do the same kind of translation as before. we need to only consider
+ // DoFs on the lines, i.e., ignoring those on the vertices
+ const unsigned int index = face_index - this->first_face_line_index;
+
+ const unsigned int face_line = index / this->dofs_per_line;
+ const unsigned int dof_index_on_line = index % this->dofs_per_line;
+
+ // we now also need to adjust the line index for the case of
+ // face orientation, face flips, etc
+ unsigned int adjusted_dof_index_on_line;
+ switch (dim)
+ {
+ case 1:
+ Assert (false, ExcInternalError());
+
+ case 2:
+ // in 2d, only face_flip has a meaning. if it is set, consider
+ // dofs in reverse order
+ if (face_flip == false)
+ adjusted_dof_index_on_line = dof_index_on_line;
+ else
+ adjusted_dof_index_on_line = this->dofs_per_line - dof_index_on_line - 1;
+ break;
+
+ case 3:
+ // in 3d, things are difficult. someone will have to think
+ // about how this code here should look like, by drawing a bunch
+ // of pictures of how all the faces can look like with the various
+ // flips and rotations.
+ //
+ // that said, the Q2 case is easy enough to implement, as is the case
+ // where everything is in standard orientation
+ Assert ((this->dofs_per_line <= 1) ||
+ ((face_orientation == true) &&
+ (face_flip == false) &&
+ (face_rotation == false)),
+ ExcNotImplemented());
+ adjusted_dof_index_on_line = dof_index_on_line;
+ break;
+ }
+
+ return (this->first_line_index
+ + GeometryInfo<dim>::face_to_cell_lines(face, face_line,
+ face_orientation,
+ face_flip,
+ face_rotation)
+ * this->dofs_per_line
+ +
+ adjusted_dof_index_on_line);
+ }
+ else
+ // DoF is on a quad
+ {
+ Assert (dim >= 3, ExcInternalError());
+
+ // ignore vertex and line dofs
+ const unsigned int index = face_index - this->first_face_quad_index;
+
+ // the same is true here as above for the 3d case -- someone will
+ // just have to draw a bunch of pictures. in the meantime,
+ // we can implement the Q2 case in which it is simple
+ Assert ((this->dofs_per_quad <= 1) ||
+ ((face_orientation == true) &&
+ (face_flip == false) &&
+ (face_rotation == false)),
+ ExcNotImplemented());
+ return (this->first_quad_index
+ + face * this->dofs_per_quad
+ + index);
+ }
+}
+
+
+
template <class POLY, int dim, int spacedim>
std::vector<unsigned int>
FE_Q_Base<POLY,dim,spacedim>::get_dpo_vector(const unsigned int deg)
{
+ AssertThrow(deg>0,ExcMessage("FE_Q needs to be of degree > 0."));
std::vector<unsigned int> dpo(dim+1, 1U);
for (unsigned int i=1; i<dpo.size(); ++i)
dpo[i]=dpo[i-1]*(deg-1);
template <class POLY, int dim, int spacedim>
-const FullMatrix<double>&
+const FullMatrix<double> &
FE_Q_Base<POLY,dim,spacedim>
::get_prolongation_matrix (const unsigned int child,
const RefinementCase<dim> &refinement_case) const
// almost negligible also for high order elements
const unsigned int dofs1d = this->degree+1;
std::vector<Table<2,double> >
- subcell_evaluations (dim, Table<2,double>(dofs1d, dofs1d));
+ subcell_evaluations (dim, Table<2,double>(dofs1d, dofs1d));
const std::vector<unsigned int> &index_map_inverse =
this->poly_space.get_numbering_inverse();
template <class POLY, int dim, int spacedim>
-const FullMatrix<double>&
+const FullMatrix<double> &
FE_Q_Base<POLY,dim,spacedim>
::get_restriction_matrix (const unsigned int child,
const RefinementCase<dim> &refinement_case) const
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2013 by the deal.II authors
+// Copyright (C) 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id: fe_q.cc 28798 2013-03-07 17:00:02Z maier $
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2012, 2013 by the deal.II authors
+// Copyright (C) 2012 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/quadrature.h>
#include <deal.II/base/qprojector.h>
x_source_fe.dofs_per_cell));
this->FE_Q_Base<TensorProductPolynomialsConst<dim>,dim,spacedim>::
- get_interpolation_matrix(x_source_fe, interpolation_matrix);
+ get_interpolation_matrix(x_source_fe, interpolation_matrix);
}
-//---------------------------------------------------------------------------
-// $Id: fe_q.inst.in 25229 2012-03-09 18:34:59Z pauletti $
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2002 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/fe/fe_q_hierarchical.h>
#include <deal.II/fe/fe_nothing.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/quadrature_lib.h>
#include <deal.II/fe/fe_q_iso_q1.h>
:
FE_Q_Base<TensorProductPolynomials<dim,Polynomials::PiecewisePolynomial<double> >, dim, spacedim> (
TensorProductPolynomials<dim,Polynomials::PiecewisePolynomial<double> >
- (Polynomials::generate_complete_Lagrange_basis_on_subdivisions(subdivisions, 1)),
+ (Polynomials::generate_complete_Lagrange_basis_on_subdivisions(subdivisions, 1)),
FiniteElementData<dim>(this->get_dpo_vector(subdivisions),
1, subdivisions,
FiniteElementData<dim>::H1),
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2013 by the deal.II authors
+// Copyright (C) 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/utilities.h>
#include <deal.II/base/quadrature.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/quadrature_lib.h>
#include <deal.II/base/qprojector.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/memory_consumption.h>
#include <deal.II/base/quadrature.h>
template <int dim, int spacedim>
-FESystem<dim,spacedim>::InternalData::InternalData(const unsigned int n_base_elements):
+FESystem<dim,spacedim>::InternalData::InternalData(const unsigned int n_base_elements,
+ const bool compute_hessians)
+:
+ compute_hessians (compute_hessians),
base_fe_datas(n_base_elements),
base_fe_values_datas(n_base_elements)
{}
template <int dim, int spacedim>
-const FullMatrix<double>&
+const FullMatrix<double> &
FESystem<dim,spacedim>
::get_restriction_matrix (const unsigned int child,
const RefinementCase<dim> &refinement_case) const
// shortcut for accessing local restrictions further down
std::vector<const FullMatrix<double> *>
- base_matrices(this->n_base_elements());
+ base_matrices(this->n_base_elements());
for (unsigned int i=0; i<this->n_base_elements(); ++i)
{
// so get the common base element and the indices therein:
const unsigned int
- base = this->system_to_base_table[i].first.first;
+ base = this->system_to_base_table[i].first.first;
const unsigned int
- base_index_i = this->system_to_base_table[i].second,
- base_index_j = this->system_to_base_table[j].second;
+ base_index_i = this->system_to_base_table[i].second,
+ base_index_j = this->system_to_base_table[j].second;
// if we are sure that DoFs i and j may couple, then copy
// entries of the matrices:
template <int dim, int spacedim>
-const FullMatrix<double>&
+const FullMatrix<double> &
FESystem<dim,spacedim>
::get_prolongation_matrix (const unsigned int child,
const RefinementCase<dim> &refinement_case) const
bool do_prolongation = true;
std::vector<const FullMatrix<double> *>
- base_matrices(this->n_base_elements());
+ base_matrices(this->n_base_elements());
for (unsigned int i=0; i<this->n_base_elements(); ++i)
{
base_matrices[i] =
this->system_to_base_table[j].first)
continue;
const unsigned int
- base = this->system_to_base_table[i].first.first;
+ base = this->system_to_base_table[i].first.first;
const unsigned int
- base_index_i = this->system_to_base_table[i].second,
- base_index_j = this->system_to_base_table[j].second;
+ base_index_i = this->system_to_base_table[i].second,
+ base_index_j = this->system_to_base_table[j].second;
prolongate(i,j) = (*base_matrices[base])(base_index_i,base_index_j);
}
prolongate.swap(const_cast<FullMatrix<double> &>
}
+template <int dim, int spacedim>
+unsigned int
+FESystem<dim,spacedim>::
+face_to_cell_index (const unsigned int face_dof_index,
+ const unsigned int face,
+ const bool face_orientation,
+ const bool face_flip,
+ const bool face_rotation) const
+{
+ // we need to ask the base elements how they want to translate
+ // the DoFs within their own numbering. thus, translate to
+ // the base element numbering and then back
+ const std::pair<std::pair<unsigned int, unsigned int>, unsigned int>
+ face_base_index = this->face_system_to_base_index(face_dof_index);
+
+ const unsigned int
+ base_face_to_cell_index
+ = this->base_element(face_base_index.first.first).face_to_cell_index (face_base_index.second,
+ face,
+ face_orientation,
+ face_flip,
+ face_rotation);
+
+ // it would be nice if we had a base_to_system_index function, but
+ // all that exists is a component_to_system_index function. we can't do
+ // this here because it won't work for non-primitive elements. consequently,
+ // simply do a loop over all dofs till we find whether it corresponds
+ // to the one we're interested in -- crude, maybe, but works for now
+ const std::pair<std::pair<unsigned int, unsigned int>, unsigned int>
+ target = std::make_pair (face_base_index.first, base_face_to_cell_index);
+ for (unsigned int i=0; i<this->dofs_per_cell; ++i)
+ if (this->system_to_base_index(i) == target)
+ return i;
+
+ Assert (false, ExcInternalError());
+ return numbers::invalid_unsigned_int;
+}
+
+
//---------------------------------------------------------------------------
// Data field initialization
const Quadrature<dim> &quadrature) const
{
UpdateFlags flags = flags_;
- InternalData *data = new InternalData(this->n_base_elements());
+ InternalData *data = new InternalData(this->n_base_elements(),
+ flags & update_hessians);
data->update_once = update_once (flags);
data->update_each = update_each (flags);
// finite differencing are required,
// then initialize some objects for
// that
- data->compute_hessians = flags & update_hessians;
if (data->compute_hessians)
{
// delete
const Quadrature<dim-1> &quadrature) const
{
UpdateFlags flags = flags_;
- InternalData *data = new InternalData(this->n_base_elements());
+ InternalData *data = new InternalData(this->n_base_elements(),
+ flags & update_hessians);
data->update_once = update_once (flags);
data->update_each = update_each (flags);
flags = data->update_once | data->update_each;
UpdateFlags sub_flags = flags;
- data->compute_hessians = flags & update_hessians;
if (data->compute_hessians)
{
sub_flags = UpdateFlags (sub_flags ^ update_hessians);
const Quadrature<dim-1> &quadrature) const
{
UpdateFlags flags = flags_;
- InternalData *data = new InternalData(this->n_base_elements());
+ InternalData *data = new InternalData(this->n_base_elements(),
+ flags & update_hessians);
data->update_once = update_once (flags);
data->update_each = update_each (flags);
flags = data->update_once | data->update_each;
UpdateFlags sub_flags = flags;
- data->compute_hessians = flags & update_hessians;
if (data->compute_hessians)
{
sub_flags = UpdateFlags (sub_flags ^ update_hessians);
unsigned int index = 0;
for (unsigned int index=0; index<fes.size(); ++index)
if (multiplicities[index]>0)
- {
- total_conformity = fes[index]->conforming_space;
- break;
- }
+ {
+ total_conformity = fes[index]->conforming_space;
+ break;
+ }
for (; index<fes.size(); ++index)
if (multiplicities[index]>0)
- total_conformity =
- typename FiniteElementData<dim>::Conformity(total_conformity
- &
- fes[index]->conforming_space);
+ total_conformity =
+ typename FiniteElementData<dim>::Conformity(total_conformity
+ &
+ fes[index]->conforming_space);
}
std::vector<unsigned int> dpo;
if (dim>2) dpo.push_back(multiplied_dofs_per_hex);
return FiniteElementData<dim> (dpo,
- multiplied_n_components,
- degree,
- total_conformity,
- summed_multiplicities);
+ multiplied_n_components,
+ degree,
+ total_conformity,
+ summed_multiplicities);
}
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
{
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/quadrature_lib.h>
#include <deal.II/base/qprojector.h>
#include <deal.II/base/utilities.h>
#include <deal.II/lac/full_matrix.h>
#include <deal.II/lac/householder.h>
-#include <deal.II/lac/vector.h>
-#include <deal.II/lac/block_vector.h>
-#include <deal.II/lac/parallel_vector.h>
-#include <deal.II/lac/parallel_block_vector.h>
-#include <deal.II/lac/petsc_parallel_vector.h>
-#include <deal.II/lac/petsc_block_vector.h>
-#include <deal.II/lac/petsc_parallel_block_vector.h>
-#include <deal.II/lac/trilinos_vector.h>
-#include <deal.II/lac/trilinos_block_vector.h>
#include <deal.II/lac/constraint_matrix.h>
#include <deal.II/grid/tria.h>
#include <deal.II/grid/tria_iterator.h>
start_indices[i] = k;
k += block_data[i];
}
-
-//TODO:[GK] This does not work for a single RT
+
for (unsigned int i=0; i<element.dofs_per_cell; ++i)
{
std::pair<unsigned int, types::global_dof_index>
}
- template <int dim, int spacedim,
- template <int, int> class DH1,
- template <int, int> class DH2,
- class InVector, class OutVector>
- void
- interpolate(const DH1<dim, spacedim> &dof1,
- const InVector &u1,
- const DH2<dim, spacedim> &dof2,
- OutVector &u2)
- {
- ConstraintMatrix dummy;
- dummy.close();
- interpolate(dof1, u1, dof2, dummy, u2);
- }
-
-
-
- template <int dim, int spacedim,
- template <int, int> class DH1,
- template <int, int> class DH2,
- class InVector, class OutVector>
- void
- interpolate (const DH1<dim, spacedim> &dof1,
- const InVector &u1,
- const DH2<dim, spacedim> &dof2,
- const ConstraintMatrix &constraints,
- OutVector &u2)
- {
- Assert(&dof1.get_tria()==&dof2.get_tria(), ExcTriangulationMismatch());
-
- Assert(u1.size()==dof1.n_dofs(),
- ExcDimensionMismatch(u1.size(), dof1.n_dofs()));
- Assert(u2.size()==dof2.n_dofs(),
- ExcDimensionMismatch(u2.size(), dof2.n_dofs()));
-
-#ifdef DEAL_II_WITH_PETSC
- if (dynamic_cast<const PETScWrappers::MPI::Vector *>(&u1) != 0)
- if (dynamic_cast<const DoFHandler<dim>*>(&dof1) != 0)
- {
- // if u1 is a parallel distributed
- // PETSc vector, we check the local
- // size of u1 for safety
- Assert(dynamic_cast<const PETScWrappers::MPI::Vector *>(&u1)->local_size() == dof1.locally_owned_dofs().n_elements(),
- ExcDimensionMismatch(dynamic_cast<const PETScWrappers::MPI::Vector *>(&u1)->local_size(), dof1.locally_owned_dofs().n_elements()));
- };
-
- if (dynamic_cast<PETScWrappers::MPI::Vector *>(&u2) != 0)
- if (dynamic_cast<const DoFHandler<dim>*>(&dof2) != 0)
- {
- Assert(dynamic_cast<PETScWrappers::MPI::Vector *>(&u2)->local_size() == dof2.locally_owned_dofs().n_elements(),
- ExcDimensionMismatch(dynamic_cast<PETScWrappers::MPI::Vector *>(&u2)->local_size(), dof2.locally_owned_dofs().n_elements()));
- };
-#endif
- // allocate vectors at maximal
- // size. will be reinited in inner
- // cell, but Vector makes sure that
- // this does not lead to
- // reallocation of memory
- Vector<typename OutVector::value_type> u1_local(DoFTools::max_dofs_per_cell(dof1));
- Vector<typename OutVector::value_type> u2_local(DoFTools::max_dofs_per_cell(dof2));
-
- // have a map for interpolation
- // matrices. shared_ptr make sure
- // that memory is released again
- std::map<const FiniteElement<dim,spacedim> *,
- std::map<const FiniteElement<dim,spacedim> *,
- std_cxx1x::shared_ptr<FullMatrix<double> > > >
- interpolation_matrices;
-
- typename DH1<dim,spacedim>::active_cell_iterator cell1 = dof1.begin_active(),
- endc1 = dof1.end();
- typename DH2<dim,spacedim>::active_cell_iterator cell2 = dof2.begin_active(),
- endc2 = dof2.end();
-
- std::vector<types::global_dof_index> dofs;
- dofs.reserve (DoFTools::max_dofs_per_cell (dof2));
-
- u2 = 0;
- OutVector touch_count(u2);
- touch_count = 0;
-
- // for distributed triangulations,
- // we can only interpolate u1 on
- // a cell, which this processor owns,
- // so we have to know the subdomain_id
- const types::subdomain_id subdomain_id =
- dof1.get_tria().locally_owned_subdomain();
-
- for (; cell1!=endc1; ++cell1, ++cell2)
- if ((cell1->subdomain_id() == subdomain_id)
- ||
- (subdomain_id == numbers::invalid_subdomain_id))
- {
- Assert(cell1->get_fe().n_components() == cell2->get_fe().n_components(),
- ExcDimensionMismatch (cell1->get_fe().n_components(),
- cell2->get_fe().n_components()));
-
- // for continuous elements on
- // grids with hanging nodes we
- // need hanging node
- // constraints. Consequentely,
- // if there are no constraints
- // then hanging nodes are not
- // allowed.
- const bool hanging_nodes_not_allowed
- = ((cell2->get_fe().dofs_per_vertex != 0) &&
- (constraints.n_constraints() == 0));
-
- if (hanging_nodes_not_allowed)
- for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
- Assert (cell1->at_boundary(face) ||
- cell1->neighbor(face)->level() == cell1->level(),
- ExcHangingNodesNotAllowed(0));
-
-
- const unsigned int dofs_per_cell1 = cell1->get_fe().dofs_per_cell;
- const unsigned int dofs_per_cell2 = cell2->get_fe().dofs_per_cell;
- u1_local.reinit (dofs_per_cell1);
- u2_local.reinit (dofs_per_cell2);
-
- // check if interpolation
- // matrix for this particular
- // pair of elements is already
- // there
- if (interpolation_matrices[&cell1->get_fe()][&cell2->get_fe()].get() == 0)
- {
- std_cxx1x::shared_ptr<FullMatrix<double> >
- interpolation_matrix (new FullMatrix<double> (dofs_per_cell2,
- dofs_per_cell1));
- interpolation_matrices[&cell1->get_fe()][&cell2->get_fe()]
- = interpolation_matrix;
-
- get_interpolation_matrix(cell1->get_fe(),
- cell2->get_fe(),
- *interpolation_matrix);
- }
-
- cell1->get_dof_values(u1, u1_local);
- interpolation_matrices[&cell1->get_fe()][&cell2->get_fe()]
- ->vmult(u2_local, u1_local);
-
- dofs.resize (dofs_per_cell2);
- cell2->get_dof_indices(dofs);
-
- for (unsigned int i=0; i<dofs_per_cell2; ++i)
- {
- u2(dofs[i])+=u2_local(i);
- touch_count(dofs[i]) += 1;
- }
- }
- // cell1 is at the end, so should
- // be cell2
- Assert (cell2 == endc2, ExcInternalError());
-
- u2.compress(VectorOperation::add);
- touch_count.compress(VectorOperation::add);
-
- // if we work on parallel distributed
- // vectors, we have to ensure, that we only
- // work on dofs this processor owns.
- IndexSet locally_owned_dofs = dof2.locally_owned_dofs();
-
- // when a discontinuous element is
- // interpolated to a continuous
- // one, we take the mean values.
- // for parallel vectors check,
- // if this component is owned by
- // this processor.
- for (types::global_dof_index i=0; i<dof2.n_dofs(); ++i)
- if (locally_owned_dofs.is_element(i))
- {
- Assert(touch_count(i)!=0, ExcInternalError());
- u2(i) /= touch_count(i);
- }
-
- // finish the work on parallel vectors
- u2.compress(VectorOperation::insert);
- // Apply hanging node constraints.
- constraints.distribute(u2);
- }
-
-
-
- template <int dim, class InVector, class OutVector, int spacedim>
- void
- back_interpolate(const DoFHandler<dim,spacedim> &dof1,
- const InVector &u1,
- const FiniteElement<dim,spacedim> &fe2,
- OutVector &u1_interpolated)
- {
- Assert(dof1.get_fe().n_components() == fe2.n_components(),
- ExcDimensionMismatch(dof1.get_fe().n_components(), fe2.n_components()));
- Assert(u1.size()==dof1.n_dofs(), ExcDimensionMismatch(u1.size(), dof1.n_dofs()));
- Assert(u1_interpolated.size()==dof1.n_dofs(),
- ExcDimensionMismatch(u1_interpolated.size(), dof1.n_dofs()));
-
-#ifdef DEAL_II_WITH_PETSC
- if (dynamic_cast<const PETScWrappers::MPI::Vector *>(&u1) != 0)
- if (dynamic_cast<const DoFHandler<dim>*>(&dof1) != 0)
- {
- // if u1 is a parallel distributed
- // PETSc vector, we check the local
- // size of u1 for safety
- Assert(dynamic_cast<const PETScWrappers::MPI::Vector *>(&u1)->local_size() == dof1.locally_owned_dofs().n_elements(),
- ExcDimensionMismatch(dynamic_cast<const PETScWrappers::MPI::Vector *>(&u1)->local_size(), dof1.locally_owned_dofs().n_elements()));
- };
-
- if (dynamic_cast<PETScWrappers::MPI::Vector *>(&u1_interpolated) != 0)
- if (dynamic_cast<const DoFHandler<dim>*>(&dof1) != 0)
- {
- Assert(dynamic_cast<PETScWrappers::MPI::Vector *>(&u1_interpolated)->local_size() == dof1.locally_owned_dofs().n_elements(),
- ExcDimensionMismatch(dynamic_cast<PETScWrappers::MPI::Vector *>(&u1_interpolated)->local_size(), dof1.locally_owned_dofs().n_elements()));
- };
-#endif
-
- // For continuous elements on grids
- // with hanging nodes we need
- // hanging node
- // constraints. Consequently, when
- // the elements are continuous no
- // hanging node constraints are
- // allowed.
- const bool hanging_nodes_not_allowed=
- (dof1.get_fe().dofs_per_vertex != 0) || (fe2.dofs_per_vertex != 0);
-
- const unsigned int dofs_per_cell1=dof1.get_fe().dofs_per_cell;
-
- Vector<typename OutVector::value_type> u1_local(dofs_per_cell1);
- Vector<typename OutVector::value_type> u1_int_local(dofs_per_cell1);
-
- const types::subdomain_id subdomain_id =
- dof1.get_tria().locally_owned_subdomain();
-
- typename DoFHandler<dim,spacedim>::active_cell_iterator cell = dof1.begin_active(),
- endc = dof1.end();
-
- FullMatrix<double> interpolation_matrix(dofs_per_cell1, dofs_per_cell1);
- get_back_interpolation_matrix(dof1.get_fe(), fe2,
- interpolation_matrix);
- for (; cell!=endc; ++cell)
- if ((cell->subdomain_id() == subdomain_id)
- ||
- (subdomain_id == numbers::invalid_subdomain_id))
- {
- if (hanging_nodes_not_allowed)
- for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
- Assert (cell->at_boundary(face) ||
- cell->neighbor(face)->level() == cell->level(),
- ExcHangingNodesNotAllowed(0));
-
- cell->get_dof_values(u1, u1_local);
- interpolation_matrix.vmult(u1_int_local, u1_local);
- cell->set_dof_values(u1_int_local, u1_interpolated);
- }
-
- // if we work on a parallel PETSc vector
- // we have to finish the work
- u1_interpolated.compress(VectorOperation::insert);
- }
-
-
-
- template <int dim,
- template <int> class DH,
- class InVector, class OutVector, int spacedim>
- void
- back_interpolate(const DH<dim> &dof1,
- const InVector &u1,
- const FiniteElement<dim,spacedim> &fe2,
- OutVector &u1_interpolated)
- {
- Assert(u1.size() == dof1.n_dofs(),
- ExcDimensionMismatch(u1.size(), dof1.n_dofs()));
- Assert(u1_interpolated.size() == dof1.n_dofs(),
- ExcDimensionMismatch(u1_interpolated.size(), dof1.n_dofs()));
-
-#ifdef DEAL_II_WITH_PETSC
- if (dynamic_cast<const PETScWrappers::MPI::Vector *>(&u1) != 0)
- if (dynamic_cast<const DoFHandler<dim>*>(&dof1) != 0)
- {
- // if u1 is a parallel distributed
- // PETSc vector, we check the local
- // size of u1 for safety
- Assert(dynamic_cast<const PETScWrappers::MPI::Vector *>(&u1)->local_size() == dof1.locally_owned_dofs().n_elements(),
- ExcDimensionMismatch(dynamic_cast<const PETScWrappers::MPI::Vector *>(&u1)->local_size(), dof1.locally_owned_dofs().n_elements()));
- };
-
- if (dynamic_cast<PETScWrappers::MPI::Vector *>(&u1_interpolated) != 0)
- if (dynamic_cast<const DoFHandler<dim>*>(&dof1) != 0)
- {
- Assert(dynamic_cast<PETScWrappers::MPI::Vector *>(&u1_interpolated)->local_size() == dof1.locally_owned_dofs().n_elements(),
- ExcDimensionMismatch(dynamic_cast<PETScWrappers::MPI::Vector *>(&u1_interpolated)->local_size(), dof1.locally_owned_dofs().n_elements()));
- };
-#endif
-
- Vector<typename OutVector::value_type> u1_local(DoFTools::max_dofs_per_cell(dof1));
- Vector<typename OutVector::value_type> u1_int_local(DoFTools::max_dofs_per_cell(dof1));
-
- const types::subdomain_id subdomain_id =
- dof1.get_tria().locally_owned_subdomain();
-
- typename DH<dim>::active_cell_iterator cell = dof1.begin_active(),
- endc = dof1.end();
-
- // map from possible fe objects in
- // dof1 to the back_interpolation
- // matrices
- std::map<const FiniteElement<dim> *,
- std_cxx1x::shared_ptr<FullMatrix<double> > > interpolation_matrices;
-
- for (; cell!=endc; ++cell)
- if ((cell->subdomain_id() == subdomain_id)
- ||
- (subdomain_id == numbers::invalid_subdomain_id))
- {
- Assert(cell->get_fe().n_components() == fe2.n_components(),
- ExcDimensionMismatch(cell->get_fe().n_components(),
- fe2.n_components()));
-
- // For continuous elements on
- // grids with hanging nodes we
- // need hanging node
- // constraints. Consequently,
- // when the elements are
- // continuous no hanging node
- // constraints are allowed.
- const bool hanging_nodes_not_allowed=
- (cell->get_fe().dofs_per_vertex != 0) || (fe2.dofs_per_vertex != 0);
-
- if (hanging_nodes_not_allowed)
- for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
- Assert (cell->at_boundary(face) ||
- cell->neighbor(face)->level() == cell->level(),
- ExcHangingNodesNotAllowed(0));
-
- const unsigned int dofs_per_cell1 = cell->get_fe().dofs_per_cell;
-
- // make sure back_interpolation
- // matrix is available
- if (interpolation_matrices[&cell->get_fe()] != 0)
- {
- interpolation_matrices[&cell->get_fe()] =
- std_cxx1x::shared_ptr<FullMatrix<double> >
- (new FullMatrix<double>(dofs_per_cell1, dofs_per_cell1));
- get_back_interpolation_matrix(dof1.get_fe(), fe2,
- *interpolation_matrices[&cell->get_fe()]);
- }
-
- u1_local.reinit (dofs_per_cell1);
- u1_int_local.reinit (dofs_per_cell1);
-
- cell->get_dof_values(u1, u1_local);
- interpolation_matrices[&cell->get_fe()]->vmult(u1_int_local, u1_local);
- cell->set_dof_values(u1_int_local, u1_interpolated);
- };
-
- // if we work on a parallel PETSc vector
- // we have to finish the work
- u1_interpolated.compress(VectorOperation::insert);
- }
-
-
-
- namespace internal
- {
- namespace
- {
- template <int dim, int spacedim, class InVector>
- void back_interpolate (const DoFHandler<dim,spacedim> &dof1,
- const ConstraintMatrix &constraints1,
- const InVector &u1,
- const DoFHandler<dim,spacedim> &dof2,
- const ConstraintMatrix &constraints2,
- InVector &u1_interpolated)
- {
- Vector<typename InVector::value_type> u2(dof2.n_dofs());
- interpolate(dof1, u1, dof2, constraints2, u2);
- interpolate(dof2, u2, dof1, constraints1, u1_interpolated);
- }
-
- // special version for PETSc
-#ifdef DEAL_II_WITH_PETSC
- template <int dim, int spacedim>
- void back_interpolate (const DoFHandler<dim,spacedim> &dof1,
- const ConstraintMatrix &constraints1,
- const PETScWrappers::MPI::Vector &u1,
- const DoFHandler<dim,spacedim> &dof2,
- const ConstraintMatrix &constraints2,
- PETScWrappers::MPI::Vector &u1_interpolated)
- {
- // if u1 is a parallel distributed PETSc vector, we create a
- // vector u2 with based on the sets of locally owned and relevant
- // dofs of dof2
- IndexSet dof2_locally_owned_dofs = dof2.locally_owned_dofs();
- IndexSet dof2_locally_relevant_dofs;
- DoFTools::extract_locally_relevant_dofs (dof2,
- dof2_locally_relevant_dofs);
-
- PETScWrappers::MPI::Vector u2_out (u1.get_mpi_communicator(),
- dof2_locally_owned_dofs);
- interpolate(dof1, u1, dof2, constraints2, u2_out);
- PETScWrappers::MPI::Vector u2 (u1.get_mpi_communicator(),
- dof2_locally_owned_dofs,
- dof2_locally_relevant_dofs);
- u2 = u2_out;
- interpolate(dof2, u2, dof1, constraints1, u1_interpolated);
- }
-#endif
-
- // special version for parallel::distributed::Vector
- template <int dim, int spacedim, typename Number>
- void back_interpolate (const DoFHandler<dim,spacedim> &dof1,
- const ConstraintMatrix &constraints1,
- const parallel::distributed::Vector<Number> &u1,
- const DoFHandler<dim,spacedim> &dof2,
- const ConstraintMatrix &constraints2,
- parallel::distributed::Vector<Number> &u1_interpolated)
- {
- IndexSet dof2_locally_owned_dofs = dof2.locally_owned_dofs();
- IndexSet dof2_locally_relevant_dofs;
- DoFTools::extract_locally_relevant_dofs (dof2,
- dof2_locally_relevant_dofs);
-
- parallel::distributed::Vector<Number>
- u2 (dof2_locally_owned_dofs,
- dof2_locally_relevant_dofs,
- u1.get_mpi_communicator());
-
- interpolate(dof1, u1, dof2, constraints2, u2);
- u2.update_ghost_values ();
- interpolate(dof2, u2, dof1, constraints1, u1_interpolated);
- }
- }
- }
-
-
- template <int dim, class InVector, class OutVector, int spacedim>
- void back_interpolate(const DoFHandler<dim,spacedim> &dof1,
- const ConstraintMatrix &constraints1,
- const InVector &u1,
- const DoFHandler<dim,spacedim> &dof2,
- const ConstraintMatrix &constraints2,
- OutVector &u1_interpolated)
- {
- // For discontinuous elements without constraints take the simpler version
- // of the back_interpolate function.
- if (dof1.get_fe().dofs_per_vertex==0 && dof2.get_fe().dofs_per_vertex==0
- && constraints1.n_constraints()==0 && constraints2.n_constraints()==0)
- back_interpolate(dof1, u1, dof2.get_fe(), u1_interpolated);
- else
- {
- Assert(dof1.get_fe().n_components() == dof2.get_fe().n_components(),
- ExcDimensionMismatch(dof1.get_fe().n_components(), dof2.get_fe().n_components()));
- Assert(u1.size()==dof1.n_dofs(), ExcDimensionMismatch(u1.size(), dof1.n_dofs()));
- Assert(u1_interpolated.size()==dof1.n_dofs(),
- ExcDimensionMismatch(u1_interpolated.size(), dof1.n_dofs()));
-
- // For continuous elements first interpolate to dof2, taking into
- // account constraints2, and then interpolate back to dof1 taking into
- // account constraints1
- internal::back_interpolate(dof1, constraints1, u1, dof2, constraints2,
- u1_interpolated);
- }
- }
-
-
-
- template <int dim, class InVector, class OutVector, int spacedim>
- void interpolation_difference (const DoFHandler<dim,spacedim> &dof1,
- const InVector &u1,
- const FiniteElement<dim,spacedim> &fe2,
- OutVector &u1_difference)
- {
- Assert(dof1.get_fe().n_components() == fe2.n_components(),
- ExcDimensionMismatch(dof1.get_fe().n_components(), fe2.n_components()));
- Assert(u1.size()==dof1.n_dofs(), ExcDimensionMismatch(u1.size(), dof1.n_dofs()));
- Assert(u1_difference.size()==dof1.n_dofs(),
- ExcDimensionMismatch(u1_difference.size(), dof1.n_dofs()));
-
-#ifdef DEAL_II_WITH_PETSC
- if (dynamic_cast<const PETScWrappers::MPI::Vector *>(&u1) != 0)
- if (dynamic_cast<const DoFHandler<dim>*>(&dof1) != 0)
- {
- // if u1 is a parallel distributed
- // PETSc vector, we check the local
- // size of u1 for safety
- Assert(dynamic_cast<const PETScWrappers::MPI::Vector *>(&u1)->local_size() == dof1.locally_owned_dofs().n_elements(),
- ExcDimensionMismatch(dynamic_cast<const PETScWrappers::MPI::Vector *>(&u1)->local_size(), dof1.locally_owned_dofs().n_elements()));
- };
-
- if (dynamic_cast<PETScWrappers::MPI::Vector *>(&u1_difference) != 0)
- if (dynamic_cast<const DoFHandler<dim>*>(&dof1) != 0)
- {
- Assert(dynamic_cast<PETScWrappers::MPI::Vector *>(&u1_difference)->local_size() == dof1.locally_owned_dofs().n_elements(),
- ExcDimensionMismatch(dynamic_cast<PETScWrappers::MPI::Vector *>(&u1_difference)->local_size(), dof1.locally_owned_dofs().n_elements()));
- };
-#endif
-
- // For continuous elements on grids
- // with hanging nodes we need
- // hanging node
- // constraints. Consequently, when
- // the elements are continuous no
- // hanging node constraints are
- // allowed.
- const bool hanging_nodes_not_allowed=
- (dof1.get_fe().dofs_per_vertex != 0) || (fe2.dofs_per_vertex != 0);
-
- const unsigned int dofs_per_cell=dof1.get_fe().dofs_per_cell;
-
- Vector<typename OutVector::value_type> u1_local(dofs_per_cell);
- Vector<typename OutVector::value_type> u1_diff_local(dofs_per_cell);
-
- const types::subdomain_id subdomain_id =
- dof1.get_tria().locally_owned_subdomain();
-
- FullMatrix<double> difference_matrix(dofs_per_cell, dofs_per_cell);
- get_interpolation_difference_matrix(dof1.get_fe(), fe2,
- difference_matrix);
-
- typename DoFHandler<dim,spacedim>::active_cell_iterator cell = dof1.begin_active(),
- endc = dof1.end();
-
- for (; cell!=endc; ++cell)
- if ((cell->subdomain_id() == subdomain_id)
- ||
- (subdomain_id == numbers::invalid_subdomain_id))
- {
- if (hanging_nodes_not_allowed)
- for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
- Assert (cell->at_boundary(face) ||
- cell->neighbor(face)->level() == cell->level(),
- ExcHangingNodesNotAllowed(0));
-
- cell->get_dof_values(u1, u1_local);
- difference_matrix.vmult(u1_diff_local, u1_local);
- cell->set_dof_values(u1_diff_local, u1_difference);
- }
-
- // if we work on a parallel PETSc vector
- // we have to finish the work and
- // update ghost values
- u1_difference.compress(VectorOperation::insert);
- }
-
-
-
- template <int dim, class InVector, class OutVector, int spacedim>
- void interpolation_difference(const DoFHandler<dim,spacedim> &dof1,
- const ConstraintMatrix &constraints1,
- const InVector &u1,
- const DoFHandler<dim,spacedim> &dof2,
- const ConstraintMatrix &constraints2,
- OutVector &u1_difference)
- {
- // For discontinuous elements
- // without constraints take the
- // cheaper version of the
- // interpolation_difference function.
- if (dof1.get_fe().dofs_per_vertex==0 && dof2.get_fe().dofs_per_vertex==0
- && constraints1.n_constraints()==0 && constraints2.n_constraints()==0)
- interpolation_difference(dof1, u1, dof2.get_fe(), u1_difference);
- else
- {
- back_interpolate(dof1, constraints1, u1, dof2, constraints2, u1_difference);
- u1_difference.sadd(-1, u1);
- }
- }
-
-
-
- template <int dim, class InVector, class OutVector, int spacedim>
- void project_dg(const DoFHandler<dim,spacedim> &dof1,
- const InVector &u1,
- const DoFHandler<dim,spacedim> &dof2,
- OutVector &u2)
- {
- Assert(&dof1.get_tria()==&dof2.get_tria(), ExcTriangulationMismatch());
- Assert(dof1.get_fe().n_components() == dof2.get_fe().n_components(),
- ExcDimensionMismatch(dof1.get_fe().n_components(), dof2.get_fe().n_components()));
- Assert(u1.size()==dof1.n_dofs(), ExcDimensionMismatch(u1.size(), dof1.n_dofs()));
- Assert(u2.size()==dof2.n_dofs(), ExcDimensionMismatch(u2.size(), dof2.n_dofs()));
-
- typename DoFHandler<dim,spacedim>::active_cell_iterator cell1 = dof1.begin_active();
- typename DoFHandler<dim,spacedim>::active_cell_iterator cell2 = dof2.begin_active();
- typename DoFHandler<dim,spacedim>::active_cell_iterator end = dof2.end();
-
- const unsigned int n1 = dof1.get_fe().dofs_per_cell;
- const unsigned int n2 = dof2.get_fe().dofs_per_cell;
-
- Vector<double> u1_local(n1);
- Vector<double> u2_local(n2);
- std::vector<types::global_dof_index> dofs(n2);
-
- FullMatrix<double> matrix(n2,n1);
- get_projection_matrix(dof1.get_fe(), dof2.get_fe(), matrix);
-
- while (cell2 != end)
- {
- cell1->get_dof_values(u1, u1_local);
- matrix.vmult(u2_local, u1_local);
- cell2->get_dof_indices(dofs);
- for (unsigned int i=0; i<n2; ++i)
- {
- u2(dofs[i])+=u2_local(i);
- }
-
- ++cell1;
- ++cell2;
- }
- }
-
-
- template <int dim, class InVector, class OutVector, int spacedim>
- void extrapolate(const DoFHandler<dim,spacedim> &dof1,
- const InVector &u1,
- const DoFHandler<dim,spacedim> &dof2,
- OutVector &u2)
- {
- ConstraintMatrix dummy;
- dummy.close();
- extrapolate(dof1, u1, dof2, dummy, u2);
- }
-
-
-
- template <int dim, class InVector, class OutVector, int spacedim>
- void extrapolate(const DoFHandler<dim,spacedim> &dof1,
- const InVector &u1,
- const DoFHandler<dim,spacedim> &dof2,
- const ConstraintMatrix &constraints,
- OutVector &u2)
- {
- Assert(dof1.get_fe().n_components() == dof2.get_fe().n_components(),
- ExcDimensionMismatch(dof1.get_fe().n_components(), dof2.get_fe().n_components()));
- Assert(&dof1.get_tria()==&dof2.get_tria(), ExcTriangulationMismatch());
- Assert(u1.size()==dof1.n_dofs(), ExcDimensionMismatch(u1.size(), dof1.n_dofs()));
- Assert(u2.size()==dof2.n_dofs(), ExcDimensionMismatch(u2.size(), dof2.n_dofs()));
-
- OutVector u3;
- u3.reinit(u2);
- interpolate(dof1, u1, dof2, constraints, u3);
-
- const unsigned int dofs_per_cell = dof2.get_fe().dofs_per_cell;
- Vector<typename OutVector::value_type> dof_values(dofs_per_cell);
-
- // make sure that each cell on the
- // coarsest level is at least once
- // refined. otherwise, we can't
- // treat these cells and would
- // generate a bogus result
- {
- typename DoFHandler<dim,spacedim>::cell_iterator cell = dof2.begin(0),
- endc = dof2.end(0);
- for (; cell!=endc; ++cell)
- Assert (cell->has_children(), ExcGridNotRefinedAtLeastOnce());
- }
-
- // then traverse grid bottom up
- for (unsigned int level=0; level<dof1.get_tria().n_levels()-1; ++level)
- {
- typename DoFHandler<dim,spacedim>::cell_iterator cell=dof2.begin(level),
- endc=dof2.end(level);
-
- for (; cell!=endc; ++cell)
- if (!cell->active())
- {
- // check whether this
- // cell has active
- // children
- bool active_children=false;
- for (unsigned int child_n=0; child_n<cell->n_children(); ++child_n)
- if (cell->child(child_n)->active())
- {
- active_children=true;
- break;
- }
-
- // if there are active
- // children, the we have
- // to work on this
- // cell. get the data
- // from the one vector
- // and set it on the
- // other
- if (active_children)
- {
- cell->get_interpolated_dof_values(u3, dof_values);
- cell->set_dof_values_by_interpolation(dof_values, u2);
- }
- }
- }
-
- // Apply hanging node constraints.
- constraints.distribute(u2);
- }
-
template <>
void
return Utilities::invert_permutation(hierarchic_to_lexicographic_numbering (fe));
}
-}
+} // end of namespace FETools
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
-for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS; Vector : SERIAL_VECTORS)
- {
- namespace FETools
- \{
-#if deal_II_dimension <= deal_II_space_dimension
- template
- void interpolate<deal_II_dimension,deal_II_space_dimension>
- (const DoFHandler<deal_II_dimension,deal_II_space_dimension> &, const Vector &,
- const DoFHandler<deal_II_dimension,deal_II_space_dimension> &, Vector &);
-
- template
- void interpolate<deal_II_dimension,deal_II_space_dimension>
- (const DoFHandler<deal_II_dimension,deal_II_space_dimension> &, const Vector &,
- const DoFHandler<deal_II_dimension,deal_II_space_dimension> &, const ConstraintMatrix &,
- Vector &);
-#endif
- \}
- }
-
for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
{
namespace FETools
{
namespace FETools
\{
+
+#if deal_II_dimension <= deal_II_space_dimension
+ template
+ void get_interpolation_matrix<deal_II_dimension,double,deal_II_space_dimension>
+ (const FiniteElement<deal_II_dimension,deal_II_space_dimension> &,
+ const FiniteElement<deal_II_dimension,deal_II_space_dimension> &,
+ FullMatrix<double> &);
+#endif
+
#if deal_II_dimension == deal_II_space_dimension
template class FEFactoryBase<deal_II_dimension>;
void compute_component_wise(
const FiniteElement<deal_II_dimension>& ,
std::vector<unsigned int>&, std::vector<std::vector<unsigned int> >&);
- template
-
- void get_interpolation_matrix<deal_II_dimension>
- (const FiniteElement<deal_II_dimension> &,
- const FiniteElement<deal_II_dimension> &,
- FullMatrix<double> &);
+
template
void get_back_interpolation_matrix<deal_II_dimension>
(const FiniteElement<deal_II_dimension> &,
(const FiniteElement<deal_II_dimension> &, FullMatrix<double> (&)[GeometryInfo<deal_II_dimension>::max_children_per_face],
unsigned int, unsigned int);
- template
- void interpolate<deal_II_dimension>
- (const hp::DoFHandler<deal_II_dimension> &, const Vector<double> &,
- const hp::DoFHandler<deal_II_dimension> &, Vector<double> &);
- template
- void interpolate<deal_II_dimension>
- (const hp::DoFHandler<deal_II_dimension> &, const Vector<double> &,
- const hp::DoFHandler<deal_II_dimension> &, const ConstraintMatrix &,
- Vector<double> &);
- template
- void interpolate<deal_II_dimension>
- (const hp::DoFHandler<deal_II_dimension> &, const Vector<float> &,
- const hp::DoFHandler<deal_II_dimension> &, Vector<float> &);
- template
- void interpolate<deal_II_dimension>
- (const hp::DoFHandler<deal_II_dimension> &, const Vector<float> &,
- const hp::DoFHandler<deal_II_dimension> &, const ConstraintMatrix &,
- Vector<float> &);
-
template FiniteElement<deal_II_dimension,deal_II_dimension> *
get_fe_from_name<deal_II_dimension> (const std::string &);
#endif
\}
}
-
-
-
-for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS; VEC : SERIAL_VECTORS)
- {
- namespace FETools
- \{
-#if deal_II_dimension == deal_II_space_dimension
- template
- void back_interpolate<deal_II_dimension>
- (const DoFHandler<deal_II_dimension> &, const VEC &,
- const FiniteElement<deal_II_dimension> &, VEC &);
- template
- void back_interpolate<deal_II_dimension>
- (const DoFHandler<deal_II_dimension> &, const ConstraintMatrix &,
- const VEC &,
- const DoFHandler<deal_II_dimension> &, const ConstraintMatrix &,
- VEC &);
- template
- void interpolation_difference<deal_II_dimension>
- (const DoFHandler<deal_II_dimension> &, const VEC &,
- const FiniteElement<deal_II_dimension> &, VEC &);
- template
- void interpolation_difference<deal_II_dimension>
- (const DoFHandler<deal_II_dimension> &, const ConstraintMatrix &,
- const VEC &,
- const DoFHandler<deal_II_dimension> &, const ConstraintMatrix &,
- VEC &);
- template
- void project_dg<deal_II_dimension>
- (const DoFHandler<deal_II_dimension> &, const VEC &,
- const DoFHandler<deal_II_dimension> &, VEC &);
- template
- void extrapolate<deal_II_dimension>
- (const DoFHandler<deal_II_dimension> &, const VEC &,
- const DoFHandler<deal_II_dimension> &, VEC &);
- template
- void extrapolate<deal_II_dimension>
- (const DoFHandler<deal_II_dimension> &, const VEC &,
- const DoFHandler<deal_II_dimension> &, const ConstraintMatrix &,
- VEC &);
-#endif
- \}
- }
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 2000 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+#include <deal.II/base/quadrature_lib.h>
+#include <deal.II/base/qprojector.h>
+#include <deal.II/base/thread_management.h>
+#include <deal.II/base/utilities.h>
+#include <deal.II/lac/vector.h>
+#include <deal.II/lac/block_vector.h>
+#include <deal.II/lac/parallel_vector.h>
+#include <deal.II/lac/parallel_block_vector.h>
+#include <deal.II/lac/petsc_parallel_vector.h>
+#include <deal.II/lac/petsc_block_vector.h>
+#include <deal.II/lac/petsc_parallel_block_vector.h>
+#include <deal.II/lac/trilinos_vector.h>
+#include <deal.II/lac/trilinos_block_vector.h>
+#include <deal.II/lac/constraint_matrix.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/fe/fe_tools.h>
+#include <deal.II/fe/fe.h>
+#include <deal.II/fe/fe_values.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/dofs/dof_accessor.h>
+#include <deal.II/dofs/dof_tools.h>
+#include <deal.II/hp/dof_handler.h>
+
+#include <deal.II/base/std_cxx1x/shared_ptr.h>
+
+#include <deal.II/base/index_set.h>
+
+#include <iostream>
+
+
+DEAL_II_NAMESPACE_OPEN
+
+namespace FETools
+{
+ template <int dim, int spacedim,
+ template <int, int> class DH1,
+ template <int, int> class DH2,
+ class InVector, class OutVector>
+ void
+ interpolate(const DH1<dim, spacedim> &dof1,
+ const InVector &u1,
+ const DH2<dim, spacedim> &dof2,
+ OutVector &u2)
+ {
+ ConstraintMatrix dummy;
+ dummy.close();
+ interpolate(dof1, u1, dof2, dummy, u2);
+ }
+
+
+
+ template <int dim, int spacedim,
+ template <int, int> class DH1,
+ template <int, int> class DH2,
+ class InVector, class OutVector>
+ void
+ interpolate (const DH1<dim, spacedim> &dof1,
+ const InVector &u1,
+ const DH2<dim, spacedim> &dof2,
+ const ConstraintMatrix &constraints,
+ OutVector &u2)
+ {
+ Assert(&dof1.get_tria()==&dof2.get_tria(), ExcTriangulationMismatch());
+
+ Assert(u1.size()==dof1.n_dofs(),
+ ExcDimensionMismatch(u1.size(), dof1.n_dofs()));
+ Assert(u2.size()==dof2.n_dofs(),
+ ExcDimensionMismatch(u2.size(), dof2.n_dofs()));
+
+#ifdef DEAL_II_WITH_PETSC
+ if (dynamic_cast<const PETScWrappers::MPI::Vector *>(&u1) != 0)
+ if (dynamic_cast<const DoFHandler<dim>*>(&dof1) != 0)
+ {
+ // if u1 is a parallel distributed
+ // PETSc vector, we check the local
+ // size of u1 for safety
+ Assert(dynamic_cast<const PETScWrappers::MPI::Vector *>(&u1)->local_size() == dof1.locally_owned_dofs().n_elements(),
+ ExcDimensionMismatch(dynamic_cast<const PETScWrappers::MPI::Vector *>(&u1)->local_size(), dof1.locally_owned_dofs().n_elements()));
+ };
+
+ if (dynamic_cast<PETScWrappers::MPI::Vector *>(&u2) != 0)
+ if (dynamic_cast<const DoFHandler<dim>*>(&dof2) != 0)
+ {
+ Assert(dynamic_cast<PETScWrappers::MPI::Vector *>(&u2)->local_size() == dof2.locally_owned_dofs().n_elements(),
+ ExcDimensionMismatch(dynamic_cast<PETScWrappers::MPI::Vector *>(&u2)->local_size(), dof2.locally_owned_dofs().n_elements()));
+ };
+#endif
+ // allocate vectors at maximal
+ // size. will be reinited in inner
+ // cell, but Vector makes sure that
+ // this does not lead to
+ // reallocation of memory
+ Vector<typename OutVector::value_type> u1_local(DoFTools::max_dofs_per_cell(dof1));
+ Vector<typename OutVector::value_type> u2_local(DoFTools::max_dofs_per_cell(dof2));
+
+ // have a map for interpolation
+ // matrices. shared_ptr make sure
+ // that memory is released again
+ std::map<const FiniteElement<dim,spacedim> *,
+ std::map<const FiniteElement<dim,spacedim> *,
+ std_cxx1x::shared_ptr<FullMatrix<double> > > >
+ interpolation_matrices;
+
+ typename DH1<dim,spacedim>::active_cell_iterator cell1 = dof1.begin_active(),
+ endc1 = dof1.end();
+ typename DH2<dim,spacedim>::active_cell_iterator cell2 = dof2.begin_active(),
+ endc2 = dof2.end();
+
+ std::vector<types::global_dof_index> dofs;
+ dofs.reserve (DoFTools::max_dofs_per_cell (dof2));
+
+ u2 = 0;
+ OutVector touch_count(u2);
+ touch_count = 0;
+
+ // for distributed triangulations,
+ // we can only interpolate u1 on
+ // a cell, which this processor owns,
+ // so we have to know the subdomain_id
+ const types::subdomain_id subdomain_id =
+ dof1.get_tria().locally_owned_subdomain();
+
+ for (; cell1!=endc1; ++cell1, ++cell2)
+ if ((cell1->subdomain_id() == subdomain_id)
+ ||
+ (subdomain_id == numbers::invalid_subdomain_id))
+ {
+ Assert(cell1->get_fe().n_components() == cell2->get_fe().n_components(),
+ ExcDimensionMismatch (cell1->get_fe().n_components(),
+ cell2->get_fe().n_components()));
+
+ // for continuous elements on
+ // grids with hanging nodes we
+ // need hanging node
+ // constraints. Consequentely,
+ // if there are no constraints
+ // then hanging nodes are not
+ // allowed.
+ const bool hanging_nodes_not_allowed
+ = ((cell2->get_fe().dofs_per_vertex != 0) &&
+ (constraints.n_constraints() == 0));
+
+ if (hanging_nodes_not_allowed)
+ for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
+ Assert (cell1->at_boundary(face) ||
+ cell1->neighbor(face)->level() == cell1->level(),
+ ExcHangingNodesNotAllowed(0));
+
+
+ const unsigned int dofs_per_cell1 = cell1->get_fe().dofs_per_cell;
+ const unsigned int dofs_per_cell2 = cell2->get_fe().dofs_per_cell;
+ u1_local.reinit (dofs_per_cell1);
+ u2_local.reinit (dofs_per_cell2);
+
+ // check if interpolation
+ // matrix for this particular
+ // pair of elements is already
+ // there
+ if (interpolation_matrices[&cell1->get_fe()][&cell2->get_fe()].get() == 0)
+ {
+ std_cxx1x::shared_ptr<FullMatrix<double> >
+ interpolation_matrix (new FullMatrix<double> (dofs_per_cell2,
+ dofs_per_cell1));
+ interpolation_matrices[&cell1->get_fe()][&cell2->get_fe()]
+ = interpolation_matrix;
+
+ get_interpolation_matrix(cell1->get_fe(),
+ cell2->get_fe(),
+ *interpolation_matrix);
+ }
+
+ cell1->get_dof_values(u1, u1_local);
+ interpolation_matrices[&cell1->get_fe()][&cell2->get_fe()]
+ ->vmult(u2_local, u1_local);
+
+ dofs.resize (dofs_per_cell2);
+ cell2->get_dof_indices(dofs);
+
+ for (unsigned int i=0; i<dofs_per_cell2; ++i)
+ {
+ u2(dofs[i])+=u2_local(i);
+ touch_count(dofs[i]) += 1;
+ }
+ }
+ // cell1 is at the end, so should
+ // be cell2
+ Assert (cell2 == endc2, ExcInternalError());
+
+ u2.compress(VectorOperation::add);
+ touch_count.compress(VectorOperation::add);
+
+ // if we work on parallel distributed
+ // vectors, we have to ensure, that we only
+ // work on dofs this processor owns.
+ IndexSet locally_owned_dofs = dof2.locally_owned_dofs();
+
+ // when a discontinuous element is
+ // interpolated to a continuous
+ // one, we take the mean values.
+ // for parallel vectors check,
+ // if this component is owned by
+ // this processor.
+ for (types::global_dof_index i=0; i<dof2.n_dofs(); ++i)
+ if (locally_owned_dofs.is_element(i))
+ {
+ Assert(touch_count(i)!=0, ExcInternalError());
+ u2(i) /= touch_count(i);
+ }
+
+ // finish the work on parallel vectors
+ u2.compress(VectorOperation::insert);
+ // Apply hanging node constraints.
+ constraints.distribute(u2);
+ }
+
+
+
+ template <int dim, class InVector, class OutVector, int spacedim>
+ void
+ back_interpolate(const DoFHandler<dim,spacedim> &dof1,
+ const InVector &u1,
+ const FiniteElement<dim,spacedim> &fe2,
+ OutVector &u1_interpolated)
+ {
+ Assert(dof1.get_fe().n_components() == fe2.n_components(),
+ ExcDimensionMismatch(dof1.get_fe().n_components(), fe2.n_components()));
+ Assert(u1.size()==dof1.n_dofs(), ExcDimensionMismatch(u1.size(), dof1.n_dofs()));
+ Assert(u1_interpolated.size()==dof1.n_dofs(),
+ ExcDimensionMismatch(u1_interpolated.size(), dof1.n_dofs()));
+
+#ifdef DEAL_II_WITH_PETSC
+ if (dynamic_cast<const PETScWrappers::MPI::Vector *>(&u1) != 0)
+ if (dynamic_cast<const DoFHandler<dim>*>(&dof1) != 0)
+ {
+ // if u1 is a parallel distributed
+ // PETSc vector, we check the local
+ // size of u1 for safety
+ Assert(dynamic_cast<const PETScWrappers::MPI::Vector *>(&u1)->local_size() == dof1.locally_owned_dofs().n_elements(),
+ ExcDimensionMismatch(dynamic_cast<const PETScWrappers::MPI::Vector *>(&u1)->local_size(), dof1.locally_owned_dofs().n_elements()));
+ };
+
+ if (dynamic_cast<PETScWrappers::MPI::Vector *>(&u1_interpolated) != 0)
+ if (dynamic_cast<const DoFHandler<dim>*>(&dof1) != 0)
+ {
+ Assert(dynamic_cast<PETScWrappers::MPI::Vector *>(&u1_interpolated)->local_size() == dof1.locally_owned_dofs().n_elements(),
+ ExcDimensionMismatch(dynamic_cast<PETScWrappers::MPI::Vector *>(&u1_interpolated)->local_size(), dof1.locally_owned_dofs().n_elements()));
+ };
+#endif
+
+ // For continuous elements on grids
+ // with hanging nodes we need
+ // hanging node
+ // constraints. Consequently, when
+ // the elements are continuous no
+ // hanging node constraints are
+ // allowed.
+ const bool hanging_nodes_not_allowed=
+ (dof1.get_fe().dofs_per_vertex != 0) || (fe2.dofs_per_vertex != 0);
+
+ const unsigned int dofs_per_cell1=dof1.get_fe().dofs_per_cell;
+
+ Vector<typename OutVector::value_type> u1_local(dofs_per_cell1);
+ Vector<typename OutVector::value_type> u1_int_local(dofs_per_cell1);
+
+ const types::subdomain_id subdomain_id =
+ dof1.get_tria().locally_owned_subdomain();
+
+ typename DoFHandler<dim,spacedim>::active_cell_iterator cell = dof1.begin_active(),
+ endc = dof1.end();
+
+ FullMatrix<double> interpolation_matrix(dofs_per_cell1, dofs_per_cell1);
+ get_back_interpolation_matrix(dof1.get_fe(), fe2,
+ interpolation_matrix);
+ for (; cell!=endc; ++cell)
+ if ((cell->subdomain_id() == subdomain_id)
+ ||
+ (subdomain_id == numbers::invalid_subdomain_id))
+ {
+ if (hanging_nodes_not_allowed)
+ for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
+ Assert (cell->at_boundary(face) ||
+ cell->neighbor(face)->level() == cell->level(),
+ ExcHangingNodesNotAllowed(0));
+
+ cell->get_dof_values(u1, u1_local);
+ interpolation_matrix.vmult(u1_int_local, u1_local);
+ cell->set_dof_values(u1_int_local, u1_interpolated);
+ }
+
+ // if we work on a parallel PETSc vector
+ // we have to finish the work
+ u1_interpolated.compress(VectorOperation::insert);
+ }
+
+
+
+ template <int dim,
+ template <int> class DH,
+ class InVector, class OutVector, int spacedim>
+ void
+ back_interpolate(const DH<dim> &dof1,
+ const InVector &u1,
+ const FiniteElement<dim,spacedim> &fe2,
+ OutVector &u1_interpolated)
+ {
+ Assert(u1.size() == dof1.n_dofs(),
+ ExcDimensionMismatch(u1.size(), dof1.n_dofs()));
+ Assert(u1_interpolated.size() == dof1.n_dofs(),
+ ExcDimensionMismatch(u1_interpolated.size(), dof1.n_dofs()));
+
+#ifdef DEAL_II_WITH_PETSC
+ if (dynamic_cast<const PETScWrappers::MPI::Vector *>(&u1) != 0)
+ if (dynamic_cast<const DoFHandler<dim>*>(&dof1) != 0)
+ {
+ // if u1 is a parallel distributed
+ // PETSc vector, we check the local
+ // size of u1 for safety
+ Assert(dynamic_cast<const PETScWrappers::MPI::Vector *>(&u1)->local_size() == dof1.locally_owned_dofs().n_elements(),
+ ExcDimensionMismatch(dynamic_cast<const PETScWrappers::MPI::Vector *>(&u1)->local_size(), dof1.locally_owned_dofs().n_elements()));
+ };
+
+ if (dynamic_cast<PETScWrappers::MPI::Vector *>(&u1_interpolated) != 0)
+ if (dynamic_cast<const DoFHandler<dim>*>(&dof1) != 0)
+ {
+ Assert(dynamic_cast<PETScWrappers::MPI::Vector *>(&u1_interpolated)->local_size() == dof1.locally_owned_dofs().n_elements(),
+ ExcDimensionMismatch(dynamic_cast<PETScWrappers::MPI::Vector *>(&u1_interpolated)->local_size(), dof1.locally_owned_dofs().n_elements()));
+ };
+#endif
+
+ Vector<typename OutVector::value_type> u1_local(DoFTools::max_dofs_per_cell(dof1));
+ Vector<typename OutVector::value_type> u1_int_local(DoFTools::max_dofs_per_cell(dof1));
+
+ const types::subdomain_id subdomain_id =
+ dof1.get_tria().locally_owned_subdomain();
+
+ typename DH<dim>::active_cell_iterator cell = dof1.begin_active(),
+ endc = dof1.end();
+
+ // map from possible fe objects in
+ // dof1 to the back_interpolation
+ // matrices
+ std::map<const FiniteElement<dim> *,
+ std_cxx1x::shared_ptr<FullMatrix<double> > > interpolation_matrices;
+
+ for (; cell!=endc; ++cell)
+ if ((cell->subdomain_id() == subdomain_id)
+ ||
+ (subdomain_id == numbers::invalid_subdomain_id))
+ {
+ Assert(cell->get_fe().n_components() == fe2.n_components(),
+ ExcDimensionMismatch(cell->get_fe().n_components(),
+ fe2.n_components()));
+
+ // For continuous elements on
+ // grids with hanging nodes we
+ // need hanging node
+ // constraints. Consequently,
+ // when the elements are
+ // continuous no hanging node
+ // constraints are allowed.
+ const bool hanging_nodes_not_allowed=
+ (cell->get_fe().dofs_per_vertex != 0) || (fe2.dofs_per_vertex != 0);
+
+ if (hanging_nodes_not_allowed)
+ for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
+ Assert (cell->at_boundary(face) ||
+ cell->neighbor(face)->level() == cell->level(),
+ ExcHangingNodesNotAllowed(0));
+
+ const unsigned int dofs_per_cell1 = cell->get_fe().dofs_per_cell;
+
+ // make sure back_interpolation
+ // matrix is available
+ if (interpolation_matrices[&cell->get_fe()] != 0)
+ {
+ interpolation_matrices[&cell->get_fe()] =
+ std_cxx1x::shared_ptr<FullMatrix<double> >
+ (new FullMatrix<double>(dofs_per_cell1, dofs_per_cell1));
+ get_back_interpolation_matrix(dof1.get_fe(), fe2,
+ *interpolation_matrices[&cell->get_fe()]);
+ }
+
+ u1_local.reinit (dofs_per_cell1);
+ u1_int_local.reinit (dofs_per_cell1);
+
+ cell->get_dof_values(u1, u1_local);
+ interpolation_matrices[&cell->get_fe()]->vmult(u1_int_local, u1_local);
+ cell->set_dof_values(u1_int_local, u1_interpolated);
+ };
+
+ // if we work on a parallel PETSc vector
+ // we have to finish the work
+ u1_interpolated.compress(VectorOperation::insert);
+ }
+
+
+
+ namespace internal
+ {
+ namespace
+ {
+ template <int dim, int spacedim, class InVector>
+ void back_interpolate (const DoFHandler<dim,spacedim> &dof1,
+ const ConstraintMatrix &constraints1,
+ const InVector &u1,
+ const DoFHandler<dim,spacedim> &dof2,
+ const ConstraintMatrix &constraints2,
+ InVector &u1_interpolated)
+ {
+ Vector<typename InVector::value_type> u2(dof2.n_dofs());
+ interpolate(dof1, u1, dof2, constraints2, u2);
+ interpolate(dof2, u2, dof1, constraints1, u1_interpolated);
+ }
+
+ // special version for PETSc
+#ifdef DEAL_II_WITH_PETSC
+ template <int dim, int spacedim>
+ void back_interpolate (const DoFHandler<dim,spacedim> &dof1,
+ const ConstraintMatrix &constraints1,
+ const PETScWrappers::MPI::Vector &u1,
+ const DoFHandler<dim,spacedim> &dof2,
+ const ConstraintMatrix &constraints2,
+ PETScWrappers::MPI::Vector &u1_interpolated)
+ {
+ // if u1 is a parallel distributed PETSc vector, we create a
+ // vector u2 with based on the sets of locally owned and relevant
+ // dofs of dof2
+ IndexSet dof2_locally_owned_dofs = dof2.locally_owned_dofs();
+ IndexSet dof2_locally_relevant_dofs;
+ DoFTools::extract_locally_relevant_dofs (dof2,
+ dof2_locally_relevant_dofs);
+
+ PETScWrappers::MPI::Vector u2_out (u1.get_mpi_communicator(),
+ dof2_locally_owned_dofs);
+ interpolate(dof1, u1, dof2, constraints2, u2_out);
+ PETScWrappers::MPI::Vector u2 (u1.get_mpi_communicator(),
+ dof2_locally_owned_dofs,
+ dof2_locally_relevant_dofs);
+ u2 = u2_out;
+ interpolate(dof2, u2, dof1, constraints1, u1_interpolated);
+ }
+#endif
+
+ // special version for parallel::distributed::Vector
+ template <int dim, int spacedim, typename Number>
+ void back_interpolate (const DoFHandler<dim,spacedim> &dof1,
+ const ConstraintMatrix &constraints1,
+ const parallel::distributed::Vector<Number> &u1,
+ const DoFHandler<dim,spacedim> &dof2,
+ const ConstraintMatrix &constraints2,
+ parallel::distributed::Vector<Number> &u1_interpolated)
+ {
+ IndexSet dof2_locally_owned_dofs = dof2.locally_owned_dofs();
+ IndexSet dof2_locally_relevant_dofs;
+ DoFTools::extract_locally_relevant_dofs (dof2,
+ dof2_locally_relevant_dofs);
+
+ parallel::distributed::Vector<Number>
+ u2 (dof2_locally_owned_dofs,
+ dof2_locally_relevant_dofs,
+ u1.get_mpi_communicator());
+
+ interpolate(dof1, u1, dof2, constraints2, u2);
+ u2.update_ghost_values ();
+ interpolate(dof2, u2, dof1, constraints1, u1_interpolated);
+ }
+ }
+ }
+
+
+ template <int dim, class InVector, class OutVector, int spacedim>
+ void back_interpolate(const DoFHandler<dim,spacedim> &dof1,
+ const ConstraintMatrix &constraints1,
+ const InVector &u1,
+ const DoFHandler<dim,spacedim> &dof2,
+ const ConstraintMatrix &constraints2,
+ OutVector &u1_interpolated)
+ {
+ // For discontinuous elements without constraints take the simpler version
+ // of the back_interpolate function.
+ if (dof1.get_fe().dofs_per_vertex==0 && dof2.get_fe().dofs_per_vertex==0
+ && constraints1.n_constraints()==0 && constraints2.n_constraints()==0)
+ back_interpolate(dof1, u1, dof2.get_fe(), u1_interpolated);
+ else
+ {
+ Assert(dof1.get_fe().n_components() == dof2.get_fe().n_components(),
+ ExcDimensionMismatch(dof1.get_fe().n_components(), dof2.get_fe().n_components()));
+ Assert(u1.size()==dof1.n_dofs(), ExcDimensionMismatch(u1.size(), dof1.n_dofs()));
+ Assert(u1_interpolated.size()==dof1.n_dofs(),
+ ExcDimensionMismatch(u1_interpolated.size(), dof1.n_dofs()));
+
+ // For continuous elements first interpolate to dof2, taking into
+ // account constraints2, and then interpolate back to dof1 taking into
+ // account constraints1
+ internal::back_interpolate(dof1, constraints1, u1, dof2, constraints2,
+ u1_interpolated);
+ }
+ }
+
+
+
+ template <int dim, class InVector, class OutVector, int spacedim>
+ void interpolation_difference (const DoFHandler<dim,spacedim> &dof1,
+ const InVector &u1,
+ const FiniteElement<dim,spacedim> &fe2,
+ OutVector &u1_difference)
+ {
+ Assert(dof1.get_fe().n_components() == fe2.n_components(),
+ ExcDimensionMismatch(dof1.get_fe().n_components(), fe2.n_components()));
+ Assert(u1.size()==dof1.n_dofs(), ExcDimensionMismatch(u1.size(), dof1.n_dofs()));
+ Assert(u1_difference.size()==dof1.n_dofs(),
+ ExcDimensionMismatch(u1_difference.size(), dof1.n_dofs()));
+
+#ifdef DEAL_II_WITH_PETSC
+ if (dynamic_cast<const PETScWrappers::MPI::Vector *>(&u1) != 0)
+ if (dynamic_cast<const DoFHandler<dim>*>(&dof1) != 0)
+ {
+ // if u1 is a parallel distributed
+ // PETSc vector, we check the local
+ // size of u1 for safety
+ Assert(dynamic_cast<const PETScWrappers::MPI::Vector *>(&u1)->local_size() == dof1.locally_owned_dofs().n_elements(),
+ ExcDimensionMismatch(dynamic_cast<const PETScWrappers::MPI::Vector *>(&u1)->local_size(), dof1.locally_owned_dofs().n_elements()));
+ };
+
+ if (dynamic_cast<PETScWrappers::MPI::Vector *>(&u1_difference) != 0)
+ if (dynamic_cast<const DoFHandler<dim>*>(&dof1) != 0)
+ {
+ Assert(dynamic_cast<PETScWrappers::MPI::Vector *>(&u1_difference)->local_size() == dof1.locally_owned_dofs().n_elements(),
+ ExcDimensionMismatch(dynamic_cast<PETScWrappers::MPI::Vector *>(&u1_difference)->local_size(), dof1.locally_owned_dofs().n_elements()));
+ };
+#endif
+
+ // For continuous elements on grids
+ // with hanging nodes we need
+ // hanging node
+ // constraints. Consequently, when
+ // the elements are continuous no
+ // hanging node constraints are
+ // allowed.
+ const bool hanging_nodes_not_allowed=
+ (dof1.get_fe().dofs_per_vertex != 0) || (fe2.dofs_per_vertex != 0);
+
+ const unsigned int dofs_per_cell=dof1.get_fe().dofs_per_cell;
+
+ Vector<typename OutVector::value_type> u1_local(dofs_per_cell);
+ Vector<typename OutVector::value_type> u1_diff_local(dofs_per_cell);
+
+ const types::subdomain_id subdomain_id =
+ dof1.get_tria().locally_owned_subdomain();
+
+ FullMatrix<double> difference_matrix(dofs_per_cell, dofs_per_cell);
+ get_interpolation_difference_matrix(dof1.get_fe(), fe2,
+ difference_matrix);
+
+ typename DoFHandler<dim,spacedim>::active_cell_iterator cell = dof1.begin_active(),
+ endc = dof1.end();
+
+ for (; cell!=endc; ++cell)
+ if ((cell->subdomain_id() == subdomain_id)
+ ||
+ (subdomain_id == numbers::invalid_subdomain_id))
+ {
+ if (hanging_nodes_not_allowed)
+ for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
+ Assert (cell->at_boundary(face) ||
+ cell->neighbor(face)->level() == cell->level(),
+ ExcHangingNodesNotAllowed(0));
+
+ cell->get_dof_values(u1, u1_local);
+ difference_matrix.vmult(u1_diff_local, u1_local);
+ cell->set_dof_values(u1_diff_local, u1_difference);
+ }
+
+ // if we work on a parallel PETSc vector
+ // we have to finish the work and
+ // update ghost values
+ u1_difference.compress(VectorOperation::insert);
+ }
+
+
+
+ template <int dim, class InVector, class OutVector, int spacedim>
+ void interpolation_difference(const DoFHandler<dim,spacedim> &dof1,
+ const ConstraintMatrix &constraints1,
+ const InVector &u1,
+ const DoFHandler<dim,spacedim> &dof2,
+ const ConstraintMatrix &constraints2,
+ OutVector &u1_difference)
+ {
+ // For discontinuous elements
+ // without constraints take the
+ // cheaper version of the
+ // interpolation_difference function.
+ if (dof1.get_fe().dofs_per_vertex==0 && dof2.get_fe().dofs_per_vertex==0
+ && constraints1.n_constraints()==0 && constraints2.n_constraints()==0)
+ interpolation_difference(dof1, u1, dof2.get_fe(), u1_difference);
+ else
+ {
+ back_interpolate(dof1, constraints1, u1, dof2, constraints2, u1_difference);
+ u1_difference.sadd(-1, u1);
+ }
+ }
+
+
+
+ template <int dim, class InVector, class OutVector, int spacedim>
+ void project_dg(const DoFHandler<dim,spacedim> &dof1,
+ const InVector &u1,
+ const DoFHandler<dim,spacedim> &dof2,
+ OutVector &u2)
+ {
+ Assert(&dof1.get_tria()==&dof2.get_tria(), ExcTriangulationMismatch());
+ Assert(dof1.get_fe().n_components() == dof2.get_fe().n_components(),
+ ExcDimensionMismatch(dof1.get_fe().n_components(), dof2.get_fe().n_components()));
+ Assert(u1.size()==dof1.n_dofs(), ExcDimensionMismatch(u1.size(), dof1.n_dofs()));
+ Assert(u2.size()==dof2.n_dofs(), ExcDimensionMismatch(u2.size(), dof2.n_dofs()));
+
+ typename DoFHandler<dim,spacedim>::active_cell_iterator cell1 = dof1.begin_active();
+ typename DoFHandler<dim,spacedim>::active_cell_iterator cell2 = dof2.begin_active();
+ typename DoFHandler<dim,spacedim>::active_cell_iterator end = dof2.end();
+
+ const unsigned int n1 = dof1.get_fe().dofs_per_cell;
+ const unsigned int n2 = dof2.get_fe().dofs_per_cell;
+
+ Vector<double> u1_local(n1);
+ Vector<double> u2_local(n2);
+ std::vector<types::global_dof_index> dofs(n2);
+
+ FullMatrix<double> matrix(n2,n1);
+ get_projection_matrix(dof1.get_fe(), dof2.get_fe(), matrix);
+
+ while (cell2 != end)
+ {
+ cell1->get_dof_values(u1, u1_local);
+ matrix.vmult(u2_local, u1_local);
+ cell2->get_dof_indices(dofs);
+ for (unsigned int i=0; i<n2; ++i)
+ {
+ u2(dofs[i])+=u2_local(i);
+ }
+
+ ++cell1;
+ ++cell2;
+ }
+ }
+
+
+ template <int dim, class InVector, class OutVector, int spacedim>
+ void extrapolate(const DoFHandler<dim,spacedim> &dof1,
+ const InVector &u1,
+ const DoFHandler<dim,spacedim> &dof2,
+ OutVector &u2)
+ {
+ ConstraintMatrix dummy;
+ dummy.close();
+ extrapolate(dof1, u1, dof2, dummy, u2);
+ }
+
+
+
+ template <int dim, class InVector, class OutVector, int spacedim>
+ void extrapolate(const DoFHandler<dim,spacedim> &dof1,
+ const InVector &u1,
+ const DoFHandler<dim,spacedim> &dof2,
+ const ConstraintMatrix &constraints,
+ OutVector &u2)
+ {
+ Assert(dof1.get_fe().n_components() == dof2.get_fe().n_components(),
+ ExcDimensionMismatch(dof1.get_fe().n_components(), dof2.get_fe().n_components()));
+ Assert(&dof1.get_tria()==&dof2.get_tria(), ExcTriangulationMismatch());
+ Assert(u1.size()==dof1.n_dofs(), ExcDimensionMismatch(u1.size(), dof1.n_dofs()));
+ Assert(u2.size()==dof2.n_dofs(), ExcDimensionMismatch(u2.size(), dof2.n_dofs()));
+
+ OutVector u3;
+ u3.reinit(u2);
+ interpolate(dof1, u1, dof2, constraints, u3);
+
+ const unsigned int dofs_per_cell = dof2.get_fe().dofs_per_cell;
+ Vector<typename OutVector::value_type> dof_values(dofs_per_cell);
+
+ // make sure that each cell on the
+ // coarsest level is at least once
+ // refined. otherwise, we can't
+ // treat these cells and would
+ // generate a bogus result
+ {
+ typename DoFHandler<dim,spacedim>::cell_iterator cell = dof2.begin(0),
+ endc = dof2.end(0);
+ for (; cell!=endc; ++cell)
+ Assert (cell->has_children(), ExcGridNotRefinedAtLeastOnce());
+ }
+
+ // then traverse grid bottom up
+ for (unsigned int level=0; level<dof1.get_tria().n_levels()-1; ++level)
+ {
+ typename DoFHandler<dim,spacedim>::cell_iterator cell=dof2.begin(level),
+ endc=dof2.end(level);
+
+ for (; cell!=endc; ++cell)
+ if (!cell->active())
+ {
+ // check whether this
+ // cell has active
+ // children
+ bool active_children=false;
+ for (unsigned int child_n=0; child_n<cell->n_children(); ++child_n)
+ if (cell->child(child_n)->active())
+ {
+ active_children=true;
+ break;
+ }
+
+ // if there are active
+ // children, the we have
+ // to work on this
+ // cell. get the data
+ // from the one vector
+ // and set it on the
+ // other
+ if (active_children)
+ {
+ cell->get_interpolated_dof_values(u3, dof_values);
+ cell->set_dof_values_by_interpolation(dof_values, u2);
+ }
+ }
+ }
+
+ // Apply hanging node constraints.
+ constraints.distribute(u2);
+ }
+
+} // end of namespace FETools
+
+
+
+/*-------------- Explicit Instantiations -------------------------------*/
+#include "fe_tools_interpolate.inst"
+
+
+/*---------------------------- fe_tools.cc ---------------------------*/
+
+DEAL_II_NAMESPACE_CLOSE
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1998 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+
+for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS; Vector : SERIAL_VECTORS)
+ {
+ namespace FETools
+ \{
+#if deal_II_dimension <= deal_II_space_dimension
+ template
+ void interpolate<deal_II_dimension,deal_II_space_dimension>
+ (const DoFHandler<deal_II_dimension,deal_II_space_dimension> &, const Vector &,
+ const DoFHandler<deal_II_dimension,deal_II_space_dimension> &, Vector &);
+
+ template
+ void interpolate<deal_II_dimension,deal_II_space_dimension>
+ (const DoFHandler<deal_II_dimension,deal_II_space_dimension> &, const Vector &,
+ const DoFHandler<deal_II_dimension,deal_II_space_dimension> &, const ConstraintMatrix &,
+ Vector &);
+#endif
+ \}
+ }
+
+for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
+ {
+ namespace FETools
+ \{
+#if deal_II_dimension == deal_II_space_dimension
+ template
+ void interpolate<deal_II_dimension>
+ (const hp::DoFHandler<deal_II_dimension> &, const Vector<double> &,
+ const hp::DoFHandler<deal_II_dimension> &, Vector<double> &);
+ template
+ void interpolate<deal_II_dimension>
+ (const hp::DoFHandler<deal_II_dimension> &, const Vector<double> &,
+ const hp::DoFHandler<deal_II_dimension> &, const ConstraintMatrix &,
+ Vector<double> &);
+ template
+ void interpolate<deal_II_dimension>
+ (const hp::DoFHandler<deal_II_dimension> &, const Vector<float> &,
+ const hp::DoFHandler<deal_II_dimension> &, Vector<float> &);
+ template
+ void interpolate<deal_II_dimension>
+ (const hp::DoFHandler<deal_II_dimension> &, const Vector<float> &,
+ const hp::DoFHandler<deal_II_dimension> &, const ConstraintMatrix &,
+ Vector<float> &);
+#endif
+ \}
+ }
+
+
+
+for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS; VEC : SERIAL_VECTORS)
+ {
+ namespace FETools
+ \{
+#if deal_II_dimension == deal_II_space_dimension
+ template
+ void back_interpolate<deal_II_dimension>
+ (const DoFHandler<deal_II_dimension> &, const VEC &,
+ const FiniteElement<deal_II_dimension> &, VEC &);
+ template
+ void back_interpolate<deal_II_dimension>
+ (const DoFHandler<deal_II_dimension> &, const ConstraintMatrix &,
+ const VEC &,
+ const DoFHandler<deal_II_dimension> &, const ConstraintMatrix &,
+ VEC &);
+ template
+ void interpolation_difference<deal_II_dimension>
+ (const DoFHandler<deal_II_dimension> &, const VEC &,
+ const FiniteElement<deal_II_dimension> &, VEC &);
+ template
+ void interpolation_difference<deal_II_dimension>
+ (const DoFHandler<deal_II_dimension> &, const ConstraintMatrix &,
+ const VEC &,
+ const DoFHandler<deal_II_dimension> &, const ConstraintMatrix &,
+ VEC &);
+ template
+ void project_dg<deal_II_dimension>
+ (const DoFHandler<deal_II_dimension> &, const VEC &,
+ const DoFHandler<deal_II_dimension> &, VEC &);
+ template
+ void extrapolate<deal_II_dimension>
+ (const DoFHandler<deal_II_dimension> &, const VEC &,
+ const DoFHandler<deal_II_dimension> &, VEC &);
+ template
+ void extrapolate<deal_II_dimension>
+ (const DoFHandler<deal_II_dimension> &, const VEC &,
+ const DoFHandler<deal_II_dimension> &, const ConstraintMatrix &,
+ VEC &);
+#endif
+ \}
+ }
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998-2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/memory_consumption.h>
#include <deal.II/base/quadrature.h>
}
+ template <int dim, int spacedim>
+ Tensor<2, dim, spacedim>::
+ Tensor(const FEValuesBase<dim, spacedim> &fe_values,
+ const unsigned int first_tensor_component)
+ :
+ fe_values(fe_values),
+ first_tensor_component(first_tensor_component),
+ shape_function_data(fe_values.fe->dofs_per_cell)
+ {
+ Assert(first_tensor_component + dim*dim - 1
+ <
+ fe_values.fe->n_components(),
+ ExcIndexRange(first_tensor_component +
+ dim*dim - 1,
+ 0,
+ fe_values.fe->n_components()));
+//TODO: we'd like to use the fields with the same name as these
+// variables from FEValuesData, but they aren't initialized yet
+// at the time we get here, so re-create it all
+ const std::vector<unsigned int> shape_function_to_row_table
+ = make_shape_function_to_row_table (*fe_values.fe);
+
+ for (unsigned int d = 0; d < dim*dim; ++d)
+ {
+ const unsigned int component = first_tensor_component + d;
+
+ for (unsigned int i = 0; i < fe_values.fe->dofs_per_cell; ++i)
+ {
+ const bool is_primitive = (fe_values.fe->is_primitive() ||
+ fe_values.fe->is_primitive(i));
+
+ if (is_primitive == true)
+ shape_function_data[i].is_nonzero_shape_function_component[d]
+ = (component ==
+ fe_values.fe->system_to_component_index(i).first);
+ else
+ shape_function_data[i].is_nonzero_shape_function_component[d]
+ = (fe_values.fe->get_nonzero_components(i)[component]
+ == true);
+
+ if (shape_function_data[i].is_nonzero_shape_function_component[d]
+ == true)
+ shape_function_data[i].row_index[d]
+ = shape_function_to_row_table[i*fe_values.fe->n_components()+component];
+ else
+ shape_function_data[i].row_index[d]
+ = numbers::invalid_unsigned_int;
+ }
+ }
+
+ for (unsigned int i = 0; i < fe_values.fe->dofs_per_cell; ++i)
+ {
+ unsigned int n_nonzero_components = 0;
+ for (unsigned int d = 0; d < dim*dim; ++d)
+ if (shape_function_data[i].is_nonzero_shape_function_component[d]
+ == true)
+ ++n_nonzero_components;
+
+ if (n_nonzero_components == 0)
+ shape_function_data[i].single_nonzero_component = -2;
+ else if (n_nonzero_components > 1)
+ shape_function_data[i].single_nonzero_component = -1;
+ else
+ {
+ for (unsigned int d = 0; d < dim*dim; ++d)
+ if (shape_function_data[i].is_nonzero_shape_function_component[d]
+ == true)
+ {
+ shape_function_data[i].single_nonzero_component
+ = shape_function_data[i].row_index[d];
+ shape_function_data[i].single_nonzero_component_index
+ = d;
+ break;
+ }
+ }
+ }
+ }
+
+
+
+ template <int dim, int spacedim>
+ Tensor<2, dim, spacedim>::Tensor()
+ :
+ fe_values(*static_cast<dealii::FEValuesBase<dim, spacedim>*> (0)),
+ first_tensor_component(numbers::invalid_unsigned_int)
+ {}
+
+
+
+ template <int dim, int spacedim>
+ Tensor<2, dim, spacedim> &
+ Tensor<2, dim, spacedim>::operator=(const Tensor<2, dim, spacedim> &)
+ {
+ // we shouldn't be copying these objects
+ Assert(false, ExcInternalError());
+ return *this;
+ }
+
namespace internal
{
const double *shape_value_ptr =
&shape_values(shape_function_data[shape_function].row_index, 0);
for (unsigned int q_point=0; q_point<n_quadrature_points; ++q_point)
- values[q_point] += value * *shape_value_ptr++;
+ values[q_point] += value **shape_value_ptr++;
}
}
template <int order, int dim, int spacedim>
void
do_function_derivatives (const ::dealii::Vector<double> &dof_values,
- const std::vector<std::vector<Tensor<order,spacedim> > > &shape_derivatives,
+ const std::vector<std::vector<dealii::Tensor<order,spacedim> > > &shape_derivatives,
const std::vector<typename Scalar<dim,spacedim>::ShapeFunctionData> &shape_function_data,
- std::vector<Tensor<order,spacedim> > &derivatives)
+ std::vector<dealii::Tensor<order,spacedim> > &derivatives)
{
const unsigned int dofs_per_cell = dof_values.size();
const unsigned int n_quadrature_points = dofs_per_cell > 0 ?
AssertDimension (derivatives.size(), n_quadrature_points);
std::fill (derivatives.begin(), derivatives.end(),
- Tensor<order,spacedim>());
+ dealii::Tensor<order,spacedim>());
for (unsigned int shape_function=0;
shape_function<dofs_per_cell; ++shape_function)
if (value == 0.)
continue;
- const Tensor<order,spacedim> *shape_derivative_ptr =
+ const dealii::Tensor<order,spacedim> *shape_derivative_ptr =
&shape_derivatives[shape_function_data[shape_function].row_index][0];
for (unsigned int q_point=0; q_point<n_quadrature_points; ++q_point)
- derivatives[q_point] += value * *shape_derivative_ptr++;
+ derivatives[q_point] += value **shape_derivative_ptr++;
}
}
template <int dim, int spacedim>
void
do_function_laplacians (const ::dealii::Vector<double> &dof_values,
- const std::vector<std::vector<Tensor<2,spacedim> > > &shape_hessians,
+ const std::vector<std::vector<dealii::Tensor<2,spacedim> > > &shape_hessians,
const std::vector<typename Scalar<dim,spacedim>::ShapeFunctionData> &shape_function_data,
std::vector<double> &laplacians)
{
if (value == 0.)
continue;
- const Tensor<2,spacedim> *shape_hessian_ptr =
+ const dealii::Tensor<2,spacedim> *shape_hessian_ptr =
&shape_hessians[shape_function_data[shape_function].row_index][0];
for (unsigned int q_point=0; q_point<n_quadrature_points; ++q_point)
laplacians[q_point] += value * trace(*shape_hessian_ptr++);
void do_function_values (const ::dealii::Vector<double> &dof_values,
const Table<2,double> &shape_values,
const std::vector<typename Vector<dim,spacedim>::ShapeFunctionData> &shape_function_data,
- std::vector<Tensor<1,spacedim> > &values)
+ std::vector<dealii::Tensor<1,spacedim> > &values)
{
const unsigned int dofs_per_cell = dof_values.size();
const unsigned int n_quadrature_points = dofs_per_cell > 0 ?
shape_values.n_cols() : values.size();
AssertDimension (values.size(), n_quadrature_points);
- std::fill (values.begin(), values.end(), Tensor<1,spacedim>());
+ std::fill (values.begin(), values.end(), dealii::Tensor<1,spacedim>());
for (unsigned int shape_function=0;
shape_function<dofs_per_cell; ++shape_function)
shape_function_data[shape_function].single_nonzero_component_index;
const double *shape_value_ptr = &shape_values(snc,0);
for (unsigned int q_point=0; q_point<n_quadrature_points; ++q_point)
- values[q_point][comp] += value * *shape_value_ptr++;
+ values[q_point][comp] += value **shape_value_ptr++;
}
else
for (unsigned int d=0; d<spacedim; ++d)
const double *shape_value_ptr =
&shape_values(shape_function_data[shape_function].row_index[d],0);
for (unsigned int q_point=0; q_point<n_quadrature_points; ++q_point)
- values[q_point][d] += value * *shape_value_ptr++;
+ values[q_point][d] += value **shape_value_ptr++;
}
}
}
template <int order, int dim, int spacedim>
void
do_function_derivatives (const ::dealii::Vector<double> &dof_values,
- const std::vector<std::vector<Tensor<order,spacedim> > > &shape_derivatives,
+ const std::vector<std::vector<dealii::Tensor<order,spacedim> > > &shape_derivatives,
const std::vector<typename Vector<dim,spacedim>::ShapeFunctionData> &shape_function_data,
- std::vector<Tensor<order+1,spacedim> > &derivatives)
+ std::vector<dealii::Tensor<order+1,spacedim> > &derivatives)
{
const unsigned int dofs_per_cell = dof_values.size();
const unsigned int n_quadrature_points = dofs_per_cell > 0 ?
AssertDimension (derivatives.size(), n_quadrature_points);
std::fill (derivatives.begin(), derivatives.end(),
- Tensor<order+1,spacedim>());
+ dealii::Tensor<order+1,spacedim>());
for (unsigned int shape_function=0;
shape_function<dofs_per_cell; ++shape_function)
{
const unsigned int comp =
shape_function_data[shape_function].single_nonzero_component_index;
- const Tensor<order,spacedim> *shape_derivative_ptr =
+ const dealii::Tensor<order,spacedim> *shape_derivative_ptr =
&shape_derivatives[snc][0];
for (unsigned int q_point=0; q_point<n_quadrature_points; ++q_point)
- derivatives[q_point][comp] += value * *shape_derivative_ptr++;
+ derivatives[q_point][comp] += value **shape_derivative_ptr++;
}
else
for (unsigned int d=0; d<spacedim; ++d)
if (shape_function_data[shape_function].is_nonzero_shape_function_component[d])
{
- const Tensor<order,spacedim> *shape_derivative_ptr =
+ const dealii::Tensor<order,spacedim> *shape_derivative_ptr =
&shape_derivatives[shape_function_data[shape_function].
row_index[d]][0];
for (unsigned int q_point=0; q_point<n_quadrature_points; ++q_point)
- derivatives[q_point][d] += value * *shape_derivative_ptr++;
+ derivatives[q_point][d] += value **shape_derivative_ptr++;
}
}
}
template <int dim, int spacedim>
void
do_function_symmetric_gradients (const ::dealii::Vector<double> &dof_values,
- const std::vector<std::vector<Tensor<1,spacedim> > > &shape_gradients,
+ const std::vector<std::vector<dealii::Tensor<1,spacedim> > > &shape_gradients,
const std::vector<typename Vector<dim,spacedim>::ShapeFunctionData> &shape_function_data,
std::vector<dealii::SymmetricTensor<2,spacedim> > &symmetric_gradients)
{
{
const unsigned int comp =
shape_function_data[shape_function].single_nonzero_component_index;
- const Tensor<1,spacedim> *shape_gradient_ptr =
+ const dealii::Tensor<1,spacedim> *shape_gradient_ptr =
&shape_gradients[snc][0];
for (unsigned int q_point=0; q_point<n_quadrature_points; ++q_point)
symmetric_gradients[q_point] += value *
else
for (unsigned int q_point=0; q_point<n_quadrature_points; ++q_point)
{
- Tensor<2,spacedim> grad;
+ dealii::Tensor<2,spacedim> grad;
for (unsigned int d=0; d<spacedim; ++d)
if (shape_function_data[shape_function].is_nonzero_shape_function_component[d])
grad[d] = value *
template <int dim, int spacedim>
void
do_function_divergences (const ::dealii::Vector<double> &dof_values,
- const std::vector<std::vector<Tensor<1,spacedim> > > &shape_gradients,
+ const std::vector<std::vector<dealii::Tensor<1,spacedim> > > &shape_gradients,
const std::vector<typename Vector<dim,spacedim>::ShapeFunctionData> &shape_function_data,
std::vector<double> &divergences)
{
{
const unsigned int comp =
shape_function_data[shape_function].single_nonzero_component_index;
- const Tensor<1,spacedim> *shape_gradient_ptr = &shape_gradients[snc][0];
+ const dealii::Tensor<1,spacedim> *shape_gradient_ptr = &shape_gradients[snc][0];
for (unsigned int q_point=0; q_point<n_quadrature_points; ++q_point)
divergences[q_point] += value * (*shape_gradient_ptr++)[comp];
}
for (unsigned int d=0; d<spacedim; ++d)
if (shape_function_data[shape_function].is_nonzero_shape_function_component[d])
{
- const Tensor<1,spacedim> *shape_gradient_ptr =
+ const dealii::Tensor<1,spacedim> *shape_gradient_ptr =
&shape_gradients[shape_function_data[shape_function].
row_index[d]][0];
for (unsigned int q_point=0; q_point<n_quadrature_points; ++q_point)
template <int dim, int spacedim>
void
do_function_curls (const ::dealii::Vector<double> &dof_values,
- const std::vector<std::vector<Tensor<1,spacedim> > > &shape_gradients,
+ const std::vector<std::vector<dealii::Tensor<1,spacedim> > > &shape_gradients,
const std::vector<typename Vector<dim,spacedim>::ShapeFunctionData> &shape_function_data,
std::vector<typename dealii::internal::CurlType<spacedim>::type> &curls)
{
if (snc != -1)
{
- const Tensor<1, spacedim> *shape_gradient_ptr =
+ const dealii::Tensor<1, spacedim> *shape_gradient_ptr =
&shape_gradients[snc][0];
switch (shape_function_data[shape_function].single_nonzero_component_index)
{
if (shape_function_data[shape_function].is_nonzero_shape_function_component[0])
{
- const Tensor<1,spacedim> *shape_gradient_ptr =
+ const dealii::Tensor<1,spacedim> *shape_gradient_ptr =
&shape_gradients[shape_function_data[shape_function].row_index[0]][0];
for (unsigned int q_point = 0; q_point < n_quadrature_points; ++q_point)
if (shape_function_data[shape_function].is_nonzero_shape_function_component[1])
{
- const Tensor<1,spacedim> *shape_gradient_ptr =
+ const dealii::Tensor<1,spacedim> *shape_gradient_ptr =
&shape_gradients[shape_function_data[shape_function].row_index[1]][0];
for (unsigned int q_point = 0; q_point < n_quadrature_points; ++q_point)
if (snc != -1)
{
- const Tensor<1, spacedim> *shape_gradient_ptr = &shape_gradients[snc][0];
+ const dealii::Tensor<1, spacedim> *shape_gradient_ptr = &shape_gradients[snc][0];
switch (shape_function_data[shape_function].single_nonzero_component_index)
{
{
if (shape_function_data[shape_function].is_nonzero_shape_function_component[0])
{
- const Tensor<1,spacedim> *shape_gradient_ptr =
+ const dealii::Tensor<1,spacedim> *shape_gradient_ptr =
&shape_gradients[shape_function_data[shape_function].row_index[0]][0];
for (unsigned int q_point = 0; q_point < n_quadrature_points; ++q_point)
if (shape_function_data[shape_function].is_nonzero_shape_function_component[1])
{
- const Tensor<1,spacedim> *shape_gradient_ptr =
+ const dealii::Tensor<1,spacedim> *shape_gradient_ptr =
&shape_gradients[shape_function_data[shape_function].row_index[1]][0];
for (unsigned int q_point = 0; q_point < n_quadrature_points; ++q_point)
if (shape_function_data[shape_function].is_nonzero_shape_function_component[2])
{
- const Tensor<1,spacedim> *shape_gradient_ptr =
+ const dealii::Tensor<1,spacedim> *shape_gradient_ptr =
&shape_gradients[shape_function_data[shape_function].row_index[2]][0];
for (unsigned int q_point = 0; q_point < n_quadrature_points; ++q_point)
template <int dim, int spacedim>
void
do_function_laplacians (const ::dealii::Vector<double> &dof_values,
- const std::vector<std::vector<Tensor<2,spacedim> > > &shape_hessians,
+ const std::vector<std::vector<dealii::Tensor<2,spacedim> > > &shape_hessians,
const std::vector<typename Vector<dim,spacedim>::ShapeFunctionData> &shape_function_data,
- std::vector<Tensor<1,spacedim> > &laplacians)
+ std::vector<dealii::Tensor<1,spacedim> > &laplacians)
{
const unsigned int dofs_per_cell = dof_values.size();
const unsigned int n_quadrature_points = dofs_per_cell > 0 ?
shape_hessians[0].size() : laplacians.size();
AssertDimension (laplacians.size(), n_quadrature_points);
- std::fill (laplacians.begin(), laplacians.end(), Tensor<1,spacedim>());
+ std::fill (laplacians.begin(), laplacians.end(),
+ dealii::Tensor<1,spacedim>());
for (unsigned int shape_function=0;
shape_function<dofs_per_cell; ++shape_function)
{
const unsigned int comp =
shape_function_data[shape_function].single_nonzero_component_index;
- const Tensor<2,spacedim> *shape_hessian_ptr =
+ const dealii::Tensor<2,spacedim> *shape_hessian_ptr =
&shape_hessians[snc][0];
for (unsigned int q_point=0; q_point<n_quadrature_points; ++q_point)
laplacians[q_point][comp] += value * trace(*shape_hessian_ptr++);
for (unsigned int d=0; d<spacedim; ++d)
if (shape_function_data[shape_function].is_nonzero_shape_function_component[d])
{
- const Tensor<2,spacedim> *shape_hessian_ptr =
+ const dealii::Tensor<2,spacedim> *shape_hessian_ptr =
&shape_hessians[shape_function_data[shape_function].
row_index[d]][0];
for (unsigned int q_point=0; q_point<n_quadrature_points; ++q_point)
(shape_function_data[shape_function].single_nonzero_component_index);
const double *shape_value_ptr = &shape_values(snc,0);
for (unsigned int q_point=0; q_point<n_quadrature_points; ++q_point)
- values[q_point][comp] += value * *shape_value_ptr++;
+ values[q_point][comp] += value **shape_value_ptr++;
}
else
for (unsigned int d=0;
const double *shape_value_ptr =
&shape_values(shape_function_data[shape_function].row_index[d],0);
for (unsigned int q_point=0; q_point<n_quadrature_points; ++q_point)
- values[q_point][comp] += value * *shape_value_ptr++;
+ values[q_point][comp] += value **shape_value_ptr++;
}
}
}
template <int dim, int spacedim>
void
do_function_divergences (const ::dealii::Vector<double> &dof_values,
- const std::vector<std::vector<Tensor<1,spacedim> > > &shape_gradients,
+ const std::vector<std::vector<dealii::Tensor<1,spacedim> > > &shape_gradients,
const std::vector<typename SymmetricTensor<2,dim,spacedim>::ShapeFunctionData> &shape_function_data,
- std::vector<Tensor<1,spacedim> > &divergences)
+ std::vector<dealii::Tensor<1,spacedim> > &divergences)
{
const unsigned int dofs_per_cell = dof_values.size();
const unsigned int n_quadrature_points = dofs_per_cell > 0 ?
shape_gradients[0].size() : divergences.size();
AssertDimension (divergences.size(), n_quadrature_points);
- std::fill (divergences.begin(), divergences.end(), Tensor<1,spacedim>());
+ std::fill (divergences.begin(), divergences.end(),
+ dealii::Tensor<1,spacedim>());
for (unsigned int shape_function=0;
shape_function<dofs_per_cell; ++shape_function)
const unsigned int comp =
shape_function_data[shape_function].single_nonzero_component_index;
- const Tensor < 1, spacedim> *shape_gradient_ptr =
+ const dealii::Tensor < 1, spacedim> *shape_gradient_ptr =
&shape_gradients[snc][0];
const unsigned int ii = dealii::SymmetricTensor<2,spacedim>::
const unsigned int comp =
shape_function_data[shape_function].single_nonzero_component_index;
- const Tensor < 1, spacedim> *shape_gradient_ptr =
+ const dealii::Tensor < 1, spacedim> *shape_gradient_ptr =
&shape_gradients[shape_function_data[shape_function].
row_index[d]][0];
for (unsigned int q_point = 0; q_point < n_quadrature_points;
}
}
+ // ---------------------- non-symmetric tensor part ------------------------
+
+ template <int dim, int spacedim>
+ void
+ do_function_values (const ::dealii::Vector<double> &dof_values,
+ const Table<2,double> &shape_values,
+ const std::vector<typename Tensor<2,dim,spacedim>::ShapeFunctionData> &shape_function_data,
+ std::vector<dealii::Tensor<2,spacedim> > &values)
+ {
+ const unsigned int dofs_per_cell = dof_values.size();
+ const unsigned int n_quadrature_points = dofs_per_cell > 0 ?
+ shape_values.n_cols() : values.size();
+ AssertDimension (values.size(), n_quadrature_points);
+
+ std::fill (values.begin(), values.end(),
+ dealii::Tensor<2,spacedim>());
+
+ for (unsigned int shape_function=0;
+ shape_function<dofs_per_cell; ++shape_function)
+ {
+ const int snc = shape_function_data[shape_function].single_nonzero_component;
+
+ if (snc == -2)
+ // shape function is zero for the selected components
+ continue;
+
+ const double value = dof_values(shape_function);
+ if (value == 0.)
+ continue;
+
+ if (snc != -1)
+ {
+ const unsigned int comp =
+ shape_function_data[shape_function].single_nonzero_component_index;
+
+ const TableIndices<2> indices = dealii::Tensor<2,spacedim>::unrolled_to_component_indices(comp);
+
+ const double *shape_value_ptr = &shape_values(snc,0);
+ for (unsigned int q_point=0; q_point<n_quadrature_points; ++q_point)
+ values[q_point][indices] += value **shape_value_ptr++;
+ }
+ else
+ for (unsigned int d=0;
+ d<dim*dim; ++d)
+ if (shape_function_data[shape_function].is_nonzero_shape_function_component[d])
+ {
+ const TableIndices<2> indices = dealii::Tensor<2,spacedim>::unrolled_to_component_indices(d);
+
+ const double *shape_value_ptr =
+ &shape_values(shape_function_data[shape_function].row_index[d],0);
+ for (unsigned int q_point=0; q_point<n_quadrature_points; ++q_point)
+ values[q_point][indices] += value **shape_value_ptr++;
+ }
+ }
+ }
+
+
+
+ template <int dim, int spacedim>
+ void
+ do_function_divergences (const ::dealii::Vector<double> &dof_values,
+ const std::vector<std::vector<dealii::Tensor<1,spacedim> > > &shape_gradients,
+ const std::vector<typename Tensor<2,dim,spacedim>::ShapeFunctionData> &shape_function_data,
+ std::vector<dealii::Tensor<1,spacedim> > &divergences)
+ {
+ const unsigned int dofs_per_cell = dof_values.size();
+ const unsigned int n_quadrature_points = dofs_per_cell > 0 ?
+ shape_gradients[0].size() : divergences.size();
+ AssertDimension (divergences.size(), n_quadrature_points);
+
+ std::fill (divergences.begin(), divergences.end(),
+ dealii::Tensor<1,spacedim>());
+
+ for (unsigned int shape_function=0;
+ shape_function<dofs_per_cell; ++shape_function)
+ {
+ const int snc = shape_function_data[shape_function].single_nonzero_component;
+
+ if (snc == -2)
+ // shape function is zero for the selected components
+ continue;
+
+ const double value = dof_values(shape_function);
+ if (value == 0.)
+ continue;
+
+ if (snc != -1)
+ {
+ const unsigned int comp =
+ shape_function_data[shape_function].single_nonzero_component_index;
+
+ const dealii::Tensor < 1, spacedim> *shape_gradient_ptr =
+ &shape_gradients[snc][0];
+
+ const TableIndices<2> indices = dealii::Tensor<2,spacedim>::unrolled_to_component_indices(comp);
+ const unsigned int ii = indices[0];
+ const unsigned int jj = indices[1];
+
+ for (unsigned int q_point = 0; q_point < n_quadrature_points;
+ ++q_point, ++shape_gradient_ptr)
+ {
+ divergences[q_point][jj] += value * (*shape_gradient_ptr)[ii];
+ }
+ }
+ else
+ {
+ for (unsigned int d = 0;
+ d < dim*dim; ++d)
+ if (shape_function_data[shape_function].is_nonzero_shape_function_component[d])
+ {
+ Assert (false, ExcNotImplemented());
+ }
+ }
+ }
+ }
+
} // end of namespace internal
internal::do_function_divergences<dim,spacedim>
(dof_values, fe_values.shape_gradients, shape_function_data, divergences);
}
+
+ template <int dim, int spacedim>
+ template <class InputVector>
+ void
+ Tensor<2, dim, spacedim>::
+ get_function_values(const InputVector &fe_function,
+ std::vector<value_type> &values) const
+ {
+ typedef FEValuesBase<dim, spacedim> FVB;
+ Assert(fe_values.update_flags & update_values,
+ typename FVB::ExcAccessToUninitializedField());
+ Assert(fe_values.present_cell.get() != 0,
+ ExcMessage("FEValues object is not reinit'ed to any cell"));
+ AssertDimension(fe_function.size(),
+ fe_values.present_cell->n_dofs_for_dof_handler());
+
+ // get function values of dofs on this cell
+ dealii::Vector<double> dof_values(fe_values.dofs_per_cell);
+ fe_values.present_cell->get_interpolated_dof_values(fe_function, dof_values);
+ internal::do_function_values<dim,spacedim>
+ (dof_values, fe_values.shape_values, shape_function_data, values);
+ }
+
+
+
+ template <int dim, int spacedim>
+ template <class InputVector>
+ void
+ Tensor<2, dim, spacedim>::
+ get_function_divergences(const InputVector &fe_function,
+ std::vector<divergence_type> &divergences) const
+ {
+ typedef FEValuesBase<dim, spacedim> FVB;
+ Assert(fe_values.update_flags & update_gradients,
+ typename FVB::ExcAccessToUninitializedField());
+ Assert(fe_values.present_cell.get() != 0,
+ ExcMessage("FEValues object is not reinit'ed to any cell"));
+ AssertDimension(fe_function.size(),
+ fe_values.present_cell->n_dofs_for_dof_handler());
+
+ // get function values of dofs
+ // on this cell
+ dealii::Vector<double> dof_values(fe_values.dofs_per_cell);
+ fe_values.present_cell->get_interpolated_dof_values(fe_function, dof_values);
+ internal::do_function_divergences<dim,spacedim>
+ (dof_values, fe_values.shape_gradients, shape_function_data, divergences);
+ }
}
scalars.resize (n_scalars);
for (unsigned int component=0; component<n_scalars; ++component)
{
-#ifndef DEAL_II_EXPLICIT_DESTRUCTOR_BUG
- scalars[component].dealii::FEValuesViews::Scalar<dim,spacedim>::~Scalar ();
-#else
+ // Use a typedef here to work around an issue with gcc-4.1:
typedef dealii::FEValuesViews::Scalar<dim,spacedim> ScalarView;
scalars[component].ScalarView::~ScalarView ();
-#endif
+
new (&scalars[component])
dealii::FEValuesViews::Scalar<dim,spacedim>(fe_values,
component);
vectors.resize (n_vectors);
for (unsigned int component=0; component<n_vectors; ++component)
{
-#ifndef DEAL_II_EXPLICIT_DESTRUCTOR_BUG
- vectors[component].dealii::FEValuesViews::Vector<dim,spacedim>::~Vector ();
-#else
+ // Use a typedef here to work around an issue with gcc-4.1:
typedef dealii::FEValuesViews::Vector<dim,spacedim> VectorView;
vectors[component].VectorView::~VectorView ();
-#endif
+
new (&vectors[component])
dealii::FEValuesViews::Vector<dim,spacedim>(fe_values,
component);
symmetric_second_order_tensors.resize(n_symmetric_second_order_tensors);
for (unsigned int component = 0; component < n_symmetric_second_order_tensors; ++component)
{
-#ifndef DEAL_II_EXPLICIT_DESTRUCTOR_BUG
- symmetric_second_order_tensors[component]
- .dealii::FEValuesViews::SymmetricTensor<2, dim, spacedim>::~SymmetricTensor();
-#else
+ // Use a typedef here to work around an issue with gcc-4.1:
typedef dealii::FEValuesViews::SymmetricTensor<2, dim, spacedim> SymmetricTensorView;
symmetric_second_order_tensors[component].SymmetricTensorView::~SymmetricTensorView();
-#endif
+
new (&symmetric_second_order_tensors[component])
dealii::FEValuesViews::SymmetricTensor<2, dim, spacedim > (fe_values,
component);
}
+
+
+ // compute number of symmetric
+ // tensors in the same way as above
+ const unsigned int n_second_order_tensors
+ = (fe.n_components() >= dim*dim ?
+ fe.n_components() - dim*dim + 1 :
+ 0);
+ second_order_tensors.resize(n_second_order_tensors);
+ for (unsigned int component = 0; component < n_second_order_tensors; ++component)
+ {
+ // Use a typedef here to work around an issue with gcc-4.1:
+ typedef dealii::FEValuesViews::Tensor<2, dim, spacedim> TensorView;
+ second_order_tensors[component].TensorView::~TensorView();
+
+ new (&second_order_tensors[component])
+ dealii::FEValuesViews::Tensor<2, dim, spacedim > (fe_values,
+ component);
+ }
}
}
}
const double *shape_value_ptr = &shape_values(shape_func, 0);
for (unsigned int point=0; point<n_quadrature_points; ++point)
- values[point] += value * *shape_value_ptr++;
+ values[point] += value **shape_value_ptr++;
}
}
{
VectorType &values_comp = values[comp];
for (unsigned int point=0; point<n_quadrature_points; ++point)
- values_comp[point] += value * *shape_value_ptr++;
+ values_comp[point] += value **shape_value_ptr++;
}
else
for (unsigned int point=0; point<n_quadrature_points; ++point)
- values[point][comp] += value * *shape_value_ptr++;
+ values[point][comp] += value **shape_value_ptr++;
}
else
for (unsigned int c=0; c<n_components; ++c)
VectorType &values_comp = values[comp];
for (unsigned int point=0; point<n_quadrature_points;
++point)
- values_comp[point] += value * *shape_value_ptr++;
+ values_comp[point] += value **shape_value_ptr++;
}
else
for (unsigned int point=0; point<n_quadrature_points; ++point)
- values[point][comp] += value * *shape_value_ptr++;
+ values[point][comp] += value **shape_value_ptr++;
}
}
}
const Tensor<order,spacedim> *shape_derivative_ptr
= &shape_derivatives[shape_func][0];
for (unsigned int point=0; point<n_quadrature_points; ++point)
- derivatives[point] += value * *shape_derivative_ptr++;
+ derivatives[point] += value **shape_derivative_ptr++;
}
}
if (quadrature_points_fastest)
for (unsigned int point=0; point<n_quadrature_points; ++point)
- derivatives[comp][point] += value * *shape_derivative_ptr++;
+ derivatives[comp][point] += value **shape_derivative_ptr++;
else
for (unsigned int point=0; point<n_quadrature_points; ++point)
- derivatives[point][comp] += value * *shape_derivative_ptr++;
+ derivatives[point][comp] += value **shape_derivative_ptr++;
}
else
for (unsigned int c=0; c<n_components; ++c)
if (quadrature_points_fastest)
for (unsigned int point=0; point<n_quadrature_points; ++point)
- derivatives[comp][point] += value * *shape_derivative_ptr++;
+ derivatives[comp][point] += value **shape_derivative_ptr++;
else
for (unsigned int point=0; point<n_quadrature_points; ++point)
- derivatives[point][comp] += value * *shape_derivative_ptr++;
+ derivatives[point][comp] += value **shape_derivative_ptr++;
}
}
}
-//-----------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//-----------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
// Declarations of member functions of FEValuesBase::CellIteratorBase
-//-----------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//-----------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
// Declarations of member functions of FEValuesBase::CellIteratorBase
-//-----------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//-----------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (VEC : SERIAL_VECTORS)
{
-//-----------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//-----------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (VEC : SERIAL_VECTORS)
{
-//-----------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//-----------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
// Instantiations of functions in FEValuesViews (explicitly write
// dealii:: namespace in order to not confuse the compiler with
template class Scalar<deal_II_dimension, deal_II_space_dimension>;
template class Vector<deal_II_dimension, deal_II_space_dimension>;
template class SymmetricTensor<2, deal_II_dimension, deal_II_space_dimension>;
+ template class Tensor<2, deal_II_dimension, deal_II_space_dimension>;
\}
#endif
#endif
template
void FEValuesViews::Scalar<deal_II_dimension, deal_II_space_dimension>
::get_function_gradients<dealii::VEC>
- (const dealii::VEC&, std::vector<Tensor<1,deal_II_space_dimension> >&) const;
+ (const dealii::VEC&, std::vector<dealii::Tensor<1,deal_II_space_dimension> >&) const;
template
void FEValuesViews::Scalar<deal_II_dimension, deal_II_space_dimension>
::get_function_hessians<dealii::VEC>
- (const dealii::VEC&, std::vector<Tensor<2,deal_II_space_dimension> >&) const;
+ (const dealii::VEC&, std::vector<dealii::Tensor<2,deal_II_space_dimension> >&) const;
template
void FEValuesViews::Scalar<deal_II_dimension, deal_II_space_dimension>
::get_function_laplacians<dealii::VEC>
template
void FEValuesViews::Vector<deal_II_dimension, deal_II_space_dimension>
::get_function_values<dealii::VEC>
- (const dealii::VEC&, std::vector<Tensor<1,deal_II_space_dimension> >&) const;
+ (const dealii::VEC&, std::vector<dealii::Tensor<1,deal_II_space_dimension> >&) const;
template
void FEValuesViews::Vector<deal_II_dimension, deal_II_space_dimension>
::get_function_gradients<dealii::VEC>
- (const dealii::VEC&, std::vector<Tensor<2,deal_II_space_dimension> >&) const;
+ (const dealii::VEC&, std::vector<dealii::Tensor<2,deal_II_space_dimension> >&) const;
template
void FEValuesViews::Vector<deal_II_dimension, deal_II_space_dimension>
::get_function_symmetric_gradients<dealii::VEC>
template
void FEValuesViews::Vector<deal_II_dimension, deal_II_space_dimension>
::get_function_hessians<dealii::VEC>
- (const dealii::VEC&, std::vector<Tensor<3,deal_II_space_dimension> >&) const;
+ (const dealii::VEC&, std::vector<dealii::Tensor<3,deal_II_space_dimension> >&) const;
template
void FEValuesViews::Vector<deal_II_dimension, deal_II_space_dimension>
::get_function_laplacians<dealii::VEC>
- (const dealii::VEC&, std::vector<Tensor<1,deal_II_space_dimension> >&) const;
+ (const dealii::VEC&, std::vector<dealii::Tensor<1,deal_II_space_dimension> >&) const;
template
void FEValuesViews::SymmetricTensor<2, deal_II_dimension, deal_II_space_dimension>
template
void FEValuesViews::SymmetricTensor<2, deal_II_dimension, deal_II_space_dimension>
::get_function_divergences<dealii::VEC>
- (const dealii::VEC&, std::vector<Tensor<1,deal_II_space_dimension> >&) const;
+ (const dealii::VEC&, std::vector<dealii::Tensor<1,deal_II_space_dimension> >&) const;
+
+ template
+ void FEValuesViews::Tensor<2, deal_II_dimension, deal_II_space_dimension>
+ ::get_function_values<dealii::VEC>
+ (const dealii::VEC&, std::vector<dealii::Tensor<2,deal_II_space_dimension> >&) const;
+ template
+ void FEValuesViews::Tensor<2, deal_II_dimension, deal_II_space_dimension>
+ ::get_function_divergences<dealii::VEC>
+ (const dealii::VEC&, std::vector<dealii::Tensor<1,deal_II_space_dimension> >&) const;
#endif
#endif
}
template
void FEValuesBase<deal_II_dimension,deal_II_space_dimension>::get_function_gradients<VEC>
- (const VEC&, std::vector<Tensor<1,deal_II_space_dimension> > &) const;
+ (const VEC&, std::vector<dealii::Tensor<1,deal_II_space_dimension> > &) const;
template
void FEValuesBase<deal_II_dimension,deal_II_space_dimension>::get_function_gradients<VEC>
(const VEC&, const VectorSlice<const std::vector<types::global_dof_index> >&,
- std::vector<Tensor<1,deal_II_space_dimension> > &) const;
+ std::vector<dealii::Tensor<1,deal_II_space_dimension> > &) const;
template
void FEValuesBase<deal_II_dimension,deal_II_space_dimension>::get_function_gradients<VEC>
- (const VEC&, std::vector<std::vector<Tensor<1,deal_II_space_dimension> > > &) const;
+ (const VEC&, std::vector<std::vector<dealii::Tensor<1,deal_II_space_dimension> > > &) const;
template
void FEValuesBase<deal_II_dimension,deal_II_space_dimension>::get_function_gradients<VEC>
(const VEC&, const VectorSlice<const std::vector<types::global_dof_index> >&,
- VectorSlice<std::vector<std::vector<Tensor<1,deal_II_space_dimension> > > >, bool) const;
+ VectorSlice<std::vector<std::vector<dealii::Tensor<1,deal_II_space_dimension> > > >, bool) const;
template
void FEValuesBase<deal_II_dimension,deal_II_space_dimension>::get_function_hessians<VEC>
- (const VEC&, std::vector<Tensor<2,deal_II_space_dimension> > &) const;
+ (const VEC&, std::vector<dealii::Tensor<2,deal_II_space_dimension> > &) const;
template
void FEValuesBase<deal_II_dimension,deal_II_space_dimension>::get_function_hessians<VEC>
(const VEC&, const VectorSlice<const std::vector<types::global_dof_index> >&,
- std::vector<Tensor<2,deal_II_space_dimension> > &) const;
+ std::vector<dealii::Tensor<2,deal_II_space_dimension> > &) const;
template
void FEValuesBase<deal_II_dimension,deal_II_space_dimension>::get_function_hessians<VEC>
- (const VEC&, std::vector<std::vector<Tensor<2,deal_II_space_dimension> > > &, bool) const;
+ (const VEC&, std::vector<std::vector<dealii::Tensor<2,deal_II_space_dimension> > > &, bool) const;
template
void FEValuesBase<deal_II_dimension,deal_II_space_dimension>::get_function_hessians<VEC>
(const VEC&, const VectorSlice<const std::vector<types::global_dof_index> >&,
- VectorSlice<std::vector<std::vector<Tensor<2,deal_II_space_dimension> > > >, bool) const;
+ VectorSlice<std::vector<std::vector<dealii::Tensor<2,deal_II_space_dimension> > > >, bool) const;
template
void FEValuesBase<deal_II_dimension,deal_II_space_dimension>::get_function_laplacians<VEC>
(const dealii::IndexSet&, std::vector<double>&) const;
template
void FEValuesViews::Scalar<deal_II_dimension>::get_function_gradients<dealii::IndexSet>
- (const dealii::IndexSet&, std::vector<Tensor<1,deal_II_dimension> >&) const;
+ (const dealii::IndexSet&, std::vector<dealii::Tensor<1,deal_II_dimension> >&) const;
template
void FEValuesViews::Scalar<deal_II_dimension>::get_function_hessians<dealii::IndexSet>
- (const dealii::IndexSet&, std::vector<Tensor<2,deal_II_dimension> >&) const;
+ (const dealii::IndexSet&, std::vector<dealii::Tensor<2,deal_II_dimension> >&) const;
template
void FEValuesViews::Scalar<deal_II_dimension>::get_function_laplacians<dealii::IndexSet>
(const dealii::IndexSet&, std::vector<double>&) const;
template
void FEValuesViews::Vector<deal_II_dimension>::get_function_values<dealii::IndexSet>
- (const dealii::IndexSet&, std::vector<Tensor<1,deal_II_dimension> >&) const;
+ (const dealii::IndexSet&, std::vector<dealii::Tensor<1,deal_II_dimension> >&) const;
template
void FEValuesViews::Vector<deal_II_dimension>::get_function_gradients<dealii::IndexSet>
- (const dealii::IndexSet&, std::vector<Tensor<2,deal_II_dimension> >&) const;
+ (const dealii::IndexSet&, std::vector<dealii::Tensor<2,deal_II_dimension> >&) const;
template
void FEValuesViews::Vector<deal_II_dimension>::get_function_symmetric_gradients<dealii::IndexSet>
(const dealii::IndexSet&, std::vector<dealii::SymmetricTensor<2,deal_II_dimension> >&) const;
(const dealii::IndexSet&, std::vector<double>&) const;
template
void FEValuesViews::Vector<deal_II_dimension>::get_function_hessians<dealii::IndexSet>
- (const dealii::IndexSet&, std::vector<Tensor<3,deal_II_dimension> >&) const;
+ (const dealii::IndexSet&, std::vector<dealii::Tensor<3,deal_II_dimension> >&) const;
template
void FEValuesViews::Vector<deal_II_dimension>::get_function_laplacians<dealii::IndexSet>
- (const dealii::IndexSet&, std::vector<Tensor<1,deal_II_dimension> >&) const;
+ (const dealii::IndexSet&, std::vector<dealii::Tensor<1,deal_II_dimension> >&) const;
template
void FEValuesViews::SymmetricTensor<2,deal_II_dimension,deal_II_dimension>::get_function_values<dealii::IndexSet>
(const dealii::IndexSet&, std::vector<dealii::SymmetricTensor<2,deal_II_dimension> >&) const;
template
void FEValuesViews::SymmetricTensor<2,deal_II_dimension,deal_II_dimension>::get_function_divergences<dealii::IndexSet>
- (const dealii::IndexSet&, std::vector<Tensor<1,deal_II_dimension> >&) const;
+ (const dealii::IndexSet&, std::vector<dealii::Tensor<1,deal_II_dimension> >&) const;
+
+ template
+ void FEValuesViews::Tensor<2,deal_II_dimension,deal_II_dimension>::get_function_values<dealii::IndexSet>
+ (const dealii::IndexSet&, std::vector<dealii::Tensor<2,deal_II_dimension> >&) const;
+ template
+ void FEValuesViews::Tensor<2,deal_II_dimension,deal_II_dimension>::get_function_divergences<dealii::IndexSet>
+ (const dealii::IndexSet&, std::vector<dealii::Tensor<1,deal_II_dimension> >&) const;
#if deal_II_dimension != 3
template
void FEValuesViews::Scalar<deal_II_dimension, deal_II_dimension+1>
::get_function_gradients<dealii::IndexSet>
- (const dealii::IndexSet&, std::vector<Tensor<1,deal_II_dimension+1> >&) const;
+ (const dealii::IndexSet&, std::vector<dealii::Tensor<1,deal_II_dimension+1> >&) const;
template
void FEValuesViews::Scalar<deal_II_dimension, deal_II_dimension+1>
::get_function_hessians<dealii::IndexSet>
- (const dealii::IndexSet&, std::vector<Tensor<2,deal_II_dimension+1> >&) const;
+ (const dealii::IndexSet&, std::vector<dealii::Tensor<2,deal_II_dimension+1> >&) const;
template
void FEValuesViews::Scalar<deal_II_dimension, deal_II_dimension+1>
::get_function_laplacians<dealii::IndexSet>
template
void FEValuesViews::Vector<deal_II_dimension, deal_II_dimension+1>
::get_function_values<dealii::IndexSet>
- (const dealii::IndexSet&, std::vector<Tensor<1,deal_II_dimension+1> >&) const;
+ (const dealii::IndexSet&, std::vector<dealii::Tensor<1,deal_II_dimension+1> >&) const;
template
void FEValuesViews::Vector<deal_II_dimension, deal_II_dimension+1>
::get_function_gradients<dealii::IndexSet>
- (const dealii::IndexSet&, std::vector<Tensor<2,deal_II_dimension+1> >&) const;
+ (const dealii::IndexSet&, std::vector<dealii::Tensor<2,deal_II_dimension+1> >&) const;
template
void FEValuesViews::Vector<deal_II_dimension, deal_II_dimension+1>
::get_function_symmetric_gradients<dealii::IndexSet>
template
void FEValuesViews::Vector<deal_II_dimension, deal_II_dimension+1>
::get_function_hessians<dealii::IndexSet>
- (const dealii::IndexSet&, std::vector<Tensor<3,deal_II_dimension+1> >&) const;
+ (const dealii::IndexSet&, std::vector<dealii::Tensor<3,deal_II_dimension+1> >&) const;
template
void FEValuesViews::Vector<deal_II_dimension, deal_II_dimension+1>
::get_function_laplacians<dealii::IndexSet>
- (const dealii::IndexSet&, std::vector<Tensor<1,deal_II_dimension+1> >&) const;
+ (const dealii::IndexSet&, std::vector<dealii::Tensor<1,deal_II_dimension+1> >&) const;
template
void FEValuesViews::SymmetricTensor<2, deal_II_dimension, deal_II_dimension+1>
template
void FEValuesViews::SymmetricTensor<2, deal_II_dimension, deal_II_dimension+1>
::get_function_divergences<dealii::IndexSet>
- (const dealii::IndexSet&, std::vector<Tensor<1,deal_II_dimension+1> >&) const;
+ (const dealii::IndexSet&, std::vector<dealii::Tensor<1,deal_II_dimension+1> >&) const;
+
+ template
+ void FEValuesViews::Tensor<2, deal_II_dimension, deal_II_dimension+1>
+ ::get_function_values<dealii::IndexSet>
+ (const dealii::IndexSet&, std::vector<dealii::Tensor<2,deal_II_dimension+1> >&) const;
+ template
+ void FEValuesViews::Tensor<2, deal_II_dimension, deal_II_dimension+1>
+ ::get_function_divergences<dealii::IndexSet>
+ (const dealii::IndexSet&, std::vector<dealii::Tensor<1,deal_II_dimension+1> >&) const;
#endif
#endif
template
void FEValuesBase<deal_II_dimension>::get_function_gradients<IndexSet>
- (const IndexSet&, std::vector<Tensor<1,deal_II_dimension> > &) const;
+ (const IndexSet&, std::vector<dealii::Tensor<1,deal_II_dimension> > &) const;
template
void FEValuesBase<deal_II_dimension>::get_function_gradients<IndexSet>
(const IndexSet&, const VectorSlice<const std::vector<types::global_dof_index> >&,
- std::vector<Tensor<1,deal_II_dimension> > &) const;
+ std::vector<dealii::Tensor<1,deal_II_dimension> > &) const;
template
void FEValuesBase<deal_II_dimension>::get_function_gradients<IndexSet>
- (const IndexSet&, std::vector<std::vector<Tensor<1,deal_II_dimension> > > &) const;
+ (const IndexSet&, std::vector<std::vector<dealii::Tensor<1,deal_II_dimension> > > &) const;
template
void FEValuesBase<deal_II_dimension>::get_function_gradients<IndexSet>
(const IndexSet&, const VectorSlice<const std::vector<types::global_dof_index> >&,
- VectorSlice<std::vector<std::vector<Tensor<1,deal_II_dimension> > > >, bool) const;
+ VectorSlice<std::vector<std::vector<dealii::Tensor<1,deal_II_dimension> > > >, bool) const;
template
void FEValuesBase<deal_II_dimension>::get_function_hessians<IndexSet>
- (const IndexSet&, std::vector<Tensor<2,deal_II_dimension> > &) const;
+ (const IndexSet&, std::vector<dealii::Tensor<2,deal_II_dimension> > &) const;
template
void FEValuesBase<deal_II_dimension>::get_function_hessians<IndexSet>
(const IndexSet&, const VectorSlice<const std::vector<types::global_dof_index> >&,
- std::vector<Tensor<2,deal_II_dimension> > &) const;
+ std::vector<dealii::Tensor<2,deal_II_dimension> > &) const;
template
void FEValuesBase<deal_II_dimension>::get_function_hessians<IndexSet>
- (const IndexSet&, std::vector<std::vector<Tensor<2,deal_II_dimension> > > &, bool) const;
+ (const IndexSet&, std::vector<std::vector<dealii::Tensor<2,deal_II_dimension> > > &, bool) const;
template
void FEValuesBase<deal_II_dimension>::get_function_hessians<IndexSet>
(const IndexSet&, const VectorSlice<const std::vector<types::global_dof_index> >&,
- VectorSlice<std::vector<std::vector<Tensor<2,deal_II_dimension> > > >, bool) const;
+ VectorSlice<std::vector<std::vector<dealii::Tensor<2,deal_II_dimension> > > >, bool) const;
template
void FEValuesBase<deal_II_dimension>::get_function_laplacians<IndexSet>
template
void FEValuesBase<deal_II_dimension,deal_II_dimension+1>::get_function_gradients<IndexSet>
- (const IndexSet&, std::vector<Tensor<1,deal_II_dimension+1> > &) const;
+ (const IndexSet&, std::vector<dealii::Tensor<1,deal_II_dimension+1> > &) const;
template
void FEValuesBase<deal_II_dimension,deal_II_dimension+1>::get_function_gradients<IndexSet>
(const IndexSet&, const VectorSlice<const std::vector<types::global_dof_index> >&,
- std::vector<Tensor<1,deal_II_dimension+1> > &) const;
+ std::vector<dealii::Tensor<1,deal_II_dimension+1> > &) const;
template
void FEValuesBase<deal_II_dimension,deal_II_dimension+1>::get_function_gradients<IndexSet>
- (const IndexSet&, std::vector<std::vector<Tensor<1,deal_II_dimension+1> > > &) const;
+ (const IndexSet&, std::vector<std::vector<dealii::Tensor<1,deal_II_dimension+1> > > &) const;
template
void FEValuesBase<deal_II_dimension,deal_II_dimension+1>::get_function_gradients<IndexSet>
(const IndexSet&, const VectorSlice<const std::vector<types::global_dof_index> >&,
- VectorSlice<std::vector<std::vector<Tensor<1,deal_II_dimension+1> > > >, bool) const;
+ VectorSlice<std::vector<std::vector<dealii::Tensor<1,deal_II_dimension+1> > > >, bool) const;
template
void FEValuesBase<deal_II_dimension,deal_II_dimension+1>::get_function_hessians<IndexSet>
- (const IndexSet&, std::vector<Tensor<2,deal_II_dimension+1> > &) const;
+ (const IndexSet&, std::vector<dealii::Tensor<2,deal_II_dimension+1> > &) const;
template
void FEValuesBase<deal_II_dimension,deal_II_dimension+1>::get_function_hessians<IndexSet>
(const IndexSet&, const VectorSlice<const std::vector<types::global_dof_index> >&,
- std::vector<Tensor<2,deal_II_dimension+1> > &) const;
+ std::vector<dealii::Tensor<2,deal_II_dimension+1> > &) const;
template
void FEValuesBase<deal_II_dimension,deal_II_dimension+1>::get_function_hessians<IndexSet>
- (const IndexSet&, std::vector<std::vector<Tensor<2,deal_II_dimension+1> > > &, bool) const;
+ (const IndexSet&, std::vector<std::vector<dealii::Tensor<2,deal_II_dimension+1> > > &, bool) const;
template
void FEValuesBase<deal_II_dimension,deal_II_dimension+1>::get_function_hessians<IndexSet>
(const IndexSet&, const VectorSlice<const std::vector<types::global_dof_index> >&,
- VectorSlice<std::vector<std::vector<Tensor<2,deal_II_dimension+1> > > >, bool) const;
+ VectorSlice<std::vector<std::vector<dealii::Tensor<2,deal_II_dimension+1> > > >, bool) const;
template
void FEValuesBase<deal_II_dimension,deal_II_dimension+1>::get_function_laplacians<IndexSet>
-//---------------------------------------------------------------------------
-// $Id: $
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2013 by the deal.II authors
+// Copyright (C) 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
// This file compiles the second half of the instantiations from fe_values.cc
// to get the memory consumption below 1.5gb with gcc.
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2005, 2006, 2009, 2011, 2012 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/grid/tria.h>
#include <deal.II/fe/mapping.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/grid/tria_accessor.h>
#include <deal.II/grid/tria_iterator.h>
const unsigned int dim = 2;
std::vector<Point<dim> > line_points (2);
- // loop over each of the lines,
- // and if it is at the
- // boundary, then first get the
- // boundary description and
- // second compute the points on
- // it. if not at the boundary,
- // get the respective points
- // from another function
+ // loop over each of the lines, and if it is at the boundary, then first get
+ // the boundary description and second compute the points on it. if not at
+ // the boundary, get the respective points from another function
for (unsigned int line_no=0; line_no<GeometryInfo<dim>::lines_per_cell; ++line_no)
{
const Triangulation<dim>::line_iterator line = cell->line(line_no);
if (line->at_boundary())
{
- // first get the normal
- // vectors at the two
- // vertices of this line
- // from the boundary
- // description
+ // first get the normal vectors at the two vertices of this line
+ // from the boundary description
const Boundary<dim> &boundary
= line->get_triangulation().get_boundary(line->boundary_indicator());
Boundary<dim>::FaceVertexNormals face_vertex_normals;
boundary.get_normals_at_vertices (line, face_vertex_normals);
- // then transform them into
- // interpolation points for
- // a cubic polynomial
+ // then transform them into interpolation points for a cubic
+ // polynomial
//
- // for this, note that if
- // we describe the boundary
- // curve as a polynomial in
- // tangential coordinate
- // @p{t=0..1} (along the
- // line) and @p{s} in
- // normal direction, then
- // the cubic mapping is
- // such that @p{s = a*t**3
- // + b*t**2 + c*t + d}, and
- // we want to determine the
- // interpolation points at
- // @p{t=1/3} and
- // @p{t=2/3}. Since at
- // @p{t=0,1} we want a
- // vertex which is actually
- // at the boundary, we know
- // that @p{d=0} and
- // @p{a=-b-c}. As
- // side-conditions, we want
- // that the derivatives at
- // @p{t=0} and @p{t=1},
- // i.e. at the vertices
- // match those returned by
- // the boundary. We then
- // have that
- // @p{s(1/3)=1/27(2b+8c)}
- // and
- // @p{s(2/3)=4/27b+10/27c}.
+ // for this, note that if we describe the boundary curve as a
+ // polynomial in tangential coordinate @p{t=0..1} (along the line)
+ // and @p{s} in normal direction, then the cubic mapping is such
+ // that @p{s = a*t**3 + b*t**2 + c*t + d}, and we want to determine
+ // the interpolation points at @p{t=0.276} and @p{t=0.724}
+ // (Gauss-Lobatto points). Since at @p{t=0,1} we want a vertex which
+ // is actually at the boundary, we know that @p{d=0} and @p{a=-b-c},
+ // which gives @p{s(0.276)} and @{s(0.726)} in terms of @p{b,c}. As
+ // side-conditions, we want that the derivatives at @p{t=0} and
+ // @p{t=1}, i.e. at the vertices match those returned by the
+ // boundary.
//
- // The task is then first
- // to determine the
- // coefficients from the
- // tangentials. for that,
- // first rotate the
- // tangents of @p{s(t)}
- // into the global
- // coordinate system. they
- // are @p{A (1,c)} and @p{A
- // (1,-b-2c)} with @p{A} the
- // rotation matrix, since
- // the tangentials in the
- // coordinate system
- // relative to the line are
- // @p{(1,c)} and @p{(1,-b-2c)}
- // at the two vertices,
- // respectively. We then
- // have to make sure by
- // matching @p{b,c} that
- // these tangentials are
- // orthogonal to the normals
- // returned by the boundary
- // object
+ // The task is then first to determine the coefficients from the
+ // tangentials. for that, first rotate the tangents of @p{s(t)} into
+ // the global coordinate system. they are @p{A (1,c)} and @p{A
+ // (1,-b-2c)} with @p{A} the rotation matrix, since the tangentials
+ // in the coordinate system relative to the line are @p{(1,c)} and
+ // @p{(1,-b-2c)} at the two vertices, respectively. We then have to
+ // make sure by matching @p{b,c} that these tangentials are
+ // orthogonal to the normals returned by the boundary object
const Tensor<1,2> coordinate_vector = line->vertex(1) - line->vertex(0);
const double h = std::sqrt(coordinate_vector * coordinate_vector);
Tensor<1,2> coordinate_axis = coordinate_vector;
-face_vertex_normals[1][0] * std::sin(alpha)))
-2*c;
+ QGaussLobatto<1> quad_points(4);
+ const double t1 = quad_points.point(1)[0];
+ const double t2 = quad_points.point(2)[0];
+ const double s_t1 = (((-b-c)*t1+b)*t1+c)*t1;
+ const double s_t2 = (((-b-c)*t2+b)*t2+c)*t2;
- // next evaluate the so
- // determined cubic
- // polynomial at the points
- // 1/3 and 2/3, first in
- // unit coordinates
- const Point<2> new_unit_points[2] = { Point<2>(1./3., 1./27.*(2*b+8*c)),
- Point<2>(2./3., 4./27.*b+10./27.*c)
+ // next evaluate the so determined cubic polynomial at the points
+ // 1/3 and 2/3, first in unit coordinates
+ const Point<2> new_unit_points[2] = { Point<2>(t1, s_t1),
+ Point<2>(t2, s_t2)
};
- // then transform these
- // points to real
- // coordinates by rotating,
+ // then transform these points to real coordinates by rotating,
// scaling and shifting
for (unsigned int i=0; i<2; ++i)
{
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/tensor.h>
#include <deal.II/base/quadrature.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/utilities.h>
#include <deal.II/base/polynomial.h>
|| (dim != spacedim)),
feq(degree)
{
- // Construct the tensor product
- // polynomials used as shape
- // functions for the Qp mapping of
- // cells at the boundary.
- std::vector<Polynomials::LagrangeEquidistant> v;
- for (unsigned int i=0; i<=degree; ++i)
- v.push_back(Polynomials::LagrangeEquidistant(degree,i));
-
- tensor_pols = new TensorProductPolynomials<dim> (v);
+ // Construct the tensor product polynomials used as shape functions for the
+ // Qp mapping of cells at the boundary.
+ const QGaussLobatto<1> points(degree+1);
+ tensor_pols = new TensorProductPolynomials<dim>
+ (Polynomials::generate_complete_Lagrange_basis(points.get_points()));
Assert (n_shape_functions==tensor_pols->n(),
ExcInternalError());
Assert(n_inner+n_outer==n_shape_functions, ExcInternalError());
}
-// Note that the CellSimilarity flag is
-// modifyable, since MappingQ can need to
-// recalculate data even when cells are
-// similar.
+// Note that the CellSimilarity flag is modifyable, since MappingQ can need to
+// recalculate data even when cells are similar.
template<int dim, int spacedim>
void
MappingQ<dim,spacedim>::fill_fe_values (
std::vector<Point<spacedim> > &normal_vectors,
CellSimilarity::Similarity &cell_similarity) const
{
- // convert data object to internal
- // data for this class. fails with
- // an exception if that is not
- // possible
+ // convert data object to internal data for this class. fails with an
+ // exception if that is not possible
Assert (dynamic_cast<InternalData *> (&mapping_data) != 0, ExcInternalError());
InternalData &data = static_cast<InternalData &> (mapping_data);
- // check whether this cell needs
- // the full mapping or can be
- // treated by a reduced Q1 mapping,
- // e.g. if the cell is in the
- // interior of the domain
+ // check whether this cell needs the full mapping or can be treated by a
+ // reduced Q1 mapping, e.g. if the cell is in the interior of the domain
data.use_mapping_q1_on_current_cell = !(use_mapping_q_on_all_cells
|| cell->has_boundary_lines());
- // depending on this result, use this or
- // the other data object for the
- // mapping. furthermore, we need to
- // ensure that the flag indicating
- // whether we can use some similarity has
- // to be modified - for a general
- // MappingQ, the data needs to be
- // recomputed anyway since then the
- // mapping changes the data. this needs
- // to be known also for later operations,
- // so modify the variable here. this also
- // affects the calculation of the next
- // cell -- if we use Q1 data on the next
- // cell, the data will still be invalid.
+ // depending on this result, use this or the other data object for the
+ // mapping. furthermore, we need to ensure that the flag indicating whether
+ // we can use some similarity has to be modified - for a general MappingQ,
+ // the data needs to be recomputed anyway since then the mapping changes the
+ // data. this needs to be known also for later operations, so modify the
+ // variable here. this also affects the calculation of the next cell -- if
+ // we use Q1 data on the next cell, the data will still be invalid.
typename MappingQ1<dim,spacedim>::InternalData *p_data=0;
if (data.use_mapping_q1_on_current_cell)
p_data=&data.mapping_q1_data;
std::vector<Tensor<1,spacedim> > &exterior_forms,
std::vector<Point<spacedim> > &normal_vectors) const
{
- // convert data object to internal
- // data for this class. fails with
- // an exception if that is not
- // possible
+ // convert data object to internal data for this class. fails with an
+ // exception if that is not possible
Assert (dynamic_cast<InternalData *> (&mapping_data) != 0,
ExcInternalError());
InternalData &data = static_cast<InternalData &> (mapping_data);
- // check whether this cell needs
- // the full mapping or can be
- // treated by a reduced Q1 mapping,
- // e.g. if the cell is entirely in
- // the interior of the domain. note
- // that it is not sufficient to ask
- // whether the present _face_ is in
- // the interior, as the mapping on
- // the face depends on the mapping
- // of the cell, which in turn
- // depends on the fact whether
- // _any_ of the faces of this cell
- // is at the boundary, not only the
- // present face
+ // check whether this cell needs the full mapping or can be treated by a
+ // reduced Q1 mapping, e.g. if the cell is entirely in the interior of the
+ // domain. note that it is not sufficient to ask whether the present _face_
+ // is in the interior, as the mapping on the face depends on the mapping of
+ // the cell, which in turn depends on the fact whether _any_ of the faces of
+ // this cell is at the boundary, not only the present face
data.use_mapping_q1_on_current_cell=!(use_mapping_q_on_all_cells
|| cell->has_boundary_lines());
- // depending on this result, use
- // this or the other data object
- // for the mapping
+ // depending on this result, use this or the other data object for the
+ // mapping
typename MappingQ1<dim,spacedim>::InternalData *p_data=0;
if (data.use_mapping_q1_on_current_cell)
p_data=&data.mapping_q1_data;
std::vector<Tensor<1,spacedim> > &exterior_forms,
std::vector<Point<spacedim> > &normal_vectors) const
{
- // convert data object to internal
- // data for this class. fails with
- // an exception if that is not
- // possible
+ // convert data object to internal data for this class. fails with an
+ // exception if that is not possible
Assert (dynamic_cast<InternalData *> (&mapping_data) != 0,
ExcInternalError());
InternalData &data = static_cast<InternalData &> (mapping_data);
- // check whether this cell needs
- // the full mapping or can be
- // treated by a reduced Q1 mapping,
- // e.g. if the cell is entirely in
- // the interior of the domain. note
- // that it is not sufficient to ask
- // whether the present _face_ is in
- // the interior, as the mapping on
- // the face depends on the mapping
- // of the cell, which in turn
- // depends on the fact whether
- // _any_ of the faces of this cell
- // is at the boundary, not only the
- // present face
+ // check whether this cell needs the full mapping or can be treated by a
+ // reduced Q1 mapping, e.g. if the cell is entirely in the interior of the
+ // domain. note that it is not sufficient to ask whether the present _face_
+ // is in the interior, as the mapping on the face depends on the mapping of
+ // the cell, which in turn depends on the fact whether _any_ of the faces of
+ // this cell is at the boundary, not only the present face
data.use_mapping_q1_on_current_cell=!(use_mapping_q_on_all_cells
|| cell->has_boundary_lines());
- // depending on this result, use
- // this or the other data object
- // for the mapping
+ // depending on this result, use this or the other data object for the
+ // mapping
typename MappingQ1<dim,spacedim>::InternalData *p_data=0;
if (data.use_mapping_q1_on_current_cell)
p_data=&data.mapping_q1_data;
const unsigned int n_inner_2d=(degree-1)*(degree-1);
const unsigned int n_outer_2d=4+4*(degree-1);
- // first check whether we have precomputed
- // the values for some polynomial degree;
- // the sizes of arrays is
- // n_inner_2d*n_outer_2d
+ // first check whether we have precomputed the values for some polynomial
+ // degree; the sizes of arrays is n_inner_2d*n_outer_2d
double const *loqv_ptr=0;
switch (degree)
{
- // for degree==1, we shouldn't have to
- // compute any support points, since
+ // for degree==1, we shouldn't have to compute any support points, since
// all of them are on the vertices
case 2:
{
- // (checked these values against the
- // output of compute_laplace_vector
- // again, and found they're indeed
- // right -- just in case someone
- // wonders where they come from --
- // WB)
+ // (checked these values against the output of compute_laplace_vector
+ // again, and found they're indeed right -- just in case someone wonders
+ // where they come from -- WB)
static const double loqv2[1*8]
= {1/16., 1/16., 1/16., 1/16., 3/16., 3/16., 3/16., 3/16.};
loqv_ptr=&loqv2[0];
break;
}
- case 3:
- {
- // (same as above)
- static const double loqv3[4*12]
- = {80/1053., 1/81., 1/81., 11/1053., 25/117., 44/351.,
- 7/117., 16/351., 25/117., 44/351., 7/117., 16/351.,
- 1/81., 80/1053., 11/1053., 1/81., 7/117., 16/351.,
- 25/117., 44/351., 44/351., 25/117., 16/351., 7/117.,
- 1/81., 11/1053., 80/1053., 1/81., 44/351., 25/117.,
- 16/351., 7/117., 7/117., 16/351., 25/117., 44/351.,
- 11/1053., 1/81., 1/81., 80/1053., 16/351., 7/117.,
- 44/351., 25/117., 16/351., 7/117., 44/351., 25/117.
- };
- Assert (sizeof(loqv3)/sizeof(loqv3[0]) ==
- n_inner_2d * n_outer_2d,
- ExcInternalError());
-
- loqv_ptr=&loqv3[0];
-
- break;
- }
-
-
- case 4:
- {
- static const double loqv4[9*16]
- = {0.07405921850311571, -0.001075744628905992,
- -0.001075744628906007, 0.001914292239071463,
- 0.2231273865431892, 0.1346851306015187,
- 0.03812914216116724, 0.02913160002633252,
- 0.02200737428129396, 0.01600835564431224,
- 0.2231273865431891, 0.1346851306015187,
- 0.03812914216116723, 0.02913160002633253,
- 0.02200737428129391, 0.01600835564431222,
-
- 0.00664803151334206, 0.006648031513342719,
- 0.002873452861657458, 0.002873452861657626,
- 0.07903572682584378, 0.05969238281250031,
- 0.03619864817415824, 0.07903572682584187,
- 0.0596923828124999, 0.03619864817415815,
- 0.1527716818820237, 0.2348152760709273,
- 0.152771681882024, 0.02496269311797778,
- 0.04081948955407129, 0.02496269311797789,
-
- -0.001075744628906923, 0.07405921850311589,
- 0.001914292239071339, -0.001075744628905884,
- 0.02913160002633509, 0.02200737428129395,
- 0.01600835564431229, 0.2231273865431878,
- 0.1346851306015183, 0.0381291421611672,
- 0.03812914216116729, 0.1346851306015185,
- 0.2231273865431898, 0.01600835564431217,
- 0.02200737428129394, 0.02913160002633262,
-
- 0.006648031513342073, 0.002873452861657473,
- 0.006648031513342726, 0.002873452861657636,
- 0.1527716818820238, 0.2348152760709273,
- 0.152771681882024, 0.02496269311797779,
- 0.04081948955407131, 0.0249626931179779,
- 0.07903572682584376, 0.05969238281250026,
- 0.03619864817415824, 0.07903572682584187,
- 0.0596923828124998, 0.0361986481741581,
-
- 0.01106770833333302, 0.01106770833333336,
- 0.01106770833333337, 0.01106770833333374,
- 0.06770833333333424, 0.1035156250000011,
- 0.0677083333333344, 0.06770833333333376,
- 0.103515624999999, 0.06770833333333399,
- 0.06770833333333422, 0.1035156250000009,
- 0.06770833333333436, 0.0677083333333337,
- 0.1035156249999988, 0.0677083333333339,
-
- 0.002873452861657185, 0.006648031513342362,
- 0.002873452861657334, 0.006648031513343038,
- 0.02496269311797779, 0.04081948955407401,
- 0.02496269311797788, 0.1527716818820234,
- 0.234815276070926, 0.1527716818820237,
- 0.03619864817415819, 0.05969238281250028,
- 0.07903572682584407, 0.03619864817415804,
- 0.05969238281249986, 0.0790357268258422,
-
- -0.001075744628906913, 0.00191429223907134,
- 0.07405921850311592, -0.001075744628905865,
- 0.03812914216116729, 0.1346851306015185,
- 0.2231273865431899, 0.01600835564431217,
- 0.02200737428129396, 0.02913160002633264,
- 0.02913160002633509, 0.02200737428129391,
- 0.01600835564431228, 0.2231273865431878,
- 0.1346851306015183, 0.03812914216116718,
-
- 0.002873452861657176, 0.002873452861657321,
- 0.006648031513342374, 0.006648031513343037,
- 0.03619864817415817, 0.05969238281250032,
- 0.07903572682584409, 0.03619864817415805,
- 0.05969238281249992, 0.07903572682584221,
- 0.02496269311797776, 0.04081948955407392,
- 0.02496269311797785, 0.1527716818820233,
- 0.2348152760709258, 0.1527716818820236,
-
- 0.001914292239071237, -0.001075744628906803,
- -0.001075744628906778, 0.07405921850311617,
- 0.01600835564431228, 0.02200737428129401,
- 0.02913160002633524, 0.03812914216116726,
- 0.1346851306015182, 0.2231273865431886,
- 0.01600835564431228, 0.02200737428129397,
- 0.02913160002633523, 0.03812914216116726,
- 0.1346851306015181, 0.2231273865431886,
- };
-
- Assert (sizeof(loqv4)/sizeof(loqv4[0]) ==
- n_inner_2d * n_outer_2d,
- ExcInternalError());
-
- loqv_ptr=&loqv4[0];
-
- break;
- }
-
- // no other cases implemented,
- // so simply fall through
+ // no other cases implemented, so simply fall through
default:
break;
}
if (loqv_ptr!=0)
{
- // precomputed. copy values to
- // the loqvs array
+ // precomputed. copy values to the loqvs array
loqvs.reinit(n_inner_2d, n_outer_2d);
for (unsigned int unit_point=0; unit_point<n_inner_2d; ++unit_point)
for (unsigned int k=0; k<n_outer_2d; ++k)
else
{
// not precomputed, then do so now
- if (dim==2)
+ if (dim == 2)
compute_laplace_vector(loqvs);
- else
- // computing the Laplace vector for
- // faces is not supported in 3d at
- // present. presumably, doing so
- // would not be so hard: we would
- // only have to call the function in
- // 2d, i.e. the quad(=face) values in
- // 3d are equal to the quad(=cell)
- // values in 2d. however, that would
- // require us to link in the 2d
- // library, which is kind of awkward
- // (note that compute_laplace_vector
- // really makes use of a lot of 2d
- // stuff, such as FEValues etc). an
- // alternative would be to precompute
- // the values of this array for a
- // couple of higher mapping orders,
- // pin down their values and insert
- // them into the array above.
- Assert (false, ExcNotImplemented());
+ else if (dim == 3)
+ {
+ MappingQ<2,2> mapping_2d(this->degree);
+ loqvs = mapping_2d.laplace_on_quad_vector;
+ }
}
- // the sum of weights of the points
- // at the outer rim should be
- // one. check this
+ // the sum of weights of the points at the outer rim should be one. check
+ // this
for (unsigned int unit_point=0; unit_point<loqvs.n_rows(); ++unit_point)
Assert(std::fabs(std::accumulate(loqvs[unit_point].begin(),
- loqvs[unit_point].end(),0.)-1)<1e-13,
+ loqvs[unit_point].end(),0.)-1)<1e-13*this->degree,
ExcInternalError());
}
{
Assert(degree>1, ExcInternalError());
- // first check whether we have
- // precomputed the values for some
- // polynomial degree
+ // first check whether we have precomputed the values for some polynomial
+ // degree
double const *lohv_ptr=0;
if (degree==2)
{
if (lohv_ptr!=0)
{
- // precomputed. copy values to
- // the lohvs array
+ // precomputed. copy values to the lohvs array
lohvs.reinit(n_inner, n_outer);
for (unsigned int unit_point=0; unit_point<n_inner; ++unit_point)
for (unsigned int k=0; k<n_outer; ++k)
// not precomputed, then do so now
compute_laplace_vector(lohvs);
- // the sum of weights of the points
- // at the outer rim should be
- // one. check this
+ // the sum of weights of the points at the outer rim should be one. check
+ // this
for (unsigned int unit_point=0; unit_point<n_inner; ++unit_point)
Assert(std::fabs(std::accumulate(lohvs[unit_point].begin(),
- lohvs[unit_point].end(),0.) - 1)<1e-13,
+ lohvs[unit_point].end(),0.) - 1)<1e-13*this->degree,
ExcInternalError());
}
Assert(lvs.n_rows()==0, ExcInternalError());
Assert(dim==2 || dim==3, ExcNotImplemented());
- // for degree==1, we shouldn't have to
- // compute any support points, since all of
- // them are on the vertices
+ // for degree==1, we shouldn't have to compute any support points, since all
+ // of them are on the vertices
Assert(degree>1, ExcInternalError());
- // compute the shape
- // gradients at the quadrature
- // points on the unit cell
+ // compute the shape gradients at the quadrature points on the unit cell
const QGauss<dim> quadrature(degree+1);
const unsigned int n_q_points=quadrature.size();
quadrature_data.shape_derivatives.resize(n_shape_functions * n_q_points);
this->compute_shapes(quadrature.get_points(), quadrature_data);
- // Compute the stiffness matrix of
- // the inner dofs
- FullMatrix<double> S(n_inner);
+ // Compute the stiffness matrix of the inner dofs
+ FullMatrix<long double> S(n_inner);
for (unsigned int point=0; point<n_q_points; ++point)
for (unsigned int i=0; i<n_inner; ++i)
for (unsigned int j=0; j<n_inner; ++j)
- S(i,j) += contract(quadrature_data.derivative(point, n_outer+i),
- quadrature_data.derivative(point, n_outer+j))
- * quadrature.weight(point);
+ {
+ long double res = 0.;
+ for (unsigned int l=0; l<dim; ++l)
+ res += (long double)quadrature_data.derivative(point, n_outer+i)[l] *
+ (long double)quadrature_data.derivative(point, n_outer+j)[l];
- // Compute the components of T to be the
- // product of gradients of inner and
+ S(i,j) += res * (long double)quadrature.weight(point);
+ }
+
+ // Compute the components of T to be the product of gradients of inner and
// outer shape functions.
- FullMatrix<double> T(n_inner, n_outer);
+ FullMatrix<long double> T(n_inner, n_outer);
for (unsigned int point=0; point<n_q_points; ++point)
for (unsigned int i=0; i<n_inner; ++i)
for (unsigned int k=0; k<n_outer; ++k)
- T(i,k) += contract(quadrature_data.derivative(point, n_outer+i),
- quadrature_data.derivative(point, k))
- *quadrature.weight(point);
+ {
+ long double res = 0.;
+ for (unsigned int l=0; l<dim; ++l)
+ res += (long double)quadrature_data.derivative(point, n_outer+i)[l] *
+ (long double)quadrature_data.derivative(point, k)[l];
+
+ T(i,k) += res *(long double)quadrature.weight(point);
+ }
- FullMatrix<double> S_1(n_inner);
+ FullMatrix<long double> S_1(n_inner);
S_1.invert(S);
- FullMatrix<double> S_1_T(n_inner, n_outer);
+ FullMatrix<long double> S_1_T(n_inner, n_outer);
// S:=S_1*T
S_1.mmult(S_1_T,T);
- // Resize and initialize the
- // lvs
+ // Resize and initialize the lvs
lvs.reinit (n_inner, n_outer);
for (unsigned int i=0; i<n_inner; ++i)
for (unsigned int k=0; k<n_outer; ++k)
MappingQ<dim,spacedim>::apply_laplace_vector(const Table<2,double> &lvs,
std::vector<Point<spacedim> > &a) const
{
- // check whether the data we need
- // is really available. if you fail
- // here and if
- // lvs==laplace_on_quad_vector in
- // the calling function, then we
- // didn't compute the quad laplace
- // vector. this is mentioned in the
- // constructor of this class,
- // although I don't understand the
- // reason for not aborting there
+ // check whether the data we need is really available. if you fail here and
+ // if lvs==laplace_on_quad_vector in the calling function, then we didn't
+ // compute the quad laplace vector. this is mentioned in the constructor of
+ // this class, although I don't understand the reason for not aborting there
// any more [WB]
Assert(lvs.n_rows()!=0, ExcLaplaceVectorNotSet(degree));
Assert(a.size()==n_outer_apply,
ExcDimensionMismatch(a.size(), n_outer_apply));
- // compute each inner point as
- // linear combination of the outer
- // points. the weights are given by
- // the lvs entries, the outer
- // points are the first (existing)
- // elements of a
+ // compute each inner point as linear combination of the outer points. the
+ // weights are given by the lvs entries, the outer points are the first
+ // (existing) elements of a
for (unsigned int unit_point=0; unit_point<n_inner_apply; ++unit_point)
{
Assert(lvs.n_cols()==n_outer_apply, ExcInternalError());
const typename Triangulation<dim,spacedim>::cell_iterator &cell,
std::vector<Point<spacedim> > &a) const
{
- // if this is a cell for which we
- // want to compute the full
- // mapping, then get them from the
- // following function
+ // if this is a cell for which we want to compute the full mapping, then get
+ // them from the following function
if (use_mapping_q_on_all_cells || cell->has_boundary_lines())
compute_support_points_laplace(cell, a);
else
- // otherwise: use a Q1 mapping
- // for which the mapping shape
- // function support points are
- // simply the vertices of the
- // cell
+ // otherwise: use a Q1 mapping for which the mapping shape function
+ // support points are simply the vertices of the cell
{
a.resize(GeometryInfo<dim>::vertices_per_cell);
MappingQ<dim,spacedim>::compute_support_points_laplace(const typename Triangulation<dim,spacedim>::cell_iterator &cell,
std::vector<Point<spacedim> > &a) const
{
- // in any case, we need the
- // vertices first
+ // in any case, we need the vertices first
a.resize(GeometryInfo<dim>::vertices_per_cell);
for (unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
a[i] = cell->vertex(i);
add_line_support_points(cell, a);
break;
case 2:
- // in 2d, add the
- // points on the four
- // bounding lines to
- // the exterior (outer)
- // points
+ // in 2d, add the points on the four bounding lines to the exterior
+ // (outer) points
add_line_support_points (cell, a);
if (dim != spacedim)
add_quad_support_points(cell, a);
case 3:
{
- // in 3d also add the
- // points located on
- // the boundary faces
+ // in 3d also add the points located on the boundary faces
add_line_support_points (cell, a);
add_quad_support_points (cell, a);
apply_laplace_vector (laplace_on_hex_vector, a);
MappingQ<1>::add_line_support_points (const Triangulation<1>::cell_iterator &,
std::vector<Point<1> > &) const
{
- // there are no points on bounding
- // lines which are to be added
+ // there are no points on bounding lines which are to be added
const unsigned int dim=1;
Assert (dim > 1, ExcImpossibleInDim(dim));
}
{
const unsigned int dim = 1;
const unsigned int spacedim = 2;
- // Ask for the mid point, if that's
- // the only thing we need.
+ // Ask for the mid point, if that's the only thing we need.
if (degree==2)
{
const Boundary<dim,spacedim> *const boundary
a.push_back(boundary->get_new_point_on_line(cell));
}
else
- // otherwise call the more
- // complicated functions and ask
- // for inner points from the
- // boundary description
+ // otherwise call the more complicated functions and ask for inner points
+ // from the boundary description
{
std::vector<Point<spacedim> > line_points (degree-1);
{
const unsigned int dim = 1;
const unsigned int spacedim = 3;
- // Ask for the mid point, if that's
- // the only thing we need.
+ // Ask for the mid point, if that's the only thing we need.
if (degree==2)
{
const Boundary<dim,spacedim> *const boundary
a.push_back(boundary->get_new_point_on_line(cell));
}
else
- // otherwise call the more
- // complicated functions and ask
- // for inner points from the
- // boundary description
+ // otherwise call the more complicated functions and ask for inner points
+ // from the boundary description
{
std::vector<Point<spacedim> > line_points (degree-1);
std::vector<Point<spacedim> > &a) const
{
static const StraightBoundary<dim,spacedim> straight_boundary;
- // if we only need the midpoint,
- // then ask for it.
+ // if we only need the midpoint, then ask for it.
if (degree==2)
{
for (unsigned int line_no=0; line_no<GeometryInfo<dim>::lines_per_cell; ++line_no)
};
}
else
- // otherwise call the more
- // complicated functions and ask
- // for inner points from the
- // boundary description
+ // otherwise call the more complicated functions and ask for inner points
+ // from the boundary description
{
std::vector<Point<spacedim> > line_points (degree-1);
- // loop over each of the lines,
- // and if it is at the
- // boundary, then first get the
- // boundary description and
- // second compute the points on
- // it
+ // loop over each of the lines, and if it is at the boundary, then first
+ // get the boundary description and second compute the points on it
for (unsigned int line_no=0; line_no<GeometryInfo<dim>::lines_per_cell; ++line_no)
{
const typename Triangulation<dim,spacedim>::line_iterator line = cell->line(line_no);
boundary->get_intermediate_points_on_line (line, line_points);
if (dim==3)
{
- // in 3D, lines might be in wrong
- // orientation. if so, reverse
+ // in 3D, lines might be in wrong orientation. if so, reverse
// the vector
if (cell->line_orientation(line_no))
a.insert (a.end(), line_points.begin(), line_points.end());
a.insert (a.end(), line_points.rbegin(), line_points.rend());
}
else
- // in 2D, lines always have the
- // correct orientation. simply
- // append all points
+ // in 2D, lines always have the correct orientation. simply append
+ // all points
a.insert (a.end(), line_points.begin(), line_points.end());
}
vertices_per_cell = GeometryInfo<3>::vertices_per_cell;
static const StraightBoundary<3> straight_boundary;
- // used if face quad at boundary or
- // entirely in the interior of the
- // domain
+ // used if face quad at boundary or entirely in the interior of the domain
std::vector<Point<3> > quad_points ((degree-1)*(degree-1));
- // used if only one line of face
- // quad is at boundary
+ // used if only one line of face quad is at boundary
std::vector<Point<3> > b(4*degree);
- // loop over all faces and collect
- // points on them
+ // loop over all faces and collect points on them
for (unsigned int face_no=0; face_no<faces_per_cell; ++face_no)
{
const Triangulation<3>::face_iterator face = cell->face(face_no);
- // select the correct mappings
- // for the present face
+ // select the correct mappings for the present face
const bool face_orientation = cell->face_orientation(face_no),
face_flip = cell->face_flip (face_no),
face_rotation = cell->face_rotation (face_no);
face_rotation)),
ExcInternalError());
- // indices of the lines that
- // bound a face are given by
- // GeometryInfo<3>::
+ // indices of the lines that bound a face are given by GeometryInfo<3>::
// face_to_cell_lines
for (unsigned int i=0; i<lines_per_face; ++i)
Assert(face->line(i)==cell->line(GeometryInfo<3>::face_to_cell_lines(
ExcInternalError());
#endif
- // if face at boundary, then
- // ask boundary object to
- // return intermediate points
- // on it
+ // if face at boundary, then ask boundary object to return intermediate
+ // points on it
if (face->at_boundary())
{
face->get_triangulation().get_boundary(face->boundary_indicator())
.get_intermediate_points_on_quad (face, quad_points);
- // in 3D, the orientation, flip and
- // rotation of the face might not
- // match what we expect here, namely
- // the standard orientation. thus
- // reorder points accordingly. since
- // a Mapping uses the same shape
- // function as an FEQ, we can ask a
- // FEQ to do the reordering for us.
+ // in 3D, the orientation, flip and rotation of the face might not
+ // match what we expect here, namely the standard orientation. thus
+ // reorder points accordingly. since a Mapping uses the same shape
+ // function as an FEQ, we can ask a FEQ to do the reordering for us.
for (unsigned int i=0; i<quad_points.size(); ++i)
a.push_back(quad_points[feq.adjust_quad_dof_index_for_face_orientation(i,
face_orientation,
}
else
{
- // face is not at boundary,
- // but maybe some of its
- // lines are. count them
+ // face is not at boundary, but maybe some of its lines are. count
+ // them
unsigned int lines_at_boundary=0;
for (unsigned int i=0; i<lines_per_face; ++i)
if (face->line(i)->at_boundary())
Assert(lines_at_boundary<=lines_per_face, ExcInternalError());
- // if at least one of the
- // lines bounding this quad
- // is at the boundary, then
- // collect points
- // separately
+ // if at least one of the lines bounding this quad is at the
+ // boundary, then collect points separately
if (lines_at_boundary>0)
{
- // call of function
- // apply_laplace_vector
- // increases size of b
- // about 1. There
- // resize b for the
- // case the mentioned
- // function was already
- // called.
+ // call of function apply_laplace_vector increases size of b
+ // about 1. There resize b for the case the mentioned function
+ // was already called.
b.resize(4*degree);
- // b is of size
- // 4*degree, make sure
- // that this is the
- // right size
+ // b is of size 4*degree, make sure that this is the right size
Assert(b.size()==vertices_per_face+lines_per_face*(degree-1),
ExcDimensionMismatch(b.size(),
vertices_per_face+lines_per_face*(degree-1)));
- // sort the points into b. We
- // used access from the cell (not
- // from the face) to fill b, so
- // we can assume a standard face
- // orientation. Doing so, the
- // calculated points will be in
+ // sort the points into b. We used access from the cell (not
+ // from the face) to fill b, so we can assume a standard face
+ // orientation. Doing so, the calculated points will be in
// standard orientation as well.
for (unsigned int i=0; i<vertices_per_face; ++i)
b[i]=a[GeometryInfo<3>::face_to_cell_vertices(face_no, i)];
a[vertices_per_cell + GeometryInfo<3>::face_to_cell_lines(
face_no, i)*(degree-1)+j];
- // Now b includes the support
- // points on the quad and we can
+ // Now b includes the support points on the quad and we can
// apply the laplace vector
apply_laplace_vector(laplace_on_quad_vector, b);
Assert(b.size()==4*degree+(degree-1)*(degree-1),
}
else
{
- // face is entirely in
- // the interior. get
- // intermediate points
- // from a straight
- // boundary object
+ // face is entirely in the interior. get intermediate points
+ // from a straight boundary object
straight_boundary.get_intermediate_points_on_quad (face, quad_points);
- // in 3D, the orientation, flip
- // and rotation of the face might
- // not match what we expect here,
- // namely the standard
- // orientation. thus reorder
- // points accordingly. since a
- // Mapping uses the same shape
- // function as an FEQ, we can ask
- // a FEQ to do the reordering for
- // us.
+ // in 3D, the orientation, flip and rotation of the face might
+ // not match what we expect here, namely the standard
+ // orientation. thus reorder points accordingly. since a Mapping
+ // uses the same shape function as an FEQ, we can ask a FEQ to
+ // do the reordering for us.
for (unsigned int i=0; i<quad_points.size(); ++i)
a.push_back(quad_points[feq.adjust_quad_dof_index_for_face_orientation(i,
face_orientation,
const MappingType mapping_type) const
{
AssertDimension (input.size(), output.size());
- // The data object may be just a
- // MappingQ1::InternalData, so we
- // have to test for this first.
+ // The data object may be just a MappingQ1::InternalData, so we have to test
+ // for this first.
const typename MappingQ1<dim,spacedim>::InternalData *q1_data =
dynamic_cast<const typename MappingQ1<dim,spacedim>::InternalData *> (&mapping_data);
Assert(q1_data!=0, ExcInternalError());
- // If it is a genuine
- // MappingQ::InternalData, we have
- // to test further
+ // If it is a genuine MappingQ::InternalData, we have to test further
if (!q1_data->is_mapping_q1_data)
{
Assert (dynamic_cast<const InternalData *>(&mapping_data) != 0,
ExcInternalError());
const InternalData &data = static_cast<const InternalData &>(mapping_data);
- // If we only use the
- // Q1-portion, we have to
- // extract that data object
+ // If we only use the Q1-portion, we have to extract that data object
if (data.use_mapping_q1_on_current_cell)
q1_data = &data.mapping_q1_data;
}
- // Now, q1_data should have the
- // right tensors in it and we call
- // the base classes transform
- // function
+ // Now, q1_data should have the right tensors in it and we call the base
+ // classes transform function
MappingQ1<dim,spacedim>::transform(input, output, *q1_data, mapping_type);
}
const MappingType mapping_type) const
{
AssertDimension (input.size(), output.size());
- // The data object may be just a
- // MappingQ1::InternalData, so we
- // have to test for this first.
+ // The data object may be just a MappingQ1::InternalData, so we have to test
+ // for this first.
const typename MappingQ1<dim,spacedim>::InternalData *q1_data =
dynamic_cast<const typename MappingQ1<dim,spacedim>::InternalData *> (&mapping_data);
Assert(q1_data!=0, ExcInternalError());
- // If it is a genuine
- // MappingQ::InternalData, we have
- // to test further
+ // If it is a genuine MappingQ::InternalData, we have to test further
if (!q1_data->is_mapping_q1_data)
{
Assert (dynamic_cast<const InternalData *>(&mapping_data) != 0,
ExcInternalError());
const InternalData &data = static_cast<const InternalData &>(mapping_data);
- // If we only use the
- // Q1-portion, we have to
- // extract that data object
+ // If we only use the Q1-portion, we have to extract that data object
if (data.use_mapping_q1_on_current_cell)
q1_data = &data.mapping_q1_data;
}
- // Now, q1_data should have the
- // right tensors in it and we call
- // the base classes transform
- // function
+ // Now, q1_data should have the right tensors in it and we call the base
+ // classes transform function
MappingQ1<dim,spacedim>::transform(input, output, *q1_data, mapping_type);
}
const MappingType mapping_type) const
{
AssertDimension (input.size(), output.size());
- // The data object may be just a
- // MappingQ1::InternalData, so we
- // have to test for this first.
+ // The data object may be just a MappingQ1::InternalData, so we have to test
+ // for this first.
const typename MappingQ1<dim,spacedim>::InternalData *q1_data =
dynamic_cast<const typename MappingQ1<dim,spacedim>::InternalData *> (&mapping_data);
Assert(q1_data!=0, ExcInternalError());
- // If it is a genuine
- // MappingQ::InternalData, we have
- // to test further
+ // If it is a genuine MappingQ::InternalData, we have to test further
if (!q1_data->is_mapping_q1_data)
{
Assert (dynamic_cast<const InternalData *>(&mapping_data) != 0,
ExcInternalError());
const InternalData &data = static_cast<const InternalData &>(mapping_data);
- // If we only use the
- // Q1-portion, we have to
- // extract that data object
+ // If we only use the Q1-portion, we have to extract that data object
if (data.use_mapping_q1_on_current_cell)
q1_data = &data.mapping_q1_data;
}
- // Now, q1_data should have the
- // right tensors in it and we call
- // the base classes transform
- // function
+ // Now, q1_data should have the right tensors in it and we call the base
+ // classes transform function
MappingQ1<dim,spacedim>::transform(input, output, *q1_data, mapping_type);
}
transform_unit_to_real_cell (const typename Triangulation<dim,spacedim>::cell_iterator &cell,
const Point<dim> &p) const
{
- // Use the get_data function to
- // create an InternalData with data
- // vectors of the right size and
- // transformation shape values
- // already computed at point p.
+ // Use the get_data function to create an InternalData with data vectors of
+ // the right size and transformation shape values already computed at point
+ // p.
const Quadrature<dim> point_quadrature(p);
std::auto_ptr<InternalData>
mdata (dynamic_cast<InternalData *> (
&*mdata);
compute_mapping_support_points(cell, p_data->mapping_support_points);
- // If this should be Q1, ignore all
- // other support points.
+ // If this should be Q1, ignore all other support points.
if (p_data->shape_values.size()<p_data->mapping_support_points.size())
p_data->mapping_support_points.resize
(GeometryInfo<dim>::vertices_per_cell);
transform_real_to_unit_cell (const typename Triangulation<dim,spacedim>::cell_iterator &cell,
const Point<spacedim> &p) const
{
- // first a Newton iteration based
- // on a Q1 mapping to get a good
- // starting point, the idea being
- // that this is cheaper than trying
- // to start with the real mapping
- // and likely also more robust.
+ // first a Newton iteration based on a Q1 mapping to get a good starting
+ // point, the idea being that this is cheaper than trying to start with the
+ // real mapping and likely also more robust.
//
- // that said, this doesn't always
- // work: there are cases where the
- // point is outside the cell and
- // the inverse mapping doesn't
- // converge. in that case, use the
- // center point of the cell as a
- // starting point if we are to go
- // on using the full mapping, or
- // just propagate up the exception
- // if we had no intention of
- // continuing with the full mapping
+ // that said, this doesn't always work: there are cases where the point is
+ // outside the cell and the inverse mapping doesn't converge. in that case,
+ // use the center point of the cell as a starting point if we are to go on
+ // using the full mapping, or just propagate up the exception if we had no
+ // intention of continuing with the full mapping
Point<dim> initial_p_unit;
try
{
}
catch (const typename Mapping<dim,spacedim>::ExcTransformationFailed &)
{
- // mirror the conditions of the
- // code below to determine if
- // we need to use an arbitrary
- // starting point or if we just
- // need to rethrow the
+ // mirror the conditions of the code below to determine if we need to
+ // use an arbitrary starting point or if we just need to rethrow the
// exception
if (cell->has_boundary_lines()
||
throw;
}
- // then a Newton iteration based on the
- // full MappingQ if we need this. note that
- // for interior cells with dim==spacedim,
- // the mapping used is in fact a Q1
- // mapping, so there is nothing we need to
- // do unless the iteration above failed
+ // then a Newton iteration based on the full MappingQ if we need this. note
+ // that for interior cells with dim==spacedim, the mapping used is in fact a
+ // Q1 mapping, so there is nothing we need to do unless the iteration above
+ // failed
if (cell->has_boundary_lines()
||
use_mapping_q_on_all_cells
||
(dim!=spacedim) )
{
- // use the full mapping. in case the
- // function above should have given us
- // something back that lies outside the
- // unit cell (that might happen because
- // we may have given a point 'p' that
- // lies inside the cell with the higher
- // order mapping, but outside the
- // Q1-mapped reference cell), then
- // project it back into the reference
- // cell in hopes that this gives a
- // better starting point to the
- // following iteration
+ // use the full mapping. in case the function above should have given us
+ // something back that lies outside the unit cell (that might happen
+ // because we may have given a point 'p' that lies inside the cell with
+ // the higher order mapping, but outside the Q1-mapped reference cell),
+ // then project it back into the reference cell in hopes that this gives
+ // a better starting point to the following iteration
initial_p_unit = GeometryInfo<dim>::project_to_unit_cell(initial_p_unit);
const Quadrature<dim> point_quadrature(initial_p_unit);
compute_mapping_support_points (cell, mdata->mapping_support_points);
- // If this is a q1 mapping,
- // then only use the support
- // points on the vertices.
+ // If this is a q1 mapping, then only use the support points on the
+ // vertices.
if (mdata->shape_values.size() < mdata->mapping_support_points.size())
mdata->mapping_support_points.resize(GeometryInfo<dim>::vertices_per_cell);
-
return this->transform_real_to_unit_cell_internal(cell, p, initial_p_unit, *mdata);
}
else
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/derivative_form.h>
#include <deal.II/base/quadrature.h>
case 1:
// in 1d, we don't have access to any of the data.aux
// fields (because it has only dim-1 components), but we
- // can still compute the boundary form simply by simply
+ // can still compute the boundary form by simply
// looking at the number of the face
boundary_forms[i][0] = (face_no == 0 ?
-1 : +1);
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
{
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/fe/mapping_q1_eulerian.h>
#include <deal.II/lac/vector.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/utilities.h>
#include <deal.II/base/quadrature_lib.h>
#include <deal.II/lac/vector.h>
#include <deal.II/lac/petsc_vector.h>
+#include <deal.II/lac/trilinos_vector.h>
+#include <deal.II/lac/trilinos_block_vector.h>
+#include <deal.II/lac/trilinos_parallel_block_vector.h>
#include <deal.II/grid/tria_iterator.h>
#include <deal.II/dofs/dof_handler.h>
#include <deal.II/dofs/dof_accessor.h>
:
Quadrature<dim>(Utilities::fixed_power<dim>(map_degree+1))
{
- // first we determine the support points
- // on the unit cell in lexicographic order.
- // for this purpose we can use an interated
- // trapezoidal quadrature rule.
- const QTrapez<1> q1d;
- const QIterated<dim> q_iterated(q1d,map_degree);
+ // first we determine the support points on the unit cell in lexicographic
+ // order, which are (in accordance with MappingQ) the support points of
+ // QGaussLobatto.
+ const QGaussLobatto<dim> q_iterated(map_degree+1);
const unsigned int n_q_points = q_iterated.size();
- // we then need to define a renumbering
- // vector that allows us to go from a
- // lexicographic numbering scheme to a hierarchic
- // one. this fragment is taking almost verbatim
- // from the MappingQ class.
-
+ // we then need to define a renumbering vector that allows us to go from a
+ // lexicographic numbering scheme to a hierarchic one. this fragment is
+ // taking almost verbatim from the MappingQ class.
std::vector<unsigned int> renumber(n_q_points);
std::vector<unsigned int> dpo(dim+1, 1U);
for (unsigned int i=1; i<dpo.size(); ++i)
FETools::lexicographic_to_hierarchic_numbering (
FiniteElementData<dim> (dpo, 1, map_degree), renumber);
- // finally we assign the quadrature points in the
- // required order.
-
+ // finally we assign the quadrature points in the required order.
for (unsigned int q=0; q<n_q_points; ++q)
this->quadrature_points[renumber[q]] = q_iterated.point(q);
}
std::vector<Point<spacedim> > &a) const
{
- // first, basic assertion
- // with respect to vector size,
+ // first, basic assertion with respect to vector size,
const types::global_dof_index n_dofs = euler_dof_handler->n_dofs();
const types::global_dof_index vector_size = euler_vector->size();
AssertDimension(vector_size,n_dofs);
- // we then transform our tria iterator
- // into a dof iterator so we can
- // access data not associated with
- // triangulations
+ // we then transform our tria iterator into a dof iterator so we can access
+ // data not associated with triangulations
typename DoFHandler<dim,spacedim>::cell_iterator dof_cell(*cell, euler_dof_handler);
Assert (dof_cell->active() == true, ExcInactiveCell());
- // our quadrature rule is chosen
- // so that each quadrature point
- // corresponds to a support point
- // in the undeformed configuration.
- // we can then query the given
- // displacement field at these points
- // to determine the shift vector that
- // maps the support points to the
- // deformed configuration.
-
- // we assume that the given field contains
- // dim displacement components, but
- // that there may be other solution
- // components as well (e.g. pressures).
- // this class therefore assumes that the
- // first dim components represent the
- // actual shift vector we need, and simply
- // ignores any components after that.
- // this implies that the user should order
- // components appropriately, or create a
- // separate dof handler for the displacements.
+ // our quadrature rule is chosen so that each quadrature point corresponds
+ // to a support point in the undeformed configuration. we can then query
+ // the given displacement field at these points to determine the shift
+ // vector that maps the support points to the deformed configuration.
+
+ // we assume that the given field contains dim displacement components, but
+ // that there may be other solution components as well (e.g. pressures).
+ // this class therefore assumes that the first dim components represent the
+ // actual shift vector we need, and simply ignores any components after
+ // that. this implies that the user should order components appropriately,
+ // or create a separate dof handler for the displacements.
const unsigned int n_support_pts = support_quadrature.size();
const unsigned int n_components = euler_dof_handler->get_fe().n_components();
std::vector<Vector<double> > shift_vector(n_support_pts,Vector<double>(n_components));
- // fill shift vector for each
- // support point using an fe_values
- // object. make sure that the
- // fe_values variable isn't used
- // simulatenously from different
+ // fill shift vector for each support point using an fe_values object. make
+ // sure that the fe_values variable isn't used simulatenously from different
// threads
Threads::Mutex::ScopedLock lock(fe_values_mutex);
fe_values.reinit(dof_cell);
fe_values.get_function_values(*euler_vector, shift_vector);
- // and finally compute the positions of the
- // support points in the deformed
+ // and finally compute the positions of the support points in the deformed
// configuration.
-
a.resize(n_support_pts);
for (unsigned int q=0; q<n_support_pts; ++q)
{
std::vector<Point<spacedim> > &normal_vectors,
CellSimilarity::Similarity &cell_similarity) const
{
- // disable any previously detected
- // similarity and hand on to the respective
+ // disable any previously detected similarity and hand on to the respective
// function of the base class.
cell_similarity = CellSimilarity::invalid_next_cell;
MappingQ<dim,spacedim>::fill_fe_values (cell, q, mapping_data,
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
{
template class MappingQEulerian<deal_II_dimension,
PETScWrappers::MPI::Vector, deal_II_space_dimension>;
# endif
+# ifdef DEAL_II_WITH_TRILINOS
+ template class MappingQEulerian<deal_II_dimension,
+ TrilinosWrappers::Vector, deal_II_space_dimension>;
+ template class MappingQEulerian<deal_II_dimension,
+ TrilinosWrappers::MPI::Vector, deal_II_space_dimension>;
+ template class MappingQEulerian<deal_II_dimension,
+ TrilinosWrappers::BlockVector, deal_II_space_dimension>;
+ template class MappingQEulerian<deal_II_dimension,
+ TrilinosWrappers::MPI::BlockVector, deal_II_space_dimension>;
+# endif
+
#endif
}
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
-FILE(GLOB _header
- ${CMAKE_SOURCE_DIR}/include/deal.II/grid/*.h
- )
-
SET(_src
grid_generator.cc
grid_in.cc
tria_objects.inst.in
)
+FILE(GLOB _header
+ ${CMAKE_SOURCE_DIR}/include/deal.II/grid/*.h
+ )
+
DEAL_II_ADD_LIBRARY(obj_grid OBJECT ${_src} ${_header} ${_inst})
EXPAND_INSTANTIATIONS(obj_grid "${_inst}")
-
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/quadrature_lib.h>
#include <deal.II/base/thread_management.h>
-namespace
+namespace GridGenerator
{
- // Corner points of the cube [-1,1]^3
- const Point<3> hexahedron[8] =
+ namespace
{
- Point<3>(-1,-1,-1),
- Point<3>(+1,-1,-1),
- Point<3>(-1,+1,-1),
- Point<3>(+1,+1,-1),
- Point<3>(-1,-1,+1),
- Point<3>(+1,-1,+1),
- Point<3>(-1,+1,+1),
- Point<3>(+1,+1,+1)
- };
-
- // Octahedron inscribed in the cube
- // [-1,1]^3
- const Point<3> octahedron[6] =
- {
- Point<3>(-1, 0, 0),
- Point<3>( 1, 0, 0),
- Point<3>( 0,-1, 0),
- Point<3>( 0, 1, 0),
- Point<3>( 0, 0,-1),
- Point<3>( 0, 0, 1)
- };
-}
-
+ // Corner points of the cube [-1,1]^3
+ const Point<3> hexahedron[8] =
+ {
+ Point<3>(-1,-1,-1),
+ Point<3>(+1,-1,-1),
+ Point<3>(-1,+1,-1),
+ Point<3>(+1,+1,-1),
+ Point<3>(-1,-1,+1),
+ Point<3>(+1,-1,+1),
+ Point<3>(-1,+1,+1),
+ Point<3>(+1,+1,+1)
+ };
-template <int dim, int spacedim>
-void
-GridGenerator::hyper_rectangle (Triangulation<dim,spacedim> &tria,
- const Point<spacedim> &p_1,
- const Point<spacedim> &p_2,
- const bool colorize)
-{
- // First, normalize input such that
- // p1 is lower in all coordinate directions.
- Point<spacedim> p1(p_1);
- Point<spacedim> p2(p_2);
+ // Octahedron inscribed in the cube
+ // [-1,1]^3
+ const Point<3> octahedron[6] =
+ {
+ Point<3>(-1, 0, 0),
+ Point<3>( 1, 0, 0),
+ Point<3>( 0,-1, 0),
+ Point<3>( 0, 1, 0),
+ Point<3>( 0, 0,-1),
+ Point<3>( 0, 0, 1)
+ };
- for (unsigned int i=0; i<spacedim; ++i)
- if (p1(i) > p2(i))
- std::swap (p1(i), p2(i));
- std::vector<Point<spacedim> > vertices (GeometryInfo<dim>::vertices_per_cell);
- switch (dim)
+ /**
+ * Perform the action specified by the @p colorize flag of the
+ * hyper_rectangle() function of this class.
+ */
+ template <int dim, int spacedim>
+ void
+ colorize_hyper_rectangle (Triangulation<dim,spacedim> &tria)
{
- case 1:
- vertices[0] = p1;
- vertices[1] = p2;
- break;
- case 2:
- vertices[0] = vertices[1] = p1;
- vertices[2] = vertices[3] = p2;
-
- vertices[1](0) = p2(0);
- vertices[2](0) = p1(0);
- break;
- case 3:
- vertices[0] = vertices[1] = vertices[2] = vertices[3] = p1;
- vertices[4] = vertices[5] = vertices[6] = vertices[7] = p2;
+ // there is nothing to do in 1d
+ if (dim > 1)
+ {
+ // there is only one cell, so
+ // simple task
+ const typename Triangulation<dim,spacedim>::cell_iterator
+ cell = tria.begin();
+ for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
+ cell->face(f)->set_boundary_indicator (f);
+ }
+ }
- vertices[1](0) = p2(0);
- vertices[2](1) = p2(1);
- vertices[3](0) = p2(0);
- vertices[3](1) = p2(1);
- vertices[4](0) = p1(0);
- vertices[4](1) = p1(1);
- vertices[5](1) = p1(1);
- vertices[6](0) = p1(0);
- break;
- default:
- Assert (false, ExcNotImplemented ());
+ void
+ colorize_subdivided_hyper_rectangle (Triangulation<1> &tria,
+ const Point<1> &,
+ const Point<1> &,
+ const double)
+ {
+ for (Triangulation<1>::cell_iterator cell = tria.begin();
+ cell != tria.end(); ++cell)
+ if (cell->center()(0) > 0)
+ cell->set_material_id(1);
+ // boundary indicators are set to
+ // 0 (left) and 1 (right) by default.
}
- // Prepare cell data
- std::vector<CellData<dim> > cells (1);
- for (unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
- cells[0].vertices[i] = i;
- cells[0].material_id = 0;
- tria.create_triangulation (vertices, cells, SubCellData());
- // Assign boundary indicators
- if (colorize)
- colorize_hyper_rectangle (tria);
-}
+ template <int dim>
+ void
+ colorize_subdivided_hyper_rectangle (Triangulation<dim> &tria,
+ const Point<dim> &p1,
+ const Point<dim> &p2,
+ const double epsilon)
+ {
+ // run through all faces and check
+ // if one of their center coordinates matches
+ // one of the corner points. Comparisons
+ // are made using an epsilon which
+ // should be smaller than the smallest cell
+ // diameter.
+ typename Triangulation<dim>::face_iterator face = tria.begin_face(),
+ endface = tria.end_face();
+ for (; face!=endface; ++face)
+ {
+ if (face->boundary_indicator() == 0)
+ {
+ const Point<dim> center (face->center());
+ if (std::abs(center(0)-p1[0]) < epsilon)
+ face->set_boundary_indicator(0);
+ else if (std::abs(center(0) - p2[0]) < epsilon)
+ face->set_boundary_indicator(1);
+ else if (dim > 1 && std::abs(center(1) - p1[1]) < epsilon)
+ face->set_boundary_indicator(2);
+ else if (dim > 1 && std::abs(center(1) - p2[1]) < epsilon)
+ face->set_boundary_indicator(3);
+ else if (dim > 2 && std::abs(center(2) - p1[2]) < epsilon)
+ face->set_boundary_indicator(4);
+ else if (dim > 2 && std::abs(center(2) - p2[2]) < epsilon)
+ face->set_boundary_indicator(5);
+ else
+ // triangulation says it
+ // is on the boundary,
+ // but we could not find
+ // on which boundary.
+ Assert (false, ExcInternalError());
-template <int dim, int spacedim>
-void
-GridGenerator::colorize_hyper_rectangle (Triangulation<dim,spacedim> &tria)
-{
- // there is nothing to do in 1d
- if (dim > 1)
- {
- // there is only one cell, so
- // simple task
- const typename Triangulation<dim,spacedim>::cell_iterator
- cell = tria.begin();
- for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
- cell->face(f)->set_boundary_indicator (f);
+ }
+ }
+ for (typename Triangulation<dim>::cell_iterator cell = tria.begin();
+ cell != tria.end(); ++cell)
+ {
+ char id = 0;
+ for (unsigned int d=0; d<dim; ++d)
+ if (cell->center()(d) > 0) id += 1 << d;
+ cell->set_material_id(id);
+ }
}
-}
-
-template <int dim, int spacedim>
-void GridGenerator::hyper_cube (Triangulation<dim,spacedim> &tria,
- const double left,
- const double right)
-{
- Assert (left < right,
- ExcMessage ("Invalid left-to-right bounds of hypercube"));
-
- Point<spacedim> p1;
- Point<spacedim> p2;
+ /**
+ * Assign boundary number zero to the inner shell boundary and 1 to the
+ * outer.
+ */
+ void colorize_hyper_shell (Triangulation<1> &,
+ const Point<1> &,
+ const double,
+ const double)
+ {
+ Assert (false, ExcNotImplemented());
+ }
- p1(spacedim-1) = 0;
- p2(spacedim-1) = 0;
- for (unsigned int i=0; i<dim; ++i)
+ /**
+ * Assign boundary number zero to the inner shell boundary and 1 to the
+ * outer.
+ */
+ void
+ colorize_hyper_shell (Triangulation<2> &tria,
+ const Point<2> &,
+ const double,
+ const double)
{
- p1(i) = left;
- p2(i) = right;
+ // In spite of receiving geometrical
+ // data, we do this only based on
+ // topology.
+
+ // For the mesh based on cube,
+ // this is highly irregular
+ for (Triangulation<2>::cell_iterator cell = tria.begin ();
+ cell != tria.end (); ++cell)
+ {
+ Assert(cell->face(2)->at_boundary(), ExcInternalError());
+ cell->face (2)->set_boundary_indicator (1);
+ }
}
- hyper_rectangle (tria, p1, p2);
-}
+ /**
+ * Assign boundary number zero to the inner shell boundary and 1 to the
+ * outer.
+ */
+ void
+ colorize_hyper_shell (Triangulation<3> &tria,
+ const Point<3> &,
+ const double,
+ const double)
+ {
+ // the following uses a good amount
+ // of knowledge about the
+ // orientation of cells. this is
+ // probably not good style...
+ if (tria.n_cells() == 6)
+ {
+ Triangulation<3>::cell_iterator cell = tria.begin();
-void
-GridGenerator::moebius (
- Triangulation<3> &tria,
- const size_type n_cells,
- const unsigned int n_rotations,
- const double R,
- const double r)
-{
- const unsigned int dim=3;
- Assert (n_cells>4, ExcMessage("More than 4 cells are needed to create a moebius grid."));
- Assert (r>0 && R>0, ExcMessage("Outer and inner radius must be positive."));
- Assert (R>r, ExcMessage("Outer radius must be greater than inner radius."));
+ cell->face(4)->set_boundary_indicator(1);
+ Assert (cell->face(4)->at_boundary(), ExcInternalError());
+ (++cell)->face(2)->set_boundary_indicator(1);
+ Assert (cell->face(2)->at_boundary(), ExcInternalError());
- std::vector<Point<dim> > vertices (4*n_cells);
- double beta_step=n_rotations*numbers::PI/2.0/n_cells;
- double alpha_step=2.0*numbers::PI/n_cells;
+ (++cell)->face(2)->set_boundary_indicator(1);
+ Assert (cell->face(2)->at_boundary(), ExcInternalError());
- for (size_type i=0; i<n_cells; ++i)
- for (unsigned int j=0; j<4; ++j)
- {
- vertices[4*i+j][0]=R*std::cos(i*alpha_step)+r*std::cos(i*beta_step+j*numbers::PI/2.0)*std::cos(i*alpha_step);
- vertices[4*i+j][1]=R*std::sin(i*alpha_step)+r*std::cos(i*beta_step+j*numbers::PI/2.0)*std::sin(i*alpha_step);
- vertices[4*i+j][2]=r*std::sin(i*beta_step+j*numbers::PI/2.0);
- }
+ (++cell)->face(0)->set_boundary_indicator(1);
+ Assert (cell->face(0)->at_boundary(), ExcInternalError());
- size_type offset=0;
+ (++cell)->face(2)->set_boundary_indicator(1);
+ Assert (cell->face(2)->at_boundary(), ExcInternalError());
- std::vector<CellData<dim> > cells (n_cells);
- for (size_type i=0; i<n_cells; ++i)
- {
- for (unsigned int j=0; j<2; ++j)
+ (++cell)->face(0)->set_boundary_indicator(1);
+ Assert (cell->face(0)->at_boundary(), ExcInternalError());
+ }
+ else if (tria.n_cells() == 12)
+ {
+ // again use some internal
+ // knowledge
+ for (Triangulation<3>::cell_iterator cell = tria.begin();
+ cell != tria.end(); ++cell)
+ {
+ Assert (cell->face(5)->at_boundary(), ExcInternalError());
+ cell->face(5)->set_boundary_indicator(1);
+ }
+ }
+ else if (tria.n_cells() == 96)
{
- cells[i].vertices[0+4*j]=offset+0+4*j;
- cells[i].vertices[1+4*j]=offset+3+4*j;
- cells[i].vertices[2+4*j]=offset+2+4*j;
- cells[i].vertices[3+4*j]=offset+1+4*j;
+ // the 96-cell hypershell is
+ // based on a once refined
+ // 12-cell mesh. consequently,
+ // since the outer faces all
+ // are face_no==5 above, so
+ // they are here (unless they
+ // are in the interior). Use
+ // this to assign boundary
+ // indicators, but also make
+ // sure that we encounter
+ // exactly 48 such faces
+ unsigned int count = 0;
+ for (Triangulation<3>::cell_iterator cell = tria.begin();
+ cell != tria.end(); ++cell)
+ if (cell->face(5)->at_boundary())
+ {
+ cell->face(5)->set_boundary_indicator(1);
+ ++count;
+ }
+ Assert (count == 48, ExcInternalError());
}
- offset+=4;
- cells[i].material_id=0;
+ else
+ Assert (false, ExcNotImplemented());
}
- // now correct the last four vertices
- cells[n_cells-1].vertices[4]=(0+n_rotations)%4;
- cells[n_cells-1].vertices[5]=(3+n_rotations)%4;
- cells[n_cells-1].vertices[6]=(2+n_rotations)%4;
- cells[n_cells-1].vertices[7]=(1+n_rotations)%4;
- GridReordering<dim>::invert_all_cells_of_negative_grid(vertices,cells);
- tria.create_triangulation_compatibility (vertices, cells, SubCellData());
-}
+ /**
+ * Assign boundary number zero the inner shell boundary, one to the outer
+ * shell boundary, two to the face with x=0, three to the face with y=0,
+ * four to the face with z=0.
+ */
+ void
+ colorize_quarter_hyper_shell(Triangulation<3> &tria,
+ const Point<3> ¢er,
+ const double inner_radius,
+ const double outer_radius)
+ {
+ if (tria.n_cells() != 3)
+ AssertThrow (false, ExcNotImplemented());
+ double middle = (outer_radius-inner_radius)/2e0 + inner_radius;
+ double eps = 1e-3*middle;
+ Triangulation<3>::cell_iterator cell = tria.begin();
-void
-GridGenerator::torus (Triangulation<2,3> &tria,
- const double R,
- const double r)
-{
- Assert (R>r, ExcMessage("Outer radius must be greater than inner radius."));
-
- const unsigned int dim=2;
- const unsigned int spacedim=3;
- std::vector<Point<spacedim> > vertices (16);
-
- vertices[0]=Point<spacedim>(R-r,0,0);
- vertices[1]=Point<spacedim>(R,-r,0);
- vertices[2]=Point<spacedim>(R+r,0,0);
- vertices[3]=Point<spacedim>(R, r,0);
- vertices[4]=Point<spacedim>(0,0,R-r);
- vertices[5]=Point<spacedim>(0,-r,R);
- vertices[6]=Point<spacedim>(0,0,R+r);
- vertices[7]=Point<spacedim>(0,r,R);
- vertices[8]=Point<spacedim>(-(R-r),0,0);
- vertices[9]=Point<spacedim>(-R,-r,0);
- vertices[10]=Point<spacedim>(-(R+r),0,0);
- vertices[11]=Point<spacedim>(-R, r,0);
- vertices[12]=Point<spacedim>(0,0,-(R-r));
- vertices[13]=Point<spacedim>(0,-r,-R);
- vertices[14]=Point<spacedim>(0,0,-(R+r));
- vertices[15]=Point<spacedim>(0,r,-R);
-
- std::vector<CellData<dim> > cells (16);
- //Right Hand Orientation
- cells[0].vertices[0] = 0;
- cells[0].vertices[1] = 4;
- cells[0].vertices[2] = 7;
- cells[0].vertices[3] = 3;
- cells[0].material_id = 0;
-
- cells[1].vertices[0] = 1;
- cells[1].vertices[1] = 5;
- cells[1].vertices[2] = 4;
- cells[1].vertices[3] = 0;
- cells[1].material_id = 0;
-
- cells[2].vertices[0] = 2;
- cells[2].vertices[1] = 6;
- cells[2].vertices[2] = 5;
- cells[2].vertices[3] = 1;
- cells[2].material_id = 0;
-
- cells[3].vertices[0] = 3;
- cells[3].vertices[1] = 7;
- cells[3].vertices[2] = 6;
- cells[3].vertices[3] = 2;
- cells[3].material_id = 0;
-
- cells[4].vertices[0] = 4;
- cells[4].vertices[1] = 8;
- cells[4].vertices[2] = 11;
- cells[4].vertices[3] = 7;
- cells[4].material_id = 0;
-
- cells[5].vertices[0] = 5;
- cells[5].vertices[1] = 9;
- cells[5].vertices[2] = 8;
- cells[5].vertices[3] = 4;
- cells[5].material_id = 0;
-
- cells[6].vertices[0] = 6;
- cells[6].vertices[1] = 10;
- cells[6].vertices[2] = 9;
- cells[6].vertices[3] = 5;
- cells[6].material_id = 0;
-
- cells[7].vertices[0] = 7;
- cells[7].vertices[1] = 11;
- cells[7].vertices[2] = 10;
- cells[7].vertices[3] = 6;
- cells[7].material_id = 0;
-
- cells[8].vertices[0] = 8;
- cells[8].vertices[1] = 12;
- cells[8].vertices[2] = 15;
- cells[8].vertices[3] = 11;
- cells[8].material_id = 0;
-
- cells[9].vertices[0] = 9;
- cells[9].vertices[1] = 13;
- cells[9].vertices[2] = 12;
- cells[9].vertices[3] = 8;
- cells[9].material_id = 0;
-
- cells[10].vertices[0] = 10;
- cells[10].vertices[1] = 14;
- cells[10].vertices[2] = 13;
- cells[10].vertices[3] = 9;
- cells[10].material_id = 0;
-
- cells[11].vertices[0] = 11;
- cells[11].vertices[1] = 15;
- cells[11].vertices[2] = 14;
- cells[11].vertices[3] = 10;
- cells[11].material_id = 0;
-
- cells[12].vertices[0] = 12;
- cells[12].vertices[1] = 0;
- cells[12].vertices[2] = 3;
- cells[12].vertices[3] = 15;
- cells[12].material_id = 0;
-
- cells[13].vertices[0] = 13;
- cells[13].vertices[1] = 1;
- cells[13].vertices[2] = 0;
- cells[13].vertices[3] = 12;
- cells[13].material_id = 0;
-
- cells[14].vertices[0] = 14;
- cells[14].vertices[1] = 2;
- cells[14].vertices[2] = 1;
- cells[14].vertices[3] = 13;
- cells[14].material_id = 0;
-
- cells[15].vertices[0] = 15;
- cells[15].vertices[1] = 3;
- cells[15].vertices[2] = 2;
- cells[15].vertices[3] = 14;
- cells[15].material_id = 0;
-
- // Must call this to be able to create a
- // correct triangulation in dealii, read
- // GridReordering<> doc
- GridReordering<dim,spacedim>::reorder_cells (cells);
- tria.create_triangulation_compatibility (vertices, cells, SubCellData());
-}
+ for (; cell!=tria.end(); ++cell)
+ for (unsigned int f=0; f<GeometryInfo<3>::faces_per_cell; ++f)
+ {
+ if (!cell->face(f)->at_boundary())
+ continue;
+ double radius = cell->face(f)->center().norm() - center.norm();
+ if (std::fabs(cell->face(f)->center()(0)) < eps ) // x = 0 set boundary 2
+ {
+ cell->face(f)->set_boundary_indicator(2);
+ for (unsigned int j=0; j<GeometryInfo<3>::lines_per_face; ++j)
+ if (cell->face(f)->line(j)->at_boundary())
+ if (std::fabs(cell->face(f)->line(j)->vertex(0).norm() - cell->face(f)->line(j)->vertex(1).norm()) > eps)
+ cell->face(f)->line(j)->set_boundary_indicator(2);
+ }
+ else if (std::fabs(cell->face(f)->center()(1)) < eps) // y = 0 set boundary 3
+ {
+ cell->face(f)->set_boundary_indicator(3);
+ for (unsigned int j=0; j<GeometryInfo<3>::lines_per_face; ++j)
+ if (cell->face(f)->line(j)->at_boundary())
+ if (std::fabs(cell->face(f)->line(j)->vertex(0).norm() - cell->face(f)->line(j)->vertex(1).norm()) > eps)
+ cell->face(f)->line(j)->set_boundary_indicator(3);
+ }
+ else if (std::fabs(cell->face(f)->center()(2)) < eps ) // z = 0 set boundary 4
+ {
+ cell->face(f)->set_boundary_indicator(4);
+ for (unsigned int j=0; j<GeometryInfo<3>::lines_per_face; ++j)
+ if (cell->face(f)->line(j)->at_boundary())
+ if (std::fabs(cell->face(f)->line(j)->vertex(0).norm() - cell->face(f)->line(j)->vertex(1).norm()) > eps)
+ cell->face(f)->line(j)->set_boundary_indicator(4);
+ }
+ else if (radius < middle) // inner radius set boundary 0
+ {
+ cell->face(f)->set_boundary_indicator(0);
+ for (unsigned int j=0; j<GeometryInfo<3>::lines_per_face; ++j)
+ if (cell->face(f)->line(j)->at_boundary())
+ if (std::fabs(cell->face(f)->line(j)->vertex(0).norm() - cell->face(f)->line(j)->vertex(1).norm()) < eps)
+ cell->face(f)->line(j)->set_boundary_indicator(0);
+ }
+ else if (radius > middle) // outer radius set boundary 1
+ {
+ cell->face(f)->set_boundary_indicator(1);
+ for (unsigned int j=0; j<GeometryInfo<3>::lines_per_face; ++j)
+ if (cell->face(f)->line(j)->at_boundary())
+ if (std::fabs(cell->face(f)->line(j)->vertex(0).norm() - cell->face(f)->line(j)->vertex(1).norm()) < eps)
+ cell->face(f)->line(j)->set_boundary_indicator(1);
+ }
+ else
+ AssertThrow (false, ExcInternalError());
+ }
+ }
-// Implementation for 2D only
-template<>
-void
-GridGenerator::parallelogram (Triangulation<2> &tria,
- const Point<2> (&corners)[2],
- const bool colorize)
-{
- std::vector<Point<2> > vertices (GeometryInfo<2>::vertices_per_cell);
-
- vertices[1] = corners[0];
- vertices[2] = corners[1];
- vertices[3] = vertices[1] + vertices[2];
- // Prepare cell data
- std::vector<CellData<2> > cells (1);
- for (unsigned int i=0; i<GeometryInfo<2>::vertices_per_cell; ++i)
- cells[0].vertices[i] = i;
- cells[0].material_id = 0;
-
- tria.create_triangulation (vertices, cells, SubCellData());
-
- // Assign boundary indicators
- if (colorize)
- colorize_hyper_rectangle (tria);
-}
+ }
-template<>
-void
-GridGenerator::parallelogram (Triangulation<2> &tria,
- const Tensor<2,2> &corners,
- const bool colorize)
-{
- // simply pass everything to the other function of same name
- const Point<2> x[2] = { corners[0], corners[1] };
- parallelogram (tria, x, colorize);
-}
+ template <int dim, int spacedim>
+ void
+ hyper_rectangle (Triangulation<dim,spacedim> &tria,
+ const Point<spacedim> &p_1,
+ const Point<spacedim> &p_2,
+ const bool colorize)
+ {
+ // First, normalize input such that
+ // p1 is lower in all coordinate directions.
+ Point<spacedim> p1(p_1);
+ Point<spacedim> p2(p_2);
+ for (unsigned int i=0; i<spacedim; ++i)
+ if (p1(i) > p2(i))
+ std::swap (p1(i), p2(i));
+ std::vector<Point<spacedim> > vertices (GeometryInfo<dim>::vertices_per_cell);
+ switch (dim)
+ {
+ case 1:
+ vertices[0] = p1;
+ vertices[1] = p2;
+ break;
+ case 2:
+ vertices[0] = vertices[1] = p1;
+ vertices[2] = vertices[3] = p2;
+
+ vertices[1](0) = p2(0);
+ vertices[2](0) = p1(0);
+ break;
+ case 3:
+ vertices[0] = vertices[1] = vertices[2] = vertices[3] = p1;
+ vertices[4] = vertices[5] = vertices[6] = vertices[7] = p2;
+
+ vertices[1](0) = p2(0);
+ vertices[2](1) = p2(1);
+ vertices[3](0) = p2(0);
+ vertices[3](1) = p2(1);
+
+ vertices[4](0) = p1(0);
+ vertices[4](1) = p1(1);
+ vertices[5](1) = p1(1);
+ vertices[6](0) = p1(0);
+
+ break;
+ default:
+ Assert (false, ExcNotImplemented ());
+ }
-// Parallelepiped implementation in 1d, 2d, and 3d. @note The
-// implementation in 1d is similar to hyper_rectangle(), and in 2d is
-// similar to parallelogram().
-//
-// The GridReordering::reorder_grid is made use of towards the end of
-// this function. Thus the triangulation is explicitly constructed for
-// all dim here since it is slightly different in that respect
-// (cf. hyper_rectangle(), parallelogram()).
-template<int dim>
-void
-GridGenerator::parallelepiped (Triangulation<dim> &tria,
- const Point<dim> (&corners) [dim],
- const bool colorize)
-{
- // Check that none of the user defined vertices overlap
- for (unsigned int i=0; i<dim; ++i)
- for (unsigned int j=i+1; j<dim; ++j)
- Assert ((corners[i]!=corners[j]),
- ExcMessage ("Invalid distance between corner points of parallelepiped."));
+ // Prepare cell data
+ std::vector<CellData<dim> > cells (1);
+ for (unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
+ cells[0].vertices[i] = i;
+ cells[0].material_id = 0;
- // Note: vertex[0] is the origin and is initialised as so here:
- std::vector<Point<dim> > vertices (GeometryInfo<dim>::vertices_per_cell);
+ tria.create_triangulation (vertices, cells, SubCellData());
- switch (dim)
- {
- // A line (1d parallelepiped)
- case 1:
- vertices[1] = corners[0];
- break;
+ // Assign boundary indicators
+ if (colorize)
+ colorize_hyper_rectangle (tria);
+ }
- // A parallelogram (2d parallelepiped)
- case 2:
- // assign corners to vertices:
- vertices[1] = corners[0];
- vertices[2] = corners[1];
- // compose the remaining vertex:
- vertices[3] = vertices[1] + vertices[2];
- break;
+ template <int dim, int spacedim>
+ void hyper_cube (Triangulation<dim,spacedim> &tria,
+ const double left,
+ const double right)
+ {
+ Assert (left < right,
+ ExcMessage ("Invalid left-to-right bounds of hypercube"));
- // A parallelepiped (3d parallelepiped)
- case 3:
- // assign corners to vertices:
- vertices[1] = corners[0];
- vertices[2] = corners[1];
- vertices[4] = corners[2];
-
- // compose the remaining vertices:
- vertices[3] = vertices[1] + vertices[2];
- vertices[5] = vertices[1] + vertices[4];
- vertices[6] = vertices[2] + vertices[4];
- vertices[7] = vertices[1] + vertices[2] + vertices[4];
- break;
+ Point<spacedim> p1;
+ Point<spacedim> p2;
- default:
- Assert (false, ExcNotImplemented());
- }
+ p1(spacedim-1) = 0;
+ p2(spacedim-1) = 0;
- // Prepare cell data and wipe material identity
- std::vector<CellData<dim> > cells (1);
- for (unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
- cells[0].vertices[i] = i;
- cells[0].material_id = 0;
+ for (unsigned int i=0; i<dim; ++i)
+ {
+ p1(i) = left;
+ p2(i) = right;
+ }
+ hyper_rectangle (tria, p1, p2);
+ }
- // Check ordering of vertices and create triangulation
- GridReordering<dim>::reorder_cells (cells);
- tria.create_triangulation (vertices, cells, SubCellData());
- // Finally assign boundary indicators according to hyper_rectangle
- if (colorize)
- colorize_hyper_rectangle (tria);
-}
-template<int dim>
-void
-GridGenerator::subdivided_parallelepiped (Triangulation<dim> &tria,
- const size_type n_subdivisions,
- const Point<dim> (&corners) [dim],
- const bool colorize)
-{
- // Equalise number of subdivisions in each dim-direction, heir
- // validity will be checked later
- size_type (n_subdivisions_) [dim];
- for (unsigned int i=0; i<dim; ++i)
- n_subdivisions_[i] = n_subdivisions;
-
- // and call the function below
- GridGenerator::subdivided_parallelepiped (tria, n_subdivisions_,
- corners,
- colorize);
-}
+ void
+ moebius (Triangulation<3> &tria,
+ const unsigned int n_cells,
+ const unsigned int n_rotations,
+ const double R,
+ const double r)
+ {
+ const unsigned int dim=3;
+ Assert (n_cells>4, ExcMessage("More than 4 cells are needed to create a moebius grid."));
+ Assert (r>0 && R>0, ExcMessage("Outer and inner radius must be positive."));
+ Assert (R>r, ExcMessage("Outer radius must be greater than inner radius."));
-template<int dim>
-void
-GridGenerator::subdivided_parallelepiped (Triangulation<dim> &tria,
- const size_type ( n_subdivisions) [dim],
- const Point<dim> (&corners) [dim],
- const bool colorize)
-{
- // Zero n_subdivisions is the origin only, which makes no sense
- for (unsigned int i=0; i<dim; ++i)
- Assert (n_subdivisions[i]>0, ExcInvalidRepetitions(n_subdivisions[i]));
- // Check corners do not overlap (unique)
- for (unsigned int i=0; i<dim; ++i)
- for (unsigned int j=i+1; j<dim; ++j)
- Assert ((corners[i]!=corners[j]),
- ExcMessage ("Invalid distance between corner points of parallelepiped."));
+ std::vector<Point<dim> > vertices (4*n_cells);
+ double beta_step=n_rotations*numbers::PI/2.0/n_cells;
+ double alpha_step=2.0*numbers::PI/n_cells;
- // Create a list of points
- Point<dim> (delta) [dim];
+ for (unsigned int i=0; i<n_cells; ++i)
+ for (unsigned int j=0; j<4; ++j)
+ {
+ vertices[4*i+j][0]=R*std::cos(i*alpha_step)+r*std::cos(i*beta_step+j*numbers::PI/2.0)*std::cos(i*alpha_step);
+ vertices[4*i+j][1]=R*std::sin(i*alpha_step)+r*std::cos(i*beta_step+j*numbers::PI/2.0)*std::sin(i*alpha_step);
+ vertices[4*i+j][2]=r*std::sin(i*beta_step+j*numbers::PI/2.0);
+ }
- for (unsigned int i=0; i<dim; ++i)
- delta[i] = corners[i]/n_subdivisions[i];
- std::vector<Point<dim> > points;
+ unsigned int offset=0;
- switch (dim)
- {
- case 1:
- for (size_type x=0; x<=n_subdivisions[0]; ++x)
- points.push_back (Point<dim> (x*delta[0]));
- break;
+ std::vector<CellData<dim> > cells (n_cells);
+ for (unsigned int i=0; i<n_cells; ++i)
+ {
+ for (unsigned int j=0; j<2; ++j)
+ {
+ cells[i].vertices[0+4*j]=offset+0+4*j;
+ cells[i].vertices[1+4*j]=offset+3+4*j;
+ cells[i].vertices[2+4*j]=offset+2+4*j;
+ cells[i].vertices[3+4*j]=offset+1+4*j;
+ }
+ offset+=4;
+ cells[i].material_id=0;
+ }
- case 2:
- for (size_type y=0; y<=n_subdivisions[1]; ++y)
- for (size_type x=0; x<=n_subdivisions[0]; ++x)
- points.push_back (Point<dim> (x*delta[0] + y*delta[1]));
- break;
+ // now correct the last four vertices
+ cells[n_cells-1].vertices[4]=(0+n_rotations)%4;
+ cells[n_cells-1].vertices[5]=(3+n_rotations)%4;
+ cells[n_cells-1].vertices[6]=(2+n_rotations)%4;
+ cells[n_cells-1].vertices[7]=(1+n_rotations)%4;
- case 3:
- for (size_type z=0; z<=n_subdivisions[2]; ++z)
- for (size_type y=0; y<=n_subdivisions[1]; ++y)
- for (size_type x=0; x<=n_subdivisions[0]; ++x)
- points.push_back (Point<dim> (x*delta[0] + y*delta[1] + z*delta[2]));
- break;
+ GridReordering<dim>::invert_all_cells_of_negative_grid(vertices,cells);
+ tria.create_triangulation_compatibility (vertices, cells, SubCellData());
+ }
- default:
- Assert (false, ExcNotImplemented());
- }
- // Prepare cell data
- size_type n_cells = 1;
- for (unsigned int i=0; i<dim; ++i)
- n_cells *= n_subdivisions[i];
- std::vector<CellData<dim> > cells (n_cells);
- // Create fixed ordering of
- switch (dim)
- {
- case 1:
- for (size_type x=0; x<n_subdivisions[0]; ++x)
- {
- cells[x].vertices[0] = x;
- cells[x].vertices[1] = x+1;
+ void
+ torus (Triangulation<2,3> &tria,
+ const double R,
+ const double r)
+ {
+ Assert (R>r, ExcMessage("Outer radius must be greater than inner radius."));
+
+ const unsigned int dim=2;
+ const unsigned int spacedim=3;
+ std::vector<Point<spacedim> > vertices (16);
+
+ vertices[0]=Point<spacedim>(R-r,0,0);
+ vertices[1]=Point<spacedim>(R,-r,0);
+ vertices[2]=Point<spacedim>(R+r,0,0);
+ vertices[3]=Point<spacedim>(R, r,0);
+ vertices[4]=Point<spacedim>(0,0,R-r);
+ vertices[5]=Point<spacedim>(0,-r,R);
+ vertices[6]=Point<spacedim>(0,0,R+r);
+ vertices[7]=Point<spacedim>(0,r,R);
+ vertices[8]=Point<spacedim>(-(R-r),0,0);
+ vertices[9]=Point<spacedim>(-R,-r,0);
+ vertices[10]=Point<spacedim>(-(R+r),0,0);
+ vertices[11]=Point<spacedim>(-R, r,0);
+ vertices[12]=Point<spacedim>(0,0,-(R-r));
+ vertices[13]=Point<spacedim>(0,-r,-R);
+ vertices[14]=Point<spacedim>(0,0,-(R+r));
+ vertices[15]=Point<spacedim>(0,r,-R);
+
+ std::vector<CellData<dim> > cells (16);
+ //Right Hand Orientation
+ cells[0].vertices[0] = 0;
+ cells[0].vertices[1] = 4;
+ cells[0].vertices[2] = 7;
+ cells[0].vertices[3] = 3;
+ cells[0].material_id = 0;
+
+ cells[1].vertices[0] = 1;
+ cells[1].vertices[1] = 5;
+ cells[1].vertices[2] = 4;
+ cells[1].vertices[3] = 0;
+ cells[1].material_id = 0;
+
+ cells[2].vertices[0] = 2;
+ cells[2].vertices[1] = 6;
+ cells[2].vertices[2] = 5;
+ cells[2].vertices[3] = 1;
+ cells[2].material_id = 0;
+
+ cells[3].vertices[0] = 3;
+ cells[3].vertices[1] = 7;
+ cells[3].vertices[2] = 6;
+ cells[3].vertices[3] = 2;
+ cells[3].material_id = 0;
+
+ cells[4].vertices[0] = 4;
+ cells[4].vertices[1] = 8;
+ cells[4].vertices[2] = 11;
+ cells[4].vertices[3] = 7;
+ cells[4].material_id = 0;
+
+ cells[5].vertices[0] = 5;
+ cells[5].vertices[1] = 9;
+ cells[5].vertices[2] = 8;
+ cells[5].vertices[3] = 4;
+ cells[5].material_id = 0;
+
+ cells[6].vertices[0] = 6;
+ cells[6].vertices[1] = 10;
+ cells[6].vertices[2] = 9;
+ cells[6].vertices[3] = 5;
+ cells[6].material_id = 0;
+
+ cells[7].vertices[0] = 7;
+ cells[7].vertices[1] = 11;
+ cells[7].vertices[2] = 10;
+ cells[7].vertices[3] = 6;
+ cells[7].material_id = 0;
+
+ cells[8].vertices[0] = 8;
+ cells[8].vertices[1] = 12;
+ cells[8].vertices[2] = 15;
+ cells[8].vertices[3] = 11;
+ cells[8].material_id = 0;
+
+ cells[9].vertices[0] = 9;
+ cells[9].vertices[1] = 13;
+ cells[9].vertices[2] = 12;
+ cells[9].vertices[3] = 8;
+ cells[9].material_id = 0;
+
+ cells[10].vertices[0] = 10;
+ cells[10].vertices[1] = 14;
+ cells[10].vertices[2] = 13;
+ cells[10].vertices[3] = 9;
+ cells[10].material_id = 0;
+
+ cells[11].vertices[0] = 11;
+ cells[11].vertices[1] = 15;
+ cells[11].vertices[2] = 14;
+ cells[11].vertices[3] = 10;
+ cells[11].material_id = 0;
+
+ cells[12].vertices[0] = 12;
+ cells[12].vertices[1] = 0;
+ cells[12].vertices[2] = 3;
+ cells[12].vertices[3] = 15;
+ cells[12].material_id = 0;
+
+ cells[13].vertices[0] = 13;
+ cells[13].vertices[1] = 1;
+ cells[13].vertices[2] = 0;
+ cells[13].vertices[3] = 12;
+ cells[13].material_id = 0;
+
+ cells[14].vertices[0] = 14;
+ cells[14].vertices[1] = 2;
+ cells[14].vertices[2] = 1;
+ cells[14].vertices[3] = 13;
+ cells[14].material_id = 0;
+
+ cells[15].vertices[0] = 15;
+ cells[15].vertices[1] = 3;
+ cells[15].vertices[2] = 2;
+ cells[15].vertices[3] = 14;
+ cells[15].material_id = 0;
+
+ // Must call this to be able to create a
+ // correct triangulation in dealii, read
+ // GridReordering<> doc
+ GridReordering<dim,spacedim>::reorder_cells (cells);
+ tria.create_triangulation_compatibility (vertices, cells, SubCellData());
+ }
- // wipe material id
- cells[x].material_id = 0;
- }
- break;
- case 2:
- {
- // Shorthand
- const size_type n_dy = n_subdivisions[1];
- const size_type n_dx = n_subdivisions[0];
+// Implementation for 2D only
+ template<>
+ void
+ parallelogram (Triangulation<2> &tria,
+ const Point<2> (&corners)[2],
+ const bool colorize)
+ {
+ std::vector<Point<2> > vertices (GeometryInfo<2>::vertices_per_cell);
+
+ vertices[1] = corners[0];
+ vertices[2] = corners[1];
+ vertices[3] = vertices[1] + vertices[2];
+ // Prepare cell data
+ std::vector<CellData<2> > cells (1);
+ for (unsigned int i=0; i<GeometryInfo<2>::vertices_per_cell; ++i)
+ cells[0].vertices[i] = i;
+ cells[0].material_id = 0;
+
+ tria.create_triangulation (vertices, cells, SubCellData());
+
+ // Assign boundary indicators
+ if (colorize)
+ colorize_hyper_rectangle (tria);
+ }
+
+
+ template<>
+ void
+ parallelogram (Triangulation<2> &tria,
+ const Tensor<2,2> &corners,
+ const bool colorize)
+ {
+ // simply pass everything to the other function of same name
+ const Point<2> x[2] = { corners[0], corners[1] };
+ parallelogram (tria, x, colorize);
+ }
+
+
+
+// Parallelepiped implementation in 1d, 2d, and 3d. @note The
+// implementation in 1d is similar to hyper_rectangle(), and in 2d is
+// similar to parallelogram().
+//
+// The GridReordering::reorder_grid is made use of towards the end of
+// this function. Thus the triangulation is explicitly constructed for
+// all dim here since it is slightly different in that respect
+// (cf. hyper_rectangle(), parallelogram()).
+ template<int dim>
+ void
+ parallelepiped (Triangulation<dim> &tria,
+ const Point<dim> (&corners) [dim],
+ const bool colorize)
+ {
+ // Check that none of the user defined vertices overlap
+ for (unsigned int i=0; i<dim; ++i)
+ for (unsigned int j=i+1; j<dim; ++j)
+ Assert ((corners[i]!=corners[j]),
+ ExcMessage ("Invalid distance between corner points of parallelepiped."));
+
+ // Note: vertex[0] is the origin and is initialised as so here:
+ std::vector<Point<dim> > vertices (GeometryInfo<dim>::vertices_per_cell);
+
+ switch (dim)
+ {
+ // A line (1d parallelepiped)
+ case 1:
+ vertices[1] = corners[0];
+ break;
+
+ // A parallelogram (2d parallelepiped)
+ case 2:
+ // assign corners to vertices:
+ vertices[1] = corners[0];
+ vertices[2] = corners[1];
+
+ // compose the remaining vertex:
+ vertices[3] = vertices[1] + vertices[2];
+ break;
+
+ // A parallelepiped (3d parallelepiped)
+ case 3:
+ // assign corners to vertices:
+ vertices[1] = corners[0];
+ vertices[2] = corners[1];
+ vertices[4] = corners[2];
+
+ // compose the remaining vertices:
+ vertices[3] = vertices[1] + vertices[2];
+ vertices[5] = vertices[1] + vertices[4];
+ vertices[6] = vertices[2] + vertices[4];
+ vertices[7] = vertices[1] + vertices[2] + vertices[4];
+ break;
+
+ default:
+ Assert (false, ExcNotImplemented());
+ }
+
+ // Prepare cell data and wipe material identity
+ std::vector<CellData<dim> > cells (1);
+ for (unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
+ cells[0].vertices[i] = i;
+ cells[0].material_id = 0;
+
+ // Check ordering of vertices and create triangulation
+ GridReordering<dim>::reorder_cells (cells);
+ tria.create_triangulation (vertices, cells, SubCellData());
+
+ // Finally assign boundary indicators according to hyper_rectangle
+ if (colorize)
+ colorize_hyper_rectangle (tria);
+ }
+
+ template<int dim>
+ void
+ subdivided_parallelepiped (Triangulation<dim> &tria,
+ const unsigned int n_subdivisions,
+ const Point<dim> (&corners) [dim],
+ const bool colorize)
+ {
+ // Equalise number of subdivisions in each dim-direction, heir
+ // validity will be checked later
+ unsigned int (n_subdivisions_) [dim];
+ for (unsigned int i=0; i<dim; ++i)
+ n_subdivisions_[i] = n_subdivisions;
+
+ // and call the function below
+ subdivided_parallelepiped (tria, n_subdivisions_,
+ corners,
+ colorize);
+ }
+
+ template<int dim>
+ void
+ subdivided_parallelepiped (Triangulation<dim> &tria,
+ const unsigned int ( n_subdivisions) [dim],
+ const Point<dim> (&corners) [dim],
+ const bool colorize)
+ {
+ // Zero n_subdivisions is the origin only, which makes no sense
+ for (unsigned int i=0; i<dim; ++i)
+ Assert (n_subdivisions[i]>0, ExcInvalidRepetitions(n_subdivisions[i]));
- for (size_type y=0; y<n_dy; ++y)
- for (size_type x=0; x<n_dx; ++x)
+ // Check corners do not overlap (unique)
+ for (unsigned int i=0; i<dim; ++i)
+ for (unsigned int j=i+1; j<dim; ++j)
+ Assert ((corners[i]!=corners[j]),
+ ExcMessage ("Invalid distance between corner points of parallelepiped."));
+
+ // Create a list of points
+ Point<dim> (delta) [dim];
+
+ for (unsigned int i=0; i<dim; ++i)
+ delta[i] = corners[i]/n_subdivisions[i];
+ std::vector<Point<dim> > points;
+
+ switch (dim)
+ {
+ case 1:
+ for (unsigned int x=0; x<=n_subdivisions[0]; ++x)
+ points.push_back (Point<dim> (x*delta[0]));
+ break;
+
+ case 2:
+ for (unsigned int y=0; y<=n_subdivisions[1]; ++y)
+ for (unsigned int x=0; x<=n_subdivisions[0]; ++x)
+ points.push_back (Point<dim> (x*delta[0] + y*delta[1]));
+ break;
+
+ case 3:
+ for (unsigned int z=0; z<=n_subdivisions[2]; ++z)
+ for (unsigned int y=0; y<=n_subdivisions[1]; ++y)
+ for (unsigned int x=0; x<=n_subdivisions[0]; ++x)
+ points.push_back (Point<dim> (x*delta[0] + y*delta[1] + z*delta[2]));
+ break;
+
+ default:
+ Assert (false, ExcNotImplemented());
+ }
+
+ // Prepare cell data
+ unsigned int n_cells = 1;
+ for (unsigned int i=0; i<dim; ++i)
+ n_cells *= n_subdivisions[i];
+ std::vector<CellData<dim> > cells (n_cells);
+
+ // Create fixed ordering of
+ switch (dim)
+ {
+ case 1:
+ for (unsigned int x=0; x<n_subdivisions[0]; ++x)
{
- const size_type c = y*n_dx + x;
- cells[c].vertices[0] = y*(n_dx+1) + x;
- cells[c].vertices[1] = y*(n_dx+1) + x+1;
- cells[c].vertices[2] = (y+1)*(n_dx+1) + x;
- cells[c].vertices[3] = (y+1)*(n_dx+1) + x+1;
+ cells[x].vertices[0] = x;
+ cells[x].vertices[1] = x+1;
// wipe material id
- cells[c].material_id = 0;
+ cells[x].material_id = 0;
}
- }
- break;
+ break;
- case 3:
- {
- // Shorthand
- const size_type n_dz = n_subdivisions[2];
- const size_type n_dy = n_subdivisions[1];
- const size_type n_dx = n_subdivisions[0];
-
- for (size_type z=0; z<n_dz; ++z)
- for (size_type y=0; y<n_dy; ++y)
- for (size_type x=0; x<n_dx; ++x)
- {
- const size_type c = z*n_dy*n_dx + y*n_dx + x;
+ case 2:
+ {
+ // Shorthand
+ const unsigned int n_dy = n_subdivisions[1];
+ const unsigned int n_dx = n_subdivisions[0];
- cells[c].vertices[0] = z*(n_dy+1)*(n_dx+1) + y*(n_dx+1) + x;
- cells[c].vertices[1] = z*(n_dy+1)*(n_dx+1) + y*(n_dx+1) + x+1;
- cells[c].vertices[2] = z*(n_dy+1)*(n_dx+1) + (y+1)*(n_dx+1) + x;
- cells[c].vertices[3] = z*(n_dy+1)*(n_dx+1) + (y+1)*(n_dx+1) + x+1;
- cells[c].vertices[4] = (z+1)*(n_dy+1)*(n_dx+1) + y*(n_dx+1) + x;
- cells[c].vertices[5] = (z+1)*(n_dy+1)*(n_dx+1) + y*(n_dx+1) + x+1;
- cells[c].vertices[6] = (z+1)*(n_dy+1)*(n_dx+1) + (y+1)*(n_dx+1) + x;
- cells[c].vertices[7] = (z+1)*(n_dy+1)*(n_dx+1) + (y+1)*(n_dx+1) + x+1;
+ for (unsigned int y=0; y<n_dy; ++y)
+ for (unsigned int x=0; x<n_dx; ++x)
+ {
+ const unsigned int c = y*n_dx + x;
+ cells[c].vertices[0] = y*(n_dx+1) + x;
+ cells[c].vertices[1] = y*(n_dx+1) + x+1;
+ cells[c].vertices[2] = (y+1)*(n_dx+1) + x;
+ cells[c].vertices[3] = (y+1)*(n_dx+1) + x+1;
// wipe material id
cells[c].material_id = 0;
}
+ }
break;
- }
- default:
- Assert (false, ExcNotImplemented());
- }
+ case 3:
+ {
+ // Shorthand
+ const unsigned int n_dz = n_subdivisions[2];
+ const unsigned int n_dy = n_subdivisions[1];
+ const unsigned int n_dx = n_subdivisions[0];
+
+ for (unsigned int z=0; z<n_dz; ++z)
+ for (unsigned int y=0; y<n_dy; ++y)
+ for (unsigned int x=0; x<n_dx; ++x)
+ {
+ const unsigned int c = z*n_dy*n_dx + y*n_dx + x;
+
+ cells[c].vertices[0] = z*(n_dy+1)*(n_dx+1) + y*(n_dx+1) + x;
+ cells[c].vertices[1] = z*(n_dy+1)*(n_dx+1) + y*(n_dx+1) + x+1;
+ cells[c].vertices[2] = z*(n_dy+1)*(n_dx+1) + (y+1)*(n_dx+1) + x;
+ cells[c].vertices[3] = z*(n_dy+1)*(n_dx+1) + (y+1)*(n_dx+1) + x+1;
+ cells[c].vertices[4] = (z+1)*(n_dy+1)*(n_dx+1) + y*(n_dx+1) + x;
+ cells[c].vertices[5] = (z+1)*(n_dy+1)*(n_dx+1) + y*(n_dx+1) + x+1;
+ cells[c].vertices[6] = (z+1)*(n_dy+1)*(n_dx+1) + (y+1)*(n_dx+1) + x;
+ cells[c].vertices[7] = (z+1)*(n_dy+1)*(n_dx+1) + (y+1)*(n_dx+1) + x+1;
+
+ // wipe material id
+ cells[c].material_id = 0;
+ }
+ break;
+ }
- // Create triangulation
- tria.create_triangulation (points, cells, SubCellData());
+ default:
+ Assert (false, ExcNotImplemented());
+ }
- // Finally assign boundary indicators according to hyper_rectangle
- if (colorize)
- colorize_hyper_rectangle (tria);
-}
+ // Create triangulation
+ tria.create_triangulation (points, cells, SubCellData());
+ // Finally assign boundary indicators according to hyper_rectangle
+ if (colorize)
+ colorize_hyper_rectangle (tria);
+ }
-template <int dim>
-void
-GridGenerator::subdivided_hyper_cube (Triangulation<dim> &tria,
- const unsigned int repetitions,
- const double left,
- const double right)
-{
- Assert (repetitions >= 1, ExcInvalidRepetitions(repetitions));
- Assert (left < right,
- ExcMessage ("Invalid left-to-right bounds of hypercube"));
-
- // first generate the necessary
- // points
- const double delta = (right-left)/repetitions;
- std::vector<Point<dim> > points;
- switch (dim)
- {
- case 1:
- for (unsigned int x=0; x<=repetitions; ++x)
- points.push_back (Point<dim> (left+x*delta));
- break;
- case 2:
- for (unsigned int y=0; y<=repetitions; ++y)
+ template <int dim>
+ void
+ subdivided_hyper_cube (Triangulation<dim> &tria,
+ const unsigned int repetitions,
+ const double left,
+ const double right)
+ {
+ Assert (repetitions >= 1, ExcInvalidRepetitions(repetitions));
+ Assert (left < right,
+ ExcMessage ("Invalid left-to-right bounds of hypercube"));
+
+ // first generate the necessary
+ // points
+ const double delta = (right-left)/repetitions;
+ std::vector<Point<dim> > points;
+ switch (dim)
+ {
+ case 1:
for (unsigned int x=0; x<=repetitions; ++x)
- points.push_back (Point<dim> (left+x*delta,
- left+y*delta));
- break;
+ points.push_back (Point<dim> (left+x*delta));
+ break;
- case 3:
- for (unsigned int z=0; z<=repetitions; ++z)
+ case 2:
for (unsigned int y=0; y<=repetitions; ++y)
for (unsigned int x=0; x<=repetitions; ++x)
points.push_back (Point<dim> (left+x*delta,
- left+y*delta,
- left+z*delta));
- break;
-
- default:
- Assert (false, ExcNotImplemented());
- }
-
- // next create the cells
- // Prepare cell data
- std::vector<CellData<dim> > cells;
- // Define these as abbreviations
- // for the step sizes below. The
- // number of points in a single
- // direction is repetitions+1
- const unsigned int dy = repetitions+1;
- const unsigned int dz = dy*dy;
- switch (dim)
- {
- case 1:
- cells.resize (repetitions);
- for (unsigned int x=0; x<repetitions; ++x)
- {
- cells[x].vertices[0] = x;
- cells[x].vertices[1] = x+1;
- cells[x].material_id = 0;
- }
- break;
+ left+y*delta));
+ break;
+
+ case 3:
+ for (unsigned int z=0; z<=repetitions; ++z)
+ for (unsigned int y=0; y<=repetitions; ++y)
+ for (unsigned int x=0; x<=repetitions; ++x)
+ points.push_back (Point<dim> (left+x*delta,
+ left+y*delta,
+ left+z*delta));
+ break;
+
+ default:
+ Assert (false, ExcNotImplemented());
+ }
- case 2:
- cells.resize (repetitions*repetitions);
- for (unsigned int y=0; y<repetitions; ++y)
+ // next create the cells
+ // Prepare cell data
+ std::vector<CellData<dim> > cells;
+ // Define these as abbreviations
+ // for the step sizes below. The
+ // number of points in a single
+ // direction is repetitions+1
+ const unsigned int dy = repetitions+1;
+ const unsigned int dz = dy*dy;
+ switch (dim)
+ {
+ case 1:
+ cells.resize (repetitions);
for (unsigned int x=0; x<repetitions; ++x)
{
- const unsigned int c = x +y*repetitions;
- cells[c].vertices[0] = x +y*dy;
- cells[c].vertices[1] = x+1+y*dy;
- cells[c].vertices[2] = x +(y+1)*dy;
- cells[c].vertices[3] = x+1+(y+1)*dy;
- cells[c].material_id = 0;
+ cells[x].vertices[0] = x;
+ cells[x].vertices[1] = x+1;
+ cells[x].material_id = 0;
}
- break;
+ break;
- case 3:
- cells.resize (repetitions*repetitions*repetitions);
- for (unsigned int z=0; z<repetitions; ++z)
+ case 2:
+ cells.resize (repetitions*repetitions);
for (unsigned int y=0; y<repetitions; ++y)
for (unsigned int x=0; x<repetitions; ++x)
{
- const unsigned int c = x+y*repetitions
- +z*repetitions*repetitions;
- cells[c].vertices[0] = x +y*dy +z*dz;
- cells[c].vertices[1] = x+1+y*dy +z*dz;
- cells[c].vertices[2] = x +(y+1)*dy+z*dz;
- cells[c].vertices[3] = x+1+(y+1)*dy+z*dz;
- cells[c].vertices[4] = x +y*dy +(z+1)*dz;
- cells[c].vertices[5] = x+1+y*dy +(z+1)*dz;
- cells[c].vertices[6] = x +(y+1)*dy+(z+1)*dz;
- cells[c].vertices[7] = x+1+(y+1)*dy+(z+1)*dz;
+ const unsigned int c = x +y*repetitions;
+ cells[c].vertices[0] = x +y*dy;
+ cells[c].vertices[1] = x+1+y*dy;
+ cells[c].vertices[2] = x +(y+1)*dy;
+ cells[c].vertices[3] = x+1+(y+1)*dy;
cells[c].material_id = 0;
}
- break;
+ break;
- default:
- // should be trivial to
- // do for 3d as well, but
- // am too tired at this
- // point of the night to
- // do that...
- //
- // contributions are welcome!
- Assert (false, ExcNotImplemented());
- }
+ case 3:
+ cells.resize (repetitions*repetitions*repetitions);
+ for (unsigned int z=0; z<repetitions; ++z)
+ for (unsigned int y=0; y<repetitions; ++y)
+ for (unsigned int x=0; x<repetitions; ++x)
+ {
+ const unsigned int c = x+y*repetitions
+ +z*repetitions*repetitions;
+ cells[c].vertices[0] = x +y*dy +z*dz;
+ cells[c].vertices[1] = x+1+y*dy +z*dz;
+ cells[c].vertices[2] = x +(y+1)*dy+z*dz;
+ cells[c].vertices[3] = x+1+(y+1)*dy+z*dz;
+ cells[c].vertices[4] = x +y*dy +(z+1)*dz;
+ cells[c].vertices[5] = x+1+y*dy +(z+1)*dz;
+ cells[c].vertices[6] = x +(y+1)*dy+(z+1)*dz;
+ cells[c].vertices[7] = x+1+(y+1)*dy+(z+1)*dz;
+ cells[c].material_id = 0;
+ }
+ break;
+
+ default:
+ // should be trivial to
+ // do for 3d as well, but
+ // am too tired at this
+ // point of the night to
+ // do that...
+ //
+ // contributions are welcome!
+ Assert (false, ExcNotImplemented());
+ }
- tria.create_triangulation (points, cells, SubCellData());
-}
+ tria.create_triangulation (points, cells, SubCellData());
+ }
-template <int dim>
-void
-GridGenerator::subdivided_hyper_rectangle (
- Triangulation<dim> &tria,
- const std::vector<unsigned int> &repetitions,
- const Point<dim> &p_1,
- const Point<dim> &p_2,
- const bool colorize)
-{
- // contributed by Joerg R. Weimar
- // (j.weimar@jweimar.de) 2003
- Assert(repetitions.size() == dim,
- ExcInvalidRepetitionsDimension(dim));
- // First, normalize input such that
- // p1 is lower in all coordinate
- // directions.
- Point<dim> p1(p_1);
- Point<dim> p2(p_2);
-
- for (unsigned int i=0; i<dim; ++i)
- if (p1(i) > p2(i))
- std::swap (p1(i), p2(i));
-
- // then check that all repetitions
- // are >= 1, and calculate deltas
- // convert repetitions from double
- // to int by taking the ceiling.
- Point<dim> delta;
-
- for (unsigned int i=0; i<dim; ++i)
- {
- Assert (repetitions[i] >= 1, ExcInvalidRepetitions(repetitions[i]));
+ template <int dim>
+ void
+ subdivided_hyper_rectangle (
+ Triangulation<dim> &tria,
+ const std::vector<unsigned int> &repetitions,
+ const Point<dim> &p_1,
+ const Point<dim> &p_2,
+ const bool colorize)
+ {
+ // contributed by Joerg R. Weimar
+ // (j.weimar@jweimar.de) 2003
+ Assert(repetitions.size() == dim,
+ ExcInvalidRepetitionsDimension(dim));
+ // First, normalize input such that
+ // p1 is lower in all coordinate
+ // directions.
+ Point<dim> p1(p_1);
+ Point<dim> p2(p_2);
+
+ for (unsigned int i=0; i<dim; ++i)
+ if (p1(i) > p2(i))
+ std::swap (p1(i), p2(i));
- delta[i] = (p2[i]-p1[i])/repetitions[i];
- }
+ // then check that all repetitions
+ // are >= 1, and calculate deltas
+ // convert repetitions from double
+ // to int by taking the ceiling.
+ Point<dim> delta;
- // then generate the necessary
- // points
- std::vector<Point<dim> > points;
- switch (dim)
- {
- case 1:
- for (unsigned int x=0; x<=repetitions[0]; ++x)
- points.push_back (Point<dim> (p1[0]+x*delta[0]));
- break;
+ for (unsigned int i=0; i<dim; ++i)
+ {
+ Assert (repetitions[i] >= 1, ExcInvalidRepetitions(repetitions[i]));
- case 2:
- for (unsigned int y=0; y<=repetitions[1]; ++y)
+ delta[i] = (p2[i]-p1[i])/repetitions[i];
+ }
+
+ // then generate the necessary
+ // points
+ std::vector<Point<dim> > points;
+ switch (dim)
+ {
+ case 1:
for (unsigned int x=0; x<=repetitions[0]; ++x)
- points.push_back (Point<dim> (p1[0]+x*delta[0],
- p1[1]+y*delta[1]));
- break;
+ points.push_back (Point<dim> (p1[0]+x*delta[0]));
+ break;
- case 3:
- for (unsigned int z=0; z<=repetitions[2]; ++z)
+ case 2:
for (unsigned int y=0; y<=repetitions[1]; ++y)
for (unsigned int x=0; x<=repetitions[0]; ++x)
points.push_back (Point<dim> (p1[0]+x*delta[0],
- p1[1]+y*delta[1],
- p1[2]+z*delta[2]));
- break;
-
- default:
- Assert (false, ExcNotImplemented());
- }
-
- // next create the cells
- // Prepare cell data
- std::vector<CellData<dim> > cells;
- switch (dim)
- {
- case 1:
- {
- cells.resize (repetitions[0]);
- for (unsigned int x=0; x<repetitions[0]; ++x)
- {
- cells[x].vertices[0] = x;
- cells[x].vertices[1] = x+1;
- cells[x].material_id = 0;
- }
- break;
- }
+ p1[1]+y*delta[1]));
+ break;
+
+ case 3:
+ for (unsigned int z=0; z<=repetitions[2]; ++z)
+ for (unsigned int y=0; y<=repetitions[1]; ++y)
+ for (unsigned int x=0; x<=repetitions[0]; ++x)
+ points.push_back (Point<dim> (p1[0]+x*delta[0],
+ p1[1]+y*delta[1],
+ p1[2]+z*delta[2]));
+ break;
+
+ default:
+ Assert (false, ExcNotImplemented());
+ }
- case 2:
- {
- cells.resize (repetitions[1]*repetitions[0]);
- for (unsigned int y=0; y<repetitions[1]; ++y)
+ // next create the cells
+ // Prepare cell data
+ std::vector<CellData<dim> > cells;
+ switch (dim)
+ {
+ case 1:
+ {
+ cells.resize (repetitions[0]);
for (unsigned int x=0; x<repetitions[0]; ++x)
{
- const unsigned int c = x+y*repetitions[0];
- cells[c].vertices[0] = y*(repetitions[0]+1)+x;
- cells[c].vertices[1] = y*(repetitions[0]+1)+x+1;
- cells[c].vertices[2] = (y+1)*(repetitions[0]+1)+x;
- cells[c].vertices[3] = (y+1)*(repetitions[0]+1)+x+1;
- cells[c].material_id = 0;
+ cells[x].vertices[0] = x;
+ cells[x].vertices[1] = x+1;
+ cells[x].material_id = 0;
}
- break;
- }
-
- case 3:
- {
- const unsigned int n_x = (repetitions[0]+1);
- const unsigned int n_xy = (repetitions[0]+1)*(repetitions[1]+1);
+ break;
+ }
- cells.resize (repetitions[2]*repetitions[1]*repetitions[0]);
- for (unsigned int z=0; z<repetitions[2]; ++z)
+ case 2:
+ {
+ cells.resize (repetitions[1]*repetitions[0]);
for (unsigned int y=0; y<repetitions[1]; ++y)
for (unsigned int x=0; x<repetitions[0]; ++x)
{
- const unsigned int c = x+y*repetitions[0] +
- z*repetitions[0]*repetitions[1];
- cells[c].vertices[0] = z*n_xy + y*n_x + x;
- cells[c].vertices[1] = z*n_xy + y*n_x + x+1;
- cells[c].vertices[2] = z*n_xy + (y+1)*n_x + x;
- cells[c].vertices[3] = z*n_xy + (y+1)*n_x + x+1;
- cells[c].vertices[4] = (z+1)*n_xy + y*n_x + x;
- cells[c].vertices[5] = (z+1)*n_xy + y*n_x + x+1;
- cells[c].vertices[6] = (z+1)*n_xy + (y+1)*n_x + x;
- cells[c].vertices[7] = (z+1)*n_xy + (y+1)*n_x + x+1;
+ const unsigned int c = x+y*repetitions[0];
+ cells[c].vertices[0] = y*(repetitions[0]+1)+x;
+ cells[c].vertices[1] = y*(repetitions[0]+1)+x+1;
+ cells[c].vertices[2] = (y+1)*(repetitions[0]+1)+x;
+ cells[c].vertices[3] = (y+1)*(repetitions[0]+1)+x+1;
cells[c].material_id = 0;
}
- break;
+ break;
+ }
- }
+ case 3:
+ {
+ const unsigned int n_x = (repetitions[0]+1);
+ const unsigned int n_xy = (repetitions[0]+1)*(repetitions[1]+1);
- default:
- Assert (false, ExcNotImplemented());
- }
+ cells.resize (repetitions[2]*repetitions[1]*repetitions[0]);
+ for (unsigned int z=0; z<repetitions[2]; ++z)
+ for (unsigned int y=0; y<repetitions[1]; ++y)
+ for (unsigned int x=0; x<repetitions[0]; ++x)
+ {
+ const unsigned int c = x+y*repetitions[0] +
+ z*repetitions[0]*repetitions[1];
+ cells[c].vertices[0] = z*n_xy + y*n_x + x;
+ cells[c].vertices[1] = z*n_xy + y*n_x + x+1;
+ cells[c].vertices[2] = z*n_xy + (y+1)*n_x + x;
+ cells[c].vertices[3] = z*n_xy + (y+1)*n_x + x+1;
+ cells[c].vertices[4] = (z+1)*n_xy + y*n_x + x;
+ cells[c].vertices[5] = (z+1)*n_xy + y*n_x + x+1;
+ cells[c].vertices[6] = (z+1)*n_xy + (y+1)*n_x + x;
+ cells[c].vertices[7] = (z+1)*n_xy + (y+1)*n_x + x+1;
+ cells[c].material_id = 0;
+ }
+ break;
- tria.create_triangulation (points, cells, SubCellData());
+ }
- if (colorize)
- {
- // to colorize, run through all
- // faces of all cells and set
- // boundary indicator to the
- // correct value if it was 0.
-
- // use a large epsilon to
- // compare numbers to avoid
- // roundoff problems.
- const double epsilon
- = 0.01 * *std::min_element (&delta[0], &delta[0]+dim);
- Assert (epsilon > 0,
- ExcMessage ("The distance between corner points must be positive."))
-
- // actual code is external since
- // 1-D is different from 2/3D.
- colorize_subdivided_hyper_rectangle (tria, p1, p2, epsilon);
- }
-}
+ default:
+ Assert (false, ExcNotImplemented());
+ }
+ tria.create_triangulation (points, cells, SubCellData());
+ if (colorize)
+ {
+ // to colorize, run through all
+ // faces of all cells and set
+ // boundary indicator to the
+ // correct value if it was 0.
+
+ // use a large epsilon to
+ // compare numbers to avoid
+ // roundoff problems.
+ const double epsilon
+ = 0.01 * *std::min_element (&delta[0], &delta[0]+dim);
+ Assert (epsilon > 0,
+ ExcMessage ("The distance between corner points must be positive."))
+
+ // actual code is external since
+ // 1-D is different from 2/3D.
+ colorize_subdivided_hyper_rectangle (tria, p1, p2, epsilon);
+ }
+ }
-template <int dim>
-void
-GridGenerator::subdivided_hyper_rectangle(
- Triangulation<dim> &tria,
- const std::vector<std::vector<double> > &step_sz,
- const Point<dim> &p_1,
- const Point<dim> &p_2,
- const bool colorize)
-{
- // contributed by Joerg R. Weimar
- // (j.weimar@jweimar.de) 2003
- // modified by Yaqi Wang 2006
- Assert(step_sz.size() == dim,
- ExcInvalidRepetitionsDimension(dim));
-
-
- // First, normalize input such that
- // p1 is lower in all coordinate
- // directions.
-
- // and check the consistency of
- // step sizes, i.e. that they all
- // add up to the sizes specified by
- // p_1 and p_2
- Point<dim> p1(p_1);
- Point<dim> p2(p_2);
- std::vector< std::vector<double> > step_sizes(step_sz);
-
- for (unsigned int i=0; i<dim; ++i)
- {
- if (p1(i) > p2(i))
- {
- std::swap (p1(i), p2(i));
- std::reverse (step_sizes[i].begin(), step_sizes[i].end());
- }
- double x = 0;
- for (size_type j=0; j<step_sizes.at(i).size(); j++)
- x += step_sizes[i][j];
- Assert(std::fabs(x - (p2(i)-p1(i))) <= 1e-12*std::fabs(x),
- ExcInvalidRepetitions (i) );
- }
+ template <int dim>
+ void
+ subdivided_hyper_rectangle(
+ Triangulation<dim> &tria,
+ const std::vector<std::vector<double> > &step_sz,
+ const Point<dim> &p_1,
+ const Point<dim> &p_2,
+ const bool colorize)
+ {
+ // contributed by Joerg R. Weimar
+ // (j.weimar@jweimar.de) 2003
+ // modified by Yaqi Wang 2006
+ Assert(step_sz.size() == dim,
+ ExcInvalidRepetitionsDimension(dim));
+
+
+ // First, normalize input such that
+ // p1 is lower in all coordinate
+ // directions.
+
+ // and check the consistency of
+ // step sizes, i.e. that they all
+ // add up to the sizes specified by
+ // p_1 and p_2
+ Point<dim> p1(p_1);
+ Point<dim> p2(p_2);
+ std::vector< std::vector<double> > step_sizes(step_sz);
+
+ for (unsigned int i=0; i<dim; ++i)
+ {
+ if (p1(i) > p2(i))
+ {
+ std::swap (p1(i), p2(i));
+ std::reverse (step_sizes[i].begin(), step_sizes[i].end());
+ }
- // then generate the necessary
- // points
- std::vector<Point<dim> > points;
- switch (dim)
- {
- case 1:
- {
- double x=0;
- for (size_type i=0; ; ++i)
- {
- points.push_back (Point<dim> (p1[0]+x));
-
- // form partial sums. in
- // the last run through
- // avoid accessing
- // non-existent values
- // and exit early instead
- if (i == step_sizes[0].size())
- break;
+ double x = 0;
+ for (unsigned int j=0; j<step_sizes.at(i).size(); j++)
+ x += step_sizes[i][j];
+ Assert(std::fabs(x - (p2(i)-p1(i))) <= 1e-12*std::fabs(x),
+ ExcInvalidRepetitions (i) );
+ }
- x += step_sizes[0][i];
- }
- break;
- }
- case 2:
- {
- double y=0;
- for (size_type j=0; ; ++j)
- {
- double x=0;
- for (size_type i=0; ; ++i)
- {
- points.push_back (Point<dim> (p1[0]+x,
- p1[1]+y));
- if (i == step_sizes[0].size())
- break;
+ // then generate the necessary
+ // points
+ std::vector<Point<dim> > points;
+ switch (dim)
+ {
+ case 1:
+ {
+ double x=0;
+ for (unsigned int i=0; ; ++i)
+ {
+ points.push_back (Point<dim> (p1[0]+x));
- x += step_sizes[0][i];
- }
+ // form partial sums. in
+ // the last run through
+ // avoid accessing
+ // non-existent values
+ // and exit early instead
+ if (i == step_sizes[0].size())
+ break;
- if (j == step_sizes[1].size())
- break;
+ x += step_sizes[0][i];
+ }
+ break;
+ }
- y += step_sizes[1][j];
- }
- break;
+ case 2:
+ {
+ double y=0;
+ for (unsigned int j=0; ; ++j)
+ {
+ double x=0;
+ for (unsigned int i=0; ; ++i)
+ {
+ points.push_back (Point<dim> (p1[0]+x,
+ p1[1]+y));
+ if (i == step_sizes[0].size())
+ break;
- }
- case 3:
- {
- double z=0;
- for (size_type k=0; ; ++k)
- {
- double y=0;
- for (size_type j=0; ; ++j)
- {
- double x=0;
- for (size_type i=0; ; ++i)
- {
- points.push_back (Point<dim> (p1[0]+x,
- p1[1]+y,
- p1[2]+z));
- if (i == step_sizes[0].size())
- break;
+ x += step_sizes[0][i];
+ }
- x += step_sizes[0][i];
- }
+ if (j == step_sizes[1].size())
+ break;
- if (j == step_sizes[1].size())
- break;
+ y += step_sizes[1][j];
+ }
+ break;
- y += step_sizes[1][j];
- }
+ }
+ case 3:
+ {
+ double z=0;
+ for (unsigned int k=0; ; ++k)
+ {
+ double y=0;
+ for (unsigned int j=0; ; ++j)
+ {
+ double x=0;
+ for (unsigned int i=0; ; ++i)
+ {
+ points.push_back (Point<dim> (p1[0]+x,
+ p1[1]+y,
+ p1[2]+z));
+ if (i == step_sizes[0].size())
+ break;
- if (k == step_sizes[2].size())
- break;
+ x += step_sizes[0][i];
+ }
- z += step_sizes[2][k];
- }
- break;
- }
+ if (j == step_sizes[1].size())
+ break;
- default:
- Assert (false, ExcNotImplemented());
- }
+ y += step_sizes[1][j];
+ }
- // next create the cells
- // Prepare cell data
- std::vector<CellData<dim> > cells;
- switch (dim)
- {
- case 1:
- {
- cells.resize (step_sizes[0].size());
- for (size_type x=0; x<step_sizes[0].size(); ++x)
- {
- cells[x].vertices[0] = x;
- cells[x].vertices[1] = x+1;
- cells[x].material_id = 0;
- }
- break;
- }
+ if (k == step_sizes[2].size())
+ break;
- case 2:
- {
- cells.resize (step_sizes[1].size()*step_sizes[0].size());
- for (size_type y=0; y<step_sizes[1].size(); ++y)
- for (size_type x=0; x<step_sizes[0].size(); ++x)
- {
- const size_type c = x+y*step_sizes[0].size();
- cells[c].vertices[0] = y*(step_sizes[0].size()+1)+x;
- cells[c].vertices[1] = y*(step_sizes[0].size()+1)+x+1;
- cells[c].vertices[2] = (y+1)*(step_sizes[0].size()+1)+x;
- cells[c].vertices[3] = (y+1)*(step_sizes[0].size()+1)+x+1;
- cells[c].material_id = 0;
+ z += step_sizes[2][k];
}
- break;
- }
+ break;
+ }
- case 3:
- {
- const size_type n_x = (step_sizes[0].size()+1);
- const size_type n_xy = (step_sizes[0].size()+1)*(step_sizes[1].size()+1);
+ default:
+ Assert (false, ExcNotImplemented());
+ }
+
+ // next create the cells
+ // Prepare cell data
+ std::vector<CellData<dim> > cells;
+ switch (dim)
+ {
+ case 1:
+ {
+ cells.resize (step_sizes[0].size());
+ for (unsigned int x=0; x<step_sizes[0].size(); ++x)
+ {
+ cells[x].vertices[0] = x;
+ cells[x].vertices[1] = x+1;
+ cells[x].material_id = 0;
+ }
+ break;
+ }
- cells.resize (step_sizes[2].size()*step_sizes[1].size()*step_sizes[0].size());
- for (size_type z=0; z<step_sizes[2].size(); ++z)
- for (size_type y=0; y<step_sizes[1].size(); ++y)
- for (size_type x=0; x<step_sizes[0].size(); ++x)
+ case 2:
+ {
+ cells.resize (step_sizes[1].size()*step_sizes[0].size());
+ for (unsigned int y=0; y<step_sizes[1].size(); ++y)
+ for (unsigned int x=0; x<step_sizes[0].size(); ++x)
{
- const size_type c = x+y*step_sizes[0].size() +
- z*step_sizes[0].size()*step_sizes[1].size();
- cells[c].vertices[0] = z*n_xy + y*n_x + x;
- cells[c].vertices[1] = z*n_xy + y*n_x + x+1;
- cells[c].vertices[2] = z*n_xy + (y+1)*n_x + x;
- cells[c].vertices[3] = z*n_xy + (y+1)*n_x + x+1;
- cells[c].vertices[4] = (z+1)*n_xy + y*n_x + x;
- cells[c].vertices[5] = (z+1)*n_xy + y*n_x + x+1;
- cells[c].vertices[6] = (z+1)*n_xy + (y+1)*n_x + x;
- cells[c].vertices[7] = (z+1)*n_xy + (y+1)*n_x + x+1;
+ const unsigned int c = x+y*step_sizes[0].size();
+ cells[c].vertices[0] = y*(step_sizes[0].size()+1)+x;
+ cells[c].vertices[1] = y*(step_sizes[0].size()+1)+x+1;
+ cells[c].vertices[2] = (y+1)*(step_sizes[0].size()+1)+x;
+ cells[c].vertices[3] = (y+1)*(step_sizes[0].size()+1)+x+1;
cells[c].material_id = 0;
}
- break;
+ break;
+ }
- }
+ case 3:
+ {
+ const unsigned int n_x = (step_sizes[0].size()+1);
+ const unsigned int n_xy = (step_sizes[0].size()+1)*(step_sizes[1].size()+1);
- default:
- Assert (false, ExcNotImplemented());
- }
+ cells.resize (step_sizes[2].size()*step_sizes[1].size()*step_sizes[0].size());
+ for (unsigned int z=0; z<step_sizes[2].size(); ++z)
+ for (unsigned int y=0; y<step_sizes[1].size(); ++y)
+ for (unsigned int x=0; x<step_sizes[0].size(); ++x)
+ {
+ const unsigned int c = x+y*step_sizes[0].size() +
+ z*step_sizes[0].size()*step_sizes[1].size();
+ cells[c].vertices[0] = z*n_xy + y*n_x + x;
+ cells[c].vertices[1] = z*n_xy + y*n_x + x+1;
+ cells[c].vertices[2] = z*n_xy + (y+1)*n_x + x;
+ cells[c].vertices[3] = z*n_xy + (y+1)*n_x + x+1;
+ cells[c].vertices[4] = (z+1)*n_xy + y*n_x + x;
+ cells[c].vertices[5] = (z+1)*n_xy + y*n_x + x+1;
+ cells[c].vertices[6] = (z+1)*n_xy + (y+1)*n_x + x;
+ cells[c].vertices[7] = (z+1)*n_xy + (y+1)*n_x + x+1;
+ cells[c].material_id = 0;
+ }
+ break;
- tria.create_triangulation (points, cells, SubCellData());
+ }
- if (colorize)
- {
- // to colorize, run through all
- // faces of all cells and set
- // boundary indicator to the
- // correct value if it was 0.
-
- // use a large epsilon to
- // compare numbers to avoid
- // roundoff problems.
- double min_size = *std::min_element (step_sizes[0].begin(),
- step_sizes[0].end());
- for (unsigned int i=1; i<dim; ++i)
- min_size = std::min (min_size,
- *std::min_element (step_sizes[i].begin(),
- step_sizes[i].end()));
- const double epsilon = 0.01 * min_size;
-
- // actual code is external since
- // 1-D is different from 2/3D.
- colorize_subdivided_hyper_rectangle (tria, p1, p2, epsilon);
- }
-}
+ default:
+ Assert (false, ExcNotImplemented());
+ }
+ tria.create_triangulation (points, cells, SubCellData());
+ if (colorize)
+ {
+ // to colorize, run through all
+ // faces of all cells and set
+ // boundary indicator to the
+ // correct value if it was 0.
+
+ // use a large epsilon to
+ // compare numbers to avoid
+ // roundoff problems.
+ double min_size = *std::min_element (step_sizes[0].begin(),
+ step_sizes[0].end());
+ for (unsigned int i=1; i<dim; ++i)
+ min_size = std::min (min_size,
+ *std::min_element (step_sizes[i].begin(),
+ step_sizes[i].end()));
+ const double epsilon = 0.01 * min_size;
+
+ // actual code is external since
+ // 1-D is different from 2/3D.
+ colorize_subdivided_hyper_rectangle (tria, p1, p2, epsilon);
+ }
+ }
-template <>
-void
-GridGenerator::subdivided_hyper_rectangle (
- Triangulation<1> &tria,
- const std::vector< std::vector<double> > &spacing,
- const Point<1> &p,
- const Table<1,types::material_id> &material_id,
- const bool colorize)
-{
- // contributed by Yaqi Wang 2006
- Assert(spacing.size() == 1,
- ExcInvalidRepetitionsDimension(1));
- const size_type n_cells = material_id.size(0);
- Assert(spacing[0].size() == n_cells,
- ExcInvalidRepetitionsDimension(1));
+ template <>
+ void
+ subdivided_hyper_rectangle (
+ Triangulation<1> &tria,
+ const std::vector< std::vector<double> > &spacing,
+ const Point<1> &p,
+ const Table<1,types::material_id> &material_id,
+ const bool colorize)
+ {
+ // contributed by Yaqi Wang 2006
+ Assert(spacing.size() == 1,
+ ExcInvalidRepetitionsDimension(1));
- double delta = std::numeric_limits<double>::max();
- for (size_type i=0; i<n_cells; i++)
- {
- Assert (spacing[0][i] >= 0, ExcInvalidRepetitions(-1));
- delta = std::min (delta, spacing[0][i]);
- }
+ const unsigned int n_cells = material_id.size(0);
- // generate the necessary points
- std::vector<Point<1> > points;
- double ax = p[0];
- for (size_type x=0; x<=n_cells; ++x)
- {
- points.push_back (Point<1> (ax));
- if (x<n_cells)
- ax += spacing[0][x];
- }
- // create the cells
- size_type n_val_cells = 0;
- for (size_type i=0; i<n_cells; i++)
- if (material_id[i]!=numbers::invalid_material_id) n_val_cells++;
+ Assert(spacing[0].size() == n_cells,
+ ExcInvalidRepetitionsDimension(1));
- std::vector<CellData<1> > cells(n_val_cells);
- size_type id = 0;
- for (size_type x=0; x<n_cells; ++x)
- if (material_id[x] != numbers::invalid_material_id)
+ double delta = std::numeric_limits<double>::max();
+ for (unsigned int i=0; i<n_cells; i++)
{
- cells[id].vertices[0] = x;
- cells[id].vertices[1] = x+1;
- cells[id].material_id = material_id[x];
- id++;
+ Assert (spacing[0][i] >= 0, ExcInvalidRepetitions(-1));
+ delta = std::min (delta, spacing[0][i]);
}
- // create triangulation
- SubCellData t;
- GridTools::delete_unused_vertices (points, cells, t);
- tria.create_triangulation (points, cells, t);
+ // generate the necessary points
+ std::vector<Point<1> > points;
+ double ax = p[0];
+ for (unsigned int x=0; x<=n_cells; ++x)
+ {
+ points.push_back (Point<1> (ax));
+ if (x<n_cells)
+ ax += spacing[0][x];
+ }
+ // create the cells
+ unsigned int n_val_cells = 0;
+ for (unsigned int i=0; i<n_cells; i++)
+ if (material_id[i]!=numbers::invalid_material_id) n_val_cells++;
+
+ std::vector<CellData<1> > cells(n_val_cells);
+ unsigned int id = 0;
+ for (unsigned int x=0; x<n_cells; ++x)
+ if (material_id[x] != numbers::invalid_material_id)
+ {
+ cells[id].vertices[0] = x;
+ cells[id].vertices[1] = x+1;
+ cells[id].material_id = material_id[x];
+ id++;
+ }
+ // create triangulation
+ SubCellData t;
+ GridTools::delete_unused_vertices (points, cells, t);
- // set boundary indicator
- if (colorize)
- Assert (false, ExcNotImplemented());
-}
+ tria.create_triangulation (points, cells, t);
+ // set boundary indicator
+ if (colorize)
+ Assert (false, ExcNotImplemented());
+ }
-template <>
-void
-GridGenerator::subdivided_hyper_rectangle (
- Triangulation<2> &tria,
- const std::vector< std::vector<double> > &spacing,
- const Point<2> &p,
- const Table<2,types::material_id> &material_id,
- const bool colorize)
-{
- // contributed by Yaqi Wang 2006
- Assert(spacing.size() == 2,
- ExcInvalidRepetitionsDimension(2));
-
- std::vector<size_type> repetitions(2);
- size_type n_cells = 1;
- double delta = std::numeric_limits<double>::max();
- for (unsigned int i=0; i<2; i++)
- {
- repetitions[i] = spacing[i].size();
- n_cells *= repetitions[i];
- for (size_type j=0; j<repetitions[i]; j++)
- {
- Assert (spacing[i][j] >= 0, ExcInvalidRepetitions(-1));
- delta = std::min (delta, spacing[i][j]);
- }
- Assert(material_id.size(i) == repetitions[i],
- ExcInvalidRepetitionsDimension(i));
- }
- // generate the necessary points
- std::vector<Point<2> > points;
- double ay = p[1];
- for (size_type y=0; y<=repetitions[1]; ++y)
- {
- double ax = p[0];
- for (size_type x=0; x<=repetitions[0]; ++x)
- {
- points.push_back (Point<2> (ax,ay));
- if (x<repetitions[0])
- ax += spacing[0][x];
- }
- if (y<repetitions[1])
- ay += spacing[1][y];
- }
+ template <>
+ void
+ subdivided_hyper_rectangle (
+ Triangulation<2> &tria,
+ const std::vector< std::vector<double> > &spacing,
+ const Point<2> &p,
+ const Table<2,types::material_id> &material_id,
+ const bool colorize)
+ {
+ // contributed by Yaqi Wang 2006
+ Assert(spacing.size() == 2,
+ ExcInvalidRepetitionsDimension(2));
+
+ std::vector<unsigned int> repetitions(2);
+ unsigned int n_cells = 1;
+ double delta = std::numeric_limits<double>::max();
+ for (unsigned int i=0; i<2; i++)
+ {
+ repetitions[i] = spacing[i].size();
+ n_cells *= repetitions[i];
+ for (unsigned int j=0; j<repetitions[i]; j++)
+ {
+ Assert (spacing[i][j] >= 0, ExcInvalidRepetitions(-1));
+ delta = std::min (delta, spacing[i][j]);
+ }
+ Assert(material_id.size(i) == repetitions[i],
+ ExcInvalidRepetitionsDimension(i));
+ }
- // create the cells
- size_type n_val_cells = 0;
- for (size_type i=0; i<material_id.size(0); i++)
- for (size_type j=0; j<material_id.size(1); j++)
- if (material_id[i][j] != numbers::invalid_material_id)
- n_val_cells++;
-
- std::vector<CellData<2> > cells(n_val_cells);
- size_type id = 0;
- for (size_type y=0; y<repetitions[1]; ++y)
- for (size_type x=0; x<repetitions[0]; ++x)
- if (material_id[x][y]!=numbers::invalid_material_id)
- {
- cells[id].vertices[0] = y*(repetitions[0]+1)+x;
- cells[id].vertices[1] = y*(repetitions[0]+1)+x+1;
- cells[id].vertices[2] = (y+1)*(repetitions[0]+1)+x;
- cells[id].vertices[3] = (y+1)*(repetitions[0]+1)+x+1;
- cells[id].material_id = material_id[x][y];
- id++;
- }
+ // generate the necessary points
+ std::vector<Point<2> > points;
+ double ay = p[1];
+ for (unsigned int y=0; y<=repetitions[1]; ++y)
+ {
+ double ax = p[0];
+ for (unsigned int x=0; x<=repetitions[0]; ++x)
+ {
+ points.push_back (Point<2> (ax,ay));
+ if (x<repetitions[0])
+ ax += spacing[0][x];
+ }
+ if (y<repetitions[1])
+ ay += spacing[1][y];
+ }
- // create triangulation
- SubCellData t;
- GridTools::delete_unused_vertices (points, cells, t);
+ // create the cells
+ unsigned int n_val_cells = 0;
+ for (unsigned int i=0; i<material_id.size(0); i++)
+ for (unsigned int j=0; j<material_id.size(1); j++)
+ if (material_id[i][j] != numbers::invalid_material_id)
+ n_val_cells++;
- tria.create_triangulation (points, cells, t);
+ std::vector<CellData<2> > cells(n_val_cells);
+ unsigned int id = 0;
+ for (unsigned int y=0; y<repetitions[1]; ++y)
+ for (unsigned int x=0; x<repetitions[0]; ++x)
+ if (material_id[x][y]!=numbers::invalid_material_id)
+ {
+ cells[id].vertices[0] = y*(repetitions[0]+1)+x;
+ cells[id].vertices[1] = y*(repetitions[0]+1)+x+1;
+ cells[id].vertices[2] = (y+1)*(repetitions[0]+1)+x;
+ cells[id].vertices[3] = (y+1)*(repetitions[0]+1)+x+1;
+ cells[id].material_id = material_id[x][y];
+ id++;
+ }
- // set boundary indicator
- if (colorize)
- {
- double eps = 0.01 * delta;
- Triangulation<2>::cell_iterator cell = tria.begin(),
- endc = tria.end();
- for (; cell !=endc; ++cell)
- {
- Point<2> cell_center = cell->center();
- for (unsigned int f=0; f<GeometryInfo<2>::faces_per_cell; ++f)
- if (cell->face(f)->boundary_indicator() == 0)
- {
- Point<2> face_center = cell->face(f)->center();
- for (unsigned int i=0; i<2; ++i)
- {
- if (face_center[i]<cell_center[i]-eps)
- cell->face(f)->set_boundary_indicator(i*2);
- if (face_center[i]>cell_center[i]+eps)
- cell->face(f)->set_boundary_indicator(i*2+1);
- }
- }
- }
- }
-}
+ // create triangulation
+ SubCellData t;
+ GridTools::delete_unused_vertices (points, cells, t);
+ tria.create_triangulation (points, cells, t);
-template <>
-void
-GridGenerator::subdivided_hyper_rectangle (
- Triangulation<3> &tria,
- const std::vector< std::vector<double> > &spacing,
- const Point<3> &p,
- const Table<3,types::material_id> &material_id,
- const bool colorize)
-{
- // contributed by Yaqi Wang 2006
- const unsigned int dim = 3;
+ // set boundary indicator
+ if (colorize)
+ {
+ double eps = 0.01 * delta;
+ Triangulation<2>::cell_iterator cell = tria.begin(),
+ endc = tria.end();
+ for (; cell !=endc; ++cell)
+ {
+ Point<2> cell_center = cell->center();
+ for (unsigned int f=0; f<GeometryInfo<2>::faces_per_cell; ++f)
+ if (cell->face(f)->boundary_indicator() == 0)
+ {
+ Point<2> face_center = cell->face(f)->center();
+ for (unsigned int i=0; i<2; ++i)
+ {
+ if (face_center[i]<cell_center[i]-eps)
+ cell->face(f)->set_boundary_indicator(i*2);
+ if (face_center[i]>cell_center[i]+eps)
+ cell->face(f)->set_boundary_indicator(i*2+1);
+ }
+ }
+ }
+ }
+ }
- Assert(spacing.size() == dim,
- ExcInvalidRepetitionsDimension(dim));
- std::vector<size_type > repetitions(dim);
- size_type n_cells = 1;
- double delta = std::numeric_limits<double>::max();
- for (unsigned int i=0; i<dim; i++)
- {
- repetitions[i] = spacing[i].size();
- n_cells *= repetitions[i];
- for (size_type j=0; j<repetitions[i]; j++)
- {
- Assert (spacing[i][j] >= 0, ExcInvalidRepetitions(-1));
- delta = std::min (delta, spacing[i][j]);
- }
- Assert(material_id.size(i) == repetitions[i],
- ExcInvalidRepetitionsDimension(i));
- }
+ template <>
+ void
+ subdivided_hyper_rectangle (
+ Triangulation<3> &tria,
+ const std::vector< std::vector<double> > &spacing,
+ const Point<3> &p,
+ const Table<3,types::material_id> &material_id,
+ const bool colorize)
+ {
+ // contributed by Yaqi Wang 2006
+ const unsigned int dim = 3;
- // generate the necessary points
- std::vector<Point<dim> > points;
- double az = p[2];
- for (size_type z=0; z<=repetitions[2]; ++z)
- {
- double ay = p[1];
- for (size_type y=0; y<=repetitions[1]; ++y)
- {
- double ax = p[0];
- for (size_type x=0; x<=repetitions[0]; ++x)
+ Assert(spacing.size() == dim,
+ ExcInvalidRepetitionsDimension(dim));
+
+ std::vector<unsigned int > repetitions(dim);
+ unsigned int n_cells = 1;
+ double delta = std::numeric_limits<double>::max();
+ for (unsigned int i=0; i<dim; i++)
+ {
+ repetitions[i] = spacing[i].size();
+ n_cells *= repetitions[i];
+ for (unsigned int j=0; j<repetitions[i]; j++)
+ {
+ Assert (spacing[i][j] >= 0, ExcInvalidRepetitions(-1));
+ delta = std::min (delta, spacing[i][j]);
+ }
+ Assert(material_id.size(i) == repetitions[i],
+ ExcInvalidRepetitionsDimension(i));
+ }
+
+ // generate the necessary points
+ std::vector<Point<dim> > points;
+ double az = p[2];
+ for (unsigned int z=0; z<=repetitions[2]; ++z)
+ {
+ double ay = p[1];
+ for (unsigned int y=0; y<=repetitions[1]; ++y)
+ {
+ double ax = p[0];
+ for (unsigned int x=0; x<=repetitions[0]; ++x)
+ {
+ points.push_back (Point<dim> (ax,ay,az));
+ if (x<repetitions[0])
+ ax += spacing[0][x];
+ }
+ if (y<repetitions[1])
+ ay += spacing[1][y];
+ }
+ if (z<repetitions[2])
+ az += spacing[2][z];
+ }
+
+ // create the cells
+ unsigned int n_val_cells = 0;
+ for (unsigned int i=0; i<material_id.size(0); i++)
+ for (unsigned int j=0; j<material_id.size(1); j++)
+ for (unsigned int k=0; k<material_id.size(2); k++)
+ if (material_id[i][j][k]!=numbers::invalid_material_id)
+ n_val_cells++;
+
+ std::vector<CellData<dim> > cells(n_val_cells);
+ unsigned int id = 0;
+ const unsigned int n_x = (repetitions[0]+1);
+ const unsigned int n_xy = (repetitions[0]+1)*(repetitions[1]+1);
+ for (unsigned int z=0; z<repetitions[2]; ++z)
+ for (unsigned int y=0; y<repetitions[1]; ++y)
+ for (unsigned int x=0; x<repetitions[0]; ++x)
+ if (material_id[x][y][z]!=numbers::invalid_material_id)
{
- points.push_back (Point<dim> (ax,ay,az));
- if (x<repetitions[0])
- ax += spacing[0][x];
+ cells[id].vertices[0] = z*n_xy + y*n_x + x;
+ cells[id].vertices[1] = z*n_xy + y*n_x + x+1;
+ cells[id].vertices[2] = z*n_xy + (y+1)*n_x + x;
+ cells[id].vertices[3] = z*n_xy + (y+1)*n_x + x+1;
+ cells[id].vertices[4] = (z+1)*n_xy + y*n_x + x;
+ cells[id].vertices[5] = (z+1)*n_xy + y*n_x + x+1;
+ cells[id].vertices[6] = (z+1)*n_xy + (y+1)*n_x + x;
+ cells[id].vertices[7] = (z+1)*n_xy + (y+1)*n_x + x+1;
+ cells[id].material_id = material_id[x][y][z];
+ id++;
}
- if (y<repetitions[1])
- ay += spacing[1][y];
- }
- if (z<repetitions[2])
- az += spacing[2][z];
- }
- // create the cells
- size_type n_val_cells = 0;
- for (size_type i=0; i<material_id.size(0); i++)
- for (size_type j=0; j<material_id.size(1); j++)
- for (size_type k=0; k<material_id.size(2); k++)
- if (material_id[i][j][k]!=numbers::invalid_material_id)
- n_val_cells++;
+ // create triangulation
+ SubCellData t;
+ GridTools::delete_unused_vertices (points, cells, t);
- std::vector<CellData<dim> > cells(n_val_cells);
- size_type id = 0;
- const size_type n_x = (repetitions[0]+1);
- const size_type n_xy = (repetitions[0]+1)*(repetitions[1]+1);
- for (size_type z=0; z<repetitions[2]; ++z)
- for (size_type y=0; y<repetitions[1]; ++y)
- for (size_type x=0; x<repetitions[0]; ++x)
- if (material_id[x][y][z]!=numbers::invalid_material_id)
+ tria.create_triangulation (points, cells, t);
+
+ // set boundary indicator
+ if (colorize && dim>1)
+ {
+ double eps = 0.01 * delta;
+ Triangulation<dim>::cell_iterator cell = tria.begin(),
+ endc = tria.end();
+ for (; cell !=endc; ++cell)
{
- cells[id].vertices[0] = z*n_xy + y*n_x + x;
- cells[id].vertices[1] = z*n_xy + y*n_x + x+1;
- cells[id].vertices[2] = z*n_xy + (y+1)*n_x + x;
- cells[id].vertices[3] = z*n_xy + (y+1)*n_x + x+1;
- cells[id].vertices[4] = (z+1)*n_xy + y*n_x + x;
- cells[id].vertices[5] = (z+1)*n_xy + y*n_x + x+1;
- cells[id].vertices[6] = (z+1)*n_xy + (y+1)*n_x + x;
- cells[id].vertices[7] = (z+1)*n_xy + (y+1)*n_x + x+1;
- cells[id].material_id = material_id[x][y][z];
- id++;
+ Point<dim> cell_center = cell->center();
+ for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
+ if (cell->face(f)->boundary_indicator() == 0)
+ {
+ Point<dim> face_center = cell->face(f)->center();
+ for (unsigned int i=0; i<dim; ++i)
+ {
+ if (face_center[i]<cell_center[i]-eps)
+ cell->face(f)->set_boundary_indicator(i*2);
+ if (face_center[i]>cell_center[i]+eps)
+ cell->face(f)->set_boundary_indicator(i*2+1);
+ }
+ }
}
+ }
+ }
- // create triangulation
- SubCellData t;
- GridTools::delete_unused_vertices (points, cells, t);
- tria.create_triangulation (points, cells, t);
- // set boundary indicator
- if (colorize && dim>1)
- {
- double eps = 0.01 * delta;
- Triangulation<dim>::cell_iterator cell = tria.begin(),
- endc = tria.end();
- for (; cell !=endc; ++cell)
- {
- Point<dim> cell_center = cell->center();
- for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
- if (cell->face(f)->boundary_indicator() == 0)
- {
- Point<dim> face_center = cell->face(f)->center();
- for (unsigned int i=0; i<dim; ++i)
- {
- if (face_center[i]<cell_center[i]-eps)
- cell->face(f)->set_boundary_indicator(i*2);
- if (face_center[i]>cell_center[i]+eps)
- cell->face(f)->set_boundary_indicator(i*2+1);
- }
- }
- }
- }
-}
+ template <>
+ void hyper_cube_slit (Triangulation<1> &,
+ const double,
+ const double,
+ const bool)
+ {
+ Assert (false, ExcNotImplemented());
+ }
-template <>
-void
-GridGenerator::colorize_subdivided_hyper_rectangle (
- Triangulation<1> &tria,
- const Point<1> &,
- const Point<1> &,
- const double)
-{
- for (Triangulation<1>::cell_iterator cell = tria.begin();
- cell != tria.end(); ++cell)
- if (cell->center()(0) > 0)
- cell->set_material_id(1);
- // boundary indicators are set to
- // 0 (left) and 1 (right) by default.
-}
+ template <>
+ void enclosed_hyper_cube (Triangulation<1> &,
+ const double,
+ const double,
+ const double,
+ const bool)
+ {
+ Assert (false, ExcNotImplemented());
+ }
-template <int dim>
-void
-GridGenerator::colorize_subdivided_hyper_rectangle (Triangulation<dim> &tria,
- const Point<dim> &p1,
- const Point<dim> &p2,
- const double epsilon)
-{
+ template <>
+ void hyper_L (Triangulation<1> &,
+ const double,
+ const double)
+ {
+ Assert (false, ExcNotImplemented());
+ }
- // run through all faces and check
- // if one of their center coordinates matches
- // one of the corner points. Comparisons
- // are made using an epsilon which
- // should be smaller than the smallest cell
- // diameter.
- typename Triangulation<dim>::face_iterator face = tria.begin_face(),
- endface = tria.end_face();
- for (; face!=endface; ++face)
- {
- if (face->boundary_indicator() == 0)
- {
- const Point<dim> center (face->center());
- if (std::abs(center(0)-p1[0]) < epsilon)
- face->set_boundary_indicator(0);
- else if (std::abs(center(0) - p2[0]) < epsilon)
- face->set_boundary_indicator(1);
- else if (dim > 1 && std::abs(center(1) - p1[1]) < epsilon)
- face->set_boundary_indicator(2);
- else if (dim > 1 && std::abs(center(1) - p2[1]) < epsilon)
- face->set_boundary_indicator(3);
- else if (dim > 2 && std::abs(center(2) - p1[2]) < epsilon)
- face->set_boundary_indicator(4);
- else if (dim > 2 && std::abs(center(2) - p2[2]) < epsilon)
- face->set_boundary_indicator(5);
- else
- // triangulation says it
- // is on the boundary,
- // but we could not find
- // on which boundary.
- Assert (false, ExcInternalError());
- }
- }
- for (typename Triangulation<dim>::cell_iterator cell = tria.begin();
- cell != tria.end(); ++cell)
- {
- char id = 0;
- for (unsigned int d=0; d<dim; ++d)
- if (cell->center()(d) > 0) id += 1 << d;
- cell->set_material_id(id);
- }
-}
+ template <>
+ void hyper_ball (Triangulation<1> &,
+ const Point<1> &,
+ const double)
+ {
+ Assert (false, ExcNotImplemented());
+ }
-template <>
-void GridGenerator::hyper_cube_slit (Triangulation<1> &,
- const double,
- const double,
- const bool)
-{
- Assert (false, ExcNotImplemented());
-}
+ template <>
+ void cylinder (Triangulation<1> &,
+ const double,
+ const double)
+ {
+ Assert (false, ExcNotImplemented());
+ }
-template <>
-void GridGenerator::enclosed_hyper_cube (Triangulation<1> &,
- const double,
- const double,
- const double,
- const bool)
-{
- Assert (false, ExcNotImplemented());
-}
+ template <>
+ void truncated_cone (Triangulation<1> &,
+ const double,
+ const double,
+ const double)
+ {
+ Assert (false, ExcNotImplemented());
+ }
-template <>
-void GridGenerator::hyper_L (Triangulation<1> &,
- const double,
- const double)
-{
- Assert (false, ExcNotImplemented());
-}
+ template <>
+ void hyper_shell (Triangulation<1> &,
+ const Point<1> &,
+ const double,
+ const double,
+ const unsigned int ,
+ const bool)
+ {
+ Assert (false, ExcNotImplemented());
+ }
-template <>
-void GridGenerator::hyper_ball (Triangulation<1> &,
- const Point<1> &,
- const double)
-{
- Assert (false, ExcNotImplemented());
-}
+ template <>
+ void cylinder_shell (Triangulation<1> &,
+ const double,
+ const double,
+ const double,
+ const unsigned int ,
+ const unsigned int )
+ {
+ Assert (false, ExcNotImplemented());
+ }
+ template <>
+ void
+ half_hyper_ball (Triangulation<1> &,
+ const Point<1> &,
+ const double)
+ {
+ Assert (false, ExcNotImplemented());
+ }
-template <>
-void GridGenerator::cylinder (Triangulation<1> &,
- const double,
- const double)
-{
- Assert (false, ExcNotImplemented());
-}
+ template <>
+ void
+ half_hyper_shell (Triangulation<1> &,
+ const Point<1> &,
+ const double,
+ const double,
+ const unsigned int ,
+ const bool)
+ {
+ Assert (false, ExcNotImplemented());
+ }
+
+ template <>
+ void quarter_hyper_shell (Triangulation<1> &,
+ const Point<1> &,
+ const double,
+ const double,
+ const unsigned int ,
+ const bool)
+ {
+ Assert (false, ExcNotImplemented());
+ }
+
+ template <>
+ void enclosed_hyper_cube (Triangulation<2> &tria,
+ const double left,
+ const double right,
+ const double thickness,
+ const bool colorize)
+ {
+ Assert(left<right,
+ ExcMessage ("Invalid left-to-right bounds of enclosed hypercube"));
+
+ std::vector<Point<2> > vertices(16);
+ double coords[4];
+ coords[0] = left-thickness;
+ coords[1] = left;
+ coords[2] = right;
+ coords[3] = right+thickness;
+
+ unsigned int k=0;
+ for (unsigned int i0=0; i0<4; ++i0)
+ for (unsigned int i1=0; i1<4; ++i1)
+ vertices[k++] = Point<2>(coords[i1], coords[i0]);
+
+ const types::material_id materials[9] = { 5, 4, 6,
+ 1, 0, 2,
+ 9, 8,10
+ };
+
+ std::vector<CellData<2> > cells(9);
+ k = 0;
+ for (unsigned int i0=0; i0<3; ++i0)
+ for (unsigned int i1=0; i1<3; ++i1)
+ {
+ cells[k].vertices[0] = i1+4*i0;
+ cells[k].vertices[1] = i1+4*i0+1;
+ cells[k].vertices[2] = i1+4*i0+4;
+ cells[k].vertices[3] = i1+4*i0+5;
+ if (colorize)
+ cells[k].material_id = materials[k];
+ ++k;
+ }
+ tria.create_triangulation (vertices,
+ cells,
+ SubCellData()); // no boundary information
+ }
-template <>
-void GridGenerator::truncated_cone (Triangulation<1> &,
- const double,
- const double,
- const double)
-{
- Assert (false, ExcNotImplemented());
-}
+// Implementation for 2D only
+ template <>
+ void
+ hyper_cube_slit (Triangulation<2> &tria,
+ const double left,
+ const double right,
+ const bool colorize)
+ {
+ const double rl2=(right+left)/2;
+ const Point<2> vertices[10] = { Point<2>(left, left ),
+ Point<2>(rl2, left ),
+ Point<2>(rl2, rl2 ),
+ Point<2>(left, rl2 ),
+ Point<2>(right,left ),
+ Point<2>(right,rl2 ),
+ Point<2>(rl2, right),
+ Point<2>(left, right),
+ Point<2>(right,right),
+ Point<2>(rl2, left )
+ };
+ const int cell_vertices[4][4] = { { 0,1,3,2 },
+ { 9,4,2,5 },
+ { 3,2,7,6 },
+ { 2,5,6,8 }
+ };
+ std::vector<CellData<2> > cells (4, CellData<2>());
+ for (unsigned int i=0; i<4; ++i)
+ {
+ for (unsigned int j=0; j<4; ++j)
+ cells[i].vertices[j] = cell_vertices[i][j];
+ cells[i].material_id = 0;
+ };
+ tria.create_triangulation (
+ std::vector<Point<2> >(&vertices[0], &vertices[10]),
+ cells,
+ SubCellData()); // no boundary information
+ if (colorize)
+ {
+ Triangulation<2>::cell_iterator cell = tria.begin();
+ cell->face(1)->set_boundary_indicator(1);
+ ++cell;
+ cell->face(3)->set_boundary_indicator(2);
+ }
+ }
-template <>
-void GridGenerator::hyper_shell (Triangulation<1> &,
- const Point<1> &,
- const double,
- const double,
- const size_type ,
- const bool)
-{
- Assert (false, ExcNotImplemented());
-}
-template <>
-void GridGenerator::colorize_hyper_shell (Triangulation<1> &,
- const Point<1> &,
- const double,
- const double)
-{
- Assert (false, ExcNotImplemented());
-}
+ template <>
+ void truncated_cone (Triangulation<2> &triangulation,
+ const double radius_0,
+ const double radius_1,
+ const double half_length)
+ {
+ Point<2> vertices_tmp[4];
+ vertices_tmp[0] = Point<2> (-half_length, -radius_0);
+ vertices_tmp[1] = Point<2> (half_length, -radius_1);
+ vertices_tmp[2] = Point<2> (-half_length, radius_0);
+ vertices_tmp[3] = Point<2> (half_length, radius_1);
-template <>
-void GridGenerator::cylinder_shell (Triangulation<1> &,
- const double,
- const double,
- const double,
- const size_type ,
- const size_type )
-{
- Assert (false, ExcNotImplemented());
-}
+ const std::vector<Point<2> > vertices (&vertices_tmp[0], &vertices_tmp[4]);
+ unsigned int cell_vertices[1][GeometryInfo<2>::vertices_per_cell];
+ for (unsigned int i = 0; i < GeometryInfo<2>::vertices_per_cell; ++i)
+ cell_vertices[0][i] = i;
-template <>
-void
-GridGenerator::half_hyper_ball (Triangulation<1> &,
- const Point<1> &,
- const double)
-{
- Assert (false, ExcNotImplemented());
-}
+ std::vector<CellData<2> > cells (1, CellData<2> ());
+ for (unsigned int i = 0; i < GeometryInfo<2>::vertices_per_cell; ++i)
+ cells[0].vertices[i] = cell_vertices[0][i];
-template <>
-void
-GridGenerator::half_hyper_shell (Triangulation<1> &,
- const Point<1> &,
- const double,
- const double,
- const size_type ,
- const bool)
-{
- Assert (false, ExcNotImplemented());
-}
+ cells[0].material_id = 0;
+ triangulation.create_triangulation (vertices, cells, SubCellData ());
-template <>
-void GridGenerator::quarter_hyper_shell (Triangulation<1> &,
- const Point<1> &,
- const double,
- const double,
- const size_type ,
- const bool)
-{
- Assert (false, ExcNotImplemented());
-}
+ Triangulation<2>::cell_iterator cell = triangulation.begin ();
-template <>
-void GridGenerator::enclosed_hyper_cube (Triangulation<2> &tria,
- const double left,
- const double right,
- const double thickness,
- const bool colorize)
-{
- Assert(left<right,
- ExcMessage ("Invalid left-to-right bounds of enclosed hypercube"));
-
- std::vector<Point<2> > vertices(16);
- double coords[4];
- coords[0] = left-thickness;
- coords[1] = left;
- coords[2] = right;
- coords[3] = right+thickness;
-
- unsigned int k=0;
- for (unsigned int i0=0; i0<4; ++i0)
- for (unsigned int i1=0; i1<4; ++i1)
- vertices[k++] = Point<2>(coords[i1], coords[i0]);
-
- const types::material_id materials[9] = { 5, 4, 6,
- 1, 0, 2,
- 9, 8,10
- };
-
- std::vector<CellData<2> > cells(9);
- k = 0;
- for (unsigned int i0=0; i0<3; ++i0)
- for (unsigned int i1=0; i1<3; ++i1)
- {
- cells[k].vertices[0] = i1+4*i0;
- cells[k].vertices[1] = i1+4*i0+1;
- cells[k].vertices[2] = i1+4*i0+4;
- cells[k].vertices[3] = i1+4*i0+5;
- if (colorize)
- cells[k].material_id = materials[k];
- ++k;
- }
- tria.create_triangulation (vertices,
- cells,
- SubCellData()); // no boundary information
-}
+ cell->face (0)->set_boundary_indicator (1);
+ cell->face (1)->set_boundary_indicator (2);
+
+ for (unsigned int i = 2; i < 4; ++i)
+ cell->face (i)->set_boundary_indicator (0);
+ }
+//TODO: Colorize edges as circumference, left and right radius
// Implementation for 2D only
-template <>
-void
-GridGenerator::hyper_cube_slit (Triangulation<2> &tria,
- const double left,
- const double right,
- const bool colorize)
-{
- const double rl2=(right+left)/2;
- const Point<2> vertices[10] = { Point<2>(left, left ),
- Point<2>(rl2, left ),
- Point<2>(rl2, rl2 ),
- Point<2>(left, rl2 ),
- Point<2>(right,left ),
- Point<2>(right,rl2 ),
- Point<2>(rl2, right),
- Point<2>(left, right),
- Point<2>(right,right),
- Point<2>(rl2, left )
- };
- const int cell_vertices[4][4] = { { 0,1,3,2 },
- { 9,4,2,5 },
- { 3,2,7,6 },
- { 2,5,6,8 }
- };
- std::vector<CellData<2> > cells (4, CellData<2>());
- for (unsigned int i=0; i<4; ++i)
- {
- for (unsigned int j=0; j<4; ++j)
- cells[i].vertices[j] = cell_vertices[i][j];
- cells[i].material_id = 0;
+ template <>
+ void
+ hyper_L (Triangulation<2> &tria,
+ const double a,
+ const double b)
+ {
+ const Point<2> vertices[8] = { Point<2> (a,a),
+ Point<2> ((a+b)/2,a),
+ Point<2> (b,a),
+ Point<2> (a,(a+b)/2),
+ Point<2> ((a+b)/2,(a+b)/2),
+ Point<2> (b,(a+b)/2),
+ Point<2> (a,b),
+ Point<2> ((a+b)/2,b)
+ };
+ const int cell_vertices[3][4] = {{0, 1, 3, 4},
+ {1, 2, 4, 5},
+ {3, 4, 6, 7}
};
- tria.create_triangulation (
- std::vector<Point<2> >(&vertices[0], &vertices[10]),
- cells,
- SubCellData()); // no boundary information
- if (colorize)
- {
- Triangulation<2>::cell_iterator cell = tria.begin();
- cell->face(1)->set_boundary_indicator(1);
- ++cell;
- cell->face(3)->set_boundary_indicator(2);
- }
-}
+ std::vector<CellData<2> > cells (3, CellData<2>());
+ for (unsigned int i=0; i<3; ++i)
+ {
+ for (unsigned int j=0; j<4; ++j)
+ cells[i].vertices[j] = cell_vertices[i][j];
+ cells[i].material_id = 0;
+ };
+ tria.create_triangulation (
+ std::vector<Point<2> >(&vertices[0], &vertices[8]),
+ cells,
+ SubCellData()); // no boundary information
+ }
-template <>
-void GridGenerator::truncated_cone (Triangulation<2> &triangulation,
- const double radius_0,
- const double radius_1,
- const double half_length)
-{
- Point<2> vertices_tmp[4];
- vertices_tmp[0] = Point<2> (-half_length, -radius_0);
- vertices_tmp[1] = Point<2> (half_length, -radius_1);
- vertices_tmp[2] = Point<2> (-half_length, radius_0);
- vertices_tmp[3] = Point<2> (half_length, radius_1);
- const std::vector<Point<2> > vertices (&vertices_tmp[0], &vertices_tmp[4]);
- unsigned int cell_vertices[1][GeometryInfo<2>::vertices_per_cell];
+// Implementation for 2D only
+ template <>
+ void
+ hyper_ball (Triangulation<2> &tria,
+ const Point<2> &p,
+ const double radius)
+ {
+ // equilibrate cell sizes at
+ // transition from the inner part
+ // to the radial cells
+ const double a = 1./(1+std::sqrt(2.0));
+ const Point<2> vertices[8] = { p+Point<2>(-1,-1) *(radius/std::sqrt(2.0)),
+ p+Point<2>(+1,-1) *(radius/std::sqrt(2.0)),
+ p+Point<2>(-1,-1) *(radius/std::sqrt(2.0)*a),
+ p+Point<2>(+1,-1) *(radius/std::sqrt(2.0)*a),
+ p+Point<2>(-1,+1) *(radius/std::sqrt(2.0)*a),
+ p+Point<2>(+1,+1) *(radius/std::sqrt(2.0)*a),
+ p+Point<2>(-1,+1) *(radius/std::sqrt(2.0)),
+ p+Point<2>(+1,+1) *(radius/std::sqrt(2.0))
+ };
+
+ const int cell_vertices[5][4] = {{0, 1, 2, 3},
+ {0, 2, 6, 4},
+ {2, 3, 4, 5},
+ {1, 7, 3, 5},
+ {6, 4, 7, 5}
+ };
- for (unsigned int i = 0; i < GeometryInfo<2>::vertices_per_cell; ++i)
- cell_vertices[0][i] = i;
+ std::vector<CellData<2> > cells (5, CellData<2>());
- std::vector<CellData<2> > cells (1, CellData<2> ());
+ for (unsigned int i=0; i<5; ++i)
+ {
+ for (unsigned int j=0; j<4; ++j)
+ cells[i].vertices[j] = cell_vertices[i][j];
+ cells[i].material_id = 0;
+ };
- for (unsigned int i = 0; i < GeometryInfo<2>::vertices_per_cell; ++i)
- cells[0].vertices[i] = cell_vertices[0][i];
+ tria.create_triangulation (
+ std::vector<Point<2> >(&vertices[0], &vertices[8]),
+ cells,
+ SubCellData()); // no boundary information
+ }
- cells[0].material_id = 0;
- triangulation.create_triangulation (vertices, cells, SubCellData ());
- Triangulation<2>::cell_iterator cell = triangulation.begin ();
- cell->face (0)->set_boundary_indicator (1);
- cell->face (1)->set_boundary_indicator (2);
+ template <>
+ void hyper_shell (Triangulation<2> &tria,
+ const Point<2> ¢er,
+ const double inner_radius,
+ const double outer_radius,
+ const unsigned int n_cells,
+ const bool colorize)
+ {
+ Assert ((inner_radius > 0) && (inner_radius < outer_radius),
+ ExcInvalidRadii ());
+
+ const double pi = numbers::PI;
+
+ // determine the number of cells
+ // for the grid. if not provided by
+ // the user determine it such that
+ // the length of each cell on the
+ // median (in the middle between
+ // the two circles) is equal to its
+ // radial extent (which is the
+ // difference between the two
+ // radii)
+ const unsigned int N = (n_cells == 0 ?
+ static_cast<unsigned int>
+ (std::ceil((2*pi* (outer_radius + inner_radius)/2) /
+ (outer_radius - inner_radius))) :
+ n_cells);
+
+ // set up N vertices on the
+ // outer and N vertices on
+ // the inner circle. the
+ // first N ones are on the
+ // outer one, and all are
+ // numbered counter-clockwise
+ std::vector<Point<2> > vertices(2*N);
+ for (unsigned int i=0; i<N; ++i)
+ {
+ vertices[i] = Point<2>( std::cos(2*pi * i/N),
+ std::sin(2*pi * i/N)) * outer_radius;
+ vertices[i+N] = vertices[i] * (inner_radius/outer_radius);
- for (unsigned int i = 2; i < 4; ++i)
- cell->face (i)->set_boundary_indicator (0);
-}
+ vertices[i] += center;
+ vertices[i+N] += center;
+ };
+ std::vector<CellData<2> > cells (N, CellData<2>());
+ for (unsigned int i=0; i<N; ++i)
+ {
+ cells[i].vertices[0] = i;
+ cells[i].vertices[1] = (i+1)%N;
+ cells[i].vertices[2] = N+i;
+ cells[i].vertices[3] = N+((i+1)%N);
-//TODO: Colorize edges as circumference, left and right radius
-// Implementation for 2D only
-template <>
-void
-GridGenerator::hyper_L (Triangulation<2> &tria,
- const double a,
- const double b)
-{
- const Point<2> vertices[8] = { Point<2> (a,a),
- Point<2> ((a+b)/2,a),
- Point<2> (b,a),
- Point<2> (a,(a+b)/2),
- Point<2> ((a+b)/2,(a+b)/2),
- Point<2> (b,(a+b)/2),
- Point<2> (a,b),
- Point<2> ((a+b)/2,b)
- };
- const int cell_vertices[3][4] = {{0, 1, 3, 4},
- {1, 2, 4, 5},
- {3, 4, 6, 7}
- };
-
- std::vector<CellData<2> > cells (3, CellData<2>());
-
- for (unsigned int i=0; i<3; ++i)
- {
- for (unsigned int j=0; j<4; ++j)
- cells[i].vertices[j] = cell_vertices[i][j];
- cells[i].material_id = 0;
- };
+ cells[i].material_id = 0;
+ };
- tria.create_triangulation (
- std::vector<Point<2> >(&vertices[0], &vertices[8]),
- cells,
- SubCellData()); // no boundary information
-}
+ tria.create_triangulation (
+ vertices, cells, SubCellData());
+ if (colorize)
+ colorize_hyper_shell(tria, center, inner_radius, outer_radius);
+ }
// Implementation for 2D only
-template <>
-void
-GridGenerator::hyper_ball (Triangulation<2> &tria,
- const Point<2> &p,
- const double radius)
-{
- // equilibrate cell sizes at
- // transition from the inner part
- // to the radial cells
- const double a = 1./(1+std::sqrt(2.0));
- const Point<2> vertices[8] = { p+Point<2>(-1,-1) *(radius/std::sqrt(2.0)),
- p+Point<2>(+1,-1) *(radius/std::sqrt(2.0)),
- p+Point<2>(-1,-1) *(radius/std::sqrt(2.0)*a),
- p+Point<2>(+1,-1) *(radius/std::sqrt(2.0)*a),
- p+Point<2>(-1,+1) *(radius/std::sqrt(2.0)*a),
- p+Point<2>(+1,+1) *(radius/std::sqrt(2.0)*a),
- p+Point<2>(-1,+1) *(radius/std::sqrt(2.0)),
- p+Point<2>(+1,+1) *(radius/std::sqrt(2.0))
- };
-
- const int cell_vertices[5][4] = {{0, 1, 2, 3},
- {0, 2, 6, 4},
- {2, 3, 4, 5},
- {1, 7, 3, 5},
- {6, 4, 7, 5}
- };
-
- std::vector<CellData<2> > cells (5, CellData<2>());
-
- for (unsigned int i=0; i<5; ++i)
- {
- for (unsigned int j=0; j<4; ++j)
- cells[i].vertices[j] = cell_vertices[i][j];
- cells[i].material_id = 0;
- };
+ template <>
+ void
+ cylinder (Triangulation<2> &tria,
+ const double radius,
+ const double half_length)
+ {
+ Point<2> p1 (-half_length, -radius);
+ Point<2> p2 (half_length, radius);
- tria.create_triangulation (
- std::vector<Point<2> >(&vertices[0], &vertices[8]),
- cells,
- SubCellData()); // no boundary information
-}
+ hyper_rectangle(tria, p1, p2, true);
+
+ Triangulation<2>::face_iterator f = tria.begin_face();
+ Triangulation<2>::face_iterator end = tria.end_face();
+ while (f != end)
+ {
+ switch (f->boundary_indicator())
+ {
+ case 0:
+ f->set_boundary_indicator(1);
+ break;
+ case 1:
+ f->set_boundary_indicator(2);
+ break;
+ default:
+ f->set_boundary_indicator(0);
+ break;
+ }
+ ++f;
+ }
+ }
// Implementation for 2D only
-template<>
-void
-GridGenerator::colorize_hyper_shell (
- Triangulation<2> &tria,
- const Point<2> &, const double, const double)
-{
- // In spite of receiving geometrical
- // data, we do this only based on
- // topology.
-
- // For the mesh based on cube,
- // this is highly irregular
- for (Triangulation<2>::cell_iterator cell = tria.begin();
- cell != tria.end(); ++cell)
- {
- Assert (cell->face(2)->at_boundary(), ExcInternalError());
- cell->face(2)->set_boundary_indicator(1);
- }
-}
-
+ template <>
+ void cylinder_shell (Triangulation<2> &,
+ const double,
+ const double,
+ const double,
+ const unsigned int,
+ const unsigned int)
+ {
+ Assert (false, ExcNotImplemented());
+ }
-template <>
-void GridGenerator::hyper_shell (Triangulation<2> &tria,
- const Point<2> ¢er,
- const double inner_radius,
- const double outer_radius,
- const size_type n_cells,
- const bool colorize)
-{
- Assert ((inner_radius > 0) && (inner_radius < outer_radius),
- ExcInvalidRadii ());
-
- const double pi = numbers::PI;
-
- // determine the number of cells
- // for the grid. if not provided by
- // the user determine it such that
- // the length of each cell on the
- // median (in the middle between
- // the two circles) is equal to its
- // radial extent (which is the
- // difference between the two
- // radii)
- const size_type N = (n_cells == 0 ?
- static_cast<size_type>
- (std::ceil((2*pi* (outer_radius + inner_radius)/2) /
- (outer_radius - inner_radius))) :
- n_cells);
-
- // set up N vertices on the
- // outer and N vertices on
- // the inner circle. the
- // first N ones are on the
- // outer one, and all are
- // numbered counter-clockwise
- std::vector<Point<2> > vertices(2*N);
- for (size_type i=0; i<N; ++i)
- {
- vertices[i] = Point<2>( std::cos(2*pi * i/N),
- std::sin(2*pi * i/N)) * outer_radius;
- vertices[i+N] = vertices[i] * (inner_radius/outer_radius);
- vertices[i] += center;
- vertices[i+N] += center;
+ template <>
+ void
+ half_hyper_ball (Triangulation<2> &tria,
+ const Point<2> &p,
+ const double radius)
+ {
+ // equilibrate cell sizes at
+ // transition from the inner part
+ // to the radial cells
+ const double a = 1./(1+std::sqrt(2.0));
+ const Point<2> vertices[8] = { p+Point<2>(0,-1) *radius,
+ p+Point<2>(+1,-1) *(radius/std::sqrt(2.0)),
+ p+Point<2>(0,-1) *(radius/std::sqrt(2.0)*a),
+ p+Point<2>(+1,-1) *(radius/std::sqrt(2.0)*a),
+ p+Point<2>(0,+1) *(radius/std::sqrt(2.0)*a),
+ p+Point<2>(+1,+1) *(radius/std::sqrt(2.0)*a),
+ p+Point<2>(0,+1) *radius,
+ p+Point<2>(+1,+1) *(radius/std::sqrt(2.0))
+ };
+
+ const int cell_vertices[5][4] = {{0, 1, 2, 3},
+ {2, 3, 4, 5},
+ {1, 7, 3, 5},
+ {6, 4, 7, 5}
};
- std::vector<CellData<2> > cells (N, CellData<2>());
-
- for (size_type i=0; i<N; ++i)
- {
- cells[i].vertices[0] = i;
- cells[i].vertices[1] = (i+1)%N;
- cells[i].vertices[2] = N+i;
- cells[i].vertices[3] = N+((i+1)%N);
-
- cells[i].material_id = 0;
- };
+ std::vector<CellData<2> > cells (4, CellData<2>());
- tria.create_triangulation (
- vertices, cells, SubCellData());
+ for (unsigned int i=0; i<4; ++i)
+ {
+ for (unsigned int j=0; j<4; ++j)
+ cells[i].vertices[j] = cell_vertices[i][j];
+ cells[i].material_id = 0;
+ };
- if (colorize)
- colorize_hyper_shell(tria, center, inner_radius, outer_radius);
-}
+ tria.create_triangulation (
+ std::vector<Point<2> >(&vertices[0], &vertices[8]),
+ cells,
+ SubCellData()); // no boundary information
+ Triangulation<2>::cell_iterator cell = tria.begin();
+ Triangulation<2>::cell_iterator end = tria.end();
-// Implementation for 2D only
-template <>
-void
-GridGenerator::cylinder (Triangulation<2> &tria,
- const double radius,
- const double half_length)
-{
- Point<2> p1 (-half_length, -radius);
- Point<2> p2 (half_length, radius);
- hyper_rectangle(tria, p1, p2, true);
+ while (cell != end)
+ {
+ for (unsigned int i=0; i<GeometryInfo<2>::faces_per_cell; ++i)
+ {
+ if (cell->face(i)->boundary_indicator() == numbers::internal_face_boundary_id)
+ continue;
- Triangulation<2>::face_iterator f = tria.begin_face();
- Triangulation<2>::face_iterator end = tria.end_face();
- while (f != end)
- {
- switch (f->boundary_indicator())
- {
- case 0:
- f->set_boundary_indicator(1);
- break;
- case 1:
- f->set_boundary_indicator(2);
- break;
- default:
- f->set_boundary_indicator(0);
- break;
- }
- ++f;
- }
-}
+ // If x is zero, then this is part of the plane
+ if (cell->face(i)->center()(0) < p(0)+1.e-5)
+ cell->face(i)->set_boundary_indicator(1);
+ }
+ ++cell;
+ }
+ }
// Implementation for 2D only
-template <>
-void GridGenerator::cylinder_shell (Triangulation<2> &,
- const double,
- const double,
- const double,
- const size_type,
- const size_type)
-{
- Assert (false, ExcNotImplemented());
-}
+ template <>
+ void
+ half_hyper_shell (Triangulation<2> &tria,
+ const Point<2> ¢er,
+ const double inner_radius,
+ const double outer_radius,
+ const unsigned int n_cells,
+ const bool colorize)
+ {
+ Assert ((inner_radius > 0) && (inner_radius < outer_radius),
+ ExcInvalidRadii ());
+
+ const double pi = numbers::PI;
+ // determine the number of cells
+ // for the grid. if not provided by
+ // the user determine it such that
+ // the length of each cell on the
+ // median (in the middle between
+ // the two circles) is equal to its
+ // radial extent (which is the
+ // difference between the two
+ // radii)
+ const unsigned int N = (n_cells == 0 ?
+ static_cast<unsigned int>
+ (std::ceil((pi* (outer_radius + inner_radius)/2) /
+ (outer_radius - inner_radius))) :
+ n_cells);
+
+ // set up N+1 vertices on the
+ // outer and N+1 vertices on
+ // the inner circle. the
+ // first N+1 ones are on the
+ // outer one, and all are
+ // numbered counter-clockwise
+ std::vector<Point<2> > vertices(2*(N+1));
+ for (unsigned int i=0; i<=N; ++i)
+ {
+ // enforce that the x-coordinates
+ // of the first and last point of
+ // each half-circle are exactly
+ // zero (contrary to what we may
+ // compute using the imprecise
+ // value of pi)
+ vertices[i] = Point<2>( ( (i==0) || (i==N) ?
+ 0 :
+ std::cos(pi * i/N - pi/2) ),
+ std::sin(pi * i/N - pi/2)) * outer_radius;
+ vertices[i+N+1] = vertices[i] * (inner_radius/outer_radius);
+
+ vertices[i] += center;
+ vertices[i+N+1] += center;
+ };
-template <>
-void
-GridGenerator::half_hyper_ball (Triangulation<2> &tria,
- const Point<2> &p,
- const double radius)
-{
- // equilibrate cell sizes at
- // transition from the inner part
- // to the radial cells
- const double a = 1./(1+std::sqrt(2.0));
- const Point<2> vertices[8] = { p+Point<2>(0,-1) *radius,
- p+Point<2>(+1,-1) *(radius/std::sqrt(2.0)),
- p+Point<2>(0,-1) *(radius/std::sqrt(2.0)*a),
- p+Point<2>(+1,-1) *(radius/std::sqrt(2.0)*a),
- p+Point<2>(0,+1) *(radius/std::sqrt(2.0)*a),
- p+Point<2>(+1,+1) *(radius/std::sqrt(2.0)*a),
- p+Point<2>(0,+1) *radius,
- p+Point<2>(+1,+1) *(radius/std::sqrt(2.0))
- };
-
- const int cell_vertices[5][4] = {{0, 1, 2, 3},
- {2, 3, 4, 5},
- {1, 7, 3, 5},
- {6, 4, 7, 5}
- };
-
- std::vector<CellData<2> > cells (4, CellData<2>());
-
- for (unsigned int i=0; i<4; ++i)
- {
- for (unsigned int j=0; j<4; ++j)
- cells[i].vertices[j] = cell_vertices[i][j];
- cells[i].material_id = 0;
- };
+ std::vector<CellData<2> > cells (N, CellData<2>());
- tria.create_triangulation (
- std::vector<Point<2> >(&vertices[0], &vertices[8]),
- cells,
- SubCellData()); // no boundary information
+ for (unsigned int i=0; i<N; ++i)
+ {
+ cells[i].vertices[0] = i;
+ cells[i].vertices[1] = (i+1)%(N+1);
+ cells[i].vertices[2] = N+1+i;
+ cells[i].vertices[3] = N+1+((i+1)%(N+1));
- Triangulation<2>::cell_iterator cell = tria.begin();
- Triangulation<2>::cell_iterator end = tria.end();
+ cells[i].material_id = 0;
+ };
+ tria.create_triangulation (vertices, cells, SubCellData());
- while (cell != end)
- {
- for (unsigned int i=0; i<GeometryInfo<2>::faces_per_cell; ++i)
- {
- if (cell->face(i)->boundary_indicator() == numbers::internal_face_boundary_id)
- continue;
+ if (colorize)
+ {
+ Triangulation<2>::cell_iterator cell = tria.begin();
+ for (; cell!=tria.end(); ++cell)
+ {
+ cell->face(2)->set_boundary_indicator(1);
+ }
+ tria.begin()->face(0)->set_boundary_indicator(3);
- // If x is zero, then this is part of the plane
- if (cell->face(i)->center()(0) < p(0)+1.e-5)
- cell->face(i)->set_boundary_indicator(1);
- }
- ++cell;
- }
-}
+ tria.last()->face(1)->set_boundary_indicator(2);
+ }
+ }
+ template <>
+ void quarter_hyper_shell (Triangulation<2> &tria,
+ const Point<2> ¢er,
+ const double inner_radius,
+ const double outer_radius,
+ const unsigned int n_cells,
+ const bool colorize)
+ {
+ Assert ((inner_radius > 0) && (inner_radius < outer_radius),
+ ExcInvalidRadii ());
+
+ const double pi = numbers::PI;
+ // determine the number of cells
+ // for the grid. if not provided by
+ // the user determine it such that
+ // the length of each cell on the
+ // median (in the middle between
+ // the two circles) is equal to its
+ // radial extent (which is the
+ // difference between the two
+ // radii)
+ const unsigned int N = (n_cells == 0 ?
+ static_cast<unsigned int>
+ (std::ceil((pi* (outer_radius + inner_radius)/4) /
+ (outer_radius - inner_radius))) :
+ n_cells);
+
+ // set up N+1 vertices on the
+ // outer and N+1 vertices on
+ // the inner circle. the
+ // first N+1 ones are on the
+ // outer one, and all are
+ // numbered counter-clockwise
+ std::vector<Point<2> > vertices(2*(N+1));
+ for (unsigned int i=0; i<=N; ++i)
+ {
+ // enforce that the x-coordinates
+ // of the last point is exactly
+ // zero (contrary to what we may
+ // compute using the imprecise
+ // value of pi)
+ vertices[i] = Point<2>( ( (i==N) ?
+ 0 :
+ std::cos(pi * i/N/2) ),
+ std::sin(pi * i/N/2)) * outer_radius;
+ vertices[i+N+1] = vertices[i] * (inner_radius/outer_radius);
+
+ vertices[i] += center;
+ vertices[i+N+1] += center;
+ };
-// Implementation for 2D only
-template <>
-void
-GridGenerator::half_hyper_shell (Triangulation<2> &tria,
- const Point<2> ¢er,
- const double inner_radius,
- const double outer_radius,
- const size_type n_cells,
- const bool colorize)
-{
- Assert ((inner_radius > 0) && (inner_radius < outer_radius),
- ExcInvalidRadii ());
-
- const double pi = numbers::PI;
- // determine the number of cells
- // for the grid. if not provided by
- // the user determine it such that
- // the length of each cell on the
- // median (in the middle between
- // the two circles) is equal to its
- // radial extent (which is the
- // difference between the two
- // radii)
- const size_type N = (n_cells == 0 ?
- static_cast<size_type>
- (std::ceil((pi* (outer_radius + inner_radius)/2) /
- (outer_radius - inner_radius))) :
- n_cells);
-
- // set up N+1 vertices on the
- // outer and N+1 vertices on
- // the inner circle. the
- // first N+1 ones are on the
- // outer one, and all are
- // numbered counter-clockwise
- std::vector<Point<2> > vertices(2*(N+1));
- for (size_type i=0; i<=N; ++i)
- {
- // enforce that the x-coordinates
- // of the first and last point of
- // each half-circle are exactly
- // zero (contrary to what we may
- // compute using the imprecise
- // value of pi)
- vertices[i] = Point<2>( ( (i==0) || (i==N) ?
- 0 :
- std::cos(pi * i/N - pi/2) ),
- std::sin(pi * i/N - pi/2)) * outer_radius;
- vertices[i+N+1] = vertices[i] * (inner_radius/outer_radius);
-
- vertices[i] += center;
- vertices[i+N+1] += center;
- };
+ std::vector<CellData<2> > cells (N, CellData<2>());
- std::vector<CellData<2> > cells (N, CellData<2>());
+ for (unsigned int i=0; i<N; ++i)
+ {
+ cells[i].vertices[0] = i;
+ cells[i].vertices[1] = (i+1)%(N+1);
+ cells[i].vertices[2] = N+1+i;
+ cells[i].vertices[3] = N+1+((i+1)%(N+1));
- for (size_type i=0; i<N; ++i)
- {
- cells[i].vertices[0] = i;
- cells[i].vertices[1] = (i+1)%(N+1);
- cells[i].vertices[2] = N+1+i;
- cells[i].vertices[3] = N+1+((i+1)%(N+1));
+ cells[i].material_id = 0;
+ };
- cells[i].material_id = 0;
- };
+ tria.create_triangulation (vertices, cells, SubCellData());
- tria.create_triangulation (vertices, cells, SubCellData());
+ if (colorize)
+ {
+ Triangulation<2>::cell_iterator cell = tria.begin();
+ for (; cell!=tria.end(); ++cell)
+ {
+ cell->face(2)->set_boundary_indicator(1);
+ }
+ tria.begin()->face(0)->set_boundary_indicator(3);
- if (colorize)
- {
- Triangulation<2>::cell_iterator cell = tria.begin();
- for (; cell!=tria.end(); ++cell)
- {
- cell->face(2)->set_boundary_indicator(1);
- }
- tria.begin()->face(0)->set_boundary_indicator(3);
+ tria.last()->face(1)->set_boundary_indicator(2);
+ }
+ }
- tria.last()->face(1)->set_boundary_indicator(2);
- }
-}
-template <>
-void GridGenerator::quarter_hyper_shell (Triangulation<2> &tria,
- const Point<2> ¢er,
- const double inner_radius,
- const double outer_radius,
- const size_type n_cells,
- const bool colorize)
-{
- Assert ((inner_radius > 0) && (inner_radius < outer_radius),
- ExcInvalidRadii ());
-
- const double pi = numbers::PI;
- // determine the number of cells
- // for the grid. if not provided by
- // the user determine it such that
- // the length of each cell on the
- // median (in the middle between
- // the two circles) is equal to its
- // radial extent (which is the
- // difference between the two
- // radii)
- const size_type N = (n_cells == 0 ?
- static_cast<size_type>
- (std::ceil((pi* (outer_radius + inner_radius)/4) /
- (outer_radius - inner_radius))) :
- n_cells);
-
- // set up N+1 vertices on the
- // outer and N+1 vertices on
- // the inner circle. the
- // first N+1 ones are on the
- // outer one, and all are
- // numbered counter-clockwise
- std::vector<Point<2> > vertices(2*(N+1));
- for (size_type i=0; i<=N; ++i)
- {
- // enforce that the x-coordinates
- // of the last point is exactly
- // zero (contrary to what we may
- // compute using the imprecise
- // value of pi)
- vertices[i] = Point<2>( ( (i==N) ?
- 0 :
- std::cos(pi * i/N/2) ),
- std::sin(pi * i/N/2)) * outer_radius;
- vertices[i+N+1] = vertices[i] * (inner_radius/outer_radius);
-
- vertices[i] += center;
- vertices[i+N+1] += center;
+// Implementation for 3D only
+ template <>
+ void hyper_cube_slit (Triangulation<3> &tria,
+ const double left,
+ const double right,
+ const bool colorize)
+ {
+ const double rl2=(right+left)/2;
+ const double len = (right-left)/2.;
+
+ const Point<3> vertices[20] =
+ {
+ Point<3>(left, left , -len/2.),
+ Point<3>(rl2, left , -len/2.),
+ Point<3>(rl2, rl2 , -len/2.),
+ Point<3>(left, rl2 , -len/2.),
+ Point<3>(right,left , -len/2.),
+ Point<3>(right,rl2 , -len/2.),
+ Point<3>(rl2, right, -len/2.),
+ Point<3>(left, right, -len/2.),
+ Point<3>(right,right, -len/2.),
+ Point<3>(rl2, left , -len/2.),
+ Point<3>(left, left , len/2.),
+ Point<3>(rl2, left , len/2.),
+ Point<3>(rl2, rl2 , len/2.),
+ Point<3>(left, rl2 , len/2.),
+ Point<3>(right,left , len/2.),
+ Point<3>(right,rl2 , len/2.),
+ Point<3>(rl2, right, len/2.),
+ Point<3>(left, right, len/2.),
+ Point<3>(right,right, len/2.),
+ Point<3>(rl2, left , len/2.)
};
-
-
- std::vector<CellData<2> > cells (N, CellData<2>());
-
- for (size_type i=0; i<N; ++i)
- {
- cells[i].vertices[0] = i;
- cells[i].vertices[1] = (i+1)%(N+1);
- cells[i].vertices[2] = N+1+i;
- cells[i].vertices[3] = N+1+((i+1)%(N+1));
-
- cells[i].material_id = 0;
+ const int cell_vertices[4][8] = { { 0,1,3,2, 10, 11, 13, 12 },
+ { 9,4,2,5, 19,14, 12, 15 },
+ { 3,2,7,6,13,12,17,16 },
+ { 2,5,6,8,12,15,16,18 }
};
+ std::vector<CellData<3> > cells (4, CellData<3>());
+ for (unsigned int i=0; i<4; ++i)
+ {
+ for (unsigned int j=0; j<8; ++j)
+ cells[i].vertices[j] = cell_vertices[i][j];
+ cells[i].material_id = 0;
+ };
+ tria.create_triangulation (
+ std::vector<Point<3> >(&vertices[0], &vertices[20]),
+ cells,
+ SubCellData()); // no boundary information
- tria.create_triangulation (vertices, cells, SubCellData());
-
- if (colorize)
- {
- Triangulation<2>::cell_iterator cell = tria.begin();
- for (; cell!=tria.end(); ++cell)
- {
- cell->face(2)->set_boundary_indicator(1);
- }
- tria.begin()->face(0)->set_boundary_indicator(3);
-
- tria.last()->face(1)->set_boundary_indicator(2);
- }
-}
+ if (colorize)
+ {
+ Assert(false, ExcNotImplemented());
+ Triangulation<3>::cell_iterator cell = tria.begin();
+ cell->face(1)->set_boundary_indicator(1);
+ ++cell;
+ cell->face(3)->set_boundary_indicator(2);
+ }
+ }
// Implementation for 3D only
-template <>
-void GridGenerator::hyper_cube_slit (Triangulation<3> &tria,
- const double left,
- const double right,
- const bool colorize)
-{
- const double rl2=(right+left)/2;
- const double len = (right-left)/2.;
-
- const Point<3> vertices[20] =
+ template <>
+ void enclosed_hyper_cube (Triangulation<3> &tria,
+ const double left,
+ const double right,
+ const double thickness,
+ const bool colorize)
{
- Point<3>(left, left , -len/2.),
- Point<3>(rl2, left , -len/2.),
- Point<3>(rl2, rl2 , -len/2.),
- Point<3>(left, rl2 , -len/2.),
- Point<3>(right,left , -len/2.),
- Point<3>(right,rl2 , -len/2.),
- Point<3>(rl2, right, -len/2.),
- Point<3>(left, right, -len/2.),
- Point<3>(right,right, -len/2.),
- Point<3>(rl2, left , -len/2.),
- Point<3>(left, left , len/2.),
- Point<3>(rl2, left , len/2.),
- Point<3>(rl2, rl2 , len/2.),
- Point<3>(left, rl2 , len/2.),
- Point<3>(right,left , len/2.),
- Point<3>(right,rl2 , len/2.),
- Point<3>(rl2, right, len/2.),
- Point<3>(left, right, len/2.),
- Point<3>(right,right, len/2.),
- Point<3>(rl2, left , len/2.)
- };
- const int cell_vertices[4][8] = { { 0,1,3,2, 10, 11, 13, 12 },
- { 9,4,2,5, 19,14, 12, 15 },
- { 3,2,7,6,13,12,17,16 },
- { 2,5,6,8,12,15,16,18 }
- };
- std::vector<CellData<3> > cells (4, CellData<3>());
- for (unsigned int i=0; i<4; ++i)
- {
- for (unsigned int j=0; j<8; ++j)
- cells[i].vertices[j] = cell_vertices[i][j];
- cells[i].material_id = 0;
+ Assert(left<right,
+ ExcMessage ("Invalid left-to-right bounds of enclosed hypercube"));
+
+ std::vector<Point<3> > vertices(64);
+ double coords[4];
+ coords[0] = left-thickness;
+ coords[1] = left;
+ coords[2] = right;
+ coords[3] = right+thickness;
+
+ unsigned int k=0;
+ for (unsigned int z=0; z<4; ++z)
+ for (unsigned int y=0; y<4; ++y)
+ for (unsigned int x=0; x<4; ++x)
+ vertices[k++] = Point<3>(coords[x], coords[y], coords[z]);
+
+ const types::material_id materials[27] =
+ {
+ 21,20,22,
+ 17,16,18,
+ 25,24,26,
+ 5 , 4, 6,
+ 1 , 0, 2,
+ 9 , 8,10,
+ 37,36,38,
+ 33,32,34,
+ 41,40,42
};
- tria.create_triangulation (
- std::vector<Point<3> >(&vertices[0], &vertices[20]),
- cells,
- SubCellData()); // no boundary information
- if (colorize)
- {
- Assert(false, ExcNotImplemented());
- Triangulation<3>::cell_iterator cell = tria.begin();
- cell->face(1)->set_boundary_indicator(1);
- ++cell;
- cell->face(3)->set_boundary_indicator(2);
- }
-}
+ std::vector<CellData<3> > cells(27);
+ k = 0;
+ for (unsigned int z=0; z<3; ++z)
+ for (unsigned int y=0; y<3; ++y)
+ for (unsigned int x=0; x<3; ++x)
+ {
+ cells[k].vertices[0] = x+4*y+16*z;
+ cells[k].vertices[1] = x+4*y+16*z+1;
+ cells[k].vertices[2] = x+4*y+16*z+4;
+ cells[k].vertices[3] = x+4*y+16*z+5;
+ cells[k].vertices[4] = x+4*y+16*z+16;
+ cells[k].vertices[5] = x+4*y+16*z+17;
+ cells[k].vertices[6] = x+4*y+16*z+20;
+ cells[k].vertices[7] = x+4*y+16*z+21;
+ if (colorize)
+ cells[k].material_id = materials[k];
+ ++k;
+ }
+ tria.create_triangulation (
+ vertices,
+ cells,
+ SubCellData()); // no boundary information
+ }
-// Implementation for 3D only
-template <>
-void GridGenerator::enclosed_hyper_cube (Triangulation<3> &tria,
- const double left,
- const double right,
- const double thickness,
- const bool colorize)
-{
- Assert(left<right,
- ExcMessage ("Invalid left-to-right bounds of enclosed hypercube"));
-
- std::vector<Point<3> > vertices(64);
- double coords[4];
- coords[0] = left-thickness;
- coords[1] = left;
- coords[2] = right;
- coords[3] = right+thickness;
-
- unsigned int k=0;
- for (unsigned int z=0; z<4; ++z)
- for (unsigned int y=0; y<4; ++y)
- for (unsigned int x=0; x<4; ++x)
- vertices[k++] = Point<3>(coords[x], coords[y], coords[z]);
-
- const types::material_id materials[27] =
+ template <>
+ void truncated_cone (Triangulation<3> &triangulation,
+ const double radius_0,
+ const double radius_1,
+ const double half_length)
{
- 21,20,22,
- 17,16,18,
- 25,24,26,
- 5 , 4, 6,
- 1 , 0, 2,
- 9 , 8,10,
- 37,36,38,
- 33,32,34,
- 41,40,42
- };
-
- std::vector<CellData<3> > cells(27);
- k = 0;
- for (unsigned int z=0; z<3; ++z)
- for (unsigned int y=0; y<3; ++y)
- for (unsigned int x=0; x<3; ++x)
- {
- cells[k].vertices[0] = x+4*y+16*z;
- cells[k].vertices[1] = x+4*y+16*z+1;
- cells[k].vertices[2] = x+4*y+16*z+4;
- cells[k].vertices[3] = x+4*y+16*z+5;
- cells[k].vertices[4] = x+4*y+16*z+16;
- cells[k].vertices[5] = x+4*y+16*z+17;
- cells[k].vertices[6] = x+4*y+16*z+20;
- cells[k].vertices[7] = x+4*y+16*z+21;
- if (colorize)
- cells[k].material_id = materials[k];
- ++k;
- }
- tria.create_triangulation (
- vertices,
- cells,
- SubCellData()); // no boundary information
-}
-
-
-
-template <>
-void GridGenerator::truncated_cone (Triangulation<3> &triangulation,
- const double radius_0,
- const double radius_1,
- const double half_length)
-{
- // Determine number of cells and vertices
- const size_type
- n_cells = static_cast<size_type>(std::floor (half_length /
- std::max (radius_0,
- radius_1) +
- 0.5));
- const size_type n_vertices = 4 * (n_cells + 1);
- std::vector<Point<3> > vertices_tmp(n_vertices);
-
- vertices_tmp[0] = Point<3> (-half_length, 0, -radius_0);
- vertices_tmp[1] = Point<3> (-half_length, radius_0, 0);
- vertices_tmp[2] = Point<3> (-half_length, -radius_0, 0);
- vertices_tmp[3] = Point<3> (-half_length, 0, radius_0);
-
- const double dx = 2 * half_length / n_cells;
-
- for (size_type i = 0; i < n_cells; ++i)
- {
- vertices_tmp[4 * (i + 1)]
- = vertices_tmp[4 * i] +
- Point<3> (dx, 0, 0.5 * (radius_0 - radius_1) * dx / half_length);
- vertices_tmp[4 * i + 5]
- = vertices_tmp[4 * i + 1] +
- Point<3> (dx, 0.5 * (radius_1 - radius_0) * dx / half_length, 0);
- vertices_tmp[4 * i + 6]
- = vertices_tmp[4 * i + 2] +
- Point<3> (dx, 0.5 * (radius_0 - radius_1) * dx / half_length, 0);
- vertices_tmp[4 * i + 7]
- = vertices_tmp[4 * i + 3] +
- Point<3> (dx, 0, 0.5 * (radius_1 - radius_0) * dx / half_length);
- }
+ // Determine number of cells and vertices
+ const unsigned int
+ n_cells = static_cast<unsigned int>(std::floor (half_length /
+ std::max (radius_0,
+ radius_1) +
+ 0.5));
+ const unsigned int n_vertices = 4 * (n_cells + 1);
+ std::vector<Point<3> > vertices_tmp(n_vertices);
+
+ vertices_tmp[0] = Point<3> (-half_length, 0, -radius_0);
+ vertices_tmp[1] = Point<3> (-half_length, radius_0, 0);
+ vertices_tmp[2] = Point<3> (-half_length, -radius_0, 0);
+ vertices_tmp[3] = Point<3> (-half_length, 0, radius_0);
+
+ const double dx = 2 * half_length / n_cells;
+
+ for (unsigned int i = 0; i < n_cells; ++i)
+ {
+ vertices_tmp[4 * (i + 1)]
+ = vertices_tmp[4 * i] +
+ Point<3> (dx, 0, 0.5 * (radius_0 - radius_1) * dx / half_length);
+ vertices_tmp[4 * i + 5]
+ = vertices_tmp[4 * i + 1] +
+ Point<3> (dx, 0.5 * (radius_1 - radius_0) * dx / half_length, 0);
+ vertices_tmp[4 * i + 6]
+ = vertices_tmp[4 * i + 2] +
+ Point<3> (dx, 0.5 * (radius_0 - radius_1) * dx / half_length, 0);
+ vertices_tmp[4 * i + 7]
+ = vertices_tmp[4 * i + 3] +
+ Point<3> (dx, 0, 0.5 * (radius_1 - radius_0) * dx / half_length);
+ }
- const std::vector<Point<3> > vertices (vertices_tmp.begin(),
- vertices_tmp.end());
- Table<2,unsigned int> cell_vertices(n_cells,GeometryInfo<3>::vertices_per_cell);
+ const std::vector<Point<3> > vertices (vertices_tmp.begin(),
+ vertices_tmp.end());
+ Table<2,unsigned int> cell_vertices(n_cells,GeometryInfo<3>::vertices_per_cell);
- for (size_type i = 0; i < n_cells; ++i)
- for (unsigned int j = 0; j < GeometryInfo<3>::vertices_per_cell; ++j)
- cell_vertices[i][j] = 4 * i + j;
+ for (unsigned int i = 0; i < n_cells; ++i)
+ for (unsigned int j = 0; j < GeometryInfo<3>::vertices_per_cell; ++j)
+ cell_vertices[i][j] = 4 * i + j;
- std::vector<CellData<3> > cells (n_cells, CellData<3> ());
+ std::vector<CellData<3> > cells (n_cells, CellData<3> ());
- for (size_type i = 0; i < n_cells; ++i)
- {
- for (unsigned int j = 0; j < GeometryInfo<3>::vertices_per_cell; ++j)
- cells[i].vertices[j] = cell_vertices[i][j];
+ for (unsigned int i = 0; i < n_cells; ++i)
+ {
+ for (unsigned int j = 0; j < GeometryInfo<3>::vertices_per_cell; ++j)
+ cells[i].vertices[j] = cell_vertices[i][j];
- cells[i].material_id = 0;
- }
+ cells[i].material_id = 0;
+ }
- triangulation.create_triangulation (vertices, cells, SubCellData ());
+ triangulation.create_triangulation (vertices, cells, SubCellData ());
- for (Triangulation<3>::cell_iterator cell = triangulation.begin ();
- cell != triangulation.end (); ++cell)
- {
- if (cell->vertex (0) (0) == -half_length)
- {
- cell->face (4)->set_boundary_indicator (1);
+ for (Triangulation<3>::cell_iterator cell = triangulation.begin ();
+ cell != triangulation.end (); ++cell)
+ {
+ if (cell->vertex (0) (0) == -half_length)
+ {
+ cell->face (4)->set_boundary_indicator (1);
- for (unsigned int i = 0; i < 4; ++i)
- cell->line (i)->set_boundary_indicator (0);
- }
+ for (unsigned int i = 0; i < 4; ++i)
+ cell->line (i)->set_boundary_indicator (0);
+ }
- if (cell->vertex (4) (0) == half_length)
- {
- cell->face (5)->set_boundary_indicator (2);
+ if (cell->vertex (4) (0) == half_length)
+ {
+ cell->face (5)->set_boundary_indicator (2);
- for (unsigned int i = 4; i < 8; ++i)
- cell->line (i)->set_boundary_indicator (0);
- }
+ for (unsigned int i = 4; i < 8; ++i)
+ cell->line (i)->set_boundary_indicator (0);
+ }
- for (unsigned int i = 0; i < 4; ++i)
- cell->face (i)->set_boundary_indicator (0);
- }
-}
+ for (unsigned int i = 0; i < 4; ++i)
+ cell->face (i)->set_boundary_indicator (0);
+ }
+ }
// Implementation for 3D only
-template <>
-void
-GridGenerator::hyper_L (Triangulation<3> &tria,
- const double a,
- const double b)
-{
- // we slice out the top back right
- // part of the cube
- const Point<3> vertices[26]
- =
+ template <>
+ void
+ hyper_L (Triangulation<3> &tria,
+ const double a,
+ const double b)
{
- // front face of the big cube
- Point<3> (a, a,a),
- Point<3> ((a+b)/2,a,a),
- Point<3> (b, a,a),
- Point<3> (a, a,(a+b)/2),
- Point<3> ((a+b)/2,a,(a+b)/2),
- Point<3> (b, a,(a+b)/2),
- Point<3> (a, a,b),
- Point<3> ((a+b)/2,a,b),
- Point<3> (b, a,b),
- // middle face of the big cube
- Point<3> (a, (a+b)/2,a),
- Point<3> ((a+b)/2,(a+b)/2,a),
- Point<3> (b, (a+b)/2,a),
- Point<3> (a, (a+b)/2,(a+b)/2),
- Point<3> ((a+b)/2,(a+b)/2,(a+b)/2),
- Point<3> (b, (a+b)/2,(a+b)/2),
- Point<3> (a, (a+b)/2,b),
- Point<3> ((a+b)/2,(a+b)/2,b),
- Point<3> (b, (a+b)/2,b),
- // back face of the big cube
- // last (top right) point is missing
- Point<3> (a, b,a),
- Point<3> ((a+b)/2,b,a),
- Point<3> (b, b,a),
- Point<3> (a, b,(a+b)/2),
- Point<3> ((a+b)/2,b,(a+b)/2),
- Point<3> (b, b,(a+b)/2),
- Point<3> (a, b,b),
- Point<3> ((a+b)/2,b,b)
- };
- const int cell_vertices[7][8] = {{0, 1, 9, 10, 3, 4, 12, 13},
- {1, 2, 10, 11, 4, 5, 13, 14},
- {3, 4, 12, 13, 6, 7, 15, 16},
- {4, 5, 13, 14, 7, 8, 16, 17},
- {9, 10, 18, 19, 12, 13, 21, 22},
- {10, 11, 19, 20, 13, 14, 22, 23},
- {12, 13, 21, 22, 15, 16, 24, 25}
- };
-
- std::vector<CellData<3> > cells (7, CellData<3>());
-
- for (unsigned int i=0; i<7; ++i)
- {
- for (unsigned int j=0; j<8; ++j)
- cells[i].vertices[j] = cell_vertices[i][j];
- cells[i].material_id = 0;
+ // we slice out the top back right
+ // part of the cube
+ const Point<3> vertices[26]
+ =
+ {
+ // front face of the big cube
+ Point<3> (a, a,a),
+ Point<3> ((a+b)/2,a,a),
+ Point<3> (b, a,a),
+ Point<3> (a, a,(a+b)/2),
+ Point<3> ((a+b)/2,a,(a+b)/2),
+ Point<3> (b, a,(a+b)/2),
+ Point<3> (a, a,b),
+ Point<3> ((a+b)/2,a,b),
+ Point<3> (b, a,b),
+ // middle face of the big cube
+ Point<3> (a, (a+b)/2,a),
+ Point<3> ((a+b)/2,(a+b)/2,a),
+ Point<3> (b, (a+b)/2,a),
+ Point<3> (a, (a+b)/2,(a+b)/2),
+ Point<3> ((a+b)/2,(a+b)/2,(a+b)/2),
+ Point<3> (b, (a+b)/2,(a+b)/2),
+ Point<3> (a, (a+b)/2,b),
+ Point<3> ((a+b)/2,(a+b)/2,b),
+ Point<3> (b, (a+b)/2,b),
+ // back face of the big cube
+ // last (top right) point is missing
+ Point<3> (a, b,a),
+ Point<3> ((a+b)/2,b,a),
+ Point<3> (b, b,a),
+ Point<3> (a, b,(a+b)/2),
+ Point<3> ((a+b)/2,b,(a+b)/2),
+ Point<3> (b, b,(a+b)/2),
+ Point<3> (a, b,b),
+ Point<3> ((a+b)/2,b,b)
+ };
+ const int cell_vertices[7][8] = {{0, 1, 9, 10, 3, 4, 12, 13},
+ {1, 2, 10, 11, 4, 5, 13, 14},
+ {3, 4, 12, 13, 6, 7, 15, 16},
+ {4, 5, 13, 14, 7, 8, 16, 17},
+ {9, 10, 18, 19, 12, 13, 21, 22},
+ {10, 11, 19, 20, 13, 14, 22, 23},
+ {12, 13, 21, 22, 15, 16, 24, 25}
};
- tria.create_triangulation (
- std::vector<Point<3> >(&vertices[0], &vertices[26]),
- cells,
- SubCellData()); // no boundary information
-}
-
-
+ std::vector<CellData<3> > cells (7, CellData<3>());
-// Implementation for 3D only
-template <>
-void
-GridGenerator::hyper_ball (Triangulation<3> &tria,
- const Point<3> &p,
- const double radius)
-{
- const double a = 1./(1+std::sqrt(3.0)); // equilibrate cell sizes at transition
- // from the inner part to the radial
- // cells
- const unsigned int n_vertices = 16;
- const Point<3> vertices[n_vertices]
- =
- {
- // first the vertices of the inner
- // cell
- p+Point<3>(-1,-1,-1) *(radius/std::sqrt(3.0)*a),
- p+Point<3>(+1,-1,-1) *(radius/std::sqrt(3.0)*a),
- p+Point<3>(+1,-1,+1) *(radius/std::sqrt(3.0)*a),
- p+Point<3>(-1,-1,+1) *(radius/std::sqrt(3.0)*a),
- p+Point<3>(-1,+1,-1) *(radius/std::sqrt(3.0)*a),
- p+Point<3>(+1,+1,-1) *(radius/std::sqrt(3.0)*a),
- p+Point<3>(+1,+1,+1) *(radius/std::sqrt(3.0)*a),
- p+Point<3>(-1,+1,+1) *(radius/std::sqrt(3.0)*a),
- // now the eight vertices at
- // the outer sphere
- p+Point<3>(-1,-1,-1) *(radius/std::sqrt(3.0)),
- p+Point<3>(+1,-1,-1) *(radius/std::sqrt(3.0)),
- p+Point<3>(+1,-1,+1) *(radius/std::sqrt(3.0)),
- p+Point<3>(-1,-1,+1) *(radius/std::sqrt(3.0)),
- p+Point<3>(-1,+1,-1) *(radius/std::sqrt(3.0)),
- p+Point<3>(+1,+1,-1) *(radius/std::sqrt(3.0)),
- p+Point<3>(+1,+1,+1) *(radius/std::sqrt(3.0)),
- p+Point<3>(-1,+1,+1) *(radius/std::sqrt(3.0)),
- };
-
- // one needs to draw the seven cubes to
- // understand what's going on here
- const unsigned int n_cells = 7;
- const int cell_vertices[n_cells][8] = {{0, 1, 4, 5, 3, 2, 7, 6}, // center
- {8, 9, 12, 13, 0, 1, 4, 5}, // bottom
- {9, 13, 1, 5, 10, 14, 2, 6}, // right
- {11, 10, 3, 2, 15, 14, 7, 6}, // top
- {8, 0, 12, 4, 11, 3, 15, 7}, // left
- {8, 9, 0, 1, 11, 10, 3, 2}, // front
- {12, 4, 13, 5, 15, 7, 14, 6}
- }; // back
-
- std::vector<CellData<3> > cells (n_cells, CellData<3>());
-
- for (unsigned int i=0; i<n_cells; ++i)
- {
- for (unsigned int j=0; j<GeometryInfo<3>::vertices_per_cell; ++j)
- cells[i].vertices[j] = cell_vertices[i][j];
- cells[i].material_id = 0;
- };
+ for (unsigned int i=0; i<7; ++i)
+ {
+ for (unsigned int j=0; j<8; ++j)
+ cells[i].vertices[j] = cell_vertices[i][j];
+ cells[i].material_id = 0;
+ };
- tria.create_triangulation (
- std::vector<Point<3> >(&vertices[0], &vertices[n_vertices]),
- cells,
- SubCellData()); // no boundary information
-}
+ tria.create_triangulation (
+ std::vector<Point<3> >(&vertices[0], &vertices[26]),
+ cells,
+ SubCellData()); // no boundary information
+ }
// Implementation for 3D only
-template <>
-void
-GridGenerator::cylinder (Triangulation<3> &tria,
- const double radius,
- const double half_length)
-{
- // Copy the base from hyper_ball<3>
- // and transform it to yz
- const double d = radius/std::sqrt(2.0);
- const double a = d/(1+std::sqrt(2.0));
- Point<3> vertices[24] =
- {
- Point<3>(-d, -half_length,-d),
- Point<3>( d, -half_length,-d),
- Point<3>(-a, -half_length,-a),
- Point<3>( a, -half_length,-a),
- Point<3>(-a, -half_length, a),
- Point<3>( a, -half_length, a),
- Point<3>(-d, -half_length, d),
- Point<3>( d, -half_length, d),
- Point<3>(-d, 0,-d),
- Point<3>( d, 0,-d),
- Point<3>(-a, 0,-a),
- Point<3>( a, 0,-a),
- Point<3>(-a, 0, a),
- Point<3>( a, 0, a),
- Point<3>(-d, 0, d),
- Point<3>( d, 0, d),
- Point<3>(-d, half_length,-d),
- Point<3>( d, half_length,-d),
- Point<3>(-a, half_length,-a),
- Point<3>( a, half_length,-a),
- Point<3>(-a, half_length, a),
- Point<3>( a, half_length, a),
- Point<3>(-d, half_length, d),
- Point<3>( d, half_length, d),
- };
- // Turn cylinder such that y->x
- for (unsigned int i=0; i<24; ++i)
- {
- const double h = vertices[i](1);
- vertices[i](1) = -vertices[i](0);
- vertices[i](0) = h;
- }
-
- int cell_vertices[10][8] =
+ template <>
+ void
+ hyper_ball (Triangulation<3> &tria,
+ const Point<3> &p,
+ const double radius)
{
- {0, 1, 8, 9, 2, 3, 10, 11},
- {0, 2, 8, 10, 6, 4, 14, 12},
- {2, 3, 10, 11, 4, 5, 12, 13},
- {1, 7, 9, 15, 3, 5, 11, 13},
- {6, 4, 14, 12, 7, 5, 15, 13}
- };
- for (unsigned int i=0; i<5; ++i)
- for (unsigned int j=0; j<8; ++j)
- cell_vertices[i+5][j] = cell_vertices[i][j]+8;
-
- std::vector<CellData<3> > cells (10, CellData<3>());
-
- for (unsigned int i=0; i<10; ++i)
- {
- for (unsigned int j=0; j<8; ++j)
- cells[i].vertices[j] = cell_vertices[i][j];
- cells[i].material_id = 0;
+ const double a = 1./(1+std::sqrt(3.0)); // equilibrate cell sizes at transition
+ // from the inner part to the radial
+ // cells
+ const unsigned int n_vertices = 16;
+ const Point<3> vertices[n_vertices]
+ =
+ {
+ // first the vertices of the inner
+ // cell
+ p+Point<3>(-1,-1,-1) *(radius/std::sqrt(3.0)*a),
+ p+Point<3>(+1,-1,-1) *(radius/std::sqrt(3.0)*a),
+ p+Point<3>(+1,-1,+1) *(radius/std::sqrt(3.0)*a),
+ p+Point<3>(-1,-1,+1) *(radius/std::sqrt(3.0)*a),
+ p+Point<3>(-1,+1,-1) *(radius/std::sqrt(3.0)*a),
+ p+Point<3>(+1,+1,-1) *(radius/std::sqrt(3.0)*a),
+ p+Point<3>(+1,+1,+1) *(radius/std::sqrt(3.0)*a),
+ p+Point<3>(-1,+1,+1) *(radius/std::sqrt(3.0)*a),
+ // now the eight vertices at
+ // the outer sphere
+ p+Point<3>(-1,-1,-1) *(radius/std::sqrt(3.0)),
+ p+Point<3>(+1,-1,-1) *(radius/std::sqrt(3.0)),
+ p+Point<3>(+1,-1,+1) *(radius/std::sqrt(3.0)),
+ p+Point<3>(-1,-1,+1) *(radius/std::sqrt(3.0)),
+ p+Point<3>(-1,+1,-1) *(radius/std::sqrt(3.0)),
+ p+Point<3>(+1,+1,-1) *(radius/std::sqrt(3.0)),
+ p+Point<3>(+1,+1,+1) *(radius/std::sqrt(3.0)),
+ p+Point<3>(-1,+1,+1) *(radius/std::sqrt(3.0)),
};
- tria.create_triangulation (
- std::vector<Point<3> >(&vertices[0], &vertices[24]),
- cells,
- SubCellData()); // no boundary information
-
- // set boundary indicators for the
- // faces at the ends to 1 and 2,
- // respectively. note that we also
- // have to deal with those lines
- // that are purely in the interior
- // of the ends. we determine wether
- // an edge is purely in the
- // interior if one of its vertices
- // is at coordinates '+-a' as set
- // above
- Triangulation<3>::cell_iterator cell = tria.begin();
- Triangulation<3>::cell_iterator end = tria.end();
-
- for (; cell != end; ++cell)
- for (unsigned int i=0; i<GeometryInfo<3>::faces_per_cell; ++i)
- if (cell->at_boundary(i))
- {
- if (cell->face(i)->center()(0) > half_length-1.e-5)
- {
- cell->face(i)->set_boundary_indicator(2);
-
- for (unsigned int e=0; e<GeometryInfo<3>::lines_per_face; ++e)
- if ((std::fabs(cell->face(i)->line(e)->vertex(0)[1]) == a) ||
- (std::fabs(cell->face(i)->line(e)->vertex(0)[2]) == a) ||
- (std::fabs(cell->face(i)->line(e)->vertex(1)[1]) == a) ||
- (std::fabs(cell->face(i)->line(e)->vertex(1)[2]) == a))
- cell->face(i)->line(e)->set_boundary_indicator(2);
- }
- else if (cell->face(i)->center()(0) < -half_length+1.e-5)
- {
- cell->face(i)->set_boundary_indicator(1);
+ // one needs to draw the seven cubes to
+ // understand what's going on here
+ const unsigned int n_cells = 7;
+ const int cell_vertices[n_cells][8] = {{0, 1, 4, 5, 3, 2, 7, 6}, // center
+ {8, 9, 12, 13, 0, 1, 4, 5}, // bottom
+ {9, 13, 1, 5, 10, 14, 2, 6}, // right
+ {11, 10, 3, 2, 15, 14, 7, 6}, // top
+ {8, 0, 12, 4, 11, 3, 15, 7}, // left
+ {8, 9, 0, 1, 11, 10, 3, 2}, // front
+ {12, 4, 13, 5, 15, 7, 14, 6}
+ }; // back
+
+ std::vector<CellData<3> > cells (n_cells, CellData<3>());
+
+ for (unsigned int i=0; i<n_cells; ++i)
+ {
+ for (unsigned int j=0; j<GeometryInfo<3>::vertices_per_cell; ++j)
+ cells[i].vertices[j] = cell_vertices[i][j];
+ cells[i].material_id = 0;
+ };
- for (unsigned int e=0; e<GeometryInfo<3>::lines_per_face; ++e)
- if ((std::fabs(cell->face(i)->line(e)->vertex(0)[1]) == a) ||
- (std::fabs(cell->face(i)->line(e)->vertex(0)[2]) == a) ||
- (std::fabs(cell->face(i)->line(e)->vertex(1)[1]) == a) ||
- (std::fabs(cell->face(i)->line(e)->vertex(1)[2]) == a))
- cell->face(i)->line(e)->set_boundary_indicator(1);
- }
- }
-}
+ tria.create_triangulation (
+ std::vector<Point<3> >(&vertices[0], &vertices[n_vertices]),
+ cells,
+ SubCellData()); // no boundary information
+ }
// Implementation for 3D only
-template <>
-void
-GridGenerator::half_hyper_ball (Triangulation<3> &tria,
- const Point<3> ¢er,
- const double radius)
-{
- // These are for the two lower squares
- const double d = radius/std::sqrt(2.0);
- const double a = d/(1+std::sqrt(2.0));
- // These are for the two upper square
- const double b = a/2.0;
- const double c = d/2.0;
- // And so are these
- const double hb = radius*std::sqrt(3.0)/4.0;
- const double hc = radius*std::sqrt(3.0)/2.0;
-
- Point<3> vertices[16] =
+ template <>
+ void
+ cylinder (Triangulation<3> &tria,
+ const double radius,
+ const double half_length)
{
- center+Point<3>( 0, d, -d),
- center+Point<3>( 0, -d, -d),
- center+Point<3>( 0, a, -a),
- center+Point<3>( 0, -a, -a),
- center+Point<3>( 0, a, a),
- center+Point<3>( 0, -a, a),
- center+Point<3>( 0, d, d),
- center+Point<3>( 0, -d, d),
-
- center+Point<3>(hc, c, -c),
- center+Point<3>(hc, -c, -c),
- center+Point<3>(hb, b, -b),
- center+Point<3>(hb, -b, -b),
- center+Point<3>(hb, b, b),
- center+Point<3>(hb, -b, b),
- center+Point<3>(hc, c, c),
- center+Point<3>(hc, -c, c),
- };
-
- int cell_vertices[6][8] =
- {
- {0, 1, 8, 9, 2, 3, 10, 11},
- {0, 2, 8, 10, 6, 4, 14, 12},
- {2, 3, 10, 11, 4, 5, 12, 13},
- {1, 7, 9, 15, 3, 5, 11, 13},
- {6, 4, 14, 12, 7, 5, 15, 13},
- {8, 10, 9, 11, 14, 12, 15, 13}
- };
-
- std::vector<CellData<3> > cells (6, CellData<3>());
+ // Copy the base from hyper_ball<3>
+ // and transform it to yz
+ const double d = radius/std::sqrt(2.0);
+ const double a = d/(1+std::sqrt(2.0));
+ Point<3> vertices[24] =
+ {
+ Point<3>(-d, -half_length,-d),
+ Point<3>( d, -half_length,-d),
+ Point<3>(-a, -half_length,-a),
+ Point<3>( a, -half_length,-a),
+ Point<3>(-a, -half_length, a),
+ Point<3>( a, -half_length, a),
+ Point<3>(-d, -half_length, d),
+ Point<3>( d, -half_length, d),
+ Point<3>(-d, 0,-d),
+ Point<3>( d, 0,-d),
+ Point<3>(-a, 0,-a),
+ Point<3>( a, 0,-a),
+ Point<3>(-a, 0, a),
+ Point<3>( a, 0, a),
+ Point<3>(-d, 0, d),
+ Point<3>( d, 0, d),
+ Point<3>(-d, half_length,-d),
+ Point<3>( d, half_length,-d),
+ Point<3>(-a, half_length,-a),
+ Point<3>( a, half_length,-a),
+ Point<3>(-a, half_length, a),
+ Point<3>( a, half_length, a),
+ Point<3>(-d, half_length, d),
+ Point<3>( d, half_length, d),
+ };
+ // Turn cylinder such that y->x
+ for (unsigned int i=0; i<24; ++i)
+ {
+ const double h = vertices[i](1);
+ vertices[i](1) = -vertices[i](0);
+ vertices[i](0) = h;
+ }
- for (unsigned int i=0; i<6; ++i)
+ int cell_vertices[10][8] =
{
- for (unsigned int j=0; j<8; ++j)
- cells[i].vertices[j] = cell_vertices[i][j];
- cells[i].material_id = 0;
+ {0, 1, 8, 9, 2, 3, 10, 11},
+ {0, 2, 8, 10, 6, 4, 14, 12},
+ {2, 3, 10, 11, 4, 5, 12, 13},
+ {1, 7, 9, 15, 3, 5, 11, 13},
+ {6, 4, 14, 12, 7, 5, 15, 13}
};
+ for (unsigned int i=0; i<5; ++i)
+ for (unsigned int j=0; j<8; ++j)
+ cell_vertices[i+5][j] = cell_vertices[i][j]+8;
- tria.create_triangulation (
- std::vector<Point<3> >(&vertices[0], &vertices[16]),
- cells,
- SubCellData()); // no boundary information
+ std::vector<CellData<3> > cells (10, CellData<3>());
- Triangulation<3>::cell_iterator cell = tria.begin();
- Triangulation<3>::cell_iterator end = tria.end();
+ for (unsigned int i=0; i<10; ++i)
+ {
+ for (unsigned int j=0; j<8; ++j)
+ cells[i].vertices[j] = cell_vertices[i][j];
+ cells[i].material_id = 0;
+ };
- // go over all faces. for the ones on the flat face, set boundary
- // indicator for face and edges to one; the rest will remain at
- // zero but we have to pay attention to those edges that are
- // at the perimeter of the flat face since they should not be
- // set to one
- while (cell != end)
- {
+ tria.create_triangulation (
+ std::vector<Point<3> >(&vertices[0], &vertices[24]),
+ cells,
+ SubCellData()); // no boundary information
+
+ // set boundary indicators for the
+ // faces at the ends to 1 and 2,
+ // respectively. note that we also
+ // have to deal with those lines
+ // that are purely in the interior
+ // of the ends. we determine whether
+ // an edge is purely in the
+ // interior if one of its vertices
+ // is at coordinates '+-a' as set
+ // above
+ Triangulation<3>::cell_iterator cell = tria.begin();
+ Triangulation<3>::cell_iterator end = tria.end();
+
+ for (; cell != end; ++cell)
for (unsigned int i=0; i<GeometryInfo<3>::faces_per_cell; ++i)
- {
- if (!cell->at_boundary(i))
- continue;
+ if (cell->at_boundary(i))
+ {
+ if (cell->face(i)->center()(0) > half_length-1.e-5)
+ {
+ cell->face(i)->set_boundary_indicator(2);
+
+ for (unsigned int e=0; e<GeometryInfo<3>::lines_per_face; ++e)
+ if ((std::fabs(cell->face(i)->line(e)->vertex(0)[1]) == a) ||
+ (std::fabs(cell->face(i)->line(e)->vertex(0)[2]) == a) ||
+ (std::fabs(cell->face(i)->line(e)->vertex(1)[1]) == a) ||
+ (std::fabs(cell->face(i)->line(e)->vertex(1)[2]) == a))
+ cell->face(i)->line(e)->set_boundary_indicator(2);
+ }
+ else if (cell->face(i)->center()(0) < -half_length+1.e-5)
+ {
+ cell->face(i)->set_boundary_indicator(1);
+
+ for (unsigned int e=0; e<GeometryInfo<3>::lines_per_face; ++e)
+ if ((std::fabs(cell->face(i)->line(e)->vertex(0)[1]) == a) ||
+ (std::fabs(cell->face(i)->line(e)->vertex(0)[2]) == a) ||
+ (std::fabs(cell->face(i)->line(e)->vertex(1)[1]) == a) ||
+ (std::fabs(cell->face(i)->line(e)->vertex(1)[2]) == a))
+ cell->face(i)->line(e)->set_boundary_indicator(1);
+ }
+ }
+ }
+
- // If the center is on the plane x=0, this is a planar element. set
- // its boundary indicator. also set the boundary indicators of the
- // bounding faces unless both vertices are on the perimeter
- if (cell->face(i)->center()(0) < center(0)+1.e-5*radius)
- {
- cell->face(i)->set_boundary_indicator(1);
- for (unsigned int j=0; j<GeometryInfo<3>::lines_per_face; ++j)
- {
- const Point<3> vertices[2]
- = { cell->face(i)->line(j)->vertex(0),
- cell->face(i)->line(j)->vertex(1) };
- if ((std::fabs(vertices[0].distance(center)-radius) >
- 1e-5*radius)
- ||
- (std::fabs(vertices[1].distance(center)-radius) >
- 1e-5*radius))
- cell->face(i)->line(j)->set_boundary_indicator(1);
- }
- }
- }
- ++cell;
- }
-}
// Implementation for 3D only
-template<>
-void
-GridGenerator::
-colorize_hyper_shell (Triangulation<3> &tria,
- const Point<3> &,
- const double,
- const double)
-{
- // the following uses a good amount
- // of knowledge about the
- // orientation of cells. this is
- // probably not good style...
- if (tria.n_cells() == 6)
+ template <>
+ void
+ half_hyper_ball (Triangulation<3> &tria,
+ const Point<3> ¢er,
+ const double radius)
+ {
+ // These are for the two lower squares
+ const double d = radius/std::sqrt(2.0);
+ const double a = d/(1+std::sqrt(2.0));
+ // These are for the two upper square
+ const double b = a/2.0;
+ const double c = d/2.0;
+ // And so are these
+ const double hb = radius*std::sqrt(3.0)/4.0;
+ const double hc = radius*std::sqrt(3.0)/2.0;
+
+ Point<3> vertices[16] =
+ {
+ center+Point<3>( 0, d, -d),
+ center+Point<3>( 0, -d, -d),
+ center+Point<3>( 0, a, -a),
+ center+Point<3>( 0, -a, -a),
+ center+Point<3>( 0, a, a),
+ center+Point<3>( 0, -a, a),
+ center+Point<3>( 0, d, d),
+ center+Point<3>( 0, -d, d),
+
+ center+Point<3>(hc, c, -c),
+ center+Point<3>(hc, -c, -c),
+ center+Point<3>(hb, b, -b),
+ center+Point<3>(hb, -b, -b),
+ center+Point<3>(hb, b, b),
+ center+Point<3>(hb, -b, b),
+ center+Point<3>(hc, c, c),
+ center+Point<3>(hc, -c, c),
+ };
+
+ int cell_vertices[6][8] =
{
- Triangulation<3>::cell_iterator cell = tria.begin();
+ {0, 1, 8, 9, 2, 3, 10, 11},
+ {0, 2, 8, 10, 6, 4, 14, 12},
+ {2, 3, 10, 11, 4, 5, 12, 13},
+ {1, 7, 9, 15, 3, 5, 11, 13},
+ {6, 4, 14, 12, 7, 5, 15, 13},
+ {8, 10, 9, 11, 14, 12, 15, 13}
+ };
- cell->face(4)->set_boundary_indicator(1);
- Assert (cell->face(4)->at_boundary(), ExcInternalError());
+ std::vector<CellData<3> > cells (6, CellData<3>());
- (++cell)->face(2)->set_boundary_indicator(1);
- Assert (cell->face(2)->at_boundary(), ExcInternalError());
+ for (unsigned int i=0; i<6; ++i)
+ {
+ for (unsigned int j=0; j<8; ++j)
+ cells[i].vertices[j] = cell_vertices[i][j];
+ cells[i].material_id = 0;
+ };
- (++cell)->face(2)->set_boundary_indicator(1);
- Assert (cell->face(2)->at_boundary(), ExcInternalError());
+ tria.create_triangulation (
+ std::vector<Point<3> >(&vertices[0], &vertices[16]),
+ cells,
+ SubCellData()); // no boundary information
- (++cell)->face(0)->set_boundary_indicator(1);
- Assert (cell->face(0)->at_boundary(), ExcInternalError());
+ Triangulation<3>::cell_iterator cell = tria.begin();
+ Triangulation<3>::cell_iterator end = tria.end();
- (++cell)->face(2)->set_boundary_indicator(1);
- Assert (cell->face(2)->at_boundary(), ExcInternalError());
+ // go over all faces. for the ones on the flat face, set boundary
+ // indicator for face and edges to one; the rest will remain at
+ // zero but we have to pay attention to those edges that are
+ // at the perimeter of the flat face since they should not be
+ // set to one
+ while (cell != end)
+ {
+ for (unsigned int i=0; i<GeometryInfo<3>::faces_per_cell; ++i)
+ {
+ if (!cell->at_boundary(i))
+ continue;
- (++cell)->face(0)->set_boundary_indicator(1);
- Assert (cell->face(0)->at_boundary(), ExcInternalError());
- }
- else if (tria.n_cells() == 12)
- {
- // again use some internal
- // knowledge
- for (Triangulation<3>::cell_iterator cell = tria.begin();
- cell != tria.end(); ++cell)
- {
- Assert (cell->face(5)->at_boundary(), ExcInternalError());
- cell->face(5)->set_boundary_indicator(1);
- }
- }
- else if (tria.n_cells() == 96)
- {
- // the 96-cell hypershell is
- // based on a once refined
- // 12-cell mesh. consequently,
- // since the outer faces all
- // are face_no==5 above, so
- // they are here (unless they
- // are in the interior). Use
- // this to assign boundary
- // indicators, but also make
- // sure that we encounter
- // exactly 48 such faces
- unsigned int count = 0;
- for (Triangulation<3>::cell_iterator cell = tria.begin();
- cell != tria.end(); ++cell)
- if (cell->face(5)->at_boundary())
- {
- cell->face(5)->set_boundary_indicator(1);
- ++count;
+ // If the center is on the plane x=0, this is a planar element. set
+ // its boundary indicator. also set the boundary indicators of the
+ // bounding faces unless both vertices are on the perimeter
+ if (cell->face(i)->center()(0) < center(0)+1.e-5*radius)
+ {
+ cell->face(i)->set_boundary_indicator(1);
+ for (unsigned int j=0; j<GeometryInfo<3>::lines_per_face; ++j)
+ {
+ const Point<3> vertices[2]
+ = { cell->face(i)->line(j)->vertex(0),
+ cell->face(i)->line(j)->vertex(1)
+ };
+ if ((std::fabs(vertices[0].distance(center)-radius) >
+ 1e-5*radius)
+ ||
+ (std::fabs(vertices[1].distance(center)-radius) >
+ 1e-5*radius))
+ cell->face(i)->line(j)->set_boundary_indicator(1);
+ }
+ }
}
- Assert (count == 48, ExcInternalError());
- }
- else
- Assert (false, ExcNotImplemented());
-}
-
-
+ ++cell;
+ }
+ }
-template <>
-void
-GridGenerator::hyper_shell (Triangulation<3> &tria,
- const Point<3> &p,
- const double inner_radius,
- const double outer_radius,
- const size_type n,
- const bool colorize)
-{
- Assert ((inner_radius > 0) && (inner_radius < outer_radius),
- ExcInvalidRadii ());
- const double irad = inner_radius/std::sqrt(3.0);
- const double orad = outer_radius/std::sqrt(3.0);
- std::vector<Point<3> > vertices;
- std::vector<CellData<3> > cells;
+ template <>
+ void
+ hyper_shell (Triangulation<3> &tria,
+ const Point<3> &p,
+ const double inner_radius,
+ const double outer_radius,
+ const unsigned int n,
+ const bool colorize)
+ {
+ Assert ((inner_radius > 0) && (inner_radius < outer_radius),
+ ExcInvalidRadii ());
- // Start with the shell bounded by
- // two nested cubes
- if (n == 6)
- {
- for (unsigned int i=0; i<8; ++i)
- vertices.push_back(p+hexahedron[i]*irad);
- for (unsigned int i=0; i<8; ++i)
- vertices.push_back(p+hexahedron[i]*orad);
+ const double irad = inner_radius/std::sqrt(3.0);
+ const double orad = outer_radius/std::sqrt(3.0);
+ std::vector<Point<3> > vertices;
+ std::vector<CellData<3> > cells;
- const unsigned int n_cells = 6;
- const int cell_vertices[n_cells][8] =
+ // Start with the shell bounded by
+ // two nested cubes
+ if (n == 6)
{
- {8, 9, 10, 11, 0, 1, 2, 3}, // bottom
- {9, 11, 1, 3, 13, 15, 5, 7}, // right
- {12, 13, 4, 5, 14, 15, 6, 7}, // top
- {8, 0, 10, 2, 12, 4, 14, 6}, // left
- {8, 9, 0, 1, 12, 13, 4, 5}, // front
- {10, 2, 11, 3, 14, 6, 15, 7}
- }; // back
+ for (unsigned int i=0; i<8; ++i)
+ vertices.push_back(p+hexahedron[i]*irad);
+ for (unsigned int i=0; i<8; ++i)
+ vertices.push_back(p+hexahedron[i]*orad);
- cells.resize(n_cells, CellData<3>());
-
- for (unsigned int i=0; i<n_cells; ++i)
+ const unsigned int n_cells = 6;
+ const int cell_vertices[n_cells][8] =
{
- for (unsigned int j=0; j<GeometryInfo<3>::vertices_per_cell; ++j)
- cells[i].vertices[j] = cell_vertices[i][j];
- cells[i].material_id = 0;
- }
+ {8, 9, 10, 11, 0, 1, 2, 3}, // bottom
+ {9, 11, 1, 3, 13, 15, 5, 7}, // right
+ {12, 13, 4, 5, 14, 15, 6, 7}, // top
+ {8, 0, 10, 2, 12, 4, 14, 6}, // left
+ {8, 9, 0, 1, 12, 13, 4, 5}, // front
+ {10, 2, 11, 3, 14, 6, 15, 7}
+ }; // back
- tria.create_triangulation (vertices, cells, SubCellData());
- }
- // A more regular subdivision can
- // be obtained by two nested
- // rhombic dodecahedra
- else if (n == 12)
- {
- for (unsigned int i=0; i<8; ++i)
- vertices.push_back(p+hexahedron[i]*irad);
- for (unsigned int i=0; i<6; ++i)
- vertices.push_back(p+octahedron[i]*inner_radius);
- for (unsigned int i=0; i<8; ++i)
- vertices.push_back(p+hexahedron[i]*orad);
- for (unsigned int i=0; i<6; ++i)
- vertices.push_back(p+octahedron[i]*outer_radius);
-
- const unsigned int n_cells = 12;
- const unsigned int rhombi[n_cells][4] =
- {
- { 10, 4, 0, 8},
- { 4, 13, 8, 6},
- { 10, 5, 4, 13},
- { 1, 9, 10, 5},
- { 9, 7, 5, 13},
- { 7, 11, 13, 6},
- { 9, 3, 7, 11},
- { 1, 12, 9, 3},
- { 12, 2, 3, 11},
- { 2, 8, 11, 6},
- { 12, 0, 2, 8},
- { 1, 10, 12, 0}
- };
+ cells.resize(n_cells, CellData<3>());
- cells.resize(n_cells, CellData<3>());
+ for (unsigned int i=0; i<n_cells; ++i)
+ {
+ for (unsigned int j=0; j<GeometryInfo<3>::vertices_per_cell; ++j)
+ cells[i].vertices[j] = cell_vertices[i][j];
+ cells[i].material_id = 0;
+ }
- for (unsigned int i=0; i<n_cells; ++i)
+ tria.create_triangulation (vertices, cells, SubCellData());
+ }
+ // A more regular subdivision can
+ // be obtained by two nested
+ // rhombic dodecahedra
+ else if (n == 12)
+ {
+ for (unsigned int i=0; i<8; ++i)
+ vertices.push_back(p+hexahedron[i]*irad);
+ for (unsigned int i=0; i<6; ++i)
+ vertices.push_back(p+octahedron[i]*inner_radius);
+ for (unsigned int i=0; i<8; ++i)
+ vertices.push_back(p+hexahedron[i]*orad);
+ for (unsigned int i=0; i<6; ++i)
+ vertices.push_back(p+octahedron[i]*outer_radius);
+
+ const unsigned int n_cells = 12;
+ const unsigned int rhombi[n_cells][4] =
{
- for (unsigned int j=0; j<4; ++j)
- {
- cells[i].vertices[j ] = rhombi[i][j];
- cells[i].vertices[j+4] = rhombi[i][j] + 14;
- }
- cells[i].material_id = 0;
- }
+ { 10, 4, 0, 8},
+ { 4, 13, 8, 6},
+ { 10, 5, 4, 13},
+ { 1, 9, 10, 5},
+ { 9, 7, 5, 13},
+ { 7, 11, 13, 6},
+ { 9, 3, 7, 11},
+ { 1, 12, 9, 3},
+ { 12, 2, 3, 11},
+ { 2, 8, 11, 6},
+ { 12, 0, 2, 8},
+ { 1, 10, 12, 0}
+ };
- tria.create_triangulation (vertices, cells, SubCellData());
- }
- else if (n == 96)
- {
- // create a triangulation based on the
- // 12-cell one where we refine the mesh
- // once and then re-arrange all
- // interior nodes so that the mesh is
- // the least distorted
- HyperShellBoundary<3> boundary (p);
- Triangulation<3> tmp;
- GridGenerator::hyper_shell (tmp, p, inner_radius, outer_radius, 12);
- tmp.set_boundary(0, boundary);
- tmp.set_boundary(1, boundary);
- tmp.refine_global (1);
-
- // let's determine the distance at
- // which the interior nodes should be
- // from the center. let's say we
- // measure distances in multiples of
- // outer_radius and call
- // r=inner_radius.
- //
- // then note
- // that we now have 48 faces on the
- // inner and 48 on the outer sphere,
- // each with an area of approximately
- // 4*pi/48*r^2 and 4*pi/48, for
- // a face edge length of approximately
- // sqrt(pi/12)*r and sqrt(pi/12)
- //
- // let's say we put the interior nodes
- // at a distance rho, then a measure of
- // deformation for the inner cells
- // would be
- // di=max(sqrt(pi/12)*r/(rho-r),
- // (rho-r)/sqrt(pi/12)/r)
- // and for the outer cells
- // do=max(sqrt(pi/12)/(1-rho),
- // (1-rho)/sqrt(pi/12))
- //
- // we now seek a rho so that the
- // deformation of cells on the inside
- // and outside is equal. there are in
- // principle four possibilities for one
- // of the branches of do== one of the
- // branches of di, though not all of
- // them satisfy do==di, of
- // course. however, we are not
- // interested in cases where the inner
- // cell is long and skinny and the
- // outer one tall -- yes, they have the
- // same aspect ratio, but in different
- // space directions.
- //
- // so it only boils down to the
- // following two possibilities: the
- // first branch of each max(.,.)
- // functions are equal, or the second
- // one are. on the other hand, since
- // they two branches are reciprocals of
- // each other, if one pair of branches
- // is equal, so is the other
- //
- // this yields the following equation
- // for rho:
- // sqrt(pi/12)*r/(rho-r)
- // == sqrt(pi/12)/(1-rho)
- // with solution rho=2r/(1+r)
- const double r = inner_radius / outer_radius;
- const double rho = 2*r/(1+r);
-
- // then this is the distance of the
- // interior nodes from the center:
- const double middle_radius = rho * outer_radius;
-
- // mark vertices we've already moved or
- // that we want to ignore: we don't
- // want to move vertices at the inner
- // or outer boundaries
- std::vector<bool> vertex_already_treated (tmp.n_vertices(), false);
- for (Triangulation<3>::active_cell_iterator cell = tmp.begin_active();
- cell != tmp.end(); ++cell)
- for (unsigned int f=0; f<GeometryInfo<3>::faces_per_cell; ++f)
- if (cell->at_boundary(f))
- for (unsigned int v=0; v<GeometryInfo<3>::vertices_per_face; ++v)
- vertex_already_treated[cell->face(f)->vertex_index(v)] = true;
-
- // now move the remaining vertices
- for (Triangulation<3>::active_cell_iterator cell = tmp.begin_active();
- cell != tmp.end(); ++cell)
- for (unsigned int v=0; v<GeometryInfo<3>::vertices_per_cell; ++v)
- if (vertex_already_treated[cell->vertex_index(v)] == false)
- {
- // this is a new interior
- // vertex. mesh refinement may
- // have placed it at a number
- // of places in radial
- // direction and oftentimes not
- // in a particularly good
- // one. move it to halfway
- // between inner and outer
- // sphere
- const Point<3> old_distance = cell->vertex(v) - p;
- const double old_radius = cell->vertex(v).distance(p);
- cell->vertex(v) = p + old_distance * (middle_radius / old_radius);
-
- vertex_already_treated[cell->vertex_index(v)] = true;
- }
+ cells.resize(n_cells, CellData<3>());
- // now copy the resulting level 1 cells
- // into the new triangulation,
- cells.resize(tmp.n_active_cells(), CellData<3>());
+ for (unsigned int i=0; i<n_cells; ++i)
+ {
+ for (unsigned int j=0; j<4; ++j)
+ {
+ cells[i].vertices[j ] = rhombi[i][j];
+ cells[i].vertices[j+4] = rhombi[i][j] + 14;
+ }
+ cells[i].material_id = 0;
+ }
- unsigned int index = 0;
- for (Triangulation<3>::active_cell_iterator cell = tmp.begin_active();
- cell != tmp.end(); ++cell, ++index)
- {
+ tria.create_triangulation (vertices, cells, SubCellData());
+ }
+ else if (n == 96)
+ {
+ // create a triangulation based on the
+ // 12-cell one where we refine the mesh
+ // once and then re-arrange all
+ // interior nodes so that the mesh is
+ // the least distorted
+ HyperShellBoundary<3> boundary (p);
+ Triangulation<3> tmp;
+ hyper_shell (tmp, p, inner_radius, outer_radius, 12);
+ tmp.set_boundary(0, boundary);
+ tmp.set_boundary(1, boundary);
+ tmp.refine_global (1);
+
+ // let's determine the distance at
+ // which the interior nodes should be
+ // from the center. let's say we
+ // measure distances in multiples of
+ // outer_radius and call
+ // r=inner_radius.
+ //
+ // then note
+ // that we now have 48 faces on the
+ // inner and 48 on the outer sphere,
+ // each with an area of approximately
+ // 4*pi/48*r^2 and 4*pi/48, for
+ // a face edge length of approximately
+ // sqrt(pi/12)*r and sqrt(pi/12)
+ //
+ // let's say we put the interior nodes
+ // at a distance rho, then a measure of
+ // deformation for the inner cells
+ // would be
+ // di=max(sqrt(pi/12)*r/(rho-r),
+ // (rho-r)/sqrt(pi/12)/r)
+ // and for the outer cells
+ // do=max(sqrt(pi/12)/(1-rho),
+ // (1-rho)/sqrt(pi/12))
+ //
+ // we now seek a rho so that the
+ // deformation of cells on the inside
+ // and outside is equal. there are in
+ // principle four possibilities for one
+ // of the branches of do== one of the
+ // branches of di, though not all of
+ // them satisfy do==di, of
+ // course. however, we are not
+ // interested in cases where the inner
+ // cell is long and skinny and the
+ // outer one tall -- yes, they have the
+ // same aspect ratio, but in different
+ // space directions.
+ //
+ // so it only boils down to the
+ // following two possibilities: the
+ // first branch of each max(.,.)
+ // functions are equal, or the second
+ // one are. on the other hand, since
+ // they two branches are reciprocals of
+ // each other, if one pair of branches
+ // is equal, so is the other
+ //
+ // this yields the following equation
+ // for rho:
+ // sqrt(pi/12)*r/(rho-r)
+ // == sqrt(pi/12)/(1-rho)
+ // with solution rho=2r/(1+r)
+ const double r = inner_radius / outer_radius;
+ const double rho = 2*r/(1+r);
+
+ // then this is the distance of the
+ // interior nodes from the center:
+ const double middle_radius = rho * outer_radius;
+
+ // mark vertices we've already moved or
+ // that we want to ignore: we don't
+ // want to move vertices at the inner
+ // or outer boundaries
+ std::vector<bool> vertex_already_treated (tmp.n_vertices(), false);
+ for (Triangulation<3>::active_cell_iterator cell = tmp.begin_active();
+ cell != tmp.end(); ++cell)
+ for (unsigned int f=0; f<GeometryInfo<3>::faces_per_cell; ++f)
+ if (cell->at_boundary(f))
+ for (unsigned int v=0; v<GeometryInfo<3>::vertices_per_face; ++v)
+ vertex_already_treated[cell->face(f)->vertex_index(v)] = true;
+
+ // now move the remaining vertices
+ for (Triangulation<3>::active_cell_iterator cell = tmp.begin_active();
+ cell != tmp.end(); ++cell)
for (unsigned int v=0; v<GeometryInfo<3>::vertices_per_cell; ++v)
- cells[index].vertices[v] = cell->vertex_index(v);
- cells[index].material_id = 0;
- }
-
- tria.create_triangulation (tmp.get_vertices(), cells, SubCellData());
- }
- else
- {
- Assert(false, ExcMessage ("Invalid number of coarse mesh cells."));
- }
+ if (vertex_already_treated[cell->vertex_index(v)] == false)
+ {
+ // this is a new interior
+ // vertex. mesh refinement may
+ // have placed it at a number
+ // of places in radial
+ // direction and oftentimes not
+ // in a particularly good
+ // one. move it to halfway
+ // between inner and outer
+ // sphere
+ const Point<3> old_distance = cell->vertex(v) - p;
+ const double old_radius = cell->vertex(v).distance(p);
+ cell->vertex(v) = p + old_distance * (middle_radius / old_radius);
+
+ vertex_already_treated[cell->vertex_index(v)] = true;
+ }
- if (colorize)
- colorize_hyper_shell(tria, p, inner_radius, outer_radius);
-}
+ // now copy the resulting level 1 cells
+ // into the new triangulation,
+ cells.resize(tmp.n_active_cells(), CellData<3>());
+ unsigned int index = 0;
+ for (Triangulation<3>::active_cell_iterator cell = tmp.begin_active();
+ cell != tmp.end(); ++cell, ++index)
+ {
+ for (unsigned int v=0; v<GeometryInfo<3>::vertices_per_cell; ++v)
+ cells[index].vertices[v] = cell->vertex_index(v);
+ cells[index].material_id = 0;
+ }
+ tria.create_triangulation (tmp.get_vertices(), cells, SubCellData());
+ }
+ else
+ {
+ Assert(false, ExcMessage ("Invalid number of coarse mesh cells."));
+ }
+ if (colorize)
+ colorize_hyper_shell(tria, p, inner_radius, outer_radius);
+ }
-// Implementation for 3D only
-template <>
-void
-GridGenerator::half_hyper_shell (Triangulation<3> &tria,
- const Point<3> ¢er,
- const double inner_radius,
- const double outer_radius,
- const size_type n,
- const bool colorize)
-{
- Assert ((inner_radius > 0) && (inner_radius < outer_radius),
- ExcInvalidRadii ());
- Assert(colorize == false, ExcNotImplemented());
- if (n <= 5)
- {
- // These are for the two lower squares
- const double d = outer_radius/std::sqrt(2.0);
- const double a = inner_radius/std::sqrt(2.0);
- // These are for the two upper square
- const double b = a/2.0;
- const double c = d/2.0;
- // And so are these
- const double hb = inner_radius*std::sqrt(3.0)/2.0;
- const double hc = outer_radius*std::sqrt(3.0)/2.0;
-
- Point<3> vertices[16] =
- {
- center+Point<3>( 0, d, -d),
- center+Point<3>( 0, -d, -d),
- center+Point<3>( 0, a, -a),
- center+Point<3>( 0, -a, -a),
- center+Point<3>( 0, a, a),
- center+Point<3>( 0, -a, a),
- center+Point<3>( 0, d, d),
- center+Point<3>( 0, -d, d),
-
- center+Point<3>(hc, c, -c),
- center+Point<3>(hc, -c, -c),
- center+Point<3>(hb, b, -b),
- center+Point<3>(hb, -b, -b),
- center+Point<3>(hb, b, b),
- center+Point<3>(hb, -b, b),
- center+Point<3>(hc, c, c),
- center+Point<3>(hc, -c, c),
- };
- int cell_vertices[5][8] =
- {
- {0, 1, 8, 9, 2, 3, 10, 11},
- {0, 2, 8, 10, 6, 4, 14, 12},
- {1, 7, 9, 15, 3, 5, 11, 13},
- {6, 4, 14, 12, 7, 5, 15, 13},
- {8, 10, 9, 11, 14, 12, 15, 13}
- };
- std::vector<CellData<3> > cells (5, CellData<3>());
+// Implementation for 3D only
+ template <>
+ void
+ half_hyper_shell (Triangulation<3> &tria,
+ const Point<3> ¢er,
+ const double inner_radius,
+ const double outer_radius,
+ const unsigned int n,
+ const bool colorize)
+ {
+ Assert ((inner_radius > 0) && (inner_radius < outer_radius),
+ ExcInvalidRadii ());
+ Assert(colorize == false, ExcNotImplemented());
- for (unsigned int i=0; i<5; ++i)
+ if (n <= 5)
+ {
+ // These are for the two lower squares
+ const double d = outer_radius/std::sqrt(2.0);
+ const double a = inner_radius/std::sqrt(2.0);
+ // These are for the two upper square
+ const double b = a/2.0;
+ const double c = d/2.0;
+ // And so are these
+ const double hb = inner_radius*std::sqrt(3.0)/2.0;
+ const double hc = outer_radius*std::sqrt(3.0)/2.0;
+
+ Point<3> vertices[16] =
{
- for (unsigned int j=0; j<8; ++j)
- cells[i].vertices[j] = cell_vertices[i][j];
- cells[i].material_id = 0;
+ center+Point<3>( 0, d, -d),
+ center+Point<3>( 0, -d, -d),
+ center+Point<3>( 0, a, -a),
+ center+Point<3>( 0, -a, -a),
+ center+Point<3>( 0, a, a),
+ center+Point<3>( 0, -a, a),
+ center+Point<3>( 0, d, d),
+ center+Point<3>( 0, -d, d),
+
+ center+Point<3>(hc, c, -c),
+ center+Point<3>(hc, -c, -c),
+ center+Point<3>(hb, b, -b),
+ center+Point<3>(hb, -b, -b),
+ center+Point<3>(hb, b, b),
+ center+Point<3>(hb, -b, b),
+ center+Point<3>(hc, c, c),
+ center+Point<3>(hc, -c, c),
};
- tria.create_triangulation (
- std::vector<Point<3> >(&vertices[0], &vertices[16]),
- cells,
- SubCellData()); // no boundary information
- }
- else
- {
- Assert(false, ExcIndexRange(n, 0, 5));
- }
+ int cell_vertices[5][8] =
+ {
+ {0, 1, 8, 9, 2, 3, 10, 11},
+ {0, 2, 8, 10, 6, 4, 14, 12},
+ {1, 7, 9, 15, 3, 5, 11, 13},
+ {6, 4, 14, 12, 7, 5, 15, 13},
+ {8, 10, 9, 11, 14, 12, 15, 13}
+ };
-}
+ std::vector<CellData<3> > cells (5, CellData<3>());
-// Implementation for 3D only
-template <>
-void
-GridGenerator::colorize_quarter_hyper_shell(Triangulation<3> &tria,
- const Point<3> ¢er,
- const double inner_radius,
- const double outer_radius)
-{
+ for (unsigned int i=0; i<5; ++i)
+ {
+ for (unsigned int j=0; j<8; ++j)
+ cells[i].vertices[j] = cell_vertices[i][j];
+ cells[i].material_id = 0;
+ };
+
+ tria.create_triangulation (
+ std::vector<Point<3> >(&vertices[0], &vertices[16]),
+ cells,
+ SubCellData()); // no boundary information
+ }
+ else
+ {
+ Assert(false, ExcIndexRange(n, 0, 5));
+ }
- if (tria.n_cells() != 3)
- AssertThrow (false, ExcNotImplemented());
+ }
- double middle = (outer_radius-inner_radius)/2e0 + inner_radius;
- double eps = 1e-3*middle;
- Triangulation<3>::cell_iterator cell = tria.begin();
- for (; cell!=tria.end(); ++cell)
- for (unsigned int f=0; f<GeometryInfo<3>::faces_per_cell; ++f)
+// Implementation for 3D only
+ template <>
+ void quarter_hyper_shell (Triangulation<3> &tria,
+ const Point<3> ¢er,
+ const double inner_radius,
+ const double outer_radius,
+ const unsigned int n,
+ const bool colorize)
+ {
+ Assert ((inner_radius > 0) && (inner_radius < outer_radius),
+ ExcInvalidRadii ());
+ if (n == 0 || n == 3)
{
- if (!cell->face(f)->at_boundary())
- continue;
+ const double a = inner_radius*std::sqrt(2.0)/2e0;
+ const double b = outer_radius*std::sqrt(2.0)/2e0;
+ const double c = a*std::sqrt(3.0)/2e0;
+ const double d = b*std::sqrt(3.0)/2e0;
+ const double e = outer_radius/2e0;
+ const double h = inner_radius/2e0;
+
+ std::vector<Point<3> > vertices;
+
+ vertices.push_back (center+Point<3>( 0, inner_radius, 0)); //0
+ vertices.push_back (center+Point<3>( a, a, 0)); //1
+ vertices.push_back (center+Point<3>( b, b, 0)); //2
+ vertices.push_back (center+Point<3>( 0, outer_radius, 0)); //3
+ vertices.push_back (center+Point<3>( 0, a , a)); //4
+ vertices.push_back (center+Point<3>( c, c , h)); //5
+ vertices.push_back (center+Point<3>( d, d , e)); //6
+ vertices.push_back (center+Point<3>( 0, b , b)); //7
+ vertices.push_back (center+Point<3>( inner_radius, 0 , 0)); //8
+ vertices.push_back (center+Point<3>( outer_radius, 0 , 0)); //9
+ vertices.push_back (center+Point<3>( a, 0 , a)); //10
+ vertices.push_back (center+Point<3>( b, 0 , b)); //11
+ vertices.push_back (center+Point<3>( 0, 0 , inner_radius)); //12
+ vertices.push_back (center+Point<3>( 0, 0 , outer_radius)); //13
+
+ const int cell_vertices[3][8] =
+ {
+ {0, 1, 3, 2, 4, 5, 7, 6},
+ {1, 8, 2, 9, 5, 10, 6, 11},
+ {4, 5, 7, 6, 12, 10, 13, 11},
+ };
+ std::vector<CellData<3> > cells(3);
- double radius = cell->face(f)->center().norm() - center.norm();
- if (std::fabs(cell->face(f)->center()(0)) < eps ) // x = 0 set boundary 2
- {
- cell->face(f)->set_boundary_indicator(2);
- for (unsigned int j=0; j<GeometryInfo<3>::lines_per_face; ++j)
- if (cell->face(f)->line(j)->at_boundary())
- if (std::fabs(cell->face(f)->line(j)->vertex(0).norm() - cell->face(f)->line(j)->vertex(1).norm()) > eps)
- cell->face(f)->line(j)->set_boundary_indicator(2);
- }
- else if (std::fabs(cell->face(f)->center()(1)) < eps) // y = 0 set boundary 3
- {
- cell->face(f)->set_boundary_indicator(3);
- for (unsigned int j=0; j<GeometryInfo<3>::lines_per_face; ++j)
- if (cell->face(f)->line(j)->at_boundary())
- if (std::fabs(cell->face(f)->line(j)->vertex(0).norm() - cell->face(f)->line(j)->vertex(1).norm()) > eps)
- cell->face(f)->line(j)->set_boundary_indicator(3);
- }
- else if (std::fabs(cell->face(f)->center()(2)) < eps ) // z = 0 set boundary 4
- {
- cell->face(f)->set_boundary_indicator(4);
- for (unsigned int j=0; j<GeometryInfo<3>::lines_per_face; ++j)
- if (cell->face(f)->line(j)->at_boundary())
- if (std::fabs(cell->face(f)->line(j)->vertex(0).norm() - cell->face(f)->line(j)->vertex(1).norm()) > eps)
- cell->face(f)->line(j)->set_boundary_indicator(4);
- }
- else if (radius < middle) // inner radius set boundary 0
- {
- cell->face(f)->set_boundary_indicator(0);
- for (unsigned int j=0; j<GeometryInfo<3>::lines_per_face; ++j)
- if (cell->face(f)->line(j)->at_boundary())
- if (std::fabs(cell->face(f)->line(j)->vertex(0).norm() - cell->face(f)->line(j)->vertex(1).norm()) < eps)
- cell->face(f)->line(j)->set_boundary_indicator(0);
- }
- else if (radius > middle) // outer radius set boundary 1
+ for (unsigned int i=0; i<3; ++i)
{
- cell->face(f)->set_boundary_indicator(1);
- for (unsigned int j=0; j<GeometryInfo<3>::lines_per_face; ++j)
- if (cell->face(f)->line(j)->at_boundary())
- if (std::fabs(cell->face(f)->line(j)->vertex(0).norm() - cell->face(f)->line(j)->vertex(1).norm()) < eps)
- cell->face(f)->line(j)->set_boundary_indicator(1);
+ for (unsigned int j=0; j<8; ++j)
+ cells[i].vertices[j] = cell_vertices[i][j];
+ cells[i].material_id = 0;
}
- else
- AssertThrow (false, ExcInternalError());
+
+ tria.create_triangulation ( vertices, cells, SubCellData()); // no boundary information
+ }
+ else
+ {
+ AssertThrow(false, ExcNotImplemented());
}
-}
+ if (colorize)
+ colorize_quarter_hyper_shell(tria, center, inner_radius, outer_radius);
+ }
// Implementation for 3D only
-template <>
-void GridGenerator::quarter_hyper_shell (Triangulation<3> &tria,
- const Point<3> ¢er,
- const double inner_radius,
- const double outer_radius,
- const size_type n,
- const bool colorize)
-{
- Assert ((inner_radius > 0) && (inner_radius < outer_radius),
- ExcInvalidRadii ());
- if (n == 0 || n == 3)
- {
- const double a = inner_radius*std::sqrt(2.0)/2e0;
- const double b = outer_radius*std::sqrt(2.0)/2e0;
- const double c = a*std::sqrt(3.0)/2e0;
- const double d = b*std::sqrt(3.0)/2e0;
- const double e = outer_radius/2e0;
- const double h = inner_radius/2e0;
-
- std::vector<Point<3> > vertices;
-
- vertices.push_back (center+Point<3>( 0, inner_radius, 0)); //0
- vertices.push_back (center+Point<3>( a, a, 0)); //1
- vertices.push_back (center+Point<3>( b, b, 0)); //2
- vertices.push_back (center+Point<3>( 0, outer_radius, 0)); //3
- vertices.push_back (center+Point<3>( 0, a , a)); //4
- vertices.push_back (center+Point<3>( c, c , h)); //5
- vertices.push_back (center+Point<3>( d, d , e)); //6
- vertices.push_back (center+Point<3>( 0, b , b)); //7
- vertices.push_back (center+Point<3>( inner_radius, 0 , 0)); //8
- vertices.push_back (center+Point<3>( outer_radius, 0 , 0)); //9
- vertices.push_back (center+Point<3>( a, 0 , a)); //10
- vertices.push_back (center+Point<3>( b, 0 , b)); //11
- vertices.push_back (center+Point<3>( 0, 0 , inner_radius)); //12
- vertices.push_back (center+Point<3>( 0, 0 , outer_radius)); //13
-
- const int cell_vertices[3][8] =
- {
- {0, 1, 3, 2, 4, 5, 7, 6},
- {1, 8, 2, 9, 5, 10, 6, 11},
- {4, 5, 7, 6, 12, 10, 13, 11},
+ template <>
+ void cylinder_shell (Triangulation<3> &tria,
+ const double length,
+ const double inner_radius,
+ const double outer_radius,
+ const unsigned int n_radial_cells,
+ const unsigned int n_axial_cells)
+ {
+ Assert ((inner_radius > 0) && (inner_radius < outer_radius),
+ ExcInvalidRadii ());
+
+ const double pi = numbers::PI;
+
+ // determine the number of cells
+ // for the grid. if not provided by
+ // the user determine it such that
+ // the length of each cell on the
+ // median (in the middle between
+ // the two circles) is equal to its
+ // radial extent (which is the
+ // difference between the two
+ // radii)
+ const unsigned int N_r = (n_radial_cells == 0 ?
+ static_cast<unsigned int>
+ (std::ceil((2*pi* (outer_radius + inner_radius)/2) /
+ (outer_radius - inner_radius))) :
+ n_radial_cells);
+ const unsigned int N_z = (n_axial_cells == 0 ?
+ static_cast<unsigned int>
+ (std::ceil (length /
+ (2*pi*(outer_radius + inner_radius)/2/N_r))) :
+ n_axial_cells);
+
+ // set up N vertices on the
+ // outer and N vertices on
+ // the inner circle. the
+ // first N ones are on the
+ // outer one, and all are
+ // numbered counter-clockwise
+ std::vector<Point<2> > vertices_2d(2*N_r);
+ for (unsigned int i=0; i<N_r; ++i)
+ {
+ vertices_2d[i] = Point<2>( std::cos(2*pi * i/N_r),
+ std::sin(2*pi * i/N_r)) * outer_radius;
+ vertices_2d[i+N_r] = vertices_2d[i] * (inner_radius/outer_radius);
};
- std::vector<CellData<3> > cells(3);
- for (unsigned int i=0; i<3; ++i)
+ std::vector<Point<3> > vertices_3d;
+ vertices_3d.reserve (2*N_r*(N_z+1));
+ for (unsigned int j=0; j<=N_z; ++j)
+ for (unsigned int i=0; i<2*N_r; ++i)
{
- for (unsigned int j=0; j<8; ++j)
- cells[i].vertices[j] = cell_vertices[i][j];
- cells[i].material_id = 0;
+ const Point<3> v (vertices_2d[i][0],
+ vertices_2d[i][1],
+ j*length/N_z);
+ vertices_3d.push_back (v);
}
- tria.create_triangulation ( vertices, cells, SubCellData()); // no boundary information
- }
- else
- {
- AssertThrow(false, ExcNotImplemented());
- }
+ std::vector<CellData<3> > cells (N_r*N_z, CellData<3>());
- if (colorize)
- colorize_quarter_hyper_shell(tria, center, inner_radius, outer_radius);
-}
+ for (unsigned int j=0; j<N_z; ++j)
+ for (unsigned int i=0; i<N_r; ++i)
+ {
+ cells[i+j*N_r].vertices[0] = i + (j+1)*2*N_r;
+ cells[i+j*N_r].vertices[1] = (i+1)%N_r + (j+1)*2*N_r;
+ cells[i+j*N_r].vertices[2] = i + j*2*N_r;
+ cells[i+j*N_r].vertices[3] = (i+1)%N_r + j*2*N_r;
+ cells[i+j*N_r].vertices[4] = N_r+i + (j+1)*2*N_r;
+ cells[i+j*N_r].vertices[5] = N_r+((i+1)%N_r) + (j+1)*2*N_r;
+ cells[i+j*N_r].vertices[6] = N_r+i + j*2*N_r;
+ cells[i+j*N_r].vertices[7] = N_r+((i+1)%N_r) + j*2*N_r;
-// Implementation for 3D only
-template <>
-void GridGenerator::cylinder_shell (Triangulation<3> &tria,
- const double length,
- const double inner_radius,
- const double outer_radius,
- const size_type n_radial_cells,
- const size_type n_axial_cells)
-{
- Assert ((inner_radius > 0) && (inner_radius < outer_radius),
- ExcInvalidRadii ());
-
- const double pi = numbers::PI;
-
- // determine the number of cells
- // for the grid. if not provided by
- // the user determine it such that
- // the length of each cell on the
- // median (in the middle between
- // the two circles) is equal to its
- // radial extent (which is the
- // difference between the two
- // radii)
- const size_type N_r = (n_radial_cells == 0 ?
- static_cast<size_type>
- (std::ceil((2*pi* (outer_radius + inner_radius)/2) /
- (outer_radius - inner_radius))) :
- n_radial_cells);
- const size_type N_z = (n_axial_cells == 0 ?
- static_cast<size_type>
- (std::ceil (length /
- (2*pi*(outer_radius + inner_radius)/2/N_r))) :
- n_axial_cells);
-
- // set up N vertices on the
- // outer and N vertices on
- // the inner circle. the
- // first N ones are on the
- // outer one, and all are
- // numbered counter-clockwise
- std::vector<Point<2> > vertices_2d(2*N_r);
- for (size_type i=0; i<N_r; ++i)
- {
- vertices_2d[i] = Point<2>( std::cos(2*pi * i/N_r),
- std::sin(2*pi * i/N_r)) * outer_radius;
- vertices_2d[i+N_r] = vertices_2d[i] * (inner_radius/outer_radius);
- };
+ cells[i+j*N_r].material_id = 0;
+ }
- std::vector<Point<3> > vertices_3d;
- vertices_3d.reserve (2*N_r*(N_z+1));
- for (size_type j=0; j<=N_z; ++j)
- for (size_type i=0; i<2*N_r; ++i)
- {
- const Point<3> v (vertices_2d[i][0],
- vertices_2d[i][1],
- j*length/N_z);
- vertices_3d.push_back (v);
- }
+ tria.create_triangulation (
+ vertices_3d, cells, SubCellData());
+ }
- std::vector<CellData<3> > cells (N_r*N_z, CellData<3>());
- for (size_type j=0; j<N_z; ++j)
- for (size_type i=0; i<N_r; ++i)
- {
- cells[i+j*N_r].vertices[0] = i + (j+1)*2*N_r;
- cells[i+j*N_r].vertices[1] = (i+1)%N_r + (j+1)*2*N_r;
- cells[i+j*N_r].vertices[2] = i + j*2*N_r;
- cells[i+j*N_r].vertices[3] = (i+1)%N_r + j*2*N_r;
- cells[i+j*N_r].vertices[4] = N_r+i + (j+1)*2*N_r;
- cells[i+j*N_r].vertices[5] = N_r+((i+1)%N_r) + (j+1)*2*N_r;
- cells[i+j*N_r].vertices[6] = N_r+i + j*2*N_r;
- cells[i+j*N_r].vertices[7] = N_r+((i+1)%N_r) + j*2*N_r;
+ template <int dim, int spacedim>
+ void
+ merge_triangulations (const Triangulation<dim, spacedim> &triangulation_1,
+ const Triangulation<dim, spacedim> &triangulation_2,
+ Triangulation<dim, spacedim> &result)
+ {
+ Assert (triangulation_1.n_levels() == 1,
+ ExcMessage ("The input triangulations must be coarse meshes."));
+ Assert (triangulation_2.n_levels() == 1,
+ ExcMessage ("The input triangulations must be coarse meshes."));
+
+ // get the union of the set of vertices
+ std::vector<Point<spacedim> > vertices = triangulation_1.get_vertices();
+ vertices.insert (vertices.end(),
+ triangulation_2.get_vertices().begin(),
+ triangulation_2.get_vertices().end());
+
+ // now form the union of the set of cells
+ std::vector<CellData<dim> > cells;
+ cells.reserve (triangulation_1.n_cells() + triangulation_2.n_cells());
+ for (typename Triangulation<dim,spacedim>::cell_iterator
+ cell = triangulation_1.begin(); cell != triangulation_1.end(); ++cell)
+ {
+ CellData<dim> this_cell;
+ for (unsigned int v=0; v<GeometryInfo<dim>::vertices_per_cell; ++v)
+ this_cell.vertices[v] = cell->vertex_index(v);
+ this_cell.material_id = cell->material_id();
+ cells.push_back (this_cell);
+ }
- cells[i+j*N_r].material_id = 0;
+ // now do the same for the other other mesh. note that we have to
+ // translate the vertex indices
+ for (typename Triangulation<dim,spacedim>::cell_iterator
+ cell = triangulation_2.begin(); cell != triangulation_2.end(); ++cell)
+ {
+ CellData<dim> this_cell;
+ for (unsigned int v=0; v<GeometryInfo<dim>::vertices_per_cell; ++v)
+ this_cell.vertices[v] = cell->vertex_index(v) + triangulation_1.n_vertices();
+ this_cell.material_id = cell->material_id();
+ cells.push_back (this_cell);
}
- tria.create_triangulation (
- vertices_3d, cells, SubCellData());
-}
+ // throw out duplicated vertices from the two meshes
+ // and create the triangulation
+ SubCellData subcell_data;
+ std::vector<unsigned int> considered_vertices;
+ GridTools::delete_duplicated_vertices (vertices, cells, subcell_data, considered_vertices);
+ result.clear ();
+ result.create_triangulation (vertices, cells, subcell_data);
+ }
+
+
+ void
+ extrude_triangulation(const Triangulation<2, 2> &input,
+ const unsigned int n_slices,
+ const double height,
+ Triangulation<3,3> &result)
+ {
+ Assert (input.n_levels() == 1,
+ ExcMessage ("The input triangulations must be coarse meshes."));
+ Assert(result.n_cells()==0, ExcMessage("resultin Triangulation need to be empty upon calling extrude_triangulation."));
+ Assert(height>0, ExcMessage("The height in extrude_triangulation needs to be positive."));
+ Assert(n_slices>=2, ExcMessage("The number of slices in extrude_triangulation needs to be at least 2."));
+ std::vector<Point<3> > points(n_slices*input.n_vertices());
+ std::vector<CellData<3> > cells;
+ cells.reserve((n_slices-1)*input.n_active_cells());
+ for (unsigned int slice=0; slice<n_slices; ++slice)
+ {
+ for (unsigned int i=0; i<input.n_vertices(); ++i)
-template <int dim, int spacedim>
-void
-GridGenerator::
-merge_triangulations (const Triangulation<dim, spacedim> &triangulation_1,
- const Triangulation<dim, spacedim> &triangulation_2,
- Triangulation<dim, spacedim> &result)
-{
- Assert (triangulation_1.n_levels() == 1,
- ExcMessage ("The input triangulations must be coarse meshes."));
- Assert (triangulation_2.n_levels() == 1,
- ExcMessage ("The input triangulations must be coarse meshes."));
-
- // get the union of the set of vertices
- std::vector<Point<spacedim> > vertices = triangulation_1.get_vertices();
- vertices.insert (vertices.end(),
- triangulation_2.get_vertices().begin(),
- triangulation_2.get_vertices().end());
-
- // now form the union of the set of cells
- std::vector<CellData<dim> > cells;
- cells.reserve (triangulation_1.n_cells() + triangulation_2.n_cells());
- for (typename Triangulation<dim,spacedim>::cell_iterator
- cell = triangulation_1.begin(); cell != triangulation_1.end(); ++cell)
- {
- CellData<dim> this_cell;
- for (unsigned int v=0; v<GeometryInfo<dim>::vertices_per_cell; ++v)
- this_cell.vertices[v] = cell->vertex_index(v);
- this_cell.material_id = cell->material_id();
- cells.push_back (this_cell);
- }
+ {
+ const Point<2> &v = input.get_vertices()[i];
+ points[i+slice*input.n_vertices()](0) = v(0);
+ points[i+slice*input.n_vertices()](1) = v(1);
+ points[i+slice*input.n_vertices()](2) = height * slice / (n_slices-1);
+ }
+ }
- // now do the same for the other other mesh. note that we have to
- // translate the vertex indices
- for (typename Triangulation<dim,spacedim>::cell_iterator
- cell = triangulation_2.begin(); cell != triangulation_2.end(); ++cell)
- {
- CellData<dim> this_cell;
- for (unsigned int v=0; v<GeometryInfo<dim>::vertices_per_cell; ++v)
- this_cell.vertices[v] = cell->vertex_index(v) + triangulation_1.n_vertices();
- this_cell.material_id = cell->material_id();
- cells.push_back (this_cell);
- }
+ for (Triangulation<2,2>::cell_iterator
+ cell = input.begin(); cell != input.end(); ++cell)
+ {
+ for (unsigned int slice=0; slice<n_slices-1; ++slice)
+ {
+ CellData<3> this_cell;
+ for (unsigned int v=0; v<GeometryInfo<2>::vertices_per_cell; ++v)
+ {
+ this_cell.vertices[v]
+ = cell->vertex_index(v)+slice*input.n_vertices();
+ this_cell.vertices[v+GeometryInfo<2>::vertices_per_cell]
+ = cell->vertex_index(v)+(slice+1)*input.n_vertices();
+ }
- // throw out duplicated vertices from the two meshes
- // and create the triangulation
- SubCellData subcell_data;
- std::vector<unsigned int> considered_vertices;
- GridTools::delete_duplicated_vertices (vertices, cells, subcell_data, considered_vertices);
- result.clear ();
- result.create_triangulation (vertices, cells, subcell_data);
-}
+ this_cell.material_id = cell->material_id();
+ cells.push_back(this_cell);
+ }
+ }
-void
-GridGenerator::
-extrude_triangulation(const Triangulation<2, 2> &input,
- const size_type n_slices,
- const double height,
- Triangulation<3,3> &result)
-{
- Assert (input.n_levels() == 1,
- ExcMessage ("The input triangulations must be coarse meshes."));
- Assert(result.n_cells()==0, ExcMessage("resultin Triangulation need to be empty upon calling extrude_triangulation."));
- Assert(height>0, ExcMessage("The height in extrude_triangulation needs to be positive."));
- Assert(n_slices>=2, ExcMessage("The number of slices in extrude_triangulation needs to be at least 2."));
+ SubCellData s;
+ types::boundary_id bid=0;
+ s.boundary_quads.reserve(input.n_active_lines()*(n_slices-1) + input.n_active_cells()*2);
+ for (Triangulation<2,2>::cell_iterator
+ cell = input.begin(); cell != input.end(); ++cell)
+ {
+ CellData<2> quad;
+ for (unsigned int f=0; f<4; ++f)
+ if (cell->at_boundary(f))
+ {
+ quad.boundary_id = cell->face(f)->boundary_indicator();
+ bid = std::max(bid, quad.boundary_id);
+ for (unsigned int slice=0; slice<n_slices-1; ++slice)
+ {
+ quad.vertices[0] = cell->face(f)->vertex_index(0)+slice*input.n_vertices();
+ quad.vertices[1] = cell->face(f)->vertex_index(1)+slice*input.n_vertices();
+ quad.vertices[2] = cell->face(f)->vertex_index(0)+(slice+1)*input.n_vertices();
+ quad.vertices[3] = cell->face(f)->vertex_index(1)+(slice+1)*input.n_vertices();
+ s.boundary_quads.push_back(quad);
+ }
+ }
+ }
- std::vector<Point<3> > points(n_slices*input.n_vertices());
- std::vector<CellData<3> > cells;
- cells.reserve((n_slices-1)*input.n_active_cells());
+ for (Triangulation<2,2>::cell_iterator
+ cell = input.begin(); cell != input.end(); ++cell)
+ {
+ CellData<2> quad;
+ quad.boundary_id = bid + 1;
+ quad.vertices[0] = cell->vertex_index(0);
+ quad.vertices[1] = cell->vertex_index(1);
+ quad.vertices[2] = cell->vertex_index(2);
+ quad.vertices[3] = cell->vertex_index(3);
+ s.boundary_quads.push_back(quad);
+
+ quad.boundary_id = bid + 2;
+ for (int i=0; i<4; ++i)
+ quad.vertices[i] += (n_slices-1)*input.n_vertices();
+ s.boundary_quads.push_back(quad);
+ }
- for (size_type slice=0; slice<n_slices; ++slice)
- {
- for (size_type i=0; i<input.n_vertices(); ++i)
+ result.create_triangulation (points,
+ cells,
+ s);
+ }
- {
- const Point<2> &v = input.get_vertices()[i];
- points[i+slice*input.n_vertices()](0) = v(0);
- points[i+slice*input.n_vertices()](1) = v(1);
- points[i+slice*input.n_vertices()](2) = height * slice / (n_slices-1);
- }
- }
- for (Triangulation<2,2>::cell_iterator
- cell = input.begin(); cell != input.end(); ++cell)
- {
- for (size_type slice=0; slice<n_slices-1; ++slice)
- {
- CellData<3> this_cell;
- for (unsigned int v=0; v<GeometryInfo<2>::vertices_per_cell; ++v)
- {
- this_cell.vertices[v]
- = cell->vertex_index(v)+slice*input.n_vertices();
- this_cell.vertices[v+GeometryInfo<2>::vertices_per_cell]
- = cell->vertex_index(v)+(slice+1)*input.n_vertices();
- }
+ /**
+ * Solve the Laplace equation for @p laplace_transformation function for one
+ * of the @p dim space dimensions. Factorized into a function of its own
+ * in order to allow parallel execution.
+ */
+ void laplace_solve (const SparseMatrix<double> &S,
+ const std::map<unsigned int,double> &m,
+ Vector<double> &u)
+ {
+ const unsigned int n_dofs=S.n();
+ FilteredMatrix<Vector<double> > SF (S);
+ PreconditionJacobi<SparseMatrix<double> > prec;
+ prec.initialize(S, 1.2);
+ FilteredMatrix<Vector<double> > PF (prec);
- this_cell.material_id = cell->material_id();
- cells.push_back(this_cell);
- }
- }
+ SolverControl control (n_dofs, 1.e-10, false, false);
+ GrowingVectorMemory<Vector<double> > mem;
+ SolverCG<Vector<double> > solver (control, mem);
- SubCellData s;
- types::boundary_id bid=0;
- s.boundary_quads.reserve(input.n_active_lines()*(n_slices-1) + input.n_active_cells()*2);
- for (Triangulation<2,2>::cell_iterator
- cell = input.begin(); cell != input.end(); ++cell)
- {
- CellData<2> quad;
- for (unsigned int f=0; f<4; ++f)
- if (cell->at_boundary(f))
- {
- quad.boundary_id = cell->face(f)->boundary_indicator();
- bid = std::max(bid, quad.boundary_id);
- for (size_type slice=0; slice<n_slices-1; ++slice)
- {
- quad.vertices[0] = cell->face(f)->vertex_index(0)+slice*input.n_vertices();
- quad.vertices[1] = cell->face(f)->vertex_index(1)+slice*input.n_vertices();
- quad.vertices[2] = cell->face(f)->vertex_index(0)+(slice+1)*input.n_vertices();
- quad.vertices[3] = cell->face(f)->vertex_index(1)+(slice+1)*input.n_vertices();
- s.boundary_quads.push_back(quad);
- }
- }
- }
+ Vector<double> f(n_dofs);
- for (Triangulation<2,2>::cell_iterator
- cell = input.begin(); cell != input.end(); ++cell)
- {
- CellData<2> quad;
- quad.boundary_id = bid + 1;
- quad.vertices[0] = cell->vertex_index(0);
- quad.vertices[1] = cell->vertex_index(1);
- quad.vertices[2] = cell->vertex_index(2);
- quad.vertices[3] = cell->vertex_index(3);
- s.boundary_quads.push_back(quad);
-
- quad.boundary_id = bid + 2;
- for (int i=0; i<4; ++i)
- quad.vertices[i] += (n_slices-1)*input.n_vertices();
- s.boundary_quads.push_back(quad);
- }
+ SF.add_constraints(m);
+ SF.apply_constraints (f, true);
+ solver.solve(SF, u, f, PF);
+ }
+// Implementation for 1D only
+ template <>
+ void laplace_transformation (Triangulation<1> &,
+ const std::map<unsigned int,Point<1> > &)
+ {
+ Assert(false, ExcNotImplemented());
+ }
- result.create_triangulation (
- points,
- cells,
- s);
-}
+// Implementation for dimensions except 1
+ template <int dim>
+ void laplace_transformation (Triangulation<dim> &tria,
+ const std::map<unsigned int,Point<dim> > &new_points)
+ {
+ // first provide everything that is
+ // needed for solving a Laplace
+ // equation.
+ MappingQ1<dim> mapping_q1;
+ FE_Q<dim> q1(1);
+
+ DoFHandler<dim> dof_handler(tria);
+ dof_handler.distribute_dofs(q1);
+
+ CompressedSparsityPattern c_sparsity_pattern (dof_handler.n_dofs (),
+ dof_handler.n_dofs ());
+ DoFTools::make_sparsity_pattern (dof_handler, c_sparsity_pattern);
+ c_sparsity_pattern.compress ();
+
+ SparsityPattern sparsity_pattern;
+ sparsity_pattern.copy_from (c_sparsity_pattern);
+ sparsity_pattern.compress ();
+
+ SparseMatrix<double> S(sparsity_pattern);
+
+ QGauss<dim> quadrature(4);
+
+ MatrixCreator::create_laplace_matrix(mapping_q1, dof_handler, quadrature, S);
+
+ // set up the boundary values for
+ // the laplace problem
+ std::vector<std::map<unsigned int,double> > m(dim);
+ typename std::map<unsigned int,Point<dim> >::const_iterator map_iter;
+ typename std::map<unsigned int,Point<dim> >::const_iterator map_end=new_points.end();
+
+ // fill these maps using the data
+ // given by new_points
+ typename DoFHandler<dim>::cell_iterator cell=dof_handler.begin_active(),
+ endc=dof_handler.end();
+ typename DoFHandler<dim>::face_iterator face;
+ for (; cell!=endc; ++cell)
+ {
+ if (cell->at_boundary())
+ for (unsigned int face_no=0; face_no<GeometryInfo<dim>::faces_per_cell; ++face_no)
+ {
+ face=cell->face(face_no);
+ if (face->at_boundary())
+ for (unsigned int vertex_no=0;
+ vertex_no<GeometryInfo<dim>::vertices_per_face; ++vertex_no)
+ {
+ const unsigned int vertex_index=face->vertex_index(vertex_no);
+ map_iter=new_points.find(vertex_index);
-// make the following function inline. this is so that it becomes marked
-// internal/weak for the linker and we don't get multiply defined errors
-// when linking with more than one dimension at a time. Usually we used
-// the trick of putting these functions in a .all_dimensions.cc file, but
-// this is not necessary here as this is an internal only function.
-inline
-void GridGenerator::laplace_solve (const SparseMatrix<double> &S,
- const std::map<size_type,double> &m,
- Vector<double> &u)
-{
- const size_type n_dofs=S.n();
- FilteredMatrix<Vector<double> > SF (S);
- PreconditionJacobi<SparseMatrix<double> > prec;
- prec.initialize(S, 1.2);
- FilteredMatrix<Vector<double> > PF (prec);
+ if (map_iter!=map_end)
+ for (unsigned int i=0; i<dim; ++i)
+ m[i].insert(std::pair<unsigned int,double> (
+ face->vertex_dof_index(vertex_no, 0), map_iter->second(i)));
+ }
+ }
+ }
- SolverControl control (n_dofs, 1.e-10, false, false);
- GrowingVectorMemory<Vector<double> > mem;
- SolverCG<Vector<double> > solver (control, mem);
+ // solve the dim problems with
+ // different right hand sides.
+ Vector<double> us[dim];
+ for (unsigned int i=0; i<dim; ++i)
+ us[i].reinit (dof_handler.n_dofs());
+
+ // solve linear systems in parallel
+ Threads::TaskGroup<> tasks;
+ for (unsigned int i=0; i<dim; ++i)
+ tasks += Threads::new_task (&laplace_solve,
+ S, m[i], us[i]);
+ tasks.join_all ();
+
+ // change the coordinates of the
+ // points of the triangulation
+ // according to the computed values
+ for (cell=dof_handler.begin_active(); cell!=endc; ++cell)
+ for (unsigned int vertex_no=0;
+ vertex_no<GeometryInfo<dim>::vertices_per_cell; ++vertex_no)
+ {
+ Point<dim> &v=cell->vertex(vertex_no);
+ const unsigned int dof_index=cell->vertex_dof_index(vertex_no, 0);
+ for (unsigned int i=0; i<dim; ++i)
+ v(i)=us[i](dof_index);
+ }
+ }
- Vector<double> f(n_dofs);
- SF.add_constraints(m);
- SF.apply_constraints (f, true);
- solver.solve(SF, u, f, PF);
-}
+ template <>
+ void hyper_cube_with_cylindrical_hole (Triangulation<1> &,
+ const double,
+ const double,
+ const double,
+ const unsigned int,
+ bool)
+ {
+ Assert(false, ExcNotImplemented());
+ }
-// Implementation for 1D only
-template <>
-void GridGenerator::laplace_transformation (Triangulation<1> &,
- const std::map<size_type,Point<1> > &)
-{
- Assert(false, ExcNotImplemented());
-}
-// Implementation for dimensions except 1
-template <int dim>
-void GridGenerator::laplace_transformation (Triangulation<dim> &tria,
- const std::map<size_type,Point<dim> > &new_points)
-{
- // first provide everything that is
- // needed for solving a Laplace
- // equation.
- MappingQ1<dim> mapping_q1;
- FE_Q<dim> q1(1);
-
- DoFHandler<dim> dof_handler(tria);
- dof_handler.distribute_dofs(q1);
-
- CompressedSparsityPattern c_sparsity_pattern (dof_handler.n_dofs (),
- dof_handler.n_dofs ());
- DoFTools::make_sparsity_pattern (dof_handler, c_sparsity_pattern);
- c_sparsity_pattern.compress ();
-
- SparsityPattern sparsity_pattern;
- sparsity_pattern.copy_from (c_sparsity_pattern);
- sparsity_pattern.compress ();
-
- SparseMatrix<double> S(sparsity_pattern);
-
- QGauss<dim> quadrature(4);
-
- MatrixCreator::create_laplace_matrix(mapping_q1, dof_handler, quadrature, S);
-
- // set up the boundary values for
- // the laplace problem
- std::vector<std::map<size_type,double> > m(dim);
- typename std::map<size_type,Point<dim> >::const_iterator map_iter;
- typename std::map<size_type,Point<dim> >::const_iterator map_end=new_points.end();
-
- // fill these maps using the data
- // given by new_points
- typename DoFHandler<dim>::cell_iterator cell=dof_handler.begin_active(),
- endc=dof_handler.end();
- typename DoFHandler<dim>::face_iterator face;
- for (; cell!=endc; ++cell)
- {
- if (cell->at_boundary())
- for (unsigned int face_no=0; face_no<GeometryInfo<dim>::faces_per_cell; ++face_no)
- {
- face=cell->face(face_no);
- if (face->at_boundary())
- for (unsigned int vertex_no=0;
- vertex_no<GeometryInfo<dim>::vertices_per_face; ++vertex_no)
+ template <>
+ void
+ hyper_cube_with_cylindrical_hole (Triangulation<2> &triangulation,
+ const double inner_radius,
+ const double outer_radius,
+ const double, // width,
+ const unsigned int, // width_repetition,
+ bool colorize)
+ {
+ const int dim = 2;
+
+ Assert(inner_radius < outer_radius,
+ ExcMessage("outer_radius has to be bigger than inner_radius."));
+
+ Point<dim> center;
+ // We create an hyper_shell in two dimensions, and then we modify it.
+ hyper_shell (triangulation,
+ center, inner_radius, outer_radius,
+ 8);
+ Triangulation<dim>::active_cell_iterator
+ cell = triangulation.begin_active(),
+ endc = triangulation.end();
+ std::vector<bool> treated_vertices(triangulation.n_vertices(), false);
+ for (; cell != endc; ++cell)
+ {
+ for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
+ if (cell->face(f)->at_boundary())
+ {
+ for (unsigned int v=0; v < GeometryInfo<dim>::vertices_per_face; ++v)
{
- const size_type vertex_index=face->vertex_index(vertex_no);
- map_iter=new_points.find(vertex_index);
-
- if (map_iter!=map_end)
- for (unsigned int i=0; i<dim; ++i)
- m[i].insert(std::pair<size_type,double> (
- face->vertex_dof_index(vertex_no, 0), map_iter->second(i)));
+ unsigned int vv = cell->face(f)->vertex_index(v);
+ if (treated_vertices[vv] == false)
+ {
+ treated_vertices[vv] = true;
+ switch (vv)
+ {
+ case 1:
+ cell->face(f)->vertex(v) = center+Point<dim>(outer_radius,outer_radius);
+ break;
+ case 3:
+ cell->face(f)->vertex(v) = center+Point<dim>(-outer_radius,outer_radius);
+ break;
+ case 5:
+ cell->face(f)->vertex(v) = center+Point<dim>(-outer_radius,-outer_radius);
+ break;
+ case 7:
+ cell->face(f)->vertex(v) = center+Point<dim>(outer_radius,-outer_radius);
+ default:
+ break;
+ }
+ }
}
- }
- }
-
- // solve the dim problems with
- // different right hand sides.
- Vector<double> us[dim];
- for (unsigned int i=0; i<dim; ++i)
- us[i].reinit (dof_handler.n_dofs());
-
- // solve linear systems in parallel
- Threads::TaskGroup<> tasks;
- for (unsigned int i=0; i<dim; ++i)
- tasks += Threads::new_task (&GridGenerator::laplace_solve,
- S, m[i], us[i]);
- tasks.join_all ();
-
- // change the coordinates of the
- // points of the triangulation
- // according to the computed values
- for (cell=dof_handler.begin_active(); cell!=endc; ++cell)
- for (size_type vertex_no=0;
- vertex_no<GeometryInfo<dim>::vertices_per_cell; ++vertex_no)
- {
- Point<dim> &v=cell->vertex(vertex_no);
- const size_type dof_index=cell->vertex_dof_index(vertex_no, 0);
- for (unsigned int i=0; i<dim; ++i)
- v(i)=us[i](dof_index);
+ }
}
-}
-
-
-
-template <>
-void GridGenerator::hyper_cube_with_cylindrical_hole (Triangulation<1> &,
- const double,
- const double,
- const double,
- const size_type,
- bool)
-{
- Assert(false, ExcNotImplemented());
-}
-
+ double eps = 1e-3 * outer_radius;
+ cell = triangulation.begin_active();
+ for (; cell != endc; ++cell)
+ {
+ for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
+ if (cell->face(f)->at_boundary())
+ {
+ double dx = cell->face(f)->center()(0) - center(0);
+ double dy = cell->face(f)->center()(1) - center(1);
+ if (colorize)
+ {
+ if (std::abs(dx + outer_radius) < eps)
+ cell->face(f)->set_boundary_indicator(0);
+ else if (std::abs(dx - outer_radius) < eps)
+ cell->face(f)->set_boundary_indicator(1);
+ else if (std::abs(dy + outer_radius) < eps)
+ cell->face(f)->set_boundary_indicator(2);
+ else if (std::abs(dy - outer_radius) < eps)
+ cell->face(f)->set_boundary_indicator(3);
+ else
+ cell->face(f)->set_boundary_indicator(4);
+ }
+ else
+ {
+ double d = (cell->face(f)->center() - center).norm();
+ if (d-inner_radius < 0)
+ cell->face(f)->set_boundary_indicator(1);
+ else
+ cell->face(f)->set_boundary_indicator(0);
+ }
+ }
+ }
+ }
-template <>
-void
-GridGenerator::hyper_cube_with_cylindrical_hole (Triangulation<2> &triangulation,
- const double inner_radius,
- const double outer_radius,
- const double, // width,
- const size_type, // width_repetition,
- bool colorize)
-{
- const int dim = 2;
-
- Assert(inner_radius < outer_radius,
- ExcMessage("outer_radius has to be bigger than inner_radius."));
-
- Point<dim> center;
- // We create an hyper_shell in two dimensions, and then we modify it.
- GridGenerator::hyper_shell (triangulation,
- center, inner_radius, outer_radius,
- 8);
- Triangulation<dim>::active_cell_iterator
- cell = triangulation.begin_active(),
- endc = triangulation.end();
- std::vector<bool> treated_vertices(triangulation.n_vertices(), false);
- for (; cell != endc; ++cell)
- {
- for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
- if (cell->face(f)->at_boundary())
- {
- for (unsigned int v=0; v < GeometryInfo<dim>::vertices_per_face; ++v)
- {
- size_type vv = cell->face(f)->vertex_index(v);
- if (treated_vertices[vv] == false)
- {
- treated_vertices[vv] = true;
- switch (vv)
- {
- case 1:
- cell->face(f)->vertex(v) = center+Point<dim>(outer_radius,outer_radius);
- break;
- case 3:
- cell->face(f)->vertex(v) = center+Point<dim>(-outer_radius,outer_radius);
- break;
- case 5:
- cell->face(f)->vertex(v) = center+Point<dim>(-outer_radius,-outer_radius);
- break;
- case 7:
- cell->face(f)->vertex(v) = center+Point<dim>(outer_radius,-outer_radius);
- default:
- break;
- }
- }
- }
- }
- }
- double eps = 1e-3 * outer_radius;
- cell = triangulation.begin_active();
- for (; cell != endc; ++cell)
- {
- for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
- if (cell->face(f)->at_boundary())
- {
- double dx = cell->face(f)->center()(0) - center(0);
- double dy = cell->face(f)->center()(1) - center(1);
- if (colorize)
- {
- if (std::abs(dx + outer_radius) < eps)
- cell->face(f)->set_boundary_indicator(0);
- else if (std::abs(dx - outer_radius) < eps)
- cell->face(f)->set_boundary_indicator(1);
- else if (std::abs(dy + outer_radius) < eps)
- cell->face(f)->set_boundary_indicator(2);
- else if (std::abs(dy - outer_radius) < eps)
- cell->face(f)->set_boundary_indicator(3);
- else
- cell->face(f)->set_boundary_indicator(4);
- }
- else
- {
- double d = (cell->face(f)->center() - center).norm();
- if (d-inner_radius < 0)
- cell->face(f)->set_boundary_indicator(1);
- else
- cell->face(f)->set_boundary_indicator(0);
- }
- }
- }
-}
-template <>
-void GridGenerator::hyper_cube_with_cylindrical_hole(Triangulation<3> &triangulation,
- const double inner_radius,
- const double outer_radius,
- const double L,
- const size_type Nz,
- bool colorize)
-{
- const int dim = 3;
-
- Assert(inner_radius < outer_radius,
- ExcMessage("outer_radius has to be bigger than inner_radius."));
- Assert(L > 0,
- ExcMessage("Must give positive extension L"));
- Assert(Nz >= 1, ExcLowerRange(1, Nz));
-
- GridGenerator::cylinder_shell (triangulation,
- L, inner_radius, outer_radius,
- 8,
- Nz);
-
- Triangulation<dim>::active_cell_iterator
- cell = triangulation.begin_active(),
- endc = triangulation.end();
- std::vector<bool> treated_vertices(triangulation.n_vertices(), false);
- for (; cell != endc; ++cell)
- {
- for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
- if (cell->face(f)->at_boundary())
- {
- for (unsigned int v=0; v < GeometryInfo<dim>::vertices_per_face; ++v)
- {
- size_type vv = cell->face(f)->vertex_index(v);
- if (treated_vertices[vv] == false)
- {
- treated_vertices[vv] = true;
- for (size_type i=0; i<=Nz; ++i)
- {
- double d = ((double) i)*L/((double) Nz);
- switch (vv-i*16)
- {
- case 1:
- cell->face(f)->vertex(v) = Point<dim>(outer_radius,outer_radius,d);
- break;
- case 3:
- cell->face(f)->vertex(v) = Point<dim>(-outer_radius,outer_radius,d);
- break;
- case 5:
- cell->face(f)->vertex(v) = Point<dim>(-outer_radius,-outer_radius,d);
- break;
- case 7:
- cell->face(f)->vertex(v) = Point<dim>(outer_radius,-outer_radius,d);
- break;
- default:
- break;
- }
- }
- }
- }
- }
- }
- double eps = 1e-3 * outer_radius;
- cell = triangulation.begin_active();
- for (; cell != endc; ++cell)
- {
- for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
- if (cell->face(f)->at_boundary())
- {
- double dx = cell->face(f)->center()(0);
- double dy = cell->face(f)->center()(1);
- double dz = cell->face(f)->center()(2);
+ template <>
+ void hyper_cube_with_cylindrical_hole(Triangulation<3> &triangulation,
+ const double inner_radius,
+ const double outer_radius,
+ const double L,
+ const unsigned int Nz,
+ bool colorize)
+ {
+ const int dim = 3;
+
+ Assert(inner_radius < outer_radius,
+ ExcMessage("outer_radius has to be bigger than inner_radius."));
+ Assert(L > 0,
+ ExcMessage("Must give positive extension L"));
+ Assert(Nz >= 1, ExcLowerRange(1, Nz));
+
+ cylinder_shell (triangulation,
+ L, inner_radius, outer_radius,
+ 8,
+ Nz);
+
+ Triangulation<dim>::active_cell_iterator
+ cell = triangulation.begin_active(),
+ endc = triangulation.end();
+ std::vector<bool> treated_vertices(triangulation.n_vertices(), false);
+ for (; cell != endc; ++cell)
+ {
+ for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
+ if (cell->face(f)->at_boundary())
+ {
+ for (unsigned int v=0; v < GeometryInfo<dim>::vertices_per_face; ++v)
+ {
+ unsigned int vv = cell->face(f)->vertex_index(v);
+ if (treated_vertices[vv] == false)
+ {
+ treated_vertices[vv] = true;
+ for (unsigned int i=0; i<=Nz; ++i)
+ {
+ double d = ((double) i)*L/((double) Nz);
+ switch (vv-i*16)
+ {
+ case 1:
+ cell->face(f)->vertex(v) = Point<dim>(outer_radius,outer_radius,d);
+ break;
+ case 3:
+ cell->face(f)->vertex(v) = Point<dim>(-outer_radius,outer_radius,d);
+ break;
+ case 5:
+ cell->face(f)->vertex(v) = Point<dim>(-outer_radius,-outer_radius,d);
+ break;
+ case 7:
+ cell->face(f)->vertex(v) = Point<dim>(outer_radius,-outer_radius,d);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ double eps = 1e-3 * outer_radius;
+ cell = triangulation.begin_active();
+ for (; cell != endc; ++cell)
+ {
+ for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
+ if (cell->face(f)->at_boundary())
+ {
+ double dx = cell->face(f)->center()(0);
+ double dy = cell->face(f)->center()(1);
+ double dz = cell->face(f)->center()(2);
- if (colorize)
- {
- if (std::abs(dx + outer_radius) < eps)
- cell->face(f)->set_boundary_indicator(0);
+ if (colorize)
+ {
+ if (std::abs(dx + outer_radius) < eps)
+ cell->face(f)->set_boundary_indicator(0);
- else if (std::abs(dx - outer_radius) < eps)
- cell->face(f)->set_boundary_indicator(1);
+ else if (std::abs(dx - outer_radius) < eps)
+ cell->face(f)->set_boundary_indicator(1);
- else if (std::abs(dy + outer_radius) < eps)
- cell->face(f)->set_boundary_indicator(2);
+ else if (std::abs(dy + outer_radius) < eps)
+ cell->face(f)->set_boundary_indicator(2);
- else if (std::abs(dy - outer_radius) < eps)
- cell->face(f)->set_boundary_indicator(3);
+ else if (std::abs(dy - outer_radius) < eps)
+ cell->face(f)->set_boundary_indicator(3);
- else if (std::abs(dz) < eps)
- cell->face(f)->set_boundary_indicator(4);
+ else if (std::abs(dz) < eps)
+ cell->face(f)->set_boundary_indicator(4);
- else if (std::abs(dz - L) < eps)
- cell->face(f)->set_boundary_indicator(5);
+ else if (std::abs(dz - L) < eps)
+ cell->face(f)->set_boundary_indicator(5);
- else
- {
- cell->face(f)->set_boundary_indicator(6);
- for (unsigned int l=0; l<GeometryInfo<dim>::lines_per_face; ++l)
- cell->face(f)->line(l)->set_boundary_indicator(6);
- }
+ else
+ {
+ cell->face(f)->set_boundary_indicator(6);
+ for (unsigned int l=0; l<GeometryInfo<dim>::lines_per_face; ++l)
+ cell->face(f)->line(l)->set_boundary_indicator(6);
+ }
- }
- else
- {
- Point<dim> c = cell->face(f)->center();
- c(2) = 0;
- double d = c.norm();
- if (d-inner_radius < 0)
- {
- cell->face(f)->set_boundary_indicator(1);
- for (unsigned int l=0; l<GeometryInfo<dim>::lines_per_face; ++l)
- cell->face(f)->line(l)->set_boundary_indicator(1);
- }
- else
- cell->face(f)->set_boundary_indicator(0);
- }
- }
- }
+ }
+ else
+ {
+ Point<dim> c = cell->face(f)->center();
+ c(2) = 0;
+ double d = c.norm();
+ if (d-inner_radius < 0)
+ {
+ cell->face(f)->set_boundary_indicator(1);
+ for (unsigned int l=0; l<GeometryInfo<dim>::lines_per_face; ++l)
+ cell->face(f)->line(l)->set_boundary_indicator(1);
+ }
+ else
+ cell->face(f)->set_boundary_indicator(0);
+ }
+ }
+ }
+ }
}
-
// explicit instantiations
#include "grid_generator.inst"
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
{
+namespace GridGenerator
+\{
#if deal_II_dimension <= deal_II_space_dimension
template void
- GridGenerator::hyper_rectangle<deal_II_dimension, deal_II_space_dimension> (
+ hyper_rectangle<deal_II_dimension, deal_II_space_dimension> (
Triangulation<deal_II_dimension, deal_II_space_dimension> &,
const Point<deal_II_space_dimension>&, const Point<deal_II_space_dimension>&,
const bool);
template void
- GridGenerator::colorize_hyper_rectangle<deal_II_dimension, deal_II_space_dimension> (
- Triangulation<deal_II_dimension, deal_II_space_dimension> &);
-
- template void
- GridGenerator::hyper_cube<deal_II_dimension, deal_II_space_dimension> (
+ hyper_cube<deal_II_dimension, deal_II_space_dimension> (
Triangulation<deal_II_dimension, deal_II_space_dimension> &, const double, const double);
template
void
- GridGenerator::merge_triangulations
+ merge_triangulations
(const Triangulation<deal_II_dimension,deal_II_space_dimension> &triangulation_1,
const Triangulation<deal_II_dimension,deal_II_space_dimension> &triangulation_2,
Triangulation<deal_II_dimension,deal_II_space_dimension> &result);
#endif
+\}
}
for (deal_II_dimension : DIMENSIONS)
{
-
+namespace GridGenerator \{
template void
- GridGenerator::subdivided_hyper_cube<deal_II_dimension> (
+ subdivided_hyper_cube<deal_II_dimension> (
Triangulation<deal_II_dimension> &,
const unsigned int, const double, const double);
template void
- GridGenerator::subdivided_hyper_rectangle<deal_II_dimension>
+ subdivided_hyper_rectangle<deal_II_dimension>
(Triangulation<deal_II_dimension> &,
const std::vector<unsigned int>&,
const Point<deal_II_dimension>&,
template
void
- GridGenerator::subdivided_hyper_rectangle(
+ subdivided_hyper_rectangle(
Triangulation<deal_II_dimension> &,
const std::vector<std::vector<double> > &,
const Point<deal_II_dimension> &,
const bool );
template void
- GridGenerator::parallelepiped<deal_II_dimension> (
+ parallelepiped<deal_II_dimension> (
Triangulation<deal_II_dimension>&,
const Point<deal_II_dimension> (&) [deal_II_dimension],
const bool);
template void
- GridGenerator::subdivided_parallelepiped<deal_II_dimension> (
+ subdivided_parallelepiped<deal_II_dimension> (
Triangulation<deal_II_dimension>&,
- const size_type,
+ const unsigned int,
const Point<deal_II_dimension> (&) [deal_II_dimension],
const bool);
template void
- GridGenerator::subdivided_parallelepiped<deal_II_dimension> (
+ subdivided_parallelepiped<deal_II_dimension> (
Triangulation<deal_II_dimension>&,
- const size_type [deal_II_dimension],
+ const unsigned int [deal_II_dimension],
const Point<deal_II_dimension> (&) [deal_II_dimension],
const bool);
#if deal_II_dimension > 1
template void
- GridGenerator::
laplace_transformation<deal_II_dimension> (Triangulation<deal_II_dimension> &,
- const std::map<types::global_dof_index,Point<deal_II_dimension> > &);
+ const std::map<unsigned int,Point<deal_II_dimension> > &);
#endif
-
+\}
}
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/path_search.h>
#include <deal.II/base/utilities.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
{
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2008, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/grid/grid_out.h>
#include <deal.II/base/parameter_handler.h>
default:
Assert (false, ExcNotImplemented());
return "";
- };
+ }
}
GridOutFlags::XFig::declare_parameters(param);
param.leave_subsection();
- param.enter_subsection("MathGl");
+ param.enter_subsection("MathGL");
GridOutFlags::MathGL::declare_parameters(param);
param.leave_subsection();
}
for (unsigned int i=0; i<vertices.size(); ++i)
if (vertex_used[i])
- {
out << '\t' << vertices[i] << '\n';
- };
// write cells or faces
const bool write_cells = dx_flags.write_cells;
for (unsigned int d=spacedim+1; d<=3; ++d)
out << " 0"; // fill with zeroes
out << std::endl;
- };
+ }
// Write cells preamble
out << "$ENDNOD" << std::endl
++vertex)
out << cell->vertex_index(GeometryInfo<dim>::ucd_to_deal[vertex])+1 << ' ';
out << std::endl;
- };
+ }
// write faces and lines with
// non-zero boundary indicator
<< "# For a description of the UCD format see the AVS Developer's guide."
<< '\n'
<< "#" << '\n';
- };
+ }
// start with ucd data
out << n_vertices << ' '
for (unsigned int d=spacedim+1; d<=3; ++d)
out << " 0"; // fill with zeroes
out << '\n';
- };
+ }
// write cells. Enumerate cells
// consecutively, starting with 1
break;
default:
Assert (false, ExcNotImplemented());
- };
+ }
// it follows a list of the
// vertices of each cell. in 1d
++vertex)
out << cell->vertex_index(GeometryInfo<dim>::ucd_to_deal[vertex])+1 << ' ';
out << '\n';
- };
+ }
// write faces and lines with
// non-zero boundary indicator
unsigned int n_levels = 0;
unsigned int n_subdomains = 0;
unsigned int n_level_subdomains = 0;
-
+
unsigned int n = 0;
unsigned int min_level, max_level;
// auxiliary array for the level subdomains being used
int level_subdomains[256];
- for(int level_subdomain_index = 0; level_subdomain_index < 256; level_subdomain_index++)
+ for (int level_subdomain_index = 0; level_subdomain_index < 256; level_subdomain_index++)
level_subdomains[level_subdomain_index] = 0;
// We use an active cell iterator to determine the
if ((unsigned int)cell->level() < min_level) min_level = cell->level();
if ((unsigned int)cell->level() > max_level) max_level = cell->level();
- materials[(unsigned int)cell->material_id()] = 1;
+ materials[(unsigned int)cell->material_id()] = 1;
levels[(unsigned int)cell->level()] = 1;
if (cell->active())
- subdomains[cell->subdomain_id()+2] = 1;
+ subdomains[cell->subdomain_id()+2] = 1;
level_subdomains[cell->level_subdomain_id()+2] = 1;
}
}
// count the level subdomains being used
- for(int level_subdomain_index = 0; level_subdomain_index < 256; level_subdomain_index++)
- {
- if(level_subdomains[level_subdomain_index]) n_level_subdomains++;
- }
+ for (int level_subdomain_index = 0; level_subdomain_index < 256; level_subdomain_index++)
+ {
+ if (level_subdomains[level_subdomain_index]) n_level_subdomains++;
+ }
switch (svg_flags.coloring)
{
- case GridOutFlags::Svg::material_id:
+ case GridOutFlags::Svg::material_id:
n = n_materials;
break;
case GridOutFlags::Svg::level_number:
case GridOutFlags::Svg::subdomain_id:
n = n_subdomains;
break;
- case GridOutFlags::Svg::level_subdomain_id: n = n_level_subdomains;
+ case GridOutFlags::Svg::level_subdomain_id:
+ n = n_level_subdomains;
break;
default:
break;
x_dimension_perspective = x_max_perspective - x_min_perspective;
y_dimension_perspective = y_max_perspective - y_min_perspective;
- cell_label_font_size = static_cast<unsigned int>(.5 + (height/100.) * 2.75) * 9. * (min_level_min_vertex_distance / std::min(x_dimension, y_dimension));
+ cell_label_font_size = static_cast<unsigned int>((int)(.5 + (height/100.) * 2.75) * 9. * (min_level_min_vertex_distance / std::min(x_dimension, y_dimension)));
// create the svg file with an internal style sheet
case GridOutFlags::Svg::subdomain_id:
while (!subdomains[labeling_index]) labeling_index++;
break;
- case GridOutFlags::Svg::level_subdomain_id:
- while(!level_subdomains[labeling_index]) labeling_index++;
- break;
+ case GridOutFlags::Svg::level_subdomain_id:
+ while (!level_subdomains[labeling_index]) labeling_index++;
+ break;
default:
break;
}
out << (unsigned int)cell->level();
break;
case GridOutFlags::Svg::subdomain_id:
- out << cell->subdomain_id() + 2;
+ if (cell->active())
+ out << cell->subdomain_id() + 2;
+ else
+ out << 'X';
+ break;
+ case GridOutFlags::Svg::level_subdomain_id:
+ out << cell->level_subdomain_id() + 2;
break;
- case GridOutFlags::Svg::level_subdomain_id:
- out << cell->level_subdomain_id() + 2;
- break;
default:
break;
}
if (svg_flags.label_subdomain_id)
{
- if (svg_flags.label_level_number || svg_flags.label_cell_index || svg_flags.label_material_id) out << ',';
- out << static_cast<int>(cell->subdomain_id());
+ if (svg_flags.label_level_number
+ || svg_flags.label_cell_index
+ || svg_flags.label_material_id)
+ out << ',';
+ if (cell->active())
+ out << static_cast<int>(cell->subdomain_id());
+ else
+ out << 'X';
}
- if(svg_flags.label_level_subdomain_id)
- {
- if(svg_flags.label_level_number
- || svg_flags.label_cell_index
- || svg_flags.label_material_id
- || svg_flags.label_subdomain_id)
- out << ',';
- out << static_cast<int>(cell->level_subdomain_id());
- }
+ if (svg_flags.label_level_subdomain_id)
+ {
+ if (svg_flags.label_level_number
+ || svg_flags.label_cell_index
+ || svg_flags.label_material_id
+ || svg_flags.label_subdomain_id)
+ out << ',';
+ out << static_cast<int>(cell->level_subdomain_id());
+ }
out << "</text>" << '\n';
}
<< "\">"
<< "subdomain_id";
- if(svg_flags.label_level_subdomain_id)
- out << ',';
+ if (svg_flags.label_level_subdomain_id)
+ out << ',';
out << "</text>" << '\n';
}
- if(svg_flags.label_level_subdomain_id)
- {
- out << " <text x= \"" << width + additional_width + static_cast<unsigned int>(.5 + (height/100.) * 2.)
- << "\" y=\"" << static_cast<unsigned int>(.5 + (height/100.) * margin_in_percent + (++line_offset) * 1.5 * font_size )
- << "\" style=\"text-anchor:start; font-style:oblique; font-size:" << font_size
- << "\">"
- << "level_subdomain_id"
- << "</text>" << '\n';
- }
+ if (svg_flags.label_level_subdomain_id)
+ {
+ out << " <text x= \"" << width + additional_width + static_cast<unsigned int>(.5 + (height/100.) * 2.)
+ << "\" y=\"" << static_cast<unsigned int>(.5 + (height/100.) * margin_in_percent + (++line_offset) * 1.5 * font_size )
+ << "\" style=\"text-anchor:start; font-style:oblique; font-size:" << font_size
+ << "\">"
+ << "level_subdomain_id"
+ << "</text>" << '\n';
+ }
}
// show azimuth angle and polar angle as text below the explanation of the cell labeling
case 3:
out << "subdomain_id";
break;
- case 4: out << "level_subdomain_id";
- break;
+ case 4:
+ out << "level_subdomain_id";
+ break;
default:
break;
}
case GridOutFlags::Svg::subdomain_id:
while (!subdomains[labeling_index]) labeling_index++;
break;
- case GridOutFlags::Svg::level_subdomain_id: while(!level_subdomains[labeling_index]) labeling_index++;
- break;
+ case GridOutFlags::Svg::level_subdomain_id:
+ while (!level_subdomains[labeling_index]) labeling_index++;
+ break;
default:
break;
}
break;
default:
Assert (false, ExcNotImplemented ());
- };
+ }
out << "\n";
// (iii) write vertex ordering
{
case 2:
out << "\nlist f 0 1 2 3"
- << "\n";
+ << "\n";
break;
case 3:
out << "\nlist f 0 2 4 6 | 1 3 5 7 | 0 4 1 5 | 2 6 3 7 | 0 1 2 3 | 4 5 6 7"
- << "\n";
+ << "\n";
break;
default:
Assert (false, ExcNotImplemented ());
- };
+ }
// (iv) write a list of vertices of cells
out << "\n#"
break;
default:
Assert (false, ExcNotImplemented());
- };
+ }
out << static_cast<unsigned int>(face->boundary_indicator())
<< ' '
<< static_cast<unsigned int>(face->boundary_indicator())
out << '\n';
++index;
- };
+ }
}
break;
default:
Assert (false, ExcNotImplemented());
- };
+ }
// note: vertex numbers are 1-base
for (unsigned int vertex=0; vertex<GeometryInfo<dim>::vertices_per_face; ++vertex)
out << face->vertex_index(GeometryInfo<dim-1>::ucd_to_deal[vertex])+1 << ' ';
out << '\n';
++index;
- };
+ }
}
{
Assert(false, ExcInternalError());
break;
- };
+ }
case 2:
{
line_list.push_back (LineEntry(p0, p1,
face->user_flag_set(),
cell->level()));
- };
- };
- };
+ }
+ }
+ }
break;
- };
+ }
case 3:
{
y_max = std::max (y_max, line->second(1));
max_level = std::max (max_level, line->level);
- };
+ }
// scale in x-direction such that
// in the output 0 <= x <= 300.
"/MCshow { currentpoint stroke m\n"
"exch dup MFwidth -2 div 3 -1 roll R MFshow } def\n")
<< '\n';
- };
+ }
out << "%%EndProlog" << '\n'
<< '\n';
// set fine lines
out << eps_flags_base.line_width << " setlinewidth" << '\n';
- };
+ }
// now write the lines
const Point<2> offset(x_min, y_min);
out << ")] "
<< "] -6 MCshow"
<< '\n';
- };
- };
+ }
+ }
// and the vertex numbers
if ((dim == 2) && (eps_flags_2.write_vertex_numbers == true))
<< ")] "
<< "] -6 MCshow"
<< '\n';
- };
- };
+ }
+ }
out << "showpage" << '\n';
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/template_constraints.h>
#include <deal.II/lac/vector.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
-//---------------------------------------------------------------------------
-// grid_reordering.cc,v 1.27 2002/05/28 07:43:22 wolf Exp
-// Version:
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/grid/grid_reordering.h>
#include <deal.II/grid/grid_reordering_internal.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/std_cxx1x/array.h>
#include <deal.II/base/quadrature_lib.h>
#include <deal.II/grid/tria.h>
+#include <deal.II/distributed/tria.h>
#include <deal.II/grid/tria_accessor.h>
#include <deal.II/grid/tria_iterator.h>
#include <deal.II/grid/tria_boundary.h>
template <int dim>
void
- laplace_transform (const std::map<types::global_dof_index,Point<dim> > &new_points,
+ laplace_transform (const std::map<unsigned int,Point<dim> > &new_points,
Triangulation<dim> &triangulation)
{
//TODO: Move implementation of this function into the current
}
}
- Assert (best_cell.first.state() == IteratorState::valid,
+ AssertThrow (best_cell.first.state() == IteratorState::valid,
ExcPointNotFound<spacedim>(p));
return best_cell;
}
}
- Assert (best_cell.first.state() == IteratorState::valid,
+ AssertThrow (best_cell.first.state() == IteratorState::valid,
ExcPointNotFound<spacedim>(p));
return best_cell;
}
-
/*
* Internally used in orthogonal_equality
*
*
* See the comment on the next function as well as the detailed
* documentation of make_periodicity_constraints and
- * collect_periodic_face_pairs for details
+ * collect_periodic_faces for details
*/
template<int dim> struct OrientationLookupTable {};
/*
- * Internally used in collect_periodic_face_pairs
+ * Internally used in collect_periodic_faces
+ */
+ template<typename CellIterator>
+ std::vector<PeriodicFacePair<CellIterator> >
+ match_periodic_face_pairs
+ (std::set<std::pair<CellIterator, unsigned int> >
+ &pairs1,
+ std::set<std::pair<typename identity<CellIterator>::type, unsigned int> >
+ &pairs2,
+ int direction,
+ const dealii::Tensor<1,CellIterator::AccessorType::space_dimension>
+ &offset)
+ {
+ static const int space_dim = CellIterator::AccessorType::space_dimension;
+ Assert (0<=direction && direction<space_dim,
+ ExcIndexRange (direction, 0, space_dim));
+
+ Assert (pairs1.size() == pairs2.size(),
+ ExcMessage ("Unmatched faces on periodic boundaries"));
+
+ typename std::vector<PeriodicFacePair<CellIterator> > matched_faces;
+
+ // Match with a complexity of O(n^2). This could be improved...
+ std::bitset<3> orientation;
+ typedef typename std::set
+ <std::pair<CellIterator, unsigned int> >::const_iterator PairIterator;
+ for (PairIterator it1 = pairs1.begin(); it1 != pairs1.end(); ++it1)
+ {
+ for (PairIterator it2 = pairs2.begin(); it2 != pairs2.end(); ++it2)
+ {
+ const CellIterator cell1 = it1->first;
+ const CellIterator cell2 = it2->first;
+ const unsigned int face_idx1 = it1->second;
+ const unsigned int face_idx2 = it2->second;
+ if (GridTools::orthogonal_equality(orientation,
+ cell1->face(face_idx1),
+ cell2->face(face_idx2),
+ direction, offset))
+ {
+ // We have a match, so insert the matching pairs and
+ // remove the matched cell in pairs2 to speed up the
+ // matching:
+ const PeriodicFacePair<CellIterator> matched_face
+ = {{cell1, cell2},{face_idx1, face_idx2}, orientation};
+ matched_faces.push_back(matched_face);
+ pairs2.erase(it2);
+ break;
+ }
+ }
+ }
+
+ AssertThrow (matched_faces.size() == pairs1.size() && pairs2.size() == 0,
+ ExcMessage ("Unmatched faces on periodic boundaries"));
+
+ return matched_faces;
+ }
+
+ /* Deprecated version of the function above with different return value.
+ * It is used the deprecated collect_periodic_face_pairs.
*/
template<typename FaceIterator>
std::map<FaceIterator, std::pair<FaceIterator, std::bitset<3> > >
- match_periodic_face_pairs (std::set<FaceIterator> &faces1, /* not const! */
- std::set<typename identity<FaceIterator>::type> &faces2, /* not const! */
- int direction,
- const dealii::Tensor<1,FaceIterator::AccessorType::space_dimension> &offset)
+ match_periodic_face_pairs
+ (std::set<FaceIterator> &faces1, /* not const! */
+ std::set<typename identity<FaceIterator>::type> &faces2, /* not const! */
+ int direction,
+ const dealii::Tensor<1,FaceIterator::AccessorType::space_dimension> &offset)
+ DEAL_II_DEPRECATED;
+
+ template<typename FaceIterator>
+ std::map<FaceIterator, std::pair<FaceIterator, std::bitset<3> > >
+ match_periodic_face_pairs
+ (std::set<FaceIterator> &faces1, /* not const! */
+ std::set<typename identity<FaceIterator>::type> &faces2, /* not const! */
+ int direction,
+ const dealii::Tensor<1,FaceIterator::AccessorType::space_dimension> &offset)
{
static const int space_dim = FaceIterator::AccessorType::space_dimension;
Assert (0<=direction && direction<space_dim,
}
+ template<typename DH>
+ std::vector<PeriodicFacePair<typename DH::cell_iterator> >
+ collect_periodic_faces
+ (const DH &dof_handler,
+ const types::boundary_id b_id1,
+ const types::boundary_id b_id2,
+ const unsigned int direction,
+ const dealii::Tensor<1,DH::space_dimension> &offset)
+ {
+ static const unsigned int dim = DH::dimension;
+ static const unsigned int space_dim = DH::space_dimension;
+ Assert (0<=direction && direction<space_dim,
+ ExcIndexRange (direction, 0, space_dim));
+
+ // Loop over all cells on the highest level and collect all boundary
+ // faces belonging to b_id1 and b_id2:
+
+ std::set<std::pair<typename DH::cell_iterator, unsigned int> > pairs1;
+ std::set<std::pair<typename DH::cell_iterator, unsigned int> > pairs2;
+
+ for (typename DH::cell_iterator cell = dof_handler.begin(0);
+ cell != dof_handler.end(0); ++cell)
+ {
+ for (unsigned int i = 0; i < GeometryInfo<dim>::faces_per_cell; ++i)
+ {
+ const typename DH::face_iterator face = cell->face(i);
+ if (face->at_boundary() && face->boundary_indicator() == b_id1)
+ {
+ const std::pair<typename DH::cell_iterator, unsigned int> pair1
+ = std::make_pair(cell, i);
+ pairs1.insert(pair1);
+ }
+
+ if (face->at_boundary() && face->boundary_indicator() == b_id2)
+ {
+ const std::pair<typename DH::cell_iterator, unsigned int> pair2
+ = std::make_pair(cell, i);
+ pairs2.insert(pair2);
+ }
+ }
+ }
+
+ Assert (pairs1.size() == pairs2.size(),
+ ExcMessage ("Unmatched faces on periodic boundaries"));
+
+ // and call match_periodic_face_pairs that does the actual matching:
+ return match_periodic_face_pairs(pairs1, pairs2, direction, offset);
+ }
+
+ template<typename DH>
+ std::vector<PeriodicFacePair<typename DH::cell_iterator> >
+ collect_periodic_faces (const DH &dof_handler,
+ const types::boundary_id b_id,
+ const unsigned int direction,
+ const dealii::Tensor<1,DH::space_dimension> &offset)
+ {
+ static const unsigned int dim = DH::dimension;
+ static const unsigned int space_dim = DH::space_dimension;
+ Assert (0<=direction && direction<space_dim,
+ ExcIndexRange (direction, 0, space_dim));
+
+ Assert(dim == space_dim,
+ ExcNotImplemented());
+
+ // Loop over all cells on the highest level and collect all boundary
+ // faces 2*direction and 2*direction*1:
+
+ std::set<std::pair<typename DH::cell_iterator, unsigned int> > pairs1;
+ std::set<std::pair<typename DH::cell_iterator, unsigned int> > pairs2;
+
+ for (typename DH::cell_iterator cell = dof_handler.begin(0);
+ cell != dof_handler.end(0); ++cell)
+ {
+ const typename DH::face_iterator face_1 = cell->face(2*direction);
+ const typename DH::face_iterator face_2 = cell->face(2*direction+1);
+
+ if (face_1->at_boundary() && face_1->boundary_indicator() == b_id)
+ {
+ const std::pair<typename DH::cell_iterator, unsigned int> pair1
+ = std::make_pair(cell, 2*direction);
+ pairs1.insert(pair1);
+ }
+
+ if (face_2->at_boundary() && face_2->boundary_indicator() == b_id)
+ {
+ const std::pair<typename DH::cell_iterator, unsigned int> pair2
+ = std::make_pair(cell, 2*direction+1);
+ pairs2.insert(pair2);
+ }
+ }
+
+ Assert (pairs1.size() == pairs2.size(),
+ ExcMessage ("Unmatched faces on periodic boundaries"));
+
+ // and call match_periodic_face_pairs that does the actual matching:
+
+ typedef std::vector<PeriodicFacePair<typename DH::cell_iterator> >
+ FaceVector;
+
+ FaceVector matching = match_periodic_face_pairs(pairs1, pairs2,
+ direction, offset);
+
+ for (typename FaceVector::iterator pairing = matching.begin();
+ pairing != matching.end(); ++pairing)
+ {
+ Assert(pairing->orientation == 1,
+ ExcMessage("Found a face match with non standard orientation. "
+ "This function is only suitable for meshes with cells "
+ "in default orientation"));
+ }
+
+ return matching;
+ }
template<typename FaceIterator>
std::map<FaceIterator, std::pair<FaceIterator, std::bitset<3> > >
return match_periodic_face_pairs(faces1, faces2, direction, offset);
}
-
-
template<typename DH>
std::map<typename DH::face_iterator, std::pair<typename DH::face_iterator, std::bitset<3> > >
collect_periodic_face_pairs (const DH &dof_handler,
int direction,
const dealii::Tensor<1,DH::space_dimension> &offset)
{
- static const int dim = DH::dimension;
- static const int space_dim = DH::space_dimension;
- Assert (0<=direction && direction<space_dim,
- ExcIndexRange (direction, 0, space_dim));
+ typedef std::vector<PeriodicFacePair<typename DH::cell_iterator> > FaceVector;
- // Loop over all cells on the highest level and collect all boundary
- // faces belonging to b_id1 and b_id2:
-
- std::set<typename DH::face_iterator> faces1;
- std::set<typename DH::face_iterator> faces2;
+ const FaceVector face_vector
+ = collect_periodic_faces (dof_handler, b_id1, b_id2, direction, offset);
- for (typename DH::cell_iterator cell = dof_handler.begin(0);
- cell != dof_handler.end(0); ++cell)
- {
- for (unsigned int i = 0; i < GeometryInfo<dim>::faces_per_cell; ++i)
- {
- const typename DH::face_iterator face = cell->face(i);
-
- if (face->at_boundary() && face->boundary_indicator() == b_id1)
- faces1.insert(face);
-
- if (face->at_boundary() && face->boundary_indicator() == b_id2)
- faces2.insert(face);
- }
- }
-
- Assert (faces1.size() == faces2.size(),
- ExcMessage ("Unmatched faces on periodic boundaries"));
+ std::map<typename DH::face_iterator,
+ std::pair<typename DH::face_iterator, std::bitset<3> > >
+ return_value;
+ for(typename FaceVector::const_iterator it = face_vector.begin();
+ it != face_vector.end(); ++it)
+ {
+ const typename DH::face_iterator face1 = it->cell[0]->face(it->face_idx[0]);
+ const typename DH::face_iterator face2 = it->cell[1]->face(it->face_idx[1]);
+ return_value[face1] = std::make_pair(face2, it->orientation);
+ }
- // and call match_periodic_face_pairs that does the actual matching:
- return match_periodic_face_pairs(faces1, faces2, direction, offset);
+ return return_value;
}
-
-
+
template<typename DH>
std::map<typename DH::face_iterator, typename DH::face_iterator>
collect_periodic_face_pairs (const DH &dof_handler,
int direction,
const dealii::Tensor<1,DH::space_dimension> &offset)
{
- static const int dim = DH::dimension;
- static const int space_dim = DH::space_dimension;
- Assert (0<=direction && direction<space_dim,
- ExcIndexRange (direction, 0, space_dim));
-
- Assert(dim == space_dim,
- ExcNotImplemented());
-
- // Loop over all cells on the highest level and collect all boundary
- // faces 2*direction and 2*direction*1:
-
- std::set<typename DH::face_iterator> faces1;
- std::set<typename DH::face_iterator> faces2;
-
- for (typename DH::cell_iterator cell = dof_handler.begin(0);
- cell != dof_handler.end(0); ++cell)
- {
- const typename DH::face_iterator face_1 = cell->face(2*direction);
- const typename DH::face_iterator face_2 = cell->face(2*direction+1);
-
- if (face_1->at_boundary() && face_1->boundary_indicator() == b_id)
- faces1.insert(face_1);
-
- if (face_2->at_boundary() && face_2->boundary_indicator() == b_id)
- faces2.insert(face_2);
- }
-
- Assert (faces1.size() == faces2.size(),
- ExcMessage ("Unmatched faces on periodic boundaries"));
-
- // and call match_periodic_face_pairs that does the actual matching:
-
- typedef std::map<typename DH::face_iterator, std::pair<typename DH::face_iterator, std::bitset<3> > > FaceMap;
- FaceMap matching = match_periodic_face_pairs(faces1, faces2, direction, offset);
-
- std::map<typename DH::face_iterator, typename DH::face_iterator>
- return_value;
-
- for (typename FaceMap::iterator pairing = matching.begin();
- pairing != matching.end(); ++pairing)
- {
- Assert(pairing->second.second == 1,
- ExcMessage("Found a face match with non standard orientation. "
- "This function is only suitable for meshes with cells "
- "in default orientation"));
-
- return_value[pairing->first] = pairing->second.first;
- }
-
+ typedef std::vector<PeriodicFacePair<typename DH::cell_iterator> > FaceVector;
+
+ const FaceVector face_vector
+ = collect_periodic_faces (dof_handler, b_id, direction, offset);
+
+ std::map<typename DH::face_iterator, typename DH::face_iterator> return_value;
+ for(typename FaceVector::const_iterator it = face_vector.begin();
+ it != face_vector.end(); ++it)
+ {
+ const typename DH::face_iterator face1 = it->cell[0]->face(it->face_idx[0]);
+ const typename DH::face_iterator face2 = it->cell[1]->face(it->face_idx[1]);
+ return_value[face1] = face2;
+ }
+
return return_value;
}
+
+ template<typename DH>
+ void
+ identify_periodic_face_pairs
+ (const DH &dof_handler,
+ const types::boundary_id b_id1,
+ const types::boundary_id b_id2,
+ const unsigned int direction,
+ std::vector<std_cxx1x::tuple<typename DH::cell_iterator, unsigned int,
+ typename DH::cell_iterator, unsigned int> >
+ &periodicity_vector)
+ {
+ typedef std::vector<PeriodicFacePair<typename DH::cell_iterator> >
+ FaceVector;
+ const FaceVector periodic_faces
+ = collect_periodic_faces(dof_handler, b_id1, b_id2, direction,
+ dealii::Tensor<1,DH::space_dimension> ());
+
+ typename FaceVector::const_iterator it, end_faces;
+ it = periodic_faces.begin();
+ end_faces = periodic_faces.end();
+
+ for(; it!=end_faces; ++it)
+ {
+
+ const std_cxx1x::tuple<typename DH::cell_iterator, unsigned int,
+ typename DH::cell_iterator, unsigned int>
+ periodic_tuple (it->cell[0], it->face_idx[0],
+ it->cell[1], it->face_idx[1]);
+
+ periodicity_vector.push_back(periodic_tuple);
+ }
+ }
} /* namespace GridTools */
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
for (X : TRIANGULATION_AND_DOFHANDLERS; deal_II_dimension : DIMENSIONS ; deal_II_space_dimension : SPACE_DIMENSIONS)
{
-
+
#if deal_II_dimension <= deal_II_space_dimension
namespace GridTools \{
}
+
+for (deal_II_dimension : DIMENSIONS ; deal_II_space_dimension : SPACE_DIMENSIONS)
+{
+
+#if deal_II_dimension <= deal_II_space_dimension
+ namespace GridTools \{
+ template
+ bool
+ have_same_coarse_mesh (const MGDoFHandler<deal_II_dimension,deal_II_space_dimension> &mesh_1,
+ const MGDoFHandler<deal_II_dimension,deal_II_space_dimension> &mesh_2);
+
+ \}
+
+ #endif
+}
+
+
for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
{
#if deal_II_dimension <= deal_II_space_dimension
volume
(const Triangulation<deal_II_dimension, deal_II_space_dimension> &,
const Mapping<deal_II_dimension, deal_II_space_dimension> &);
-
+
template
void delete_unused_vertices (std::vector<Point<deal_II_space_dimension> > &,
std::vector<CellData<deal_II_dimension> > &,
template
void partition_triangulation (const unsigned int,
Triangulation<deal_II_dimension, deal_II_space_dimension> &);
-
+
template
void partition_triangulation (const unsigned int,
const SparsityPattern &,
(const hp::MappingCollection<deal_II_dimension, deal_II_space_dimension> &,
const hp::DoFHandler<deal_II_dimension, deal_II_space_dimension> &,
const Point<deal_II_space_dimension> &);
-
-
+
+
template
void get_subdomain_association (const Triangulation<deal_II_dimension, deal_II_space_dimension> &,
std::vector<types::subdomain_id> &);
unsigned int count_cells_with_subdomain_association(
const Triangulation<deal_II_dimension, deal_II_space_dimension> &,
const types::subdomain_id);
-
+
template
double
minimal_cell_diameter (const Triangulation<deal_II_dimension, deal_II_space_dimension> &triangulation);
-
+
template
double
maximal_cell_diameter (const Triangulation<deal_II_dimension, deal_II_space_dimension> &triangulation);
const Triangulation<deal_II_dimension, deal_II_space_dimension> &triangulation_1,
const Triangulation<deal_II_dimension, deal_II_space_dimension> &triangulation_2,
Triangulation<deal_II_dimension, deal_II_space_dimension> &result);
-#if deal_II_dimension == deal_II_space_dimension
+#if deal_II_dimension == deal_II_space_dimension
template
void
- laplace_transform (const std::map<types::global_dof_index,Point<deal_II_dimension> > &new_points,
+ laplace_transform (const std::map<unsigned int,Point<deal_II_dimension> > &new_points,
Triangulation<deal_II_dimension> &triangulation);
template
Triangulation<deal_II_dimension,deal_II_space_dimension> &triangulation);
#endif
-
+
\}
#endif
-
+
}
#if deal_II_dimension >= 2
+ template
+ std::vector<PeriodicFacePair<X::cell_iterator> >
+ collect_periodic_faces
+ (const X &,
+ const types::boundary_id,
+ const types::boundary_id,
+ unsigned int,
+ const Tensor<1,X::space_dimension> &);
+
+ template<typename DH>
+ std::vector<PeriodicFacePair<X::cell_iterator> >
+ collect_periodic_faces
+ (const X &,
+ const types::boundary_id,
+ unsigned int,
+ const Tensor<1,X::space_dimension> &);
+
template
std::map<X::face_iterator, std::pair<X::face_iterator, std::bitset<3> > >
collect_periodic_face_pairs
const types::boundary_id,
const types::boundary_id,
int,
- const Tensor<1,deal_II_space_dimension> &);
-
+ const Tensor<1,X::space_dimension> &);
template
std::map<X::active_face_iterator, std::pair<X::active_face_iterator, std::bitset<3> > >
collect_periodic_face_pairs
const types::boundary_id,
const types::boundary_id,
int,
- const Tensor<1,deal_II_space_dimension> &);
+ const Tensor<1,X::active_face_iterator::AccessorType::space_dimension> &);
template
std::map<X::face_iterator, std::pair<X::face_iterator, std::bitset<3> > >
const types::boundary_id,
const types::boundary_id,
int,
- const Tensor<1,deal_II_space_dimension> &);
+ const Tensor<1,X::space_dimension> &);
template
std::map<X::face_iterator, X::face_iterator>
const types::boundary_id,
int,
const Tensor<1,deal_II_space_dimension> &);
+
+ template
+ void
+ identify_periodic_face_pairs
+ (const X &,
+ const types::boundary_id,
+ const types::boundary_id,
+ const unsigned int,
+ std::vector<std_cxx1x::tuple<X::cell_iterator, unsigned int,
+ X::cell_iterator, unsigned int> > &);
#endif
#endif
}
+for (deal_II_dimension : DIMENSIONS ; deal_II_space_dimension : SPACE_DIMENSIONS)
+{
+#if deal_II_dimension <= deal_II_space_dimension
+ #if deal_II_dimension >= 2
+ namespace GridTools \{
+ template
+ void
+ identify_periodic_face_pairs
+ (const parallel::distributed::Triangulation<deal_II_dimension, deal_II_space_dimension> &,
+ const types::boundary_id,
+ const types::boundary_id,
+ const unsigned int,
+ std::vector<std_cxx1x::tuple<parallel::distributed::Triangulation<deal_II_dimension, deal_II_space_dimension>::cell_iterator,
+ unsigned int,
+ parallel::distributed::Triangulation<deal_II_dimension, deal_II_space_dimension>::cell_iterator,
+ unsigned int> > &);
+ \}
+ #endif
+#endif
+}
+
+
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2011, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/memory_consumption.h>
#include <deal.II/base/smartpointer.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2010 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (X : TRIANGULATION_AND_DOFHANDLERS; deal_II_dimension : DIMENSIONS ; deal_II_space_dimension : SPACE_DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/memory_consumption.h>
#include <deal.II/grid/persistent_tria.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/memory_consumption.h>
#include <deal.II/base/table.h>
// first, we only collect the data
// now
- // the bool array stores, wether the lines
+ // the bool array stores, whether the lines
// are in the standard orientation or not
// note that QuadComparator is a
else
{
- // look wether it exists in
+ // look whether it exists in
// reverse direction
std::swap (line_vertices.first, line_vertices.second);
if (needed_lines.find(line_vertices) != needed_lines.end())
if (needed_lines.find(line_vertices) != needed_lines.end())
line[i] = needed_lines[line_vertices];
else
- // look wether it exists
+ // look whether it exists
// in reverse direction
{
std::swap (line_vertices.first, line_vertices.second);
/**
* Helper function for
- * @p fix_coarsen_flags. Return wether
+ * @p fix_coarsen_flags. Return whether
* coarsening of this cell is allowed.
* Coarsening can be forbidden if the
* neighboring cells are or will be
// to the common neighbor cell,
// not to its children. what we
// really want to know in the
- // following is, wether the
+ // following is, whether the
// neighbor cell is refined twice
// with reference to our cell.
// that only has to be asked, if
Its entries are indexes by the local indeces of the common face.
For example if two elements share a face, and this face is
face 0 for element 0 and face 1 for element 1, then
- table(0,1) will tell wether the orientation are the same (true) or
+ table(0,1) will tell whether the orientation are the same (true) or
opposite (false).
Even though there may be a combinatorial/graph theory argument to get
typename Triangulation<dim,spacedim>::cell_iterator
Triangulation<dim,spacedim>::last () const
{
- return last (levels.size()-1);
-}
-
-
+ const unsigned int level = levels.size()-1;
-template <int dim, int spacedim>
-typename Triangulation<dim,spacedim>::cell_iterator
-Triangulation<dim,spacedim>::last (const unsigned int level) const
-{
Assert (level<n_global_levels() || level<levels.size(), ExcInvalidLevel(level));
if (levels[level]->cells.cells.size() ==0)
return end(level);
{
// get the last used cell
cell_iterator cell = last();
-
+
if (cell != end())
{
// then move to the last active one
if (cell->active()==true)
- return cell;
+ return cell;
while ((--cell).state() == IteratorState::valid)
- if (cell->active()==true)
- return cell;
+ if (cell->active()==true)
+ return cell;
}
return cell;
}
-template <int dim, int spacedim>
-typename Triangulation<dim,spacedim>::active_cell_iterator
-Triangulation<dim,spacedim>::last_active (const unsigned int level) const
-{
- // get the last used cell on this level
- cell_iterator cell = last(level);
-
- if (cell != end(level))
- {
- // then move to the last active one
- if (cell->active()==true)
- return cell;
- while ((--cell).state() == IteratorState::valid)
- if (cell->active()==true)
- return cell;
- }
- return cell;
-}
-
-
-
template <int dim, int spacedim>
typename Triangulation<dim,spacedim>::cell_iterator
Triangulation<dim,spacedim>::end () const
typename Triangulation<dim, spacedim>::active_cell_iterator
Triangulation<dim, spacedim>::end_active (const unsigned int level) const
{
- return (level == levels.size()-1 ?
+ Assert (level<n_global_levels() || level < levels.size(), ExcInvalidLevel(level));
+ return (level >= levels.size()-1 ?
active_cell_iterator(end()) :
begin_active (level+1));
}
{
case 1:
Assert (level<n_global_levels() || level<levels.size(), ExcInvalidLevel(level));
-
+
if (level >= levels.size() || levels[level]->cells.cells.size() == 0)
return end_line();
case 3:
{
Assert (level<n_global_levels() || level<levels.size(), ExcInvalidLevel(level));
-
+
if (level >= levels.size() || levels[level]->cells.cells.size() == 0)
return end_hex();
-
+
return raw_hex_iterator (const_cast<Triangulation<dim,spacedim>*>(this),
level,
0);
// deleted (if the latter are on a
// higher level for example)
//
- // if there is only one level,
- // there can not be anything to do
+ // since we delete the *children* of cells, we can ignore cells
+ // on the highest level, i.e., level must be less than or equal
+ // to n_levels()-2.
if (levels.size() >= 2)
- for (cell = last(levels.size()-2); cell!=endc; --cell)
- if (cell->user_flag_set())
+ for (cell = last(); cell!=endc; --cell)
+ if (cell->level()<=static_cast<int>(levels.size()-2) && cell->user_flag_set())
// use a separate function,
// since this is dimension
// specific
// next global loop. when this
// function terminates, the
// requirement will be
- // fullfilled. However, it might be
+ // fulfilled. However, it might be
// faster to insert an inner loop
// here.
bool changed = true;
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/grid/tria.h>
#include <deal.II/grid/tria_levels.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/tensor.h>
#include <deal.II/grid/tria_boundary.h>
}
+
+template <int dim, int spacedim>
+const std::vector<Point<1> > &
+Boundary<dim,spacedim>::
+get_line_support_points (const unsigned int n_intermediate_points) const
+{
+ if (points.size() <= n_intermediate_points ||
+ points[n_intermediate_points].get() == 0)
+ {
+ Threads::Mutex::ScopedLock lock(mutex);
+ if (points.size() <= n_intermediate_points)
+ points.resize(n_intermediate_points+1);
+
+ // another thread might have created points in the meantime
+ if (points[n_intermediate_points].get() == 0)
+ {
+ std_cxx1x::shared_ptr<QGaussLobatto<1> >
+ quadrature (new QGaussLobatto<1>(n_intermediate_points+2));
+ points[n_intermediate_points] = quadrature;
+ }
+ }
+ return points[n_intermediate_points]->get_points();
+}
+
+
+
+
/* -------------------------- StraightBoundary --------------------- */
const unsigned int n=points.size();
Assert(n>0, ExcInternalError());
- const double dx=1./(n+1);
- double x=dx;
-
+ // Use interior points of QGaussLobatto quadrature formula support points
+ // for consistency with MappingQ
+ const std::vector<Point<1> > &line_points = this->get_line_support_points(n);
const Point<spacedim> vertices[2] = { line->vertex(0),
line->vertex(1)
};
- for (unsigned int i=0; i<n; ++i, x+=dx)
- points[i] = (1-x)*vertices[0] + x*vertices[1];
+ for (unsigned int i=0; i<n; ++i)
+ {
+ const double x = line_points[i+1][0];
+ points[i] = (1-x)*vertices[0] + x*vertices[1];
+ }
}
const unsigned int n=points.size();
Assert(n>0, ExcInternalError());
- const double dx=1./(n+1);
- double x=dx;
+ // Use interior points of QGaussLobatto quadrature formula support points
+ // for consistency with MappingQ
+ const std::vector<Point<1> > &line_points = this->get_line_support_points(n);
const Point<spacedim> vertices[2] = { line->vertex(0),
line->vertex(1)
};
- for (unsigned int i=0; i<n; ++i, x+=dx)
- points[i] = (1-x)*vertices[0] + x*vertices[1];
+ for (unsigned int i=0; i<n; ++i)
+ {
+ const double x = line_points[1+i][0];
+ points[i] = (1-x)*vertices[0] + x*vertices[1];
+ }
}
// is n a square number
Assert(m*m==n, ExcInternalError());
- const double ds=1./(m+1);
- double y=ds;
+ const std::vector<Point<1> > &line_points = this->get_line_support_points(m);
const Point<spacedim> vertices[4] = { quad->vertex(0),
quad->vertex(1),
quad->vertex(3)
};
- for (unsigned int i=0; i<m; ++i, y+=ds)
+ for (unsigned int i=0; i<m; ++i)
{
- double x=ds;
- for (unsigned int j=0; j<m; ++j, x+=ds)
- points[i*m+j]=((1-x) * vertices[0] +
- x * vertices[1]) * (1-y) +
- ((1-x) * vertices[2] +
- x * vertices[3]) * y;
+ const double y=line_points[1+i][0];
+ for (unsigned int j=0; j<m; ++j)
+ {
+ const double x=line_points[1+j][0];
+ points[i*m+j]=((1-x) * vertices[0] +
+ x * vertices[1]) * (1-y) +
+ ((1-x) * vertices[2] +
+ x * vertices[3]) * y;
+ }
}
}
// is n a square number
Assert(m*m==n, ExcInternalError());
- const double ds=1./(m+1);
- double y=ds;
+ const std::vector<Point<1> > &line_points = this->get_line_support_points(m);
const Point<spacedim> vertices[4] = { quad->vertex(0),
quad->vertex(1),
quad->vertex(3)
};
- for (unsigned int i=0; i<m; ++i, y+=ds)
+ for (unsigned int i=0; i<m; ++i)
{
- double x=ds;
- for (unsigned int j=0; j<m; ++j, x+=ds)
- points[i*m+j]=((1-x) * vertices[0] +
- x * vertices[1]) * (1-y) +
- ((1-x) * vertices[2] +
- x * vertices[3]) * y;
+ const double y=line_points[1+i][0];
+ for (unsigned int j=0; j<m; ++j)
+ {
+ const double x=line_points[1+j][0];
+ points[i*m+j]=((1-x) * vertices[0] +
+ x * vertices[1]) * (1-y) +
+ ((1-x) * vertices[2] +
+ x * vertices[3]) * y;
+ }
}
}
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/grid/tria_boundary_lib.h>
#include <deal.II/grid/tria.h>
const unsigned int n=points.size();
Assert(n>0, ExcInternalError());
- // Do a simple linear interpolation
- // followed by projection, using
- // the same algorithm as above
- const Point<spacedim> ds = (v1-v0) / (n+1);
+ // Do a simple linear interpolation followed by projection, using the same
+ // algorithm as above
+ const std::vector<Point<1> > &line_points = this->get_line_support_points(n);
for (unsigned int i=0; i<n; ++i)
{
- const Point<spacedim> middle = v0 + (i+1)*ds;
+ const double x = line_points[i+1][0];
+ const Point<spacedim> middle = (1-x)*v0 + x*v1;
const Point<spacedim> vector_from_axis = (middle-point_on_axis) -
((middle-point_on_axis) * direction) * direction;
{
const unsigned int n = points.size ();
const Point<dim> axis = x_1 - x_0;
- const Point<dim> dx = (p1 - p0) / (n + 1);
Assert (n > 0, ExcInternalError ());
- for (unsigned int i = 0; i < n; ++i)
+ const std::vector<Point<1> > &line_points = this->get_line_support_points(n);
+
+ for (unsigned int i=0; i<n; ++i)
{
+ const double x = line_points[i+1][0];
+
// Compute the current point.
- const Point<dim> x_i = p0 + (i + 1) * dx;
- // To project this point on the
- // boundary of the cone we first
- // compute the orthogonal
- // projection of this point onto
- // the axis of the cone.
+ const Point<dim> x_i = (1-x)*p0 + x*p1;
+ // To project this point on the boundary of the cone we first compute
+ // the orthogonal projection of this point onto the axis of the cone.
const double c = (x_i - x_0) * axis / axis.square ();
const Point<dim> x_ip = x_0 + c * axis;
- // Compute the projection of
- // the middle point on the
- // boundary of the cone.
+ // Compute the projection of the middle point on the boundary of the
+ // cone.
points[i] = x_ip + get_radius (x_ip) * (x_i - x_ip) / (x_i - x_ip).norm ();
}
}
const Point<dim> axis = x_1 - x_0;
// Compute the middle point of the line.
const Point<dim> middle = StraightBoundary<dim>::get_new_point_on_line (line);
- // To project it on the boundary of
- // the cone we first compute the
- // orthogonal projection of the
- // middle point onto the axis of
- // the cone.
+ // To project it on the boundary of the cone we first compute the orthogonal
+ // projection of the middle point onto the axis of the cone.
const double c = (middle - x_0) * axis / axis.square ();
const Point<dim> middle_p = x_0 + c * axis;
- // Compute the projection of the
- // middle point on the boundary
- // of the cone.
+ // Compute the projection of the middle point on the boundary of the cone.
return middle_p + get_radius (middle_p) * (middle - middle_p) / (middle - middle_p).norm ();
}
const int dim = 3;
const Point<dim> axis = x_1 - x_0;
- // Compute the middle point of the
- // quad.
+ // Compute the middle point of the quad.
const Point<dim> middle = StraightBoundary<3>::get_new_point_on_quad (quad);
- // Same algorithm as above: To
- // project it on the boundary of
- // the cone we first compute the
- // orthogonal projection of the
- // middle point onto the axis of
- // the cone.
+ // Same algorithm as above: To project it on the boundary of the cone we
+ // first compute the orthogonal projection of the middle point onto the axis
+ // of the cone.
const double c = (middle - x_0) * axis / axis.square ();
const Point<dim> middle_p = x_0 + c * axis;
- // Compute the projection of the
- // middle point on the boundary
- // of the cone.
+ // Compute the projection of the middle point on the boundary of the cone.
return middle_p + get_radius (middle_p) * (middle - middle_p) / (middle - middle_p).norm ();
}
for (unsigned int vertex = 0; vertex < GeometryInfo<dim>::vertices_per_cell; ++vertex)
{
- // Compute the orthogonal
- // projection of the vertex onto
- // the axis of the cone.
+ // Compute the orthogonal projection of the vertex onto the axis of the
+ // cone.
const double c = (face->vertex (vertex) - x_0) * axis / axis.square ();
const Point<dim> vertex_p = x_0 + c * axis;
- // Then compute the vector
- // pointing from the point
- // <tt>vertex_p</tt> on the axis
- // to the vertex.
+ // Then compute the vector pointing from the point <tt>vertex_p</tt> on
+ // the axis to the vertex.
const Point<dim> axis_to_vertex = face->vertex (vertex) - vertex_p;
face_vertex_normals[vertex] = axis_to_vertex / axis_to_vertex.norm ();
Assert(std::fabs(v1.square()-r2)<eps*r2, ExcInternalError());
const double alpha=std::acos((v0*v1)/std::sqrt(v0.square()*v1.square()));
- const double d_alpha=alpha/(n+1);
const Point<spacedim> pm=0.5*(v0+v1);
const double h=std::sqrt(pm.square());
- double beta=0;
- unsigned int left_index=0, right_index=0;
- if ((n+1)%2==0)
- {
- // if the number of
- // parts is even insert
- // the midpoint
- left_index=(n-1)/2;
- right_index=left_index;
- points[left_index]=pm;
- --left_index;
- ++right_index;
- beta=d_alpha;
- }
- else
- {
- beta=(n/2+1)*d_alpha-alpha/2.;
- right_index=n/2;
- left_index=n/2-1;
- }
-
// n even: m=n/2,
// n odd: m=(n-1)/2
+ const std::vector<Point<1> > &line_points = this->get_line_support_points(n);
const unsigned int m=n/2;
- for (unsigned int i=0; i<m ; ++i, ++right_index, --left_index, beta+=d_alpha)
+ for (unsigned int i=0; i<m ; ++i)
{
- Assert(right_index<n, ExcInternalError());
- Assert(left_index+1>=1, ExcInternalError());
-
- double d=h*std::tan(beta);
- points[right_index]=pm+d/length*(v1-v0);
- points[left_index]=pm-d/length*(v1-v0);
+ const double beta = alpha * (line_points[i+1][0]-0.5);
+ const double d=h*std::tan(beta);
+ points[i]=pm+d/length*(v1-v0);
+ points[n-1-i]=pm-d/length*(v1-v0);
}
+ if ((n+1)%2==0)
+ // if the number of parts is even insert the midpoint
+ points[(n-1)/2]=pm;
+
- // project the points from the
- // straight line to the
- // HyperBallBoundary
+ // project the points from the straight line to the HyperBallBoundary
for (unsigned int i=0; i<n; ++i)
{
points[i] *= r / std::sqrt(points[i].square());
if ((line_center(0) == this->center(0))
&&
((std::fabs(vertices[0].distance(this->center)-this->radius) >
- 1e-5*this->radius)
+ 1e-5*this->radius)
||
(std::fabs(vertices[1].distance(this->center)-this->radius) >
- 1e-5*this->radius)))
+ 1e-5*this->radius)))
return line_center;
else
return HyperBallBoundary<dim>::get_new_point_on_line (line);
get_intermediate_points_on_line (const typename Triangulation<dim>::line_iterator &line,
std::vector<Point<dim> > &points) const
{
- // check whether center of object is
- // at x==0, since then it belongs
- // to the plane part of the
- // boundary
+ // check whether center of object is at x==0, since then it belongs to the
+ // plane part of the boundary
const Point<dim> line_center = line->center();
if (line_center(0) == this->center(0))
return StraightBoundary<dim>::get_intermediate_points_on_line (line, points);
points[0]=get_new_point_on_quad(quad);
else
{
- // check whether center of
- // object is at x==0, since
- // then it belongs to the plane
- // part of the boundary
+ // check whether center of object is at x==0, since then it belongs to
+ // the plane part of the boundary
const Point<dim> quad_center = quad->center();
if (quad_center(0) == this->center(0))
StraightBoundary<dim>::get_intermediate_points_on_quad (quad, points);
get_normals_at_vertices (const typename Triangulation<dim>::face_iterator &face,
typename Boundary<dim>::FaceVertexNormals &face_vertex_normals) const
{
- // check whether center of object is
- // at x==0, since then it belongs
- // to the plane part of the
- // boundary
+ // check whether center of object is at x==0, since then it belongs to the
+ // plane part of the boundary
const Point<dim> quad_center = face->center();
if (quad_center(0) == this->center(0))
StraightBoundary<dim>::get_normals_at_vertices (face, face_vertex_normals);
{
switch (dim)
{
- // in 2d, first check whether the two
- // end points of the line are on the
- // axis of symmetry. if so, then return
- // the mid point
+ // in 2d, first check whether the two end points of the line are on the
+ // axis of symmetry. if so, then return the mid point
case 2:
{
if ((line->vertex(0)(0) == this->center(0))
(line->vertex(1)(0) == this->center(0)))
return (line->vertex(0) + line->vertex(1))/2;
else
- // otherwise we are on the outer or
- // inner part of the shell. proceed
+ // otherwise we are on the outer or inner part of the shell. proceed
// as in the base class
return HyperShellBoundary<dim>::get_new_point_on_line (line);
}
- // in 3d, a line is a straight
- // line if it is on the symmetry
- // plane and if not both of its
- // end points are on either the
- // inner or outer sphere
+ // in 3d, a line is a straight line if it is on the symmetry plane and if
+ // not both of its end points are on either the inner or outer sphere
case 3:
{
- outer_radius) < 1e-12 * outer_radius))))
return (line->vertex(0) + line->vertex(1))/2;
else
- // otherwise we are on the outer or
- // inner part of the shell. proceed
+ // otherwise we are on the outer or inner part of the shell. proceed
// as in the base class
return HyperShellBoundary<dim>::get_new_point_on_line (line);
}
HalfHyperShellBoundary<dim>::
get_new_point_on_quad (const typename Triangulation<dim>::quad_iterator &quad) const
{
- // if this quad is on the symmetry plane,
- // take the center point and project it
- // outward to the same radius as the
- // centers of the two radial lines
+ // if this quad is on the symmetry plane, take the center point and project
+ // it outward to the same radius as the centers of the two radial lines
if ((quad->vertex(0)(0) == this->center(0)) &&
(quad->vertex(1)(0) == this->center(0)) &&
(quad->vertex(2)(0) == this->center(0)) &&
Assert (false, ExcInternalError());
}
- // otherwise we are on the outer or
- // inner part of the shell. proceed
- // as in the base class
+ // otherwise we are on the outer or inner part of the shell. proceed as in
+ // the base class
return HyperShellBoundary<dim>::get_new_point_on_quad (quad);
}
{
switch (dim)
{
- // in 2d, first check whether the two
- // end points of the line are on the
- // axis of symmetry. if so, then return
- // the mid point
+ // in 2d, first check whether the two end points of the line are on the
+ // axis of symmetry. if so, then return the mid point
case 2:
{
if ((line->vertex(0)(0) == this->center(0))
(line->vertex(1)(0) == this->center(0)))
StraightBoundary<dim>::get_intermediate_points_on_line (line, points);
else
- // otherwise we are on the outer or
- // inner part of the shell. proceed
+ // otherwise we are on the outer or inner part of the shell. proceed
// as in the base class
HyperShellBoundary<dim>::get_intermediate_points_on_line (line, points);
break;
}
- // in 3d, a line is a straight
- // line if it is on the symmetry
- // plane and if not both of its
- // end points are on either the
- // inner or outer sphere
+ // in 3d, a line is a straight line if it is on the symmetry plane and if
+ // not both of its end points are on either the inner or outer sphere
case 3:
{
if (((line->vertex(0)(0) == this->center(0))
- outer_radius) < 1e-12 * outer_radius))))
StraightBoundary<dim>::get_intermediate_points_on_line (line, points);
else
- // otherwise we are on the outer or
- // inner part of the shell. proceed
+ // otherwise we are on the outer or inner part of the shell. proceed
// as in the base class
HyperShellBoundary<dim>::get_intermediate_points_on_line (line, points);
{
Assert (dim < 3, ExcNotImplemented());
- // check whether center of object is
- // at x==0, since then it belongs
- // to the plane part of the
- // boundary
+ // check whether center of object is at x==0, since then it belongs to the
+ // plane part of the boundary
const Point<dim> quad_center = quad->center();
if (quad_center(0) == this->center(0))
StraightBoundary<dim>::get_intermediate_points_on_quad (quad, points);
Point<2> middle(0,0);
- //Take care for periodic conditions,
- //For instance phi0= 0, phi1= 3/2*Pi middle has to be 7/4*Pi not 3/4*Pi
- //This also works for -Pi/2 + Pi, middle is 5/4*Pi
+ //Take care for periodic conditions, For instance phi0= 0, phi1= 3/2*Pi
+ //middle has to be 7/4*Pi not 3/4*Pi. This also works for -Pi/2 + Pi, middle
+ //is 5/4*Pi
for (unsigned int i=0; i<2; i++)
if (std::abs(p0(i)-p1(i))> numbers::PI)
middle(i)=2*numbers::PI;
get_intermediate_points_on_line (const Triangulation<2, 3>::line_iterator &line,
std::vector< Point< 3 > > &points) const
{
- //Almost the same implementation as StraightBoundary<2,3>
+ //Almost the same implementation as StraightBoundary<2,3>
unsigned int npoints=points.size();
if (npoints==0) return;
offset[0]=0;
offset[1]=0;
- //Take care for periodic conditions & negative angles,
- //see get_new_point_on_line() above
- //Because we dont have a symmetric interpolation (just the middle) we need to
- //add 2*Pi to each almost zero and negative angles.
+ //Take care for periodic conditions & negative angles, see
+ //get_new_point_on_line() above. Because we dont have a symmetric
+ //interpolation (just the middle) we need to add 2*Pi to each almost zero
+ //and negative angles.
for (unsigned int i=0; i<2; i++)
for (unsigned int j=1; j<2; j++)
{
p[j](i)+=2*numbers::PI*offset[i];
- double dx=1.0/(npoints+1);
- double x=dx;
Point<2> target;
- for (unsigned int i=0; i<npoints; i++,x+=dx)
+ const std::vector<Point<1> > &line_points = this->get_line_support_points(npoints);
+ for (unsigned int i=0; i<npoints; i++)
{
+ const double x = line_points[i+1][0];
target= (1-x)*p[0] + x*p[1];
points[i]=get_real_coord(target);
}
// is n a square number
Assert(m*m==n, ExcInternalError());
- const double ds=1./(m+1);
- double y=ds;
-
Point<2> p[4];
for (unsigned int i=0; i<4; i++)
offset[0]=0;
offset[1]=0;
- //Take care for periodic conditions & negative angles,
- //see get_new_point_on_line() above
- //Because we dont have a symmetric interpolation (just the middle) we need to
- //add 2*Pi to each almost zero and negative angles.
+ //Take care for periodic conditions & negative angles, see
+ //get_new_point_on_line() above. Because we dont have a symmetric
+ //interpolation (just the middle) we need to add 2*Pi to each almost zero
+ //and negative angles.
for (unsigned int i=0; i<2; i++)
for (unsigned int j=1; j<4; j++)
{
if (p[j](i)<1.E-12 ) //Take care for periodic conditions & negative angles
p[j](i)+=2*numbers::PI*offset[i];
- for (unsigned int i=0; i<m; ++i, y+=ds)
+ const std::vector<Point<1> > &line_points = this->get_line_support_points(m);
+ for (unsigned int i=0; i<m; ++i)
{
- double x=ds;
- for (unsigned int j=0; j<m; ++j, x+=ds)
+ const double y=line_points[i+1][0];
+ for (unsigned int j=0; j<m; ++j)
{
+ const double x=line_points[j+1][0];
target=((1-x) * p[0] +
x * p[1]) * (1-y) +
((1-x) * p[2] +
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
{
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/memory_consumption.h>
#include <deal.II/grid/tria_faces.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2007, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/memory_consumption.h>
#include <deal.II/grid/tria_levels.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2007, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/memory_consumption.h>
#include <deal.II/grid/tria_objects.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2007, 2010, 2012 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
{
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
-FILE(GLOB _header
- ${CMAKE_SOURCE_DIR}/include/deal.II/hp/*.h
- )
-
SET(_src
dof_faces.cc
dof_handler.cc
- dof_levels.cc
- dof_objects.cc
+ dof_level.cc
fe_collection.cc
fe_values.cc
mapping_collection.cc
mapping_collection.inst.in
)
+FILE(GLOB _header
+ ${CMAKE_SOURCE_DIR}/include/deal.II/hp/*.h
+ )
+
DEAL_II_ADD_LIBRARY(obj_hp OBJECT ${_src} ${_header} ${_inst})
EXPAND_INSTANTIATIONS(obj_hp "${_inst}")
-
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2011, 2012 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/memory_consumption.h>
#include <deal.II/hp/dof_faces.h>
{
namespace hp
{
+// ---------------------- DoFObjects ----------------------------
+
+ template <int structdim>
+ std::size_t
+ DoFIndicesOnFacesOrEdges<structdim>::memory_consumption () const
+ {
+ return (MemoryConsumption::memory_consumption (dofs) +
+ MemoryConsumption::memory_consumption (dof_offsets));
+ }
+
+
+ // explicit instantiations
+ template
+ std::size_t
+ DoFIndicesOnFacesOrEdges<1>::memory_consumption () const;
+
+ template
+ std::size_t
+ DoFIndicesOnFacesOrEdges<2>::memory_consumption () const;
+
+ template
+ std::size_t
+ DoFIndicesOnFacesOrEdges<3>::memory_consumption () const;
+
+
+// ---------------------- DoFFaces ----------------------------
std::size_t
- DoFFaces<1>::memory_consumption () const
+ DoFIndicesOnFaces<1>::memory_consumption () const
{
return 0;
}
std::size_t
- DoFFaces<2>::memory_consumption () const
+ DoFIndicesOnFaces<2>::memory_consumption () const
{
return MemoryConsumption::memory_consumption (lines);
}
std::size_t
- DoFFaces<3>::memory_consumption () const
+ DoFIndicesOnFaces<3>::memory_consumption () const
{
- return (MemoryConsumption::memory_consumption (quads) +
+ return (MemoryConsumption::memory_consumption (lines) +
MemoryConsumption::memory_consumption (quads) );
}
-//---------------------------- hp_dof_handler.cc ------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------- hp_dof_handler.cc ------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/memory_consumption.h>
#include <deal.II/base/geometry_info.h>
#include <deal.II/base/std_cxx1x/bind.h>
#include <deal.II/hp/dof_handler.h>
-#include <deal.II/hp/dof_objects.h>
-#include <deal.II/hp/dof_levels.h>
+#include <deal.II/hp/dof_level.h>
#include <deal.II/hp/dof_faces.h>
#include <deal.II/dofs/dof_accessor.h>
#include <deal.II/grid/tria_accessor.h>
// active_fe_indices field which
// we have to backup before
{
- std::vector<std::vector<unsigned int> >
+ std::vector<std::vector<DoFLevel::active_fe_index_type> >
active_fe_backup(dof_handler.levels.size ());
for (unsigned int level = 0; level<dof_handler.levels.size (); ++level)
- std::swap (dof_handler.levels[level]->active_fe_indices, active_fe_backup[level]);
+ std::swap (dof_handler.levels[level]->active_fe_indices,
+ active_fe_backup[level]);
// delete all levels and set them up
// newly, since vectors are
for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
{
- dof_handler.levels.push_back (new internal::hp::DoFLevel<dim>);
+ dof_handler.levels.push_back (new internal::hp::DoFLevel);
std::swap (active_fe_backup[level],
dof_handler.levels[level]->active_fe_indices);
}
// finite element is used for it
for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
{
- dof_handler.levels[level]->dof_object.dof_offsets
- = std::vector<types::global_dof_index> (
+ dof_handler.levels[level]->dof_offsets
+ = std::vector<DoFLevel::offset_type> (
dof_handler.tria->n_raw_lines(level),
- DoFHandler<dim,spacedim>::invalid_dof_index);
+ (DoFLevel::offset_type)(-1));
+ dof_handler.levels[level]->cell_cache_offsets
+ = std::vector<DoFLevel::offset_type> (
+ dof_handler.tria->n_raw_lines(level),
+ (DoFLevel::offset_type)(-1));
types::global_dof_index next_free_dof = 0;
+ types::global_dof_index cache_size = 0;
for (typename DoFHandler<dim,spacedim>::active_cell_iterator
cell=dof_handler.begin_active(level);
cell!=dof_handler.end_active(level); ++cell)
if (!cell->has_children())
{
- dof_handler.levels[level]->dof_object.dof_offsets[cell->index()] = next_free_dof;
+ dof_handler.levels[level]->dof_offsets[cell->index()] = next_free_dof;
next_free_dof += cell->get_fe().dofs_per_line;
+
+ dof_handler.levels[level]->cell_cache_offsets[cell->index()] = cache_size;
+ cache_size += cell->get_fe().dofs_per_cell;
}
- dof_handler.levels[level]->dof_object.dofs
+ dof_handler.levels[level]->dof_indices
= std::vector<types::global_dof_index> (next_free_dof,
DoFHandler<dim,spacedim>::invalid_dof_index);
+ dof_handler.levels[level]->cell_dof_indices_cache
+ = std::vector<types::global_dof_index> (cache_size,
+ DoFHandler<dim,spacedim>::invalid_dof_index);
}
// safety check: make sure that
if (!cell->has_children())
counter += cell->get_fe().dofs_per_line;
- Assert (dof_handler.levels[level]->dof_object.dofs.size() == counter,
+ Assert (dof_handler.levels[level]->dof_indices.size() == counter,
ExcInternalError());
Assert (static_cast<unsigned int>
- (std::count (dof_handler.levels[level]->dof_object.dof_offsets.begin(),
- dof_handler.levels[level]->dof_object.dof_offsets.end(),
- DoFHandler<dim,spacedim>::invalid_dof_index))
+ (std::count (dof_handler.levels[level]->dof_offsets.begin(),
+ dof_handler.levels[level]->dof_offsets.end(),
+ (DoFLevel::offset_type)(-1)))
==
dof_handler.tria->n_raw_lines(level) - dof_handler.tria->n_active_lines(level),
ExcInternalError());
// active_fe_indices field which
// we have to backup before
{
- std::vector<std::vector<unsigned int> >
+ std::vector<std::vector<DoFLevel::active_fe_index_type> >
active_fe_backup(dof_handler.levels.size ());
for (unsigned int level = 0; level<dof_handler.levels.size (); ++level)
std::swap (dof_handler.levels[level]->active_fe_indices,
for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
{
- dof_handler.levels.push_back (new internal::hp::DoFLevel<dim>);
+ dof_handler.levels.push_back (new internal::hp::DoFLevel);
std::swap (active_fe_backup[level],
dof_handler.levels[level]->active_fe_indices);
}
- dof_handler.faces = new internal::hp::DoFFaces<2>;
+ dof_handler.faces = new internal::hp::DoFIndicesOnFaces<2>;
}
// finite element is used for it
for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
{
- dof_handler.levels[level]->dof_object.dof_offsets
- = std::vector<types::global_dof_index> (
+ dof_handler.levels[level]->dof_offsets
+ = std::vector<DoFLevel::offset_type> (
dof_handler.tria->n_raw_quads(level),
- DoFHandler<dim,spacedim>::invalid_dof_index);
+ (DoFLevel::offset_type)(-1));
+ dof_handler.levels[level]->cell_cache_offsets
+ = std::vector<DoFLevel::offset_type> (
+ dof_handler.tria->n_raw_quads(level),
+ (DoFLevel::offset_type)(-1));
types::global_dof_index next_free_dof = 0;
+ types::global_dof_index cache_size = 0;
for (typename DoFHandler<dim,spacedim>::active_cell_iterator
cell=dof_handler.begin_active(level);
cell!=dof_handler.end_active(level); ++cell)
if (!cell->has_children())
{
- dof_handler.levels[level]->dof_object.dof_offsets[cell->index()] = next_free_dof;
+ dof_handler.levels[level]->dof_offsets[cell->index()] = next_free_dof;
next_free_dof += cell->get_fe().dofs_per_quad;
+
+ dof_handler.levels[level]->cell_cache_offsets[cell->index()] = cache_size;
+ cache_size += cell->get_fe().dofs_per_cell;
}
- dof_handler.levels[level]->dof_object.dofs
+ dof_handler.levels[level]->dof_indices
= std::vector<types::global_dof_index> (next_free_dof,
DoFHandler<dim,spacedim>::invalid_dof_index);
+ dof_handler.levels[level]->cell_dof_indices_cache
+ = std::vector<types::global_dof_index> (cache_size,
+ DoFHandler<dim,spacedim>::invalid_dof_index);
}
// safety check: make sure that
if (!cell->has_children())
counter += cell->get_fe().dofs_per_quad;
- Assert (dof_handler.levels[level]->dof_object.dofs.size() == counter,
+ Assert (dof_handler.levels[level]->dof_indices.size() == counter,
ExcInternalError());
Assert (static_cast<unsigned int>
- (std::count (dof_handler.levels[level]->dof_object.dof_offsets.begin(),
- dof_handler.levels[level]->dof_object.dof_offsets.end(),
- DoFHandler<dim,spacedim>::invalid_dof_index))
+ (std::count (dof_handler.levels[level]->dof_offsets.begin(),
+ dof_handler.levels[level]->dof_offsets.end(),
+ (DoFLevel::offset_type)(-1)))
==
dof_handler.tria->n_raw_quads(level) - dof_handler.tria->n_active_quads(level),
ExcInternalError());
// then allocate as much space as
// we need and prime the linked
// list for lines (see the
- // description in hp::DoFLevels)
+ // description in hp::DoFLevel)
// with the indices we will
// need. note that our task is
// more complicated since two
// active ones will have a
// non-invalid value later on
dof_handler.faces->lines.dof_offsets
- = std::vector<types::global_dof_index> (dof_handler.tria->n_raw_lines(),
- DoFHandler<dim,spacedim>::invalid_dof_index);
+ = std::vector<unsigned int> (dof_handler.tria->n_raw_lines(),
+ (unsigned int)(-1));
dof_handler.faces->lines.dofs
= std::vector<types::global_dof_index> (n_line_slots,
DoFHandler<dim,spacedim>::invalid_dof_index);
// active_fe_indices field which
// we have to backup before
{
- std::vector<std::vector<unsigned int> >
+ std::vector<std::vector<DoFLevel::active_fe_index_type> >
active_fe_backup(dof_handler.levels.size ());
for (unsigned int level = 0; level<dof_handler.levels.size (); ++level)
std::swap (dof_handler.levels[level]->active_fe_indices,
for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
{
- dof_handler.levels.push_back (new internal::hp::DoFLevel<dim>);
+ dof_handler.levels.push_back (new internal::hp::DoFLevel);
std::swap (active_fe_backup[level],
dof_handler.levels[level]->active_fe_indices);
}
- dof_handler.faces = new internal::hp::DoFFaces<3>;
+ dof_handler.faces = new internal::hp::DoFIndicesOnFaces<3>;
}
// finite element is used for it
for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
{
- dof_handler.levels[level]->dof_object.dof_offsets
- = std::vector<types::global_dof_index> (dof_handler.tria->n_raw_hexs(level),
- DoFHandler<dim,spacedim>::invalid_dof_index);
+ dof_handler.levels[level]->dof_offsets
+ = std::vector<DoFLevel::offset_type> (
+ dof_handler.tria->n_raw_hexs(level),
+ (DoFLevel::offset_type)(-1));
+ dof_handler.levels[level]->cell_cache_offsets
+ = std::vector<DoFLevel::offset_type> (
+ dof_handler.tria->n_raw_hexs(level),
+ (DoFLevel::offset_type)(-1));
types::global_dof_index next_free_dof = 0;
+ types::global_dof_index cache_size = 0;
for (typename DoFHandler<dim,spacedim>::active_cell_iterator
cell=dof_handler.begin_active(level);
cell!=dof_handler.end_active(level); ++cell)
if (!cell->has_children())
{
- dof_handler.levels[level]->dof_object.dof_offsets[cell->index()] = next_free_dof;
+ dof_handler.levels[level]->dof_offsets[cell->index()] = next_free_dof;
next_free_dof += cell->get_fe().dofs_per_hex;
+
+ dof_handler.levels[level]->cell_cache_offsets[cell->index()] = cache_size;
+ cache_size += cell->get_fe().dofs_per_cell;
}
- dof_handler.levels[level]->dof_object.dofs
+ dof_handler.levels[level]->dof_indices
= std::vector<types::global_dof_index> (next_free_dof,
DoFHandler<dim,spacedim>::invalid_dof_index);
+ dof_handler.levels[level]->cell_dof_indices_cache
+ = std::vector<types::global_dof_index> (cache_size,
+ DoFHandler<dim,spacedim>::invalid_dof_index);
}
// safety check: make sure that
if (!cell->has_children())
counter += cell->get_fe().dofs_per_hex;
- Assert (dof_handler.levels[level]->dof_object.dofs.size() == counter,
+ Assert (dof_handler.levels[level]->dof_indices.size() == counter,
ExcInternalError());
Assert (static_cast<unsigned int>
- (std::count (dof_handler.levels[level]->dof_object.dof_offsets.begin(),
- dof_handler.levels[level]->dof_object.dof_offsets.end(),
- DoFHandler<dim,spacedim>::invalid_dof_index))
+ (std::count (dof_handler.levels[level]->dof_offsets.begin(),
+ dof_handler.levels[level]->dof_offsets.end(),
+ (DoFLevel::offset_type)(-1)))
==
dof_handler.tria->n_raw_hexs(level) - dof_handler.tria->n_active_hexs(level),
ExcInternalError());
// then allocate as much space as
// we need and prime the linked
// list for quad (see the
- // description in hp::DoFLevels)
+ // description in hp::DoFLevel)
// with the indices we will
// need. note that our task is
// more complicated since two
if (true)
{
dof_handler.faces->quads.dof_offsets
- = std::vector<types::global_dof_index> (dof_handler.tria->n_raw_quads(),
- DoFHandler<dim,spacedim>::invalid_dof_index);
+ = std::vector<unsigned int>
+ (dof_handler.tria->n_raw_quads(),
+ (unsigned int)(-1));
dof_handler.faces->quads.dofs
= std::vector<types::global_dof_index> (n_quad_slots,
DoFHandler<dim,spacedim>::invalid_dof_index);
// line_dofs_offsets field
dof_handler.faces->lines.dof_offsets
.resize (dof_handler.tria->n_raw_lines(),
- numbers::invalid_dof_index);
+ numbers::invalid_unsigned_int);
unsigned int line_slots_needed = 0;
for (unsigned int line=0; line<dof_handler.tria->n_raw_lines(); ++line)
max_couplings_between_dofs (const DoFHandler<1,spacedim> &dof_handler)
{
return std::min(static_cast<types::global_dof_index> (3*
- dof_handler.finite_elements->max_dofs_per_vertex() +
- 2*dof_handler.finite_elements->max_dofs_per_line()),
- dof_handler.n_dofs());
+ dof_handler.finite_elements->max_dofs_per_vertex() +
+ 2*dof_handler.finite_elements->max_dofs_per_line()),
+ dof_handler.n_dofs());
}
const unsigned int dofs_per_face = cell->get_fe().dofs_per_face;
dofs_on_face.resize (dofs_per_face);
- cell->face(f)->get_dof_indices (dofs_on_face);
+ cell->face(f)->get_dof_indices (dofs_on_face,
+ cell->active_fe_index());
for (unsigned int i=0; i<dofs_per_face; ++i)
boundary_dofs.insert(dofs_on_face[i]);
};
ExcMessage ("Global number of degrees of freedom is too large."));
number_cache.n_locally_owned_dofs_per_processor
= std::vector<types::global_dof_index> (1,
- (types::global_dof_index) number_cache.n_global_dofs);
+ (types::global_dof_index) number_cache.n_global_dofs);
number_cache.locally_owned_dofs_per_processor
= std::vector<IndexSet> (1,
number_cache.locally_owned_dofs);
+ // update the cache used for cell dof indices and compress the data on the levels
+ for (active_cell_iterator cell = begin_active();
+ cell != end(); ++cell)
+ cell->update_cell_dof_indices_cache ();
+
+ for (unsigned int level=0; level<levels.size(); ++level)
+ levels[level]->compress_data (*finite_elements);
+
// finally restore the user flags
const_cast<Triangulation<dim,spacedim> &>(*tria).load_user_flags(user_flags);
}
}
#endif
+ // uncompress the internal storage scheme of dofs on cells
+ // so that we can access dofs in turns
+ for (unsigned int level=0; level<levels.size(); ++level)
+ levels[level]->uncompress_data (*finite_elements);
+
+ // do the renumbering
renumber_dofs_internal (new_numbers, dealii::internal::int2type<dim>());
+
+ // update the cache used for cell dof indices
+ for (active_cell_iterator cell = begin_active();
+ cell != end(); ++cell)
+ cell->update_cell_dof_indices_cache ();
+
+ // now re-compress the dof indices
+ for (unsigned int level=0; level<levels.size(); ++level)
+ levels[level]->compress_data (*finite_elements);
}
// Create sufficiently many
// hp::DoFLevels.
while (levels.size () < tria->n_levels ())
- levels.push_back (new dealii::internal::hp::DoFLevel<dim>);
+ levels.push_back (new dealii::internal::hp::DoFLevel);
// then make sure that on each
// level we have the appropriate
{
create_active_fe_table ();
- // Remember if the cells have already
+ // Remember if the cells already have
// children. That will make the transfer
// of the active_fe_index to the finer
// levels easier.
std::vector<bool> *has_children_level =
new std::vector<bool> (cells_on_level);
- // Check for each cell, if it has children.
- std::transform (tria->levels[i]->cells.refinement_cases.begin (),
- tria->levels[i]->cells.refinement_cases.end (),
- has_children_level->begin (),
- std::bind2nd (std::not_equal_to<unsigned char>(),
- static_cast<unsigned char>(RefinementCase<dim>::no_refinement)));
-
- has_children.push_back (has_children_level);
- }
- }
-
-
-
- template <>
- void DoFHandler<1>::pre_refinement_action ()
- {
- create_active_fe_table ();
-
- // Remember if the cells have already
- // children. That will make the transfer
- // of the active_fe_index to the finer
- // levels easier.
- Assert (has_children.size () == 0, ExcInternalError ());
- for (unsigned int i=0; i<levels.size(); ++i)
- {
- const unsigned int cells_on_level = tria->n_raw_cells (i);
- std::vector<bool> *has_children_level =
- new std::vector<bool> (cells_on_level);
-
- // Check for each cell, if it has
- // children. here we cannot use
- // refinement_cases, since it is unused in
- // 1d (as there is only one choice
- // anyway). use the 'children' vector
- // instead
- std::transform (tria->levels[i]->cells.children.begin (),
- tria->levels[i]->cells.children.end (),
- has_children_level->begin (),
- std::bind2nd (std::not_equal_to<int>(), -1));
-
- has_children.push_back (has_children_level);
- }
- }
-
-
-
- template <>
- void DoFHandler<1,2>::pre_refinement_action ()
- {
- create_active_fe_table ();
-
- // Remember if the cells have already
- // children. That will make the transfer
- // of the active_fe_index to the finer
- // levels easier.
- Assert (has_children.size () == 0, ExcInternalError ());
- for (unsigned int i=0; i<levels.size(); ++i)
- {
- const unsigned int lines_on_level = tria->n_raw_lines(i);
- std::vector<bool> *has_children_level =
- new std::vector<bool> (lines_on_level);
-
- // Check for each cell, if it has children.
- std::transform (tria->levels[i]->cells.children.begin (),
- tria->levels[i]->cells.children.end (),
- has_children_level->begin (),
- std::bind2nd (std::not_equal_to<int>(), -1));
-
- has_children.push_back (has_children_level);
- }
- }
-
-
-
- template <>
- void DoFHandler<1,3>::pre_refinement_action ()
- {
- create_active_fe_table ();
-
- // Remember if the cells have already
- // children. That will make the transfer
- // of the active_fe_index to the finer
- // levels easier.
- Assert (has_children.size () == 0, ExcInternalError ());
- for (unsigned int i=0; i<levels.size(); ++i)
- {
- const unsigned int lines_on_level = tria->n_raw_lines(i);
- std::vector<bool> *has_children_level =
- new std::vector<bool> (lines_on_level);
-
- // Check for each cell, if it has children.
- std::transform (tria->levels[i]->cells.children.begin (),
- tria->levels[i]->cells.children.end (),
- has_children_level->begin (),
- std::bind2nd (std::not_equal_to<int>(), -1));
+ // Check for each cell, if it has children. in 1d,
+ // we don't store refinement cases, so use the 'children'
+ // vector instead
+ if (dim == 1)
+ std::transform (tria->levels[i]->cells.children.begin (),
+ tria->levels[i]->cells.children.end (),
+ has_children_level->begin (),
+ std::bind2nd (std::not_equal_to<int>(), -1));
+ else
+ std::transform (tria->levels[i]->cells.refinement_cases.begin (),
+ tria->levels[i]->cells.refinement_cases.end (),
+ has_children_level->begin (),
+ std::bind2nd (std::not_equal_to<unsigned char>(),
+ static_cast<unsigned char>(RefinementCase<dim>::no_refinement)));
has_children.push_back (has_children_level);
}
{
Assert (has_children.size () == levels.size (), ExcInternalError ());
- // In each refinement at most one new
- // new level may appear. If that happened
- // it is appended to the DoFHandler
- // levels.
- if (levels.size () < tria->n_levels ())
- levels.push_back (new dealii::internal::hp::DoFLevel<dim>);
+ // Normally only one level is added, but if this Triangulation
+ // is created by copy_triangulation, it can be more than one level.
+ while (levels.size () < tria->n_levels ())
+ levels.push_back (new dealii::internal::hp::DoFLevel);
// Coarsening can lead to the loss
// of levels. Hence remove them.
levels.pop_back ();
}
+ Assert(levels.size () == tria->n_levels (), ExcInternalError());
+
// Resize active_fe_indices
// vectors. use zero indicator to
// extend
children_level != has_children.end ();
++children_level)
delete (*children_level);
- /*
- for_each (has_children.begin (),
- has_children.end (),
- delete());
- */
has_children.clear ();
}
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
{
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 2003 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+#include <deal.II/base/memory_consumption.h>
+#include <deal.II/hp/dof_level.h>
+#include <deal.II/hp/fe_collection.h>
+#include <iostream>
+
+DEAL_II_NAMESPACE_OPEN
+
+namespace internal
+{
+ namespace hp
+ {
+ template <int dim, int spacedim>
+ void
+ DoFLevel::compress_data (const dealii::hp::FECollection<dim,spacedim> &fe_collection)
+ {
+ return;
+
+ if (dof_offsets.size() == 0 || dof_indices.size()==0)
+ return;
+
+ // in a first run through, count how many new slots we need in the
+ // dof_indices array after compression. note that the 'cell'
+ // counter is incremented inside the loop
+ unsigned int new_size = 0;
+ for (unsigned int cell=0; cell<dof_offsets.size(); )
+ // see if this cell is active on the current level
+ if (dof_offsets[cell] != (offset_type)(-1))
+ {
+ // find the next cell active on this level
+ unsigned int next_cell = cell+1;
+ while ((next_cell<dof_offsets.size()) &&
+ (dof_offsets[next_cell] == (offset_type)(-1)))
+ ++next_cell;
+
+ const unsigned int next_offset = (next_cell < dof_offsets.size() ?
+ dof_offsets[next_cell] :
+ dof_indices.size());
+
+ Assert (next_offset-dof_offsets[cell] == fe_collection[active_fe_indices[cell]].template n_dofs_per_object<dim>(),
+ ExcInternalError());
+
+ // see if the range of dofs for this cell can be compressed and if so
+ // how many slots we have to store for them
+ if (next_offset > dof_offsets[cell])
+ {
+ bool compressible = true;
+ for (unsigned int j=dof_offsets[cell]+1; j<next_offset; ++j)
+ if (dof_indices[j] != dof_indices[j-1]+1)
+ {
+ compressible = false;
+ break;
+ }
+ if (compressible == true)
+ new_size += 1;
+ else
+ new_size += (next_offset-dof_offsets[cell]);
+ }
+
+ // then move on to the next cell
+ cell = next_cell;
+ }
+ else
+ ++cell;
+
+ // now allocate the new array and copy into it whatever we need
+ std::vector<types::global_dof_index> new_dof_indices;
+ new_dof_indices.reserve(new_size);
+ for (unsigned int cell=0; cell<dof_offsets.size(); )
+ // see if this cell is active on the current level
+ if (dof_offsets[cell] != (offset_type)(-1))
+ {
+ // find the next cell active on this level
+ unsigned int next_cell = cell+1;
+ while ((next_cell<dof_offsets.size()) &&
+ (dof_offsets[next_cell] == (offset_type)(-1)))
+ ++next_cell;
+
+ const unsigned int next_offset = (next_cell < dof_offsets.size() ?
+ dof_offsets[next_cell] :
+ dof_indices.size());
+
+ Assert (next_offset-dof_offsets[cell] == fe_collection[active_fe_indices[cell]].template n_dofs_per_object<dim>(),
+ ExcInternalError());
+
+ // see if the range of dofs for this cell can be compressed and if so
+ // how many slots we have to store for them
+ if (next_offset > dof_offsets[cell])
+ {
+ bool compressible = true;
+ for (unsigned int j=dof_offsets[cell]+1; j<next_offset; ++j)
+ if (dof_indices[j] != dof_indices[j-1]+1)
+ {
+ compressible = false;
+ break;
+ }
+
+ // if this cell is compressible, then copy the first index and mark this
+ // in the dof_offsets array
+ if (compressible == true)
+ {
+ new_dof_indices.push_back (dof_indices[dof_offsets[cell]]);
+
+ // make sure that the current active_fe_index indicates
+ // that this entry hasn't been compressed yet
+ Assert ((signed_active_fe_index_type)active_fe_indices[cell] >= 0, ExcInternalError());
+
+ // then mark the compression
+ active_fe_indices[cell] = (active_fe_index_type)~(signed_active_fe_index_type)active_fe_indices[cell];
+ }
+ else
+ for (unsigned int i=dof_offsets[cell]; i<next_offset; ++i)
+ new_dof_indices.push_back (dof_indices[i]);
+ }
+
+ // then move on to the next cell
+ cell = next_cell;
+ }
+ else
+ ++cell;
+
+ // finally swap old and new content
+ Assert (new_dof_indices.size() == new_size, ExcInternalError());
+ dof_indices.swap (new_dof_indices);
+ }
+
+
+
+ template <int dim, int spacedim>
+ void
+ DoFLevel::uncompress_data(const dealii::hp::FECollection<dim,spacedim> &fe_collection)
+ {
+ return;
+
+ if (dof_offsets.size() == 0 || dof_indices.size()==0)
+ return;
+
+ // in a first run through, count how many new slots we need in the
+ // dof_indices array after uncompression.
+ unsigned int new_size = 0;
+ for (unsigned int cell=0; cell<dof_offsets.size(); ++cell)
+ if (dof_offsets[cell] != (offset_type)(-1))
+ {
+ // we know now that the slot for this cell is used. extract the
+ // active_fe_index for it and see how many entries we need
+ new_size += fe_collection[active_fe_index(cell)].template n_dofs_per_object<dim>();
+ }
+
+ // now allocate the new array and copy into it whatever we need
+ std::vector<types::global_dof_index> new_dof_indices;
+ new_dof_indices.reserve(new_size);
+ std::vector<offset_type> new_dof_offsets (dof_offsets.size(), (offset_type)(-1));
+ for (unsigned int cell=0; cell<dof_offsets.size(); )
+ // see if this cell is active on the current level
+ if (dof_offsets[cell] != (offset_type)(-1))
+ {
+ // find the next cell active on this level
+ unsigned int next_cell = cell+1;
+ while ((next_cell<dof_offsets.size()) &&
+ (dof_offsets[next_cell] == (offset_type)(-1)))
+ ++next_cell;
+
+ const unsigned int next_offset = (next_cell < dof_offsets.size() ?
+ dof_offsets[next_cell] :
+ dof_indices.size());
+
+ // set offset for this cell
+ new_dof_offsets[cell] = new_dof_indices.size();
+
+ // see if we need to uncompress this set of dofs
+ if ((signed_active_fe_index_type)active_fe_indices[cell]>=0)
+ {
+ // apparently not. simply copy them
+ Assert (next_offset-dof_offsets[cell] == fe_collection[active_fe_indices[cell]].template n_dofs_per_object<dim>(),
+ ExcInternalError());
+ for (unsigned int i=dof_offsets[cell]; i<next_offset; ++i)
+ new_dof_indices.push_back (dof_indices[i]);
+ }
+ else
+ {
+ // apparently so. uncompress
+ Assert (next_offset-dof_offsets[cell] == 1,
+ ExcInternalError());
+ for (unsigned int i=0; i<fe_collection[active_fe_indices[cell]].template n_dofs_per_object<dim>(); ++i)
+ new_dof_indices.push_back (dof_indices[dof_offsets[cell]]+i);
+ }
+
+ // then move on to the next cell
+ cell = next_cell;
+ }
+ else
+ ++cell;
+
+ // verify correct size, then swap arrays
+ Assert (new_dof_indices.size() == new_size, ExcInternalError());
+ dof_indices.swap (new_dof_indices);
+ dof_offsets.swap (new_dof_offsets);
+ }
+
+
+ std::size_t
+ DoFLevel::memory_consumption () const
+ {
+ return (MemoryConsumption::memory_consumption (active_fe_indices) +
+ MemoryConsumption::memory_consumption (dof_indices) +
+ MemoryConsumption::memory_consumption (dof_offsets) +
+ MemoryConsumption::memory_consumption (cell_cache_offsets) +
+ MemoryConsumption::memory_consumption(cell_dof_indices_cache));
+ }
+
+
+ // explicit instantiations
+ template void DoFLevel::compress_data(const dealii::hp::FECollection<1,1> &);
+ template void DoFLevel::compress_data(const dealii::hp::FECollection<1,2> &);
+ template void DoFLevel::compress_data(const dealii::hp::FECollection<1,3> &);
+ template void DoFLevel::compress_data(const dealii::hp::FECollection<2,2> &);
+ template void DoFLevel::compress_data(const dealii::hp::FECollection<2,3> &);
+ template void DoFLevel::compress_data(const dealii::hp::FECollection<3,3> &);
+
+ template void DoFLevel::uncompress_data(const dealii::hp::FECollection<1,1> &);
+ template void DoFLevel::uncompress_data(const dealii::hp::FECollection<1,2> &);
+ template void DoFLevel::uncompress_data(const dealii::hp::FECollection<1,3> &);
+ template void DoFLevel::uncompress_data(const dealii::hp::FECollection<2,2> &);
+ template void DoFLevel::uncompress_data(const dealii::hp::FECollection<2,3> &);
+ template void DoFLevel::uncompress_data(const dealii::hp::FECollection<3,3> &);
+ }
+}
+
+DEAL_II_NAMESPACE_CLOSE
+++ /dev/null
-//---------------------------- hp_dof_levels.cc ---------------------------
-// $Id$
-// Version: $Name$
-//
-// Copyright (C) 2003, 2006, 2011, 2012 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.
-//
-//---------------------------- hp_dof_levels.cc ------------------------
-
-
-#include <deal.II/base/memory_consumption.h>
-#include <deal.II/hp/dof_levels.h>
-
-DEAL_II_NAMESPACE_OPEN
-
-namespace internal
-{
- namespace hp
- {
-
- std::size_t
- DoFLevel<1>::memory_consumption () const
- {
- return (DoFLevel<0>::memory_consumption() +
- MemoryConsumption::memory_consumption (dof_object));
- }
-
-
-
- std::size_t
- DoFLevel<2>::memory_consumption () const
- {
- return (DoFLevel<0>::memory_consumption () +
- MemoryConsumption::memory_consumption (dof_object));
- }
-
-
-
- std::size_t
- DoFLevel<3>::memory_consumption () const
- {
- return (DoFLevel<0>::memory_consumption () +
- MemoryConsumption::memory_consumption (dof_object));
- }
-
-
-
- std::size_t
- DoFLevel<0>::memory_consumption () const
- {
- return MemoryConsumption::memory_consumption (active_fe_indices);
- }
-
- }
-}
-
-DEAL_II_NAMESPACE_CLOSE
+++ /dev/null
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
-//
-// Copyright (C) 2006, 2011, 2012 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 <deal.II/base/memory_consumption.h>
-#include <deal.II/hp/dof_objects.h>
-
-DEAL_II_NAMESPACE_OPEN
-
-namespace internal
-{
- namespace hp
- {
- template <int structdim>
- std::size_t
- DoFObjects<structdim>::memory_consumption () const
- {
- return (MemoryConsumption::memory_consumption (dofs) +
- MemoryConsumption::memory_consumption (dof_offsets));
- }
-
-
- // explicit instantiations
- template
- std::size_t
- DoFObjects<1>::memory_consumption () const;
-
- template
- std::size_t
- DoFObjects<2>::memory_consumption () const;
-
- template
- std::size_t
- DoFObjects<3>::memory_consumption () const;
- }
-}
-
-DEAL_II_NAMESPACE_CLOSE
-//---------------------------- fe_collection.cc ---------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2006, 2011, 2012 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------- fe_collection.cc ---------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/memory_consumption.h>
#include <deal.II/hp/fe_collection.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
{
-//---------------------------- hp_fe_values.cc ---------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------- hp_fe_values.cc ---------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/hp/fe_values.h>
#include <deal.II/fe/mapping_q1.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
{
-//----------------------- mapping_collection.cc ---------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2006, 2011, 2012 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//----------------------- mapping_collection.cc ---------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/memory_consumption.h>
#include <deal.II/hp/mapping_collection.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
{
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
## Copyright (C) 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
-FILE(GLOB _header
- ${CMAKE_SOURCE_DIR}/include/deal.II/integrators/*.h
+SET(_src
)
-SET(_src
+FILE(GLOB _header
+ ${CMAKE_SOURCE_DIR}/include/deal.II/integrators/*.h
)
DEAL_II_ADD_LIBRARY(obj_integrators OBJECT ${_src} ${_header})
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
-FILE(GLOB _header
- ${CMAKE_SOURCE_DIR}/include/deal.II/lac/*.h
- )
-
SET(_src
block_matrix_array.cc
block_sparse_matrix.cc
vector.cc
vector_memory.cc
vector_view.cc
-)
+ )
SET(_inst
block_sparse_matrix.inst.in
vector.inst.in
vector_memory.inst.in
vector_view.inst.in
-)
+ )
+
+FILE(GLOB _header
+ ${CMAKE_SOURCE_DIR}/include/deal.II/lac/*.h
+ )
DEAL_II_ADD_LIBRARY(obj_lac OBJECT ${_src} ${_header} ${_inst})
EXPAND_INSTANTIATIONS(obj_lac "${_inst}")
-
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2008, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/lac/block_matrix_array.h>
#include <deal.II/lac/vector.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2004, 2005, 2006, 2011, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/lac/block_sparse_matrix.templates.h>
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (S : REAL_SCALARS)
{
template class BlockSparseMatrix<S>;
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/lac/block_sparse_matrix_ez.h>
#include <deal.II/lac/block_sparse_matrix_ez.templates.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/vector_slice.h>
#include <deal.II/base/memory_consumption.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/lac/block_vector.templates.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (S : REAL_SCALARS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2012 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/chunk_sparse_matrix.templates.h>
#include <deal.II/lac/block_vector.h>
-//---------------------------- sparse_matrix.inst.in ---------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2006, 2007, 2008 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------- sparse_matrix.inst.in ---------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
// real instantiations
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/lac/chunk_sparsity_pattern.h>
#include <deal.II/lac/compressed_sparsity_pattern.h>
void
ChunkSparsityPattern::reinit (
- const size_type m,
- const size_type n,
- const VectorSlice<const std::vector<size_type> > &row_lengths,
- const size_type chunk_size)
+ const size_type m,
+ const size_type n,
+ const VectorSlice<const std::vector<size_type> > &row_lengths,
+ const size_type chunk_size)
{
Assert (row_lengths.size() == m, ExcInvalidNumber (m));
Assert (chunk_size > 0, ExcInvalidNumber (chunk_size));
// distinguish between compressed sparsity types that define row_begin()
// and SparsityPattern that uses begin() as iterator type
template <typename Sparsity>
- void copy_row (const Sparsity &csp,
- const size_type row,
- ChunkSparsityPattern &dst)
+ void copy_row (const Sparsity &csp,
+ const size_type row,
+ const unsigned int chunk_size,
+ CompressedSimpleSparsityPattern &dst)
{
typename Sparsity::row_iterator col_num = csp.row_begin (row);
+ const size_type reduced_row = row/chunk_size;
for (; col_num != csp.row_end (row); ++col_num)
- dst.add (row, *col_num);
+ dst.add (reduced_row, *col_num/chunk_size);
}
- void copy_row (const SparsityPattern &csp,
- const size_type row,
- ChunkSparsityPattern &dst)
+ void copy_row (const SparsityPattern &csp,
+ const size_type row,
+ const unsigned int chunk_size,
+ CompressedSimpleSparsityPattern &dst)
{
SparsityPattern::iterator col_num = csp.begin (row);
+ const size_type reduced_row = row/chunk_size;
for (; col_num != csp.end (row); ++col_num)
- dst.add (row, col_num->column());
+ dst.add (reduced_row, col_num->column()/chunk_size);
}
}
}
const size_type chunk_size)
{
Assert (chunk_size > 0, ExcInvalidNumber (chunk_size));
+ this->chunk_size = chunk_size;
+ rows = csp.n_rows();
+ cols = csp.n_cols();
- // count number of entries per row, then initialize the underlying sparsity
- // pattern
- std::vector<size_type> entries_per_row (csp.n_rows(), 0);
- for (size_type row = 0; row<csp.n_rows(); ++row)
- entries_per_row[row] = csp.row_length(row);
+ // simple case: just use the other sparsity pattern
+ if (chunk_size == 1)
+ {
+ sparsity_pattern.copy_from (csp);
+ return;
+ }
- reinit (csp.n_rows(), csp.n_cols(),
- entries_per_row,
- chunk_size);
+ // create a temporary compressed sparsity pattern that collects all entries
+ // from the input sparsity pattern and then initialize the underlying small
+ // sparsity pattern
+ const size_type m_chunks = (csp.n_rows()+chunk_size-1) / chunk_size,
+ n_chunks = (csp.n_cols()+chunk_size-1) / chunk_size;
+ CompressedSimpleSparsityPattern temporary_sp(m_chunks, n_chunks);
- // then actually fill it
for (size_type row = 0; row<csp.n_rows(); ++row)
- internal::copy_row(csp, row, *this);
+ internal::copy_row(csp, row, chunk_size, temporary_sp);
- // finally compress
- compress ();
+ sparsity_pattern.copy_from (temporary_sp);
}
for (size_type row=0; row<matrix.m(); ++row)
{
for (size_type col=0; col<matrix.n(); ++col)
- if (matrix(row,col) != 0)
- ++entries_per_row[row];
+ if (matrix(row,col) != 0)
+ ++entries_per_row[row];
if ((matrix.m() == matrix.n())
- &&
- (matrix(row,row) == 0))
- ++entries_per_row[row];
+ &&
+ (matrix(row,row) == 0))
+ ++entries_per_row[row];
}
reinit (matrix.m(), matrix.n(),
-ChunkSparsityPattern::size_type
+ChunkSparsityPattern::size_type
ChunkSparsityPattern::max_entries_per_row () const
{
return sparsity_pattern.max_entries_per_row() * chunk_size;
-ChunkSparsityPattern::size_type
+ChunkSparsityPattern::size_type
ChunkSparsityPattern::row_length (const size_type i) const
{
Assert (i<rows, ExcIndexRange(i,0,rows));
-ChunkSparsityPattern::size_type
+ChunkSparsityPattern::size_type
ChunkSparsityPattern::n_nonzero_elements () const
{
if ((n_rows() % chunk_size == 0)
else
{
- // if columns don't align, then just iterate over all chunks and see
- // what this leads to. follow the advice in the documentation of the
- // sparsity pattern iterators to do the loop over individual rows,
- // rather than all elements
- size_type n = 0;
-
- for (size_type row = 0; row < sparsity_pattern.n_rows(); ++row)
- {
- SparsityPattern::const_iterator p = sparsity_pattern.begin(row);
- for (; p!=sparsity_pattern.end(row); ++p)
- if ((row != sparsity_pattern.n_rows() - 1)
- &&
- (p->column() != sparsity_pattern.n_cols() - 1))
- n += chunk_size * chunk_size;
- else if ((row == sparsity_pattern.n_rows() - 1)
- &&
- (p->column() != sparsity_pattern.n_cols() - 1))
- // last chunk row, but not last chunk column. only a smaller
- // number (n_rows % chunk_size) of rows actually exist
- n += (n_rows() % chunk_size) * chunk_size;
- else if ((row != sparsity_pattern.n_rows() - 1)
- &&
- (p->column() == sparsity_pattern.n_cols() - 1))
- // last chunk column, but not row
- n += (n_cols() % chunk_size) * chunk_size;
- else
- // bottom right chunk
- n += (n_cols() % chunk_size) *
- (n_rows() % chunk_size);
- }
-
- return n;
+ // if columns don't align, then just iterate over all chunks and see
+ // what this leads to. follow the advice in the documentation of the
+ // sparsity pattern iterators to do the loop over individual rows,
+ // rather than all elements
+ size_type n = 0;
+
+ for (size_type row = 0; row < sparsity_pattern.n_rows(); ++row)
+ {
+ SparsityPattern::const_iterator p = sparsity_pattern.begin(row);
+ for (; p!=sparsity_pattern.end(row); ++p)
+ if ((row != sparsity_pattern.n_rows() - 1)
+ &&
+ (p->column() != sparsity_pattern.n_cols() - 1))
+ n += chunk_size * chunk_size;
+ else if ((row == sparsity_pattern.n_rows() - 1)
+ &&
+ (p->column() != sparsity_pattern.n_cols() - 1))
+ // last chunk row, but not last chunk column. only a smaller
+ // number (n_rows % chunk_size) of rows actually exist
+ n += (n_rows() % chunk_size) * chunk_size;
+ else if ((row != sparsity_pattern.n_rows() - 1)
+ &&
+ (p->column() == sparsity_pattern.n_cols() - 1))
+ // last chunk column, but not row
+ n += (n_cols() % chunk_size) * chunk_size;
+ else
+ // bottom right chunk
+ n += (n_cols() % chunk_size) *
+ (n_rows() % chunk_size);
+ }
+
+ return n;
}
}
}
-ChunkSparsityPattern::size_type
+ChunkSparsityPattern::size_type
ChunkSparsityPattern::bandwidth () const
{
// calculate the bandwidth from that of the underlying sparsity
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2012 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/compressed_set_sparsity_pattern.h>
-CompressedSetSparsityPattern::size_type
+CompressedSetSparsityPattern::size_type
CompressedSetSparsityPattern::max_entries_per_row () const
{
size_type m = 0;
-CompressedSetSparsityPattern::size_type
+CompressedSetSparsityPattern::size_type
CompressedSetSparsityPattern::bandwidth () const
{
size_type b=0;
-CompressedSetSparsityPattern::size_type
+CompressedSetSparsityPattern::size_type
CompressedSetSparsityPattern::n_nonzero_elements () const
{
size_type n=0;
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2009, 2011, 2012 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/compressed_simple_sparsity_pattern.h>
#include <deal.II/base/memory_consumption.h>
}
+CompressedSimpleSparsityPattern::CompressedSimpleSparsityPattern (const IndexSet &rowset_)
+ :
+ rows(0),
+ cols(0),
+ rowset(0)
+{
+ reinit (rowset_.size(), rowset_.size(), rowset_);
+}
+
CompressedSimpleSparsityPattern::CompressedSimpleSparsityPattern (const size_type n)
:
-CompressedSimpleSparsityPattern::size_type
+CompressedSimpleSparsityPattern::size_type
CompressedSimpleSparsityPattern::max_entries_per_row () const
{
size_type m = 0;
-CompressedSimpleSparsityPattern::size_type
+CompressedSimpleSparsityPattern::size_type
CompressedSimpleSparsityPattern::bandwidth () const
{
size_type b=0;
-CompressedSimpleSparsityPattern::size_type
+CompressedSimpleSparsityPattern::size_type
CompressedSimpleSparsityPattern::n_nonzero_elements () const
{
size_type n=0;
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2012 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/compressed_sparsity_pattern.h>
-CompressedSparsityPattern::size_type
+CompressedSparsityPattern::size_type
CompressedSparsityPattern::max_entries_per_row () const
{
size_type m = 0;
-CompressedSparsityPattern::size_type
+CompressedSparsityPattern::size_type
CompressedSparsityPattern::bandwidth () const
{
size_type b=0;
-CompressedSparsityPattern::size_type
+CompressedSparsityPattern::size_type
CompressedSparsityPattern::n_nonzero_elements () const
{
size_type n=0;
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/constraint_matrix.h>
#include <deal.II/lac/constraint_matrix.templates.h>
// won't modify the size any more after this point.
{
std::vector<size_type> new_lines (lines_cache.size(),
- numbers::invalid_size_type);
+ numbers::invalid_size_type);
size_type counter = 0;
for (std::vector<ConstraintLine>::const_iterator line=lines.begin();
line!=lines.end(); ++line, ++counter)
for (ConstraintLine::Entries::const_iterator j=other_line->begin();
j!=other_line->end(); ++j)
tmp.push_back (std::pair<size_type,double>(j->first,
- j->second*weight));
+ j->second*weight));
line->inhomogeneity += other_constraints.get_inhomogeneity(line->entries[i].first) *
weight;
void ConstraintMatrix::reinit (const IndexSet &local_constraints)
{
local_lines = local_constraints;
+
+ // make sure the IndexSet is compressed. Otherwise this can lead to crashes
+ // that are hard to find (only happen in release mode).
+ // see tests/mpi/constraint_matrix_crash_01
+ local_lines.compress();
+
clear();
}
q!=lines[distribute[column]].entries.size();
++q)
{
- const size_type
+ const size_type
new_col = lines[distribute[column]].entries[q].first;
sparsity.add (row, new_col);
q!=lines[distribute[column]].entries.size();
++q)
{
- const size_type
+ const size_type
new_col = lines[distribute[column]].entries[q].first;
sparsity.add (row, new_col);
// otherwise, the number states which line in the constraint matrix
// handles this index
std::vector<size_type> distribute(sparsity.n_rows(),
- numbers::invalid_size_type);
+ numbers::invalid_size_type);
for (size_type c=0; c<lines.size(); ++c)
distribute[lines[c].line] = c;
q!=lines[distribute[column]].entries.size();
++q)
{
- const size_type
+ const size_type
new_col = lines[distribute[column]].entries[q].first;
sparsity.add (row, new_col);
// otherwise, the number states which line in the constraint matrix
// handles this index
std::vector<size_type> distribute (sparsity.n_rows(),
- numbers::invalid_size_type);
+ numbers::invalid_size_type);
for (size_type c=0; c<lines.size(); ++c)
distribute[lines[c].line] = c;
// otherwise, the number states which line in the constraint matrix
// handles this index
std::vector<size_type> distribute (sparsity.n_rows(),
- numbers::invalid_size_type);
+ numbers::invalid_size_type);
for (size_type c=0; c<lines.size(); ++c)
distribute[lines[c].line] = static_cast<signed int>(c);
// otherwise, the number states which line in the constraint matrix
// handles this index
std::vector<size_type> distribute (sparsity.n_rows(),
- numbers::invalid_size_type);
+ numbers::invalid_size_type);
for (size_type c=0; c<lines.size(); ++c)
distribute[lines[c].line] = static_cast<signed int>(c);
// otherwise, the number states which line in the constraint matrix
// handles this index
std::vector<size_type> distribute (sparsity.n_rows(),
- numbers::invalid_size_type);
+ numbers::invalid_size_type);
for (size_type c=0; c<lines.size(); ++c)
distribute[lines[c].line] = static_cast<signed int>(c);
if (distribute[global_col] == numbers::invalid_size_type)
// distribute entry at irregular row @p{row} and
// regular column global_col.
- { for (size_type q=0;
+ {
+ for (size_type q=0;
q!=lines[distribute[row]].entries.size(); ++q)
sparsity.add (lines[distribute[row]].entries[q].first,
global_col);
else
// distribute entry at irregular row @p{row} and
// irregular column @p{global_col}
- { for (size_type p=0;
+ {
+ for (size_type p=0;
p!=lines[distribute[row]].entries.size(); ++p)
for (size_type q=0; q!=lines[distribute[global_col]].entries.size(); ++q)
sparsity.add (lines[distribute[row]].entries[p].first,
}
+bool ConstraintMatrix::are_identity_constrained (const size_type index1,
+ const size_type index2) const
+{
+ if (is_constrained(index1) == true)
+ {
+ const ConstraintLine &p = lines[lines_cache[calculate_line_index(index1)]];
+ Assert (p.line == index1, ExcInternalError());
+
+ // return if an entry for this line was found and if it has only one
+ // entry equal to 1.0 and that one is index2
+ return ((p.entries.size() == 1) &&
+ (p.entries[0].first == index2) &&
+ (p.entries[0].second == 1.0));
+ }
+ else if (is_constrained(index2) == true)
+ {
+ const ConstraintLine &p = lines[lines_cache[calculate_line_index(index2)]];
+ Assert (p.line == index2, ExcInternalError());
+
+ // return if an entry for this line was found and if it has only one
+ // entry equal to 1.0 and that one is index1
+ return ((p.entries.size() == 1) &&
+ (p.entries[0].first == index1) &&
+ (p.entries[0].second == 1.0));
+ }
+ else
+ return false;
+}
+
+
-ConstraintMatrix::size_type
+ConstraintMatrix::size_type
ConstraintMatrix::max_constraint_indirections () const
{
size_type return_value = 0;
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (S: REAL_SCALARS; T : DEAL_II_VEC_TEMPLATES)
{
template void ConstraintMatrix::condense<T<S> >(const T<S> &, T<S> &) const;
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/logstream.h>
#include <deal.II/lac/full_matrix.templates.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (S : REAL_SCALARS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2008, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/lac/lapack_full_matrix.h>
#include <deal.II/lac/lapack_templates.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2013 by the deal.II authors
+// Copyright (C) 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (S : REAL_SCALARS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2002, 2003, 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 2002 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/matrix_lib.templates.h>
#include <deal.II/lac/sparse_matrix.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/matrix_out.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/parallel_vector.h>
#include <deal.II/lac/parallel_vector.templates.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2011 by the deal.II authors
+// Copyright (C) 2011 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (SCALAR : REAL_SCALARS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2008, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/petsc_block_sparse_matrix.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2008, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/petsc_full_matrix.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/petsc_matrix_base.h>
- MatrixBase::size_type
+ MatrixBase::size_type
MatrixBase::n () const
{
PetscInt n_rows, n_cols;
- MatrixBase::size_type
+ MatrixBase::size_type
MatrixBase::local_size () const
{
PetscInt n_rows, n_cols;
- MatrixBase::size_type
+ MatrixBase::size_type
MatrixBase::n_nonzero_elements () const
{
MatInfo mat_info;
- MatrixBase::size_type
+ MatrixBase::size_type
MatrixBase::
row_length (const size_type row) const
{
ierr = MatGetRow(*this, row, &ncols, &colnums, &values);
AssertThrow (ierr == 0, MatrixBase::ExcPETScError(ierr));
- // then restore the matrix and return the
- // number of columns in this row as
- // queried previously
+ // then restore the matrix and return the number of columns in this row as
+ // queried previously. Starting with PETSc 3.4, MatRestoreRow actually
+ // resets the last three arguments to zero/NULL, to avoid abuse of pointers
+ // now dangling. as a consequence, we need to save the size of the array
+ // and return the saved value.
+ const PetscInt ncols_saved = ncols;
ierr = MatRestoreRow(*this, row, &ncols, &colnums, &values);
AssertThrow (ierr == 0, MatrixBase::ExcPETScError(ierr));
- return ncols;
+ return ncols_saved;
}
MatrixBase &
MatrixBase::add (const MatrixBase &other,
- const PetscScalar factor)
+ const PetscScalar factor)
{
const int ierr = MatAXPY (matrix, factor,
- other, DIFFERENT_NONZERO_PATTERN);
+ other, DIFFERENT_NONZERO_PATTERN);
Assert (ierr == 0, ExcPETScError(ierr));
return *this;
}
-
+
void
MatrixBase::vmult (VectorBase &dst,
MatView (matrix, PETSC_VIEWER_STDOUT_WORLD);
}
+ void
+ MatrixBase::print (std::ostream &out,
+ const bool alternative_output) const
+ {
+ std::pair<MatrixBase::size_type, MatrixBase::size_type>
+ loc_range = local_range();
+
+ PetscInt ncols;
+ const PetscInt *colnums;
+ const PetscScalar *values;
+
+ MatrixBase::size_type row;
+ for (row = loc_range.first; row < loc_range.second; ++row)
+ {
+ int ierr;
+ ierr = MatGetRow(*this, row, &ncols, &colnums, &values);
+ AssertThrow (ierr == 0, MatrixBase::ExcPETScError(ierr));
+
+ for (PetscInt col = 0; col < ncols; ++col)
+ {
+ out << "(" << row << "," << colnums[col] << ") " << values[col] << std::endl;
+ }
+
+ ierr = MatRestoreRow(*this, row, &ncols, &colnums, &values);
+ AssertThrow (ierr == 0, MatrixBase::ExcPETScError(ierr));
+ }
+
+ AssertThrow (out, ExcIO());
+ }
+
std::size_t
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2012 by the deal.II authors
+// Copyright (C) 2012 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/lac/petsc_matrix_free.h>
vmult (*y, *x);
// copy the result back to dst
- ierr = VecCopy (&(*(*y)), dst);
+ ierr = VecCopy (static_cast<const Vec &>(*y), dst);
AssertThrow (ierr == 0, ExcPETScError(ierr));
delete (x);
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2008, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/petsc_parallel_block_sparse_matrix.h>
}
}
+ void
+ BlockSparseMatrix::
+ reinit(const std::vector<IndexSet> &rows,
+ const std::vector<IndexSet> &cols,
+ const BlockCompressedSimpleSparsityPattern &bcsp,
+ const MPI_Comm &com)
+ {
+ Assert(rows.size() == bcsp.n_block_rows(), ExcMessage("invalid size"));
+ Assert(cols.size() == bcsp.n_block_cols(), ExcMessage("invalid size"));
+
+
+ clear();
+ this->sub_objects.reinit (bcsp.n_block_rows(),
+ bcsp.n_block_cols());
+
+ std::vector<types::global_dof_index> row_sizes;
+ for (unsigned int r=0; r<bcsp.n_block_rows(); ++r)
+ row_sizes.push_back( bcsp.block(r,0).n_rows() );
+ this->row_block_indices.reinit (row_sizes);
+
+ std::vector<types::global_dof_index> col_sizes;
+ for (unsigned int c=0; c<bcsp.n_block_cols(); ++c)
+ col_sizes.push_back( bcsp.block(0,c).n_cols() );
+ this->column_block_indices.reinit (col_sizes);
+
+ for (unsigned int r=0; r<this->n_block_rows(); ++r)
+ for (unsigned int c=0; c<this->n_block_cols(); ++c)
+ {
+ Assert(rows[r].size() == bcsp.block(r,c).n_rows(), ExcMessage("invalid size"));
+ Assert(cols[c].size() == bcsp.block(r,c).n_cols(), ExcMessage("invalid size"));
+
+ BlockType *p = new BlockType();
+ p->reinit(rows[r],
+ cols[c],
+ bcsp.block(r,c),
+ com);
+ this->sub_objects[r][c] = p;
+ }
+
+ collect_sizes();
+ }
+
+ void
+ BlockSparseMatrix::
+ reinit(const std::vector<IndexSet> &sizes,
+ const BlockCompressedSimpleSparsityPattern &bcsp,
+ const MPI_Comm &com)
+ {
+ reinit(sizes, sizes, bcsp, com);
+ }
+
void
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2008, 2012, 2013 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/petsc_parallel_block_vector.h>
this->components.resize(this->n_blocks());
for (unsigned int i=0; i<this->n_blocks(); ++i)
- components[i].reinit (MPI_Comm(), 0, 0);
+ components[i].reinit (MPI_COMM_SELF, 0, 0);
collect_sizes();
}
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/petsc_parallel_sparse_matrix.h>
}
+ SparseMatrix::~SparseMatrix ()
+ {
+#if DEAL_II_PETSC_VERSION_LT(3,2,0)
+ const int ierr = MatDestroy (matrix);
+#else
+ const int ierr = MatDestroy (&matrix);
+#endif
+ }
SparseMatrix::SparseMatrix (const MPI_Comm &communicator,
const size_type m,
return *this;
}
+ void
+ SparseMatrix::copy_from (const SparseMatrix &other)
+ {
+ if (&other == this)
+ return;
+
+ this->communicator = other.communicator;
+ int ierr = MatCopy(other.matrix, matrix, SAME_NONZERO_PATTERN);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+ }
void
SparseMatrix::reinit (const MPI_Comm &communicator,
preset_nonzero_locations);
}
+ template <typename SparsityType>
+ void
+ SparseMatrix::
+ reinit (const IndexSet &local_rows,
+ const IndexSet &local_columns,
+ const SparsityType &sparsity_pattern,
+ const MPI_Comm &communicator)
+ {
+ this->communicator = communicator;
+
+ // get rid of old matrix and generate a
+ // new one
+#if DEAL_II_PETSC_VERSION_LT(3,2,0)
+ const int ierr = MatDestroy (matrix);
+#else
+ const int ierr = MatDestroy (&matrix);
+#endif
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+ do_reinit (local_rows, local_columns, sparsity_pattern);
+ }
void
SparseMatrix::do_reinit (const size_type m,
}
+ template <typename SparsityType>
+ void
+ SparseMatrix::
+ do_reinit (const IndexSet &local_rows,
+ const IndexSet &local_columns,
+ const SparsityType &sparsity_pattern)
+ {
+ Assert(sparsity_pattern.n_rows()==local_rows.size(),
+ ExcMessage("SparsityPattern and IndexSet have different number of rows"));
+ Assert(sparsity_pattern.n_cols()==local_columns.size(),
+ ExcMessage("SparsityPattern and IndexSet have different number of columns"));
+ Assert(local_rows.is_contiguous() && local_columns.is_contiguous(),
+ ExcMessage("PETSc only supports contiguous row/column ranges"));
+
+
+
+
+ // create the matrix. We do not set row length but set the
+ // correct SparsityPattern later.
+ int ierr;
+
+ ierr = MatCreate(communicator,&matrix);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+ ierr = MatSetSizes(matrix,
+ local_rows.n_elements(),
+ local_columns.n_elements(),
+ sparsity_pattern.n_rows(),
+ sparsity_pattern.n_cols());
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+ ierr = MatSetType(matrix,MATMPIAIJ);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+
+ // next preset the exact given matrix
+ // entries with zeros. this doesn't avoid any
+ // memory allocations, but it at least
+ // avoids some searches later on. the
+ // key here is that we can use the
+ // matrix set routines that set an
+ // entire row at once, not a single
+ // entry at a time
+ //
+ // for the usefulness of this option
+ // read the documentation of this
+ // class.
+ //if (preset_nonzero_locations == true)
+ if (local_rows.n_elements()>0)
+ {
+ Assert(local_columns.n_elements()>0, ExcInternalError());
+ // MatMPIAIJSetPreallocationCSR
+ // can be used to allocate the sparsity
+ // pattern of a matrix
+
+ const PetscInt local_row_start = local_rows.nth_index_in_set(0);
+ const PetscInt
+ local_row_end = local_row_start + local_rows.n_elements();
+
+
+ // first set up the column number
+ // array for the rows to be stored
+ // on the local processor. have one
+ // dummy entry at the end to make
+ // sure petsc doesn't read past the
+ // end
+ std::vector<PetscInt>
+
+ rowstart_in_window (local_row_end - local_row_start + 1, 0),
+ colnums_in_window;
+ {
+ unsigned int n_cols = 0;
+ for (PetscInt i=local_row_start; i<local_row_end; ++i)
+ {
+ const PetscInt row_length = sparsity_pattern.row_length(i);
+ rowstart_in_window[i+1-local_row_start]
+ = rowstart_in_window[i-local_row_start] + row_length;
+ n_cols += row_length;
+ }
+ colnums_in_window.resize (n_cols+1, -1);
+ }
+
+ // now copy over the information
+ // from the sparsity pattern.
+ {
+ PetscInt *ptr = & colnums_in_window[0];
+
+ for (PetscInt i=local_row_start; i<local_row_end; ++i)
+ {
+ typename SparsityType::row_iterator
+ row_start = sparsity_pattern.row_begin(i),
+ row_end = sparsity_pattern.row_end(i);
+
+ std::copy(row_start, row_end, ptr);
+ ptr += row_end - row_start;
+ }
+ }
+
+
+ // then call the petsc function
+ // that summarily allocates these
+ // entries:
+ MatMPIAIJSetPreallocationCSR (matrix,
+ &rowstart_in_window[0],
+ &colnums_in_window[0],
+ 0);
+ }
+ else
+ {
+ PetscInt i=0;
+ MatMPIAIJSetPreallocationCSR (matrix,
+ &i,
+ &i,
+ 0);
+
+
+ }
+ compress (dealii::VectorOperation::insert);
+
+ {
+
+ // Tell PETSc that we are not
+ // planning on adding new entries
+ // to the matrix. Generate errors
+ // in debug mode.
+ int ierr;
+#if DEAL_II_PETSC_VERSION_LT(3,0,0)
+#ifdef DEBUG
+ ierr = MatSetOption (matrix, MAT_NEW_NONZERO_LOCATION_ERR);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+#else
+ ierr = MatSetOption (matrix, MAT_NO_NEW_NONZERO_LOCATIONS);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+#endif
+#else
+#ifdef DEBUG
+ ierr = MatSetOption (matrix, MAT_NEW_NONZERO_LOCATION_ERR, PETSC_TRUE);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+#else
+ ierr = MatSetOption (matrix, MAT_NEW_NONZERO_LOCATIONS, PETSC_FALSE);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+#endif
+#endif
+
+ // Tell PETSc to keep the
+ // SparsityPattern entries even if
+ // we delete a row with
+ // clear_rows() which calls
+ // MatZeroRows(). Otherwise one can
+ // not write into that row
+ // afterwards.
+#if DEAL_II_PETSC_VERSION_LT(3,0,0)
+ ierr = MatSetOption (matrix, MAT_KEEP_ZEROED_ROWS);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+#elif DEAL_II_PETSC_VERSION_LT(3,1,0)
+ ierr = MatSetOption (matrix, MAT_KEEP_ZEROED_ROWS, PETSC_TRUE);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+#else
+ ierr = MatSetOption (matrix, MAT_KEEP_NONZERO_PATTERN, PETSC_TRUE);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+#endif
+
+ }
+
+ }
+
template <typename SparsityType>
void
local_row_start += local_rows_per_process[p];
local_col_start += local_columns_per_process[p];
}
- const size_type
+ const size_type
local_row_end = local_row_start + local_rows_per_process[this_process];
#if DEAL_II_PETSC_VERSION_LT(2,3,3)
//at least starting from 2.3.3 (tested,
//see below)
- const size_type
+ const size_type
local_col_end = local_col_start + local_columns_per_process[this_process];
// then count the elements in- and
// now copy over the information
// from the sparsity pattern.
{
- PetscInt* ptr = & colnums_in_window[0];
+ PetscInt *ptr = & colnums_in_window[0];
for (size_type i=local_row_start; i<local_row_end; ++i)
{
const unsigned int,
const bool);
+ template void
+ SparseMatrix::
+ reinit (const IndexSet &,
+ const IndexSet &,
+ const CompressedSimpleSparsityPattern &,
+ const MPI_Comm &);
+
template void
SparseMatrix::do_reinit (const SparsityPattern &,
const std::vector<size_type> &,
const unsigned int ,
const bool);
+ template void
+ SparseMatrix::
+ do_reinit (const IndexSet &,
+ const IndexSet &,
+ const CompressedSimpleSparsityPattern &);
+
PetscScalar
SparseMatrix::matrix_norm_square (const Vector &v) const
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2006, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/petsc_parallel_vector.h>
const int ierr
= VecCreateSeq (PETSC_COMM_SELF, n, &vector);
AssertThrow (ierr == 0, ExcPETScError(ierr));
+ ghosted = false;
}
Vector::create_vector(local.size(), local.n_elements(), ghost_set);
}
+ Vector::Vector (const IndexSet &local,
+ const IndexSet &ghost,
+ const MPI_Comm &communicator)
+ :
+ communicator (communicator)
+ {
+ Assert(local.is_contiguous(), ExcNotImplemented());
+
+ IndexSet ghost_set = ghost;
+ ghost_set.subtract_set(local);
+
+ Vector::create_vector(local.size(), local.n_elements(), ghost_set);
+ }
+
+
+ Vector::Vector (const IndexSet &local,
+ const MPI_Comm &communicator)
+ :
+ communicator (communicator)
+ {
+ Assert(local.is_contiguous(), ExcNotImplemented());
+ Vector::create_vector(local.size(), local.n_elements());
+ }
+
+
Vector::Vector (const MPI_Comm &communicator,
- const IndexSet &local)
- :
- communicator (communicator)
+ const IndexSet &local)
+ :
+ communicator (communicator)
{
Assert(local.is_contiguous(), ExcNotImplemented());
Vector::create_vector(local.size(), local.n_elements());
MPI_Allreduce (&k, &k_global, 1,
MPI_INT, MPI_LOR, communicator);
- if (k_global)
+ if (k_global || has_ghost_elements())
{
// FIXME: I'd like to use this here,
// but somehow it leads to odd errors
Vector::reinit (const Vector &v,
const bool fast)
{
- communicator = v.communicator;
-
- reinit (communicator, v.size(), v.local_size(), fast);
+ if (v.has_ghost_elements())
+ {
+ reinit (v.locally_owned_elements(), v.ghost_indices, v.communicator);
+ if (!fast)
+ {
+ int ierr = VecSet(vector, 0.0);
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+ }
+ }
+ else
+ reinit (v.communicator, v.size(), v.local_size(), fast);
}
const IndexSet &local,
const IndexSet &ghost)
{
+ reinit(local, ghost, comm);
+ }
+
+ void
+ Vector::reinit (const IndexSet &local,
+ const IndexSet &ghost,
+ const MPI_Comm &comm)
+ {
+ int ierr;
+#if DEAL_II_PETSC_VERSION_LT(3,2,0)
+ ierr = VecDestroy (vector);
+#else
+ ierr = VecDestroy (&vector);
+#endif
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+
communicator = comm;
Assert(local.is_contiguous(), ExcNotImplemented());
void
Vector::reinit (const MPI_Comm &comm,
- const IndexSet &local)
+ const IndexSet &local)
+ {
+ reinit(local, comm);
+ }
+
+ void
+ Vector::reinit (const IndexSet &local,
+ const MPI_Comm &comm)
{
+ int ierr;
+#if DEAL_II_PETSC_VERSION_LT(3,2,0)
+ ierr = VecDestroy (vector);
+#else
+ ierr = VecDestroy (&vector);
+#endif
+ AssertThrow (ierr == 0, ExcPETScError(ierr));
+
communicator = comm;
Assert(local.is_contiguous(), ExcNotImplemented());
+ Assert(local.size()>0, ExcMessage("can not create vector of size 0."));
create_vector(local.size(), local.n_elements());
}
Vector::operator = (const PETScWrappers::Vector &v)
{
Assert(last_action==VectorOperation::unknown,
- ExcMessage("Call to compress() required before calling operator=."));
+ ExcMessage("Call to compress() required before calling operator=."));
//TODO [TH]: can not access v.last_action here. Implement is_compressed()?
//Assert(v.last_action==VectorOperation::unknown,
// ExcMessage("Call to compress() required before calling operator=."));
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2006, 2008, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/petsc_precondition.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2006, 2008, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/logstream.h>
#include <deal.II/lac/petsc_solver.h>
}
PetscErrorCode SparseDirectMUMPS::convergence_test (KSP /*ksp*/,
- const PetscInt iteration,
- const PetscReal residual_norm,
- KSPConvergedReason *reason,
- void *solver_control_x)
+ const PetscInt iteration,
+ const PetscReal residual_norm,
+ KSPConvergedReason *reason,
+ void *solver_control_x)
{
SolverControl &solver_control = *reinterpret_cast<SolverControl *>(solver_control_x);
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2008, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/petsc_sparse_matrix.h>
// convert, unless we want to play dirty
// tricks with conversions of pointers
const std::vector<PetscInt>
- int_row_lengths (row_lengths.begin(), row_lengths.end());
+ int_row_lengths (row_lengths.begin(), row_lengths.end());
const int ierr
= MatCreateSeqAIJ(PETSC_COMM_SELF, m, n, 0,
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2006, 2008, 2012 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/petsc_vector.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2004 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/petsc_vector_base.h>
attained_ownership(true)
{
Assert( multithread_info.is_running_single_threaded(),
- ExcMessage("PETSc does not support multi-threaded access, set "
- "the thread limit to 1 in MPI_InitFinalize()."));
+ ExcMessage("PETSc does not support multi-threaded access, set "
+ "the thread limit to 1 in MPI_InitFinalize()."));
}
attained_ownership(true)
{
Assert( multithread_info.is_running_single_threaded(),
- ExcMessage("PETSc does not support multi-threaded access, set "
- "the thread limit to 1 in MPI_InitFinalize()."));
+ ExcMessage("PETSc does not support multi-threaded access, set "
+ "the thread limit to 1 in MPI_InitFinalize()."));
int ierr = VecDuplicate (v.vector, &vector);
AssertThrow (ierr == 0, ExcPETScError(ierr));
attained_ownership(false)
{
Assert( multithread_info.is_running_single_threaded(),
- ExcMessage("PETSc does not support multi-threaded access, set "
- "the thread limit to 1 in MPI_InitFinalize()."));
+ ExcMessage("PETSc does not support multi-threaded access, set "
+ "the thread limit to 1 in MPI_InitFinalize()."));
}
- VectorBase::size_type
+ VectorBase::size_type
VectorBase::size () const
{
PetscInt sz;
- VectorBase::size_type
+ VectorBase::size_type
VectorBase::local_size () const
{
PetscInt sz;
return mean;
#else // PETSC_USE_COMPLEX
- Assert ((false),
- ExcMessage ("Your PETSc/SLEPc installation was configured with scalar-type complex "
- "but this function is not defined for complex types."));
+ Assert ((false),
+ ExcMessage ("Your PETSc/SLEPc installation was configured with scalar-type complex "
+ "but this function is not defined for complex types."));
- // Prevent compiler warning about no return value
- PetscScalar dummy;
- return dummy;
+ // Prevent compiler warning about no return value
+ PetscScalar dummy;
+ return dummy;
#endif
}
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/precondition_block.templates.h>
#include <deal.II/lac/sparse_matrix.h>
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2009, 2010 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (S : REAL_SCALARS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/precondition_block.templates.h>
#include <deal.II/lac/sparse_matrix_ez.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/relaxation_block.templates.h>
#include <deal.II/lac/sparse_matrix.h>
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2009, 2010, 2011 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (S1, S2 : REAL_SCALARS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
-// Author: Toby D. Young, Polish Academy of Sciences, 2008-2013
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009-2013 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/slepc_solver.h>
:
solver_control (cn),
mpi_communicator (mpi_communicator),
- target_eigenvalue (PETSC_NULL),
+ target_eigenvalue (0.),
set_which (EPS_LARGEST_MAGNITUDE),
set_problem (EPS_NHEP),
opA (NULL),
}
void
- SolverBase::solve (const size_type n_eigenpairs,
- size_type *n_converged)
+ SolverBase::solve (const unsigned int n_eigenpairs,
+ unsigned int *n_converged)
{
int ierr;
AssertThrow (ierr == 0, ExcSLEPcError(ierr));
}
- // set transformation type if any
+ // if a spectral transformation is to be used, set the
+ // transformation and target the wanted eigenvalues
if (transformation)
- transformation->set_context (solver_data->eps);
+ {
+ // set transformation type if any
+ transformation->set_context (solver_data->eps);
+
+ // set target eigenvalues to solve for
+ ierr = EPSSetTarget (solver_data->eps, target_eigenvalue);
+ AssertThrow (ierr == 0, ExcSLEPcError(ierr));
+ }
- // set target eigenvalues to solve for
- ierr = EPSSetTarget (solver_data->eps, target_eigenvalue);
- AssertThrow (ierr == 0, ExcSLEPcError(ierr));
-
// set which portion of the eigenspectrum to solve for
ierr = EPSSetWhichEigenpairs (solver_data->eps, set_which);
AssertThrow (ierr == 0, ExcSLEPcError(ierr));
// get number of converged eigenstates
ierr = EPSGetConverged (solver_data->eps,
- reinterpret_cast<PetscInt *>(n_converged));
+ reinterpret_cast<PetscInt*>(n_converged));
AssertThrow (ierr == 0, ExcSLEPcError(ierr));
- PetscInt n_iterations = 0;
- double residual_norm = 1e300;
+ PetscInt n_iterations = 0;
+ PetscReal residual_norm = 1.e300;
// @todo Investigate elaborating on some of this to act on the
// complete eigenspectrum
ierr = EPSGetIterationNumber (solver_data->eps, &n_iterations);
AssertThrow (ierr == 0, ExcSLEPcError(ierr));
- // get the residual norm of the most extreme eigenvalue
- ierr = EPSComputeResidualNorm (solver_data->eps, 0, &residual_norm);
- AssertThrow (ierr == 0, ExcSLEPcError(ierr));
+ // get the residual norm of the most extreme eigenvalue if and
+ // only if at least one eigenvector has converged.
+ if ((*n_converged)>0)
+ {
+ ierr = EPSComputeResidualNorm (solver_data->eps, 0, &residual_norm);
+ AssertThrow (ierr == 0, ExcSLEPcError(ierr));
+ }
// check the solver state
const SolverControl::State state
}
void
- SolverBase::get_eigenpair (const size_type index,
+ SolverBase::get_eigenpair (const unsigned int index,
PetscScalar &eigenvalues,
PETScWrappers::VectorBase &eigenvectors)
{
// get converged eigenpair
int ierr = EPSGetEigenpair (solver_data->eps, index,
- &eigenvalues, PETSC_NULL,
- eigenvectors, PETSC_NULL);
+ &eigenvalues, PETSC_NULL,
+ eigenvectors, PETSC_NULL);
AssertThrow (ierr == 0, ExcSLEPcError(ierr));
}
{
#ifndef PETSC_USE_COMPLEX
AssertThrow (solver_data.get() != 0, ExcSLEPcWrappersUsageError());
-
+
// get converged eigenpair
int ierr = EPSGetEigenpair (solver_data->eps, index,
- &real_eigenvalues, &imag_eigenvalues,
- real_eigenvectors, imag_eigenvectors);
+ &real_eigenvalues, &imag_eigenvalues,
+ real_eigenvectors, imag_eigenvectors);
AssertThrow (ierr == 0, ExcSLEPcError(ierr));
#else
Assert ((false),
this->solver_control.max_steps());
AssertThrow (ierr == 0, ExcSLEPcError(ierr));
#else
- // Supress compiler warnings about unused paameters.
+ // Suppress compiler warnings about unused parameters.
(void) eps;
// PETSc/SLEPc version must be > 3.1.0.
this->solver_control.max_steps());
AssertThrow (ierr == 0, ExcSLEPcError(ierr));
#else
- // Supress compiler warnings about unused paameters.
+ // Suppress compiler warnings about unused parameters.
(void) eps;
// PETSc/SLEPc version must be > 3.1.0.
/* ---------------------- LAPACK ------------------------- */
SolverLAPACK::SolverLAPACK (SolverControl &cn,
- const MPI_Comm &mpi_communicator,
- const AdditionalData &data)
+ const MPI_Comm &mpi_communicator,
+ const AdditionalData &data)
:
SolverBase (cn, mpi_communicator),
additional_data (data)
this->solver_control.max_steps());
AssertThrow (ierr == 0, ExcSLEPcError(ierr));
#else
- // Supress compiler warnings about unused paameters.
+ // Suppress compiler warnings about unused parameters.
(void) eps;
Assert ((false),
DEAL_II_NAMESPACE_CLOSE
-#else
-
-// On gcc2.95 on Alpha OSF1, the native assembler does not like empty
-// files, so provide some dummy code
-namespace
-{
- void dummy () {}
-}
#endif // DEAL_II_WITH_SLEPC
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
-// Author: Toby D. Young, Polish Academy of Sciences, 2009
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2012 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/slepc_spectral_transformation.h>
DEAL_II_NAMESPACE_CLOSE
-#else
-// On gcc2.95 on Alpha OSF1, the native assembler does not like empty
-// files, so provide some dummy code
-namespace
-{
- void dummy () {}
-}
#endif // DEAL_II_WITH_SLEPC
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/lac/solver.h>
#include <deal.II/lac/vector_memory.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2013 by the deal.II authors
+// Copyright (C) 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (S : SERIAL_VECTORS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2010, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/logstream.h>
#include <deal.II/base/parameter_handler.h>
-//---------------------------------------------------------------------------
-// Copyright (C) 2002, 2003, 2005, 2006, 2012 by the deal.II authors
-// by the deal.II authors and Stephen "Cheffo" Kolaroff
+// ---------------------------------------------------------------------
+// $Id$
//
-// 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.
+// Copyright (C) 2002 - 2013 by the deal.II authors
//
-//---------------------------------------------------------------------------
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/lac/sparse_decomposition.templates.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2001 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/sparse_direct.h>
#include <deal.II/base/memory_consumption.h>
for (size_type row = 0; row < matrix.m(); ++row)
{
for (typename Matrix::const_iterator p=matrix.begin(row);
- p!=matrix.end(row); ++p)
+ p!=matrix.end(row); ++p)
{
// write entry into the first free one for this row
Ai[row_pointers[row]] = p->column();
void
-SparseDirectUMFPACK::solve (Vector<double> &rhs_and_solution) const
+SparseDirectUMFPACK::solve (Vector<double> &rhs_and_solution,
+ bool transpose /*=false*/) const
{
// make sure that some kind of factorize() call has happened before
Assert (Ap.size() != 0, ExcNotInitialized());
// solve the system. note that since UMFPACK wants compressed column
// storage instead of the compressed row storage format we use in
// deal.II's SparsityPattern classes, we solve for UMFPACK's A^T instead
+
+ // Conversely, if we solve for the transpose, we have to use UMFPACK_A
+ // instead.
const int status
- = umfpack_dl_solve (UMFPACK_At,
+ = umfpack_dl_solve (transpose ? UMFPACK_A : UMFPACK_At,
&Ap[0], &Ai[0], &Ax[0],
rhs_and_solution.begin(), rhs.begin(),
numeric_decomposition,
void
-SparseDirectUMFPACK::solve (BlockVector<double> &rhs_and_solution) const
+SparseDirectUMFPACK::solve (BlockVector<double> &rhs_and_solution,
+ bool transpose /*=false*/) const
{
// the UMFPACK functions want a contiguous array of elements, so
// there is no way around copying data around. thus, just copy the
// data into a regular vector and back
Vector<double> tmp (rhs_and_solution.size());
tmp = rhs_and_solution;
- solve (tmp);
+ solve (tmp, transpose);
rhs_and_solution = tmp;
}
template <class Matrix>
void
SparseDirectUMFPACK::solve (const Matrix &matrix,
- Vector<double> &rhs_and_solution)
+ Vector<double> &rhs_and_solution,
+ bool transpose /*=false*/)
{
factorize (matrix);
- solve (rhs_and_solution);
+ solve (rhs_and_solution, transpose);
}
template <class Matrix>
void
-SparseDirectUMFPACK::solve (const Matrix &matrix,
- BlockVector<double> &rhs_and_solution)
+SparseDirectUMFPACK::solve (const Matrix &matrix,
+ BlockVector<double> &rhs_and_solution,
+ bool transpose /*=false*/)
{
factorize (matrix);
- solve (rhs_and_solution);
+ solve (rhs_and_solution, transpose);
}
void
-SparseDirectUMFPACK::solve (Vector<double> &) const
+SparseDirectUMFPACK::solve (Vector<double> &, bool) const
{
AssertThrow(false, ExcMessage("To call this function you need UMFPACK, but configured deal.II without passing the necessary switch to 'cmake'. Please consult the installation instructions in doc/readme.html."));
}
void
-SparseDirectUMFPACK::solve (BlockVector<double> &) const
+SparseDirectUMFPACK::solve (BlockVector<double> &, bool) const
{
AssertThrow(false, ExcMessage("To call this function you need UMFPACK, but configured deal.II without passing the necessary switch to 'cmake'. Please consult the installation instructions in doc/readme.html."));
}
template <class Matrix>
void
SparseDirectUMFPACK::solve (const Matrix &,
- Vector<double> &)
+ Vector<double> &,
+ bool)
{
AssertThrow(false, ExcMessage("To call this function you need UMFPACK, but configured deal.II without passing the necessary switch to 'cmake'. Please consult the installation instructions in doc/readme.html."));
}
template <class Matrix>
void
SparseDirectUMFPACK::solve (const Matrix &,
- BlockVector<double> &)
+ BlockVector<double> &,
+ bool)
{
AssertThrow(false, ExcMessage("To call this function you need UMFPACK, but configured deal.II without passing the necessary switch to 'cmake'. Please consult the installation instructions in doc/readme.html."));
}
void
SparseDirectUMFPACK::Tvmult (
- Vector<double> &,
- const Vector<double> &) const
+ Vector<double> &dst,
+ const Vector<double> &src) const
{
- Assert(false, ExcNotImplemented());
+ dst = src;
+ this->solve(dst, /*transpose=*/ true);
+}
+
+
+
+void
+SparseDirectUMFPACK::Tvmult (
+ BlockVector<double> &dst,
+ const BlockVector<double> &src) const
+{
+ dst = src;
+ this->solve(dst, /*transpose=*/ true);
}
+
#ifdef DEAL_II_WITH_MUMPS
SparseDirectMUMPS::SparseDirectMUMPS ()
for (size_type row = 0; row < matrix.m(); ++row)
{
for (typename Matrix::const_iterator ptr = matrix.begin (row);
- ptr != matrix.end (row); ++ptr)
+ ptr != matrix.end (row); ++ptr)
if (std::abs (ptr->value ()) > 0.0)
{
a[index] = ptr->value ();
// explicit instantiations for SparseMatrixUMFPACK
-#define InstantiateUMFPACK(MATRIX) \
- template \
- void SparseDirectUMFPACK::factorize (const MATRIX &); \
- template \
- void SparseDirectUMFPACK::solve (const MATRIX &, \
- Vector<double> &); \
- template \
- void SparseDirectUMFPACK::solve (const MATRIX &, \
- BlockVector<double> &); \
- template \
- void SparseDirectUMFPACK::initialize (const MATRIX &, \
+#define InstantiateUMFPACK(MATRIX) \
+ template \
+ void SparseDirectUMFPACK::factorize (const MATRIX &); \
+ template \
+ void SparseDirectUMFPACK::solve (const MATRIX &, \
+ Vector<double> &, \
+ bool); \
+ template \
+ void SparseDirectUMFPACK::solve (const MATRIX &, \
+ BlockVector<double> &, \
+ bool); \
+ template \
+ void SparseDirectUMFPACK::initialize (const MATRIX &, \
const AdditionalData);
InstantiateUMFPACK(SparseMatrix<double>)
// explicit instantiations for SparseDirectMUMPS
#ifdef DEAL_II_WITH_MUMPS
-#define InstantiateMUMPS(MATRIX) \
- template \
+#define InstantiateMUMPS(MATRIX) \
+ template \
void SparseDirectMUMPS::initialize (const MATRIX &, const Vector<double> &);
InstantiateMUMPS(SparseMatrix<double>)
-//---------------------------------------------------------------------------
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2012 by the deal.II authors
+// ---------------------------------------------------------------------
+// $Id$
//
-// 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.
+// Copyright (C) 1999 - 2013 by the deal.II authors
//
-//---------------------------------------------------------------------------
-
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/sparse_ilu.templates.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/sparse_matrix.templates.h>
#include <deal.II/lac/block_vector.h>
-//---------------------------- sparse_matrix.inst.in ---------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2006, 2007, 2009, 2011 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------- sparse_matrix.inst.in ---------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
// real instantiations
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2007, 2012 by the deal.II authors
+// Copyright (C) 2007 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/sparse_matrix_ez.templates.h>
#include <deal.II/lac/block_vector.h>
-//---------------------------- sparse_matrix_ez.inst.in ---------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2002, 2003, 2006, 2007 by the deal.II authors
+// Copyright (C) 2002 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------- sparse_matrix_ez.inst.in ---------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (S : REAL_SCALARS)
-//---------------------------------------------------------------------------
-// Copyright (C) 2002, 2003, 2005, 2006, 2012 by the deal.II authors
-// by the deal.II authors and Stephen "Cheffo" Kolaroff
+// ---------------------------------------------------------------------
+// $Id$
//
-// 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.
+// Copyright (C) 2002 - 2013 by the deal.II authors
//
-//---------------------------------------------------------------------------
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/lac/sparse_mic.templates.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/sparse_vanka.templates.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/vector_slice.h>
#include <deal.II/base/utilities.h>
std::size_t vec_len = 0;
for (size_type i=0; i<m; ++i)
vec_len += std::min(static_cast<size_type>(store_diagonal_first_in_row ?
- std::max(row_lengths[i], 1U) :
- row_lengths[i]),
+ std::max(row_lengths[i], 1U) :
+ row_lengths[i]),
n);
// sometimes, no entries are
max_row_length = (row_lengths.size() == 0 ?
0 :
std::min (static_cast<size_type>(*std::max_element(row_lengths.begin(),
- row_lengths.end())),
+ row_lengths.end())),
n));
if (store_diagonal_first_in_row && (max_row_length==0) && (m!=0))
rowstart[i] = rowstart[i-1] +
(store_diagonal_first_in_row ?
std::max(std::min(static_cast<size_type>(row_lengths[i-1]),n),
- static_cast<size_type> (1U)) :
+ static_cast<size_type> (1U)) :
std::min(static_cast<size_type>(row_lengths[i-1]),n));
Assert ((rowstart[rows]==vec_len)
||
-SparsityPattern::size_type
+SparsityPattern::size_type
SparsityPattern::max_entries_per_row () const
{
// if compress() has not yet been
-SparsityPattern::size_type
+SparsityPattern::size_type
SparsityPattern::operator () (const size_type i,
const size_type j) const
{
&colnums[rowstart[i]]);
const size_type *const p
= Utilities::lower_bound<const size_type *> (sorted_region_start,
- &colnums[rowstart[i+1]],
- j);
+ &colnums[rowstart[i+1]],
+ j);
if ((p != &colnums[rowstart[i+1]]) && (*p == j))
return (p - &colnums[0]);
else
-SparsityPattern::size_type
+SparsityPattern::size_type
SparsityPattern::row_position (const size_type i, const size_type j) const
{
Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject());
-SparsityPattern::size_type
+SparsityPattern::size_type
SparsityPattern::bandwidth () const
{
Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject());
template void SparsityPattern::copy_from<float> (const FullMatrix<float> &, bool);
template void SparsityPattern::copy_from<double> (const FullMatrix<double> &, bool);
+template void SparsityPattern::copy_from<SparsityPattern> (const SparsityPattern &);
template void SparsityPattern::copy_from<CompressedSparsityPattern> (const CompressedSparsityPattern &);
template void SparsityPattern::copy_from<CompressedSetSparsityPattern> (const CompressedSetSparsityPattern &);
template void SparsityPattern::copy_from<CompressedSimpleSparsityPattern> (const CompressedSimpleSparsityPattern &);
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/exceptions.h>
#include <deal.II/lac/exceptions.h>
MPI_Waitall(requests.size(), &requests[0], MPI_STATUSES_IGNORE);
}
+
+template <class CSP_t>
+void distribute_sparsity_pattern(CSP_t &csp,
+ const std::vector<IndexSet> &owned_set_per_cpu,
+ const MPI_Comm &mpi_comm,
+ const IndexSet &myrange)
+{
+ size_type myid = Utilities::MPI::this_mpi_process(mpi_comm);
+
+ typedef std::map<size_type, std::vector<size_type> > map_vec_t;
+ map_vec_t send_data;
+
+ {
+ unsigned int dest_cpu=0;
+
+ size_type n_local_rel_rows = myrange.n_elements();
+ for (size_type row_idx=0; row_idx<n_local_rel_rows; ++row_idx)
+ {
+ size_type row=myrange.nth_index_in_set(row_idx);
+
+ // calculate destination CPU, note that we start the search
+ // at last destination cpu, because even if the owned ranges
+ // are not contiguous, they hopefully consist of large blocks
+ while (!owned_set_per_cpu[dest_cpu].is_element(row))
+ {
+ ++dest_cpu;
+ if (dest_cpu==owned_set_per_cpu.size()) // wrap around
+ dest_cpu=0;
+ }
+
+ //skip myself
+ if (dest_cpu==myid)
+ continue;
+
+ size_type rlen = csp.row_length(row);
+
+ //skip empty lines
+ if (!rlen)
+ continue;
+
+ //save entries
+ std::vector<size_type> &dst = send_data[dest_cpu];
+
+ dst.push_back(rlen); // number of entries
+ dst.push_back(row); // row index
+ for (size_type c=0; c<rlen; ++c)
+ {
+ //columns
+ size_type column = csp.column_number(row, c);
+ dst.push_back(column);
+ }
+ }
+
+ }
+
+ unsigned int num_receive=0;
+ {
+ std::vector<unsigned int> send_to;
+ send_to.reserve(send_data.size());
+ for (map_vec_t::iterator it=send_data.begin(); it!=send_data.end(); ++it)
+ send_to.push_back(it->first);
+
+ num_receive =
+ Utilities::MPI::
+ compute_point_to_point_communication_pattern(mpi_comm, send_to).size();
+ }
+
+ std::vector<MPI_Request> requests(send_data.size());
+
+
+ // send data
+ {
+ unsigned int idx=0;
+ for (map_vec_t::iterator it=send_data.begin(); it!=send_data.end(); ++it, ++idx)
+ MPI_Isend(&(it->second[0]),
+ it->second.size(),
+ DEAL_II_DOF_INDEX_MPI_TYPE,
+ it->first,
+ 124,
+ mpi_comm,
+ &requests[idx]);
+ }
+
+//TODO: In the following, we read individual bytes and then reinterpret them
+// as size_type objects. this is error prone. use properly typed reads that
+// match the write above
+ {
+ //receive
+ std::vector<size_type> recv_buf;
+ for (unsigned int index=0; index<num_receive; ++index)
+ {
+ MPI_Status status;
+ int len;
+ MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, mpi_comm, &status);
+ Assert (status.MPI_TAG==124, ExcInternalError());
+
+ MPI_Get_count(&status, MPI_BYTE, &len);
+ Assert( len%sizeof(unsigned int)==0, ExcInternalError());
+
+ recv_buf.resize(len/sizeof(size_type));
+
+ MPI_Recv(&recv_buf[0], len, MPI_BYTE, status.MPI_SOURCE,
+ status.MPI_TAG, mpi_comm, &status);
+
+ std::vector<size_type>::const_iterator ptr = recv_buf.begin();
+ std::vector<size_type>::const_iterator end = recv_buf.end();
+ while (ptr+1<end)
+ {
+ size_type num=*(ptr++);
+ size_type row=*(ptr++);
+ for (unsigned int c=0; c<num; ++c)
+ {
+ csp.add(row, *ptr);
+ ptr++;
+ }
+ }
+ Assert(ptr==end, ExcInternalError());
+ }
+ }
+
+ // complete all sends, so that we can
+ // safely destroy the buffers.
+ MPI_Waitall(requests.size(), &requests[0], MPI_STATUSES_IGNORE);
+}
+
+
#endif
}
#ifdef DEAL_II_WITH_MPI
SPARSITY_FUNCTIONS(CompressedSparsityPattern);
SPARSITY_FUNCTIONS(CompressedSimpleSparsityPattern);
-SPARSITY_FUNCTIONS(BlockCompressedSimpleSparsityPattern);
+
+template void SparsityTools::distribute_sparsity_pattern
+<BlockCompressedSimpleSparsityPattern>
+(BlockCompressedSimpleSparsityPattern &csp,
+ const std::vector<IndexSet> &owned_set_per_cpu,
+ const MPI_Comm &mpi_comm,
+ const IndexSet &myrange);
+
#endif
#undef SPARSITY_FUNCTIONS
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/swappable_vector.templates.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2005, 2006, 2012 by the deal.II authors
+// Copyright (C) 2005 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/lac/tridiagonal_matrix.h>
#include <deal.II/lac/vector.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2009, 2012 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/trilinos_block_sparse_matrix.h>
BlockSparseMatrix::reinit (const std::vector<Epetra_Map> &,
const dealii::BlockCompressedSimpleSparsityPattern &);
+ template void
+ BlockSparseMatrix::reinit (const std::vector<IndexSet> &,
+ const dealii::BlockCompressedSimpleSparsityPattern &,
+ const MPI_Comm &);
+
}
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2009, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/trilinos_block_vector.h>
BlockVector &
BlockVector::operator = (const BlockVector &v)
{
+ // we only allow assignment to vectors with the same number of blocks
+ // or to an empty BlockVector
+ Assert (n_blocks() == 0 || n_blocks() == v.n_blocks(),
+ ExcDimensionMismatch(n_blocks(), v.n_blocks()));
+
if (this->n_blocks() != v.n_blocks())
reinit(v.n_blocks());
collect_sizes();
}
+ void
+ BlockVector::reinit (const std::vector<IndexSet> ¶llel_partitioning,
+ const std::vector<IndexSet> &ghost_values,
+ const MPI_Comm &communicator)
+ {
+ const size_type no_blocks = parallel_partitioning.size();
+ std::vector<size_type> block_sizes (no_blocks);
+
+ for (size_type i=0; i<no_blocks; ++i)
+ {
+ block_sizes[i] = parallel_partitioning[i].size();
+ }
+
+ this->block_indices.reinit (block_sizes);
+ if (components.size() != n_blocks())
+ components.resize(n_blocks());
+
+ for (size_type i=0; i<n_blocks(); ++i)
+ components[i].reinit(parallel_partitioning[i], ghost_values[i], communicator);
+
+ collect_sizes();
+ }
void
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/trilinos_precondition.h>
for (size_type d=0; d<constant_modes_dimension; ++d)
for (size_type row=0; row<my_size; ++row)
{
- TrilinosWrappers::types::int_type global_row_id =
+ TrilinosWrappers::types::int_type global_row_id =
constant_modes_are_global ? gid(domain_map,row) : row;
distributed_constant_modes[d][row] =
additional_data.constant_modes[d][global_row_id];
// equidistributed map; avoid
// storing the nonzero
// elements.
- vector_distributor.reset (new Epetra_Map(static_cast<TrilinosWrappers::types::int_type>(n_rows),
- 0, communicator));
+ vector_distributor.reset (new Epetra_Map(static_cast<TrilinosWrappers::types::int_type>(n_rows),
+ 0, communicator));
if (trilinos_matrix.get() == 0)
trilinos_matrix.reset (new SparseMatrix());
const AdditionalData &, const double,
const ::dealii::SparsityPattern *);
+
+
+
+ /* -------------------------- PreconditionAMG -------------------------- */
+
+ void
+ PreconditionIdentity::vmult(VectorBase &dst,
+ const VectorBase &src) const
+ {
+ dst = src;
+ }
+
+ void
+ PreconditionIdentity::Tvmult(VectorBase &dst,
+ const VectorBase &src) const
+ {
+ dst = src;
+ }
+
+ void
+ PreconditionIdentity::vmult(dealii::Vector<double> &dst,
+ const dealii::Vector<double> &src) const
+ {
+ dst = src;
+ }
+
+ void
+ PreconditionIdentity::Tvmult(dealii::Vector<double> &dst,
+ const dealii::Vector<double> &src) const
+ {
+ dst = src;
+ }
+
+ void
+ PreconditionIdentity::vmult(parallel::distributed::Vector<double> &dst,
+ const parallel::distributed::Vector<double> &src) const
+ {
+ dst = src;
+ }
+
+ void
+ PreconditionIdentity::Tvmult(parallel::distributed::Vector<double> &dst,
+ const parallel::distributed::Vector<double> &src) const
+ {
+ dst = src;
+ }
}
DEAL_II_NAMESPACE_CLOSE
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2010, 2012 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/trilinos_solver.h>
const VectorBase &b,
const PreconditionBase &preconditioner)
{
- int ierr;
-
linear_problem.reset();
// We need an
&x.trilinos_vector(),
const_cast<Epetra_MultiVector *>(&b.trilinos_vector())));
- // Next we can allocate the
- // AztecOO solver...
- solver.SetProblem(*linear_problem);
-
- // ... and we can specify the
- // solver to be used.
- switch (solver_name)
- {
- case cg:
- solver.SetAztecOption(AZ_solver, AZ_cg);
- break;
- case cgs:
- solver.SetAztecOption(AZ_solver, AZ_cgs);
- break;
- case gmres:
- solver.SetAztecOption(AZ_solver, AZ_gmres);
- solver.SetAztecOption(AZ_kspace, additional_data.gmres_restart_parameter);
- break;
- case bicgstab:
- solver.SetAztecOption(AZ_solver, AZ_bicgstab);
- break;
- case tfqmr:
- solver.SetAztecOption(AZ_solver, AZ_tfqmr);
- break;
- default:
- Assert (false, ExcNotImplemented());
- }
+ execute_solve(preconditioner);
+ }
- // Introduce the
- // preconditioner, ...
- ierr = solver.SetPrecOperator (const_cast<Epetra_Operator *>
- (preconditioner.preconditioner.get()));
- AssertThrow (ierr == 0, ExcTrilinosError(ierr));
- // ... set some options, ...
- solver.SetAztecOption (AZ_output, additional_data.output_solver_details ?
- AZ_all : AZ_none);
- solver.SetAztecOption (AZ_conv, AZ_noscaled);
- // ... and then solve!
- ierr = solver.Iterate (solver_control.max_steps(),
- solver_control.tolerance());
-
- // report errors in more detail
- // than just by checking whether
- // the return status is zero or
- // greater. the error strings are
- // taken from the implementation
- // of the AztecOO::Iterate
- // function
- switch (ierr)
- {
- case -1:
- AssertThrow (false, ExcMessage("AztecOO::Iterate error code -1: "
- "option not implemented"));
- case -2:
- AssertThrow (false, ExcMessage("AztecOO::Iterate error code -2: "
- "numerical breakdown"));
- case -3:
- AssertThrow (false, ExcMessage("AztecOO::Iterate error code -3: "
- "loss of precision"));
- case -4:
- AssertThrow (false, ExcMessage("AztecOO::Iterate error code -4: "
- "GMRES hessenberg ill-conditioned"));
- default:
- AssertThrow (ierr >= 0, ExcTrilinosError(ierr));
- }
+ void
+ SolverBase::solve (Epetra_Operator &A,
+ VectorBase &x,
+ const VectorBase &b,
+ const PreconditionBase &preconditioner)
+ {
+ linear_problem.reset();
- // Finally, let the deal.II
- // SolverControl object know
- // what has happened. If the
- // solve succeeded, the status
- // of the solver control will
- // turn into
- // SolverControl::success.
- solver_control.check (solver.NumIters(), solver.TrueResidual());
+ // We need an
+ // Epetra_LinearProblem object
+ // to let the AztecOO solver
+ // know about the matrix and
+ // vectors.
+ linear_problem.reset
+ (new Epetra_LinearProblem(&A,
+ &x.trilinos_vector(),
+ const_cast<Epetra_MultiVector *>(&b.trilinos_vector())));
- if (solver_control.last_check() != SolverControl::success)
- throw SolverControl::NoConvergence (solver_control.last_step(),
- solver_control.last_value());
+ execute_solve(preconditioner);
}
const dealii::Vector<double> &b,
const PreconditionBase &preconditioner)
{
- int ierr;
-
linear_problem.reset();
// In case we call the solver with
(const_cast<Epetra_CrsMatrix *>(&A.trilinos_matrix()),
&ep_x, &ep_b));
+ execute_solve(preconditioner);
+ }
+
+
+
+ void
+ SolverBase::solve (Epetra_Operator &A,
+ dealii::Vector<double> &x,
+ const dealii::Vector<double> &b,
+ const PreconditionBase &preconditioner)
+ {
+ linear_problem.reset();
+
+ Epetra_Vector ep_x (View, A.OperatorDomainMap(), x.begin());
+ Epetra_Vector ep_b (View, A.OperatorRangeMap(), const_cast<double *>(b.begin()));
+
+ // We need an
+ // Epetra_LinearProblem object
+ // to let the AztecOO solver
+ // know about the matrix and
+ // vectors.
+ linear_problem.reset (new Epetra_LinearProblem(&A,&ep_x, &ep_b));
+
+ execute_solve(preconditioner);
+ }
+
+
+
+ void
+ SolverBase::execute_solve(const PreconditionBase &preconditioner)
+ {
+ int ierr;
+
// Next we can allocate the
// AztecOO solver...
solver.SetProblem(*linear_problem);
Assert (false, ExcNotImplemented());
}
- // Introduce the
- // preconditioner, ...
- ierr = solver.SetPrecOperator (const_cast<Epetra_Operator *>
- (preconditioner.preconditioner.get()));
- AssertThrow (ierr == 0, ExcTrilinosError(ierr));
+ // Introduce the preconditioner,
+ // if the identity preconditioner is used,
+ // the precondioner is set to none, ...
+ if (preconditioner.preconditioner.use_count()!=0)
+ {
+ ierr = solver.SetPrecOperator (const_cast<Epetra_Operator *>
+ (preconditioner.preconditioner.get()));
+ AssertThrow (ierr == 0, ExcTrilinosError(ierr));
+ }
+ else
+ solver.SetAztecOption(AZ_precond,AZ_none);
// ... set some options, ...
solver.SetAztecOption (AZ_output, additional_data.output_solver_details ?
// ... and then solve!
ierr = solver.Iterate (solver_control.max_steps(),
solver_control.tolerance());
- AssertThrow (ierr >= 0, ExcTrilinosError(ierr));
+
+ // report errors in more detail
+ // than just by checking whether
+ // the return status is zero or
+ // greater. the error strings are
+ // taken from the implementation
+ // of the AztecOO::Iterate
+ // function
+ switch (ierr)
+ {
+ case -1:
+ AssertThrow (false, ExcMessage("AztecOO::Iterate error code -1: "
+ "option not implemented"));
+ case -2:
+ AssertThrow (false, ExcMessage("AztecOO::Iterate error code -2: "
+ "numerical breakdown"));
+ case -3:
+ AssertThrow (false, ExcMessage("AztecOO::Iterate error code -3: "
+ "loss of precision"));
+ case -4:
+ AssertThrow (false, ExcMessage("AztecOO::Iterate error code -4: "
+ "GMRES hessenberg ill-conditioned"));
+ default:
+ AssertThrow (ierr >= 0, ExcTrilinosError(ierr));
+ }
// Finally, let the deal.II
// SolverControl object know
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/trilinos_sparse_matrix.h>
{
namespace
{
- // distinguish between compressed sparsity types that define row_begin()
- // and SparsityPattern that uses begin() as iterator type
+ // distinguish between compressed sparsity types that define row_begin()
+ // and SparsityPattern that uses begin() as iterator type
template <typename Sparsity>
void copy_row (const Sparsity &csp,
const size_type row,
column_space_map.reset (new Epetra_Map (input_col_map));
const size_type first_row = min_my_gid(input_row_map),
- last_row = max_my_gid(input_row_map)+1;
+ last_row = max_my_gid(input_row_map)+1;
std::vector<int> n_entries_per_row(last_row-first_row);
for (size_type row=first_row; row<last_row; ++row)
// check whether we got the number of columns right.
AssertDimension (sparsity_pattern.n_cols(),static_cast<size_type>(
- n_global_cols(*graph)));
+ n_global_cols(*graph)));
// And now finally generate the matrix.
matrix.reset (new Epetra_FECrsMatrix(Copy, *graph, false));
// Extract local indices in
// the matrix.
int trilinos_i = matrix->LRID(static_cast<TrilinosWrappers::types::int_type>(i)),
- trilinos_j = matrix->LCID(static_cast<TrilinosWrappers::types::int_type>(j));
+ trilinos_j = matrix->LCID(static_cast<TrilinosWrappers::types::int_type>(j));
TrilinosScalar value = 0.;
// If the data is not on the
// Extract local indices in
// the matrix.
int trilinos_i = matrix->LRID(static_cast<TrilinosWrappers::types::int_type>(i)),
- trilinos_j = matrix->LCID(static_cast<TrilinosWrappers::types::int_type>(j));
+ trilinos_j = matrix->LCID(static_cast<TrilinosWrappers::types::int_type>(j));
TrilinosScalar value = 0.;
// If the data is not on the
SparseMatrix::memory_consumption () const
{
size_type static_memory = sizeof(this) + sizeof (*matrix)
- + sizeof(*matrix->Graph().DataPtr());
+ + sizeof(*matrix->Graph().DataPtr());
return ((sizeof(TrilinosScalar)+sizeof(TrilinosWrappers::types::int_type))*
- matrix->NumMyNonzeros() + sizeof(int)*local_size() + static_memory);
+ matrix->NumMyNonzeros() + sizeof(int)*local_size() + static_memory);
}
}
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2013 by the deal.II authors
+// Copyright (C) 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (S : REAL_SCALARS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/trilinos_sparsity_pattern.h>
return graph.NumGlobalRows();
}
- int n_global_cols(const Epetra_CrsGraph &graph)
+ int n_global_cols(const Epetra_CrsGraph &graph)
{
return graph.NumGlobalCols();
}
{
return graph.GRID(i);
}
- #else
+#else
long long int n_global_elements (const Epetra_BlockMap &map)
{
return map.NumGlobalElements64();
// would it point to?)
Assert (ncols != 0, ExcInternalError());
colnum_cache.reset (new std::vector<size_type> (colnums,
- colnums+ncols));
+ colnums+ncols));
}
}
compressed (true)
{
column_space_map.reset(new Epetra_Map (TrilinosWrappers::types::int_type(0),
- TrilinosWrappers::types::int_type(0),
- Utilities::Trilinos::comm_self()));
+ TrilinosWrappers::types::int_type(0),
+ Utilities::Trilinos::comm_self()));
graph.reset (new Epetra_FECrsGraph(View,
- *column_space_map,
- *column_space_map,
- 0));
+ *column_space_map,
+ *column_space_map,
+ 0));
graph->FillComplete();
}
:
Subscriptor(),
column_space_map (new Epetra_Map(TrilinosWrappers::types::int_type(0),
- TrilinosWrappers::types::int_type(0),
- Utilities::Trilinos::comm_self())),
+ TrilinosWrappers::types::int_type(0),
+ Utilities::Trilinos::comm_self())),
compressed (false),
graph (new Epetra_FECrsGraph(View,
- *column_space_map,
*column_space_map,
- 0))
+ *column_space_map,
+ 0))
{
Assert (input_sparsity.n_rows() == 0,
ExcMessage ("Copy constructor only works for empty sparsity patterns."));
const size_type n_entries_per_row)
{
const Epetra_Map rows (TrilinosWrappers::types::int_type(m), 0,
- Utilities::Trilinos::comm_self());
+ Utilities::Trilinos::comm_self());
const Epetra_Map columns (TrilinosWrappers::types::int_type(n), 0,
- Utilities::Trilinos::comm_self());
+ Utilities::Trilinos::comm_self());
reinit (rows, columns, n_entries_per_row);
}
const std::vector<size_type> &n_entries_per_row)
{
const Epetra_Map rows (TrilinosWrappers::types::int_type(m), 0,
- Utilities::Trilinos::comm_self());
+ Utilities::Trilinos::comm_self());
const Epetra_Map columns (TrilinosWrappers::types::int_type(n), 0,
- Utilities::Trilinos::comm_self());
+ Utilities::Trilinos::comm_self());
reinit (rows, columns, n_entries_per_row);
}
namespace
{
typedef dealii::types::global_dof_index size_type;
- // distinguish between compressed sparsity types that define row_begin()
- // and SparsityPattern that uses begin() as iterator type
+ // distinguish between compressed sparsity types that define row_begin()
+ // and SparsityPattern that uses begin() as iterator type
template <typename Sparsity>
void copy_row (const Sparsity &csp,
const size_type row,
ExcMessage ("This function is not efficient if the map is not contiguous."));
const size_type first_row = min_my_gid(input_row_map),
- last_row = max_my_gid(input_row_map)+1;
+ last_row = max_my_gid(input_row_map)+1;
std::vector<int> n_entries_per_row(last_row - first_row);
- // Trilinos wants the row length as an int
- // this is hopefully never going to be a problem.
+ // Trilinos wants the row length as an int
+ // this is hopefully never going to be a problem.
for (size_type row=first_row; row<last_row; ++row)
n_entries_per_row[row-first_row] = static_cast<int>(sp.row_length(row));
SparsityPattern::copy_from (const SparsityType &sp)
{
const Epetra_Map rows (TrilinosWrappers::types::int_type(sp.n_rows()), 0,
- Utilities::Trilinos::comm_self());
+ Utilities::Trilinos::comm_self());
const Epetra_Map columns (TrilinosWrappers::types::int_type(sp.n_cols()), 0,
- Utilities::Trilinos::comm_self());
+ Utilities::Trilinos::comm_self());
reinit (rows, columns, sp);
}
// the pointer and generate an
// empty sparsity pattern.
column_space_map.reset (new Epetra_Map (TrilinosWrappers::types::int_type(0),
- TrilinosWrappers::types::int_type(0),
- Utilities::Trilinos::comm_self()));
+ TrilinosWrappers::types::int_type(0),
+ Utilities::Trilinos::comm_self()));
graph.reset (new Epetra_FECrsGraph(View, *column_space_map,
*column_space_map, 0));
graph->FillComplete();
// Extract local indices in
// the matrix.
int trilinos_i = graph->LRID(static_cast<TrilinosWrappers::types::int_type>(i)),
- trilinos_j = graph->LCID(static_cast<TrilinosWrappers::types::int_type>(j));
+ trilinos_j = graph->LCID(static_cast<TrilinosWrappers::types::int_type>(j));
// If the data is not on the
// present processor, we throw
// Generate the view and make
// sure that we have not generated
// an error.
- // TODO: trilinos_i is the local row index -> it is an int but
+ // TODO: trilinos_i is the local row index -> it is an int but
// ExtractGlobalRowView requires trilinos_i to be the global row
// index and thus it should be a long long int
int ierr = graph->ExtractGlobalRowView(
- static_cast<TrilinosWrappers::types::int_type>(trilinos_i),
- nnz_extracted, col_indices);
+ static_cast<TrilinosWrappers::types::int_type>(trilinos_i),
+ nnz_extracted, col_indices);
Assert (ierr==0, ExcTrilinosError(ierr));
Assert (nnz_present == nnz_extracted,
ExcDimensionMismatch(nnz_present, nnz_extracted));
// Prepare pointers for extraction
// of a view of the row.
int nnz_present = graph->NumGlobalIndices(
- static_cast<TrilinosWrappers::types::int_type>(i));
+ static_cast<TrilinosWrappers::types::int_type>(i));
int nnz_extracted;
int *col_indices;
// sure that we have not generated
// an error.
int ierr = graph->ExtractMyRowView(trilinos_i,
- nnz_extracted, col_indices);
+ nnz_extracted, col_indices);
Assert (ierr==0, ExcTrilinosError(ierr));
Assert (nnz_present == nnz_extracted,
// Search the index
int *el_find = std::find(col_indices, col_indices + nnz_present,
- static_cast<int>(trilinos_j));
+ static_cast<int>(trilinos_j));
int local_col_index = (int)(el_find - col_indices);
// x-y, that is we have to exchange
// the order of output
out << indices[global_row_index(*graph,static_cast<int>(j))]
- << " " << -static_cast<signed int>(row) << std::endl;
+ << " " << -static_cast<signed int>(row) << std::endl;
}
AssertThrow (out, ExcIO());
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2009, 2012, 2013 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/trilinos_vector.h>
// by calling either the 32- or 64-bit function necessary, and returns the
// result in the correct data type so that we can use it in calling other
// Epetra member functions that are overloaded by index type
- int* my_global_elements(const Epetra_BlockMap &map)
+ int *my_global_elements(const Epetra_BlockMap &map)
{
- return map.MyGlobalElements();
+ return map.MyGlobalElements();
}
// define a helper function that queries the global vector length of an
- // Epetra_FEVector object by calling either the 32- or 64-bit
+ // Epetra_FEVector object by calling either the 32- or 64-bit
// function necessary.
int global_length(const Epetra_FEVector &vector)
{
// by calling either the 32- or 64-bit function necessary, and returns the
// result in the correct data type so that we can use it in calling other
// Epetra member functions that are overloaded by index type
- long long int* my_global_elements(const Epetra_BlockMap &map)
+ long long int *my_global_elements(const Epetra_BlockMap &map)
{
- return map.MyGlobalElements64();
+ return map.MyGlobalElements64();
}
// define a helper function that queries the global vector length of an
- // Epetra_FEVector object by calling either the 32- or 64-bit
+ // Epetra_FEVector object by calling either the 32- or 64-bit
// function necessary.
long long int global_length(const Epetra_FEVector &vector)
{
VectorBase()
{
AssertThrow (n_global_elements(input_map) == n_global_elements(v.vector->Map()),
- ExcDimensionMismatch (n_global_elements(input_map),
- n_global_elements(v.vector->Map())));
+ ExcDimensionMismatch (n_global_elements(input_map),
+ n_global_elements(v.vector->Map())));
last_action = Zero;
:
VectorBase()
{
- AssertThrow (parallel_partitioner.size() ==
+ AssertThrow (parallel_partitioner.size() ==
static_cast<size_type>(n_global_elements(v.vector->Map())),
ExcDimensionMismatch (parallel_partitioner.size(),
n_global_elements(v.vector->Map())));
reinit (v, false, true);
}
+ Vector::Vector (const IndexSet &local,
+ const IndexSet &ghost,
+ const MPI_Comm &communicator)
+ :
+ VectorBase()
+ {
+ IndexSet parallel_partitioning = local;
+ parallel_partitioning.add_indices(ghost);
+ reinit(parallel_partitioning, communicator);
+ }
+
Vector::~Vector ()
}
+ void Vector::reinit(const IndexSet &local, const IndexSet &ghost, const MPI_Comm &communicator)
+ {
+ IndexSet parallel_partitioning = local;
+ parallel_partitioning.add_indices(ghost);
+ reinit(parallel_partitioning, communicator);
+ }
+
Vector &
Vector::operator = (const Vector &v)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/memory_consumption.h>
#include <deal.II/lac/trilinos_vector_base.h>
{
#ifndef DEAL_II_USE_LARGE_INDEX_TYPE
// define a helper function that queries the global vector length of an
- // Epetra_FEVector object by calling either the 32- or 64-bit
+ // Epetra_FEVector object by calling either the 32- or 64-bit
// function necessary.
int global_length(const Epetra_FEVector &vector)
{
}
#else
// define a helper function that queries the global vector length of an
- // Epetra_FEVector object by calling either the 32- or 64-bit
+ // Epetra_FEVector object by calling either the 32- or 64-bit
// function necessary.
long long int global_length(const Epetra_FEVector &vector)
{
// we can use []. Note that we
// can only get local values.
- const TrilinosWrappers::types::int_type local_index =
+ const TrilinosWrappers::types::int_type local_index =
vector.vector->Map().LID(static_cast<TrilinosWrappers::types::int_type>(index));
Assert (local_index >= 0,
ExcAccessToNonLocalElement (index,
{
// Extract local indices in
// the vector.
- TrilinosWrappers::types::int_type trilinos_i =
+ TrilinosWrappers::types::int_type trilinos_i =
vector->Map().LID(static_cast<TrilinosWrappers::types::int_type>(index));
TrilinosScalar value = 0.;
{
// Extract local indices in
// the vector.
- TrilinosWrappers::types::int_type trilinos_i =
+ TrilinosWrappers::types::int_type trilinos_i =
vector->Map().LID(static_cast<TrilinosWrappers::types::int_type>(index));
TrilinosScalar value = 0.;
//entry.
return sizeof(*this)
+ this->local_size()*( sizeof(double)+
- sizeof(TrilinosWrappers::types::int_type) );
+ sizeof(TrilinosWrappers::types::int_type) );
}
} /* end of namespace TrilinosWrappers */
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2008 by the deal.II authors
+// Copyright (C) 2008 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (SCALAR : REAL_SCALARS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/vector.templates.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (SCALAR : REAL_SCALARS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2007, 2008, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2007 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/vector_memory.h>
#include <deal.II/lac/vector.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (VECTOR : SERIAL_VECTORS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/vector_view.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (SCALAR : REAL_SCALARS)
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
## Copyright (C) 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
-FILE(GLOB _header
- ${CMAKE_SOURCE_DIR}/include/deal.II/matrix_free/*.h
- )
-
SET(_src
matrix_free.cc
)
matrix_free.inst.in
)
+FILE(GLOB _header
+ ${CMAKE_SOURCE_DIR}/include/deal.II/matrix_free/*.h
+ )
+
DEAL_II_ADD_LIBRARY(obj_matrix_free OBJECT ${_src} ${_header} ${_inst})
EXPAND_INSTANTIATIONS(obj_matrix_free "${_inst}")
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2011 by the deal.II authors
+// Copyright (C) 2011 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/matrix_free/matrix_free.templates.h>
#include <deal.II/base/utilities.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
{
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
## Copyright (C) 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
-FILE(GLOB _header
- ${CMAKE_SOURCE_DIR}/include/deal.II/meshworker/*.h
- )
-
SET(_src
mesh_worker.cc
mesh_worker_info.cc
mesh_worker_vector_selector.inst.in
)
+FILE(GLOB _header
+ ${CMAKE_SOURCE_DIR}/include/deal.II/meshworker/*.h
+ )
+
DEAL_II_ADD_LIBRARY(obj_meshworker OBJECT ${_src} ${_header} ${_inst})
EXPAND_INSTANTIATIONS(obj_meshworker "${_inst}")
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2006 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/meshworker/local_results.h>
#include <deal.II/meshworker/local_integrator.h>
{}
+ template <int dim, int spacedim, typename number>
+ LocalIntegrator<dim, spacedim, number>::LocalIntegrator (bool c, bool b, bool f)
+ :
+ use_cell(c), use_boundary(b), use_face(f)
+ {}
+
+
template <int dim, int spacedim, typename number>
LocalIntegrator<dim, spacedim, number>::~LocalIntegrator ()
{}
+ template <int dim, int spacedim, typename number>
+ void
+ LocalIntegrator<dim, spacedim, number>::cell (DoFInfo<dim, spacedim, number> &,
+ IntegrationInfo<dim, spacedim> &) const
+ {
+ Assert(false, ExcPureFunction());
+ }
+
+
+ template <int dim, int spacedim, typename number>
+ void
+ LocalIntegrator<dim, spacedim, number>::boundary (DoFInfo<dim, spacedim, number> &,
+ IntegrationInfo<dim, spacedim> &) const
+ {
+ Assert(false, ExcPureFunction());
+ }
+
+
+ template <int dim, int spacedim, typename number>
+ void
+ LocalIntegrator<dim, spacedim, number>::face (DoFInfo<dim, spacedim, number> &,
+ DoFInfo<dim, spacedim, number> &,
+ IntegrationInfo<dim, spacedim> &,
+ IntegrationInfo<dim, spacedim> &) const
+ {
+ Assert(false, ExcPureFunction());
+ }
+
+
template class LocalIntegrator<1,1,float>;
template class LocalIntegrator<1,1,double>;
template class LocalIntegrator<1,2,float>;
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/lac/vector.h>
#include <deal.II/lac/block_vector.h>
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2012, 2013 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
{
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/lac/vector.h>
#include <deal.II/lac/block_vector.h>
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
namespace MeshWorker
\{
template class VectorData<VECTOR,deal_II_dimension>;
+ template class VectorData<const VECTOR,deal_II_dimension>;
template class MGVectorData<VECTOR,deal_II_dimension>;
+ template class MGVectorData<const VECTOR,deal_II_dimension>;
\}
}
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012, 2013 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
-FILE(GLOB _header
- ${CMAKE_SOURCE_DIR}/include/deal.II/multigrid/*.h
- )
-
SET(_src
mg_base.cc
mg_dof_handler.cc
multigrid.inst.in
)
+FILE(GLOB _header
+ ${CMAKE_SOURCE_DIR}/include/deal.II/multigrid/*.h
+ )
+
DEAL_II_ADD_LIBRARY(obj_multigrid OBJECT ${_src} ${_header} ${_inst})
EXPAND_INSTANTIATIONS(obj_multigrid "${_inst}")
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2010, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/vector.h>
#include <deal.II/lac/block_vector.h>
-//---------------------------------------------------------------------------
-// $Id: vector_tools.inst.in 26105 2012-08-23 22:10:05Z heister $
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2012 by the deal.II authors
+// Copyright (C) 2012 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (VEC : SERIAL_VECTORS)
{
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/memory_consumption.h>
#include <deal.II/lac/sparse_matrix.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/multithread_info.h>
#include <deal.II/base/logstream.h>
endc = dof.end(level);
for (; cell!=endc; ++cell)
{
+ if (!cell->is_locally_owned_on_level()) continue;
+
cell->get_mg_dof_indices (dofs_on_this_cell);
// make sparsity pattern for this cell
for (unsigned int i=0; i<dofs_per_cell; ++i)
SparsityPattern &sparsity,
const unsigned int level)
{
- Assert ((level>=1) && (level<dof.get_tria().n_levels()),
- ExcIndexRange(level, 1, dof.get_tria().n_levels()));
+ Assert ((level>=1) && (level<dof.get_tria().n_global_levels()),
+ ExcIndexRange(level, 1, dof.get_tria().n_global_levels()));
const types::global_dof_index fine_dofs = dof.n_dofs(level);
const types::global_dof_index coarse_dofs = dof.n_dofs(level-1);
endc = dof.end(level);
for (; cell!=endc; ++cell)
{
+ if (!cell->is_locally_owned_on_level()) continue;
+
cell->get_mg_dof_indices (dofs_on_this_cell);
// Loop over all interior neighbors
for (unsigned int face = 0;
for (; cell!=endc; ++cell)
{
+ if (!cell->is_locally_owned_on_level()) continue;
+
cell->get_mg_dof_indices (dofs_on_this_cell);
// make sparsity pattern for this cell
for (unsigned int i=0; i<total_dofs; ++i)
const FiniteElement<dim> &fe = dof.get_fe();
const unsigned int n_comp = fe.n_components();
- Assert ((level>=1) && (level<dof.get_tria().n_levels()),
- ExcIndexRange(level, 1, dof.get_tria().n_levels()));
+ Assert ((level>=1) && (level<dof.get_tria().n_global_levels()),
+ ExcIndexRange(level, 1, dof.get_tria().n_global_levels()));
const types::global_dof_index fine_dofs = dof.n_dofs(level);
const types::global_dof_index coarse_dofs = dof.n_dofs(level-1);
for (; cell!=endc; ++cell)
{
+ if (!cell->is_locally_owned_on_level()) continue;
+
cell->get_mg_dof_indices (dofs_on_this_cell);
// Loop over all interior neighbors
for (unsigned int face = 0;
{
const FiniteElement<dim> &fe = dof_handler.get_fe();
const unsigned int n_components = fe.n_components();
- const unsigned int nlevels = dof_handler.get_tria().n_levels();
+ const unsigned int nlevels = dof_handler.get_tria().n_global_levels();
Assert (result.size() == nlevels,
ExcDimensionMismatch(result.size(), nlevels));
{
const FiniteElement<DH::dimension,DH::space_dimension> &fe = dof_handler.get_fe();
const unsigned int n_blocks = fe.n_blocks();
- const unsigned int n_levels = dof_handler.get_tria().n_levels();
+ const unsigned int n_levels = dof_handler.get_tria().n_global_levels();
AssertDimension (dofs_per_block.size(), n_levels);
if (function_map.size() == 0)
return;
- const unsigned int n_levels = dof.get_tria().n_levels();
+ const unsigned int n_levels = dof.get_tria().n_global_levels();
for (; cell!=endc; ++cell)
if (dof.get_tria().locally_owned_subdomain()==numbers::invalid_subdomain_id
|| cell->level_subdomain_id()==dof.get_tria().locally_owned_subdomain())
- for (unsigned int face_no = 0; face_no < GeometryInfo<dim>::faces_per_cell;
- ++face_no)
- {
- if (cell->at_boundary(face_no) == false)
- continue;
+ for (unsigned int face_no = 0; face_no < GeometryInfo<dim>::faces_per_cell;
+ ++face_no)
+ {
+ if (cell->at_boundary(face_no) == false)
+ continue;
- const FiniteElement<dim> &fe = cell->get_fe();
- const unsigned int level = cell->level();
-
- // we can presently deal only with
- // primitive elements for boundary
- // values. this does not preclude
- // us using non-primitive elements
- // in components that we aren't
- // interested in, however. make
- // sure that all shape functions
- // that are non-zero for the
- // components we are interested in,
- // are in fact primitive
- for (unsigned int i=0; i<cell->get_fe().dofs_per_cell; ++i)
- {
- const ComponentMask &nonzero_component_array
- = cell->get_fe().get_nonzero_components (i);
- for (unsigned int c=0; c<n_components; ++c)
- if ((nonzero_component_array[c] == true)
- &&
- (component_mask[c] == true))
- Assert (cell->get_fe().is_primitive (i),
- ExcMessage ("This function can only deal with requested boundary "
- "values that correspond to primitive (scalar) base "
- "elements"));
- }
+ const FiniteElement<dim> &fe = cell->get_fe();
+ const unsigned int level = cell->level();
+
+ // we can presently deal only with
+ // primitive elements for boundary
+ // values. this does not preclude
+ // us using non-primitive elements
+ // in components that we aren't
+ // interested in, however. make
+ // sure that all shape functions
+ // that are non-zero for the
+ // components we are interested in,
+ // are in fact primitive
+ for (unsigned int i=0; i<cell->get_fe().dofs_per_cell; ++i)
+ {
+ const ComponentMask &nonzero_component_array
+ = cell->get_fe().get_nonzero_components (i);
+ for (unsigned int c=0; c<n_components; ++c)
+ if ((nonzero_component_array[c] == true)
+ &&
+ (component_mask[c] == true))
+ Assert (cell->get_fe().is_primitive (i),
+ ExcMessage ("This function can only deal with requested boundary "
+ "values that correspond to primitive (scalar) base "
+ "elements"));
+ }
- typename DoFHandler<dim,spacedim>::face_iterator face = cell->face(face_no);
- const types::boundary_id boundary_component = face->boundary_indicator();
- if (function_map.find(boundary_component) != function_map.end())
- // face is of the right component
- {
- // get indices, physical location and
- // boundary values of dofs on this
- // face
- local_dofs.resize (fe.dofs_per_face);
- face->get_mg_dof_indices (level, local_dofs);
- if (fe_is_system)
- {
- // enter those dofs
- // into the list that
- // match the
- // component
- // signature. avoid
- // the usual
- // complication that
- // we can't just use
- // *_system_to_component_index
- // for non-primitive
- // FEs
- for (unsigned int i=0; i<local_dofs.size(); ++i)
- {
- unsigned int component;
- if (fe.is_primitive())
- component = fe.face_system_to_component_index(i).first;
- else
- {
- // non-primitive
- // case. make
- // sure that
- // this
- // particular
- // shape
- // function
- // _is_
- // primitive,
- // and get at
- // it's
- // component. use
- // usual
- // trick to
- // transfer
- // face dof
- // index to
- // cell dof
- // index
- const unsigned int cell_i
- = (dim == 1 ?
- i
- :
- (dim == 2 ?
- (i<2*fe.dofs_per_vertex ? i : i+2*fe.dofs_per_vertex)
- :
- (dim == 3 ?
- (i<4*fe.dofs_per_vertex ?
- i
+ typename DoFHandler<dim,spacedim>::face_iterator face = cell->face(face_no);
+ const types::boundary_id boundary_component = face->boundary_indicator();
+ if (function_map.find(boundary_component) != function_map.end())
+ // face is of the right component
+ {
+ // get indices, physical location and
+ // boundary values of dofs on this
+ // face
+ local_dofs.resize (fe.dofs_per_face);
+ face->get_mg_dof_indices (level, local_dofs);
+ if (fe_is_system)
+ {
+ // enter those dofs
+ // into the list that
+ // match the
+ // component
+ // signature. avoid
+ // the usual
+ // complication that
+ // we can't just use
+ // *_system_to_component_index
+ // for non-primitive
+ // FEs
+ for (unsigned int i=0; i<local_dofs.size(); ++i)
+ {
+ unsigned int component;
+ if (fe.is_primitive())
+ component = fe.face_system_to_component_index(i).first;
+ else
+ {
+ // non-primitive
+ // case. make
+ // sure that
+ // this
+ // particular
+ // shape
+ // function
+ // _is_
+ // primitive,
+ // and get at
+ // it's
+ // component. use
+ // usual
+ // trick to
+ // transfer
+ // face dof
+ // index to
+ // cell dof
+ // index
+ const unsigned int cell_i
+ = (dim == 1 ?
+ i
+ :
+ (dim == 2 ?
+ (i<2*fe.dofs_per_vertex ? i : i+2*fe.dofs_per_vertex)
:
- (i<4*fe.dofs_per_vertex+4*fe.dofs_per_line ?
- i+4*fe.dofs_per_vertex
+ (dim == 3 ?
+ (i<4*fe.dofs_per_vertex ?
+ i
+ :
+ (i<4*fe.dofs_per_vertex+4*fe.dofs_per_line ?
+ i+4*fe.dofs_per_vertex
+ :
+ i+4*fe.dofs_per_vertex+8*fe.dofs_per_line))
:
- i+4*fe.dofs_per_vertex+8*fe.dofs_per_line))
- :
- numbers::invalid_unsigned_int)));
- Assert (cell_i < fe.dofs_per_cell, ExcInternalError());
-
- // make sure
- // that if
- // this is
- // not a
- // primitive
- // shape function,
- // then all
- // the
- // corresponding
- // components
- // in the
- // mask are
- // not set
+ numbers::invalid_unsigned_int)));
+ Assert (cell_i < fe.dofs_per_cell, ExcInternalError());
+
+ // make sure
+ // that if
+ // this is
+ // not a
+ // primitive
+ // shape function,
+ // then all
+ // the
+ // corresponding
+ // components
+ // in the
+ // mask are
+ // not set
// if (!fe.is_primitive(cell_i))
// for (unsigned int c=0; c<n_components; ++c)
// if (fe.get_nonzero_components(cell_i)[c])
// components. if shape function is non-primitive, then we will ignore
// the result in the following anyway, otherwise there's only one
// non-zero component which we will use
- component = fe.get_nonzero_components(cell_i).first_selected_component();
- }
+ component = fe.get_nonzero_components(cell_i).first_selected_component();
+ }
- if (component_mask[component] == true)
- boundary_indices[level].insert(local_dofs[i]);
- }
- }
- else
- for (unsigned int i=0; i<local_dofs.size(); ++i)
- boundary_indices[level].insert(local_dofs[i]);
- }
- }
+ if (component_mask[component] == true)
+ boundary_indices[level].insert(local_dofs[i]);
+ }
+ }
+ else
+ for (unsigned int i=0; i<local_dofs.size(); ++i)
+ boundary_indices[level].insert(local_dofs[i]);
+ }
+ }
}
}
std::vector<IndexSet> &boundary_indices,
const ComponentMask &component_mask)
{
- Assert (boundary_indices.size() == dof.get_tria().n_levels(),
+ Assert (boundary_indices.size() == dof.get_tria().n_global_levels(),
ExcDimensionMismatch (boundary_indices.size(),
- dof.get_tria().n_levels()));
+ dof.get_tria().n_global_levels()));
std::vector<std::set<types::global_dof_index> >
- my_boundary_indices (dof.get_tria().n_levels());
+ my_boundary_indices (dof.get_tria().n_global_levels());
make_boundary_list (dof, function_map, my_boundary_indices, component_mask);
- for (unsigned int i=0; i<dof.get_tria().n_levels(); ++i)
+ for (unsigned int i=0; i<dof.get_tria().n_global_levels(); ++i)
{
boundary_indices[i] = IndexSet (dof.n_dofs(i));
boundary_indices[i].add_indices (my_boundary_indices[i].begin(),
extract_inner_interface_dofs (const DoFHandler<dim,spacedim> &mg_dof_handler,
std::vector<std::vector<bool> > &interface_dofs)
{
- Assert (interface_dofs.size() == mg_dof_handler.get_tria().n_levels(),
+ Assert (interface_dofs.size() == mg_dof_handler.get_tria().n_global_levels(),
ExcDimensionMismatch (interface_dofs.size(),
- mg_dof_handler.get_tria().n_levels()));
+ mg_dof_handler.get_tria().n_global_levels()));
- for (unsigned int l=0; l<mg_dof_handler.get_tria().n_levels(); ++l)
+ for (unsigned int l=0; l<mg_dof_handler.get_tria().n_global_levels(); ++l)
{
Assert (interface_dofs[l].size() == mg_dof_handler.n_dofs(l),
ExcDimensionMismatch (interface_dofs[l].size(),
extract_non_interface_dofs (const DoFHandler<dim,spacedim> &mg_dof_handler,
std::vector<std::set<types::global_dof_index> > &non_interface_dofs)
{
- Assert (non_interface_dofs.size() == mg_dof_handler.get_tria().n_levels(),
+ Assert (non_interface_dofs.size() == mg_dof_handler.get_tria().n_global_levels(),
ExcDimensionMismatch (non_interface_dofs.size(),
- mg_dof_handler.get_tria().n_levels()));
+ mg_dof_handler.get_tria().n_global_levels()));
const FiniteElement<dim,spacedim> &fe = mg_dof_handler.get_fe();
std::vector<std::vector<bool> > &interface_dofs,
std::vector<std::vector<bool> > &boundary_interface_dofs)
{
- Assert (interface_dofs.size() == mg_dof_handler.get_tria().n_levels(),
+ Assert (interface_dofs.size() == mg_dof_handler.get_tria().n_global_levels(),
ExcDimensionMismatch (interface_dofs.size(),
- mg_dof_handler.get_tria().n_levels()));
- Assert (boundary_interface_dofs.size() == mg_dof_handler.get_tria().n_levels(),
+ mg_dof_handler.get_tria().n_global_levels()));
+ Assert (boundary_interface_dofs.size() == mg_dof_handler.get_tria().n_global_levels(),
ExcDimensionMismatch (boundary_interface_dofs.size(),
- mg_dof_handler.get_tria().n_levels()));
+ mg_dof_handler.get_tria().n_global_levels()));
- for (unsigned int l=0; l<mg_dof_handler.get_tria().n_levels(); ++l)
+ for (unsigned int l=0; l<mg_dof_handler.get_tria().n_global_levels(); ++l)
{
Assert (interface_dofs[l].size() == mg_dof_handler.n_dofs(l),
ExcDimensionMismatch (interface_dofs[l].size(),
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (PATTERN : SPARSITY_PATTERNS; deal_II_dimension : DIMENSIONS;
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2012 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/logstream.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/logstream.h>
#include <deal.II/base/function.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 by the deal.II authors
+// Copyright (C) 2003 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/logstream.h>
#include <deal.II/base/function.h>
cell != mg_dof.end(level); ++cell)
if (cell->has_children() &&
( mg_dof.get_tria().locally_owned_subdomain()==numbers::invalid_subdomain_id
- || cell->level_subdomain_id()==mg_dof.get_tria().locally_owned_subdomain()
- ))
+ || cell->level_subdomain_id()==mg_dof.get_tria().locally_owned_subdomain()
+ ))
{
cell->get_mg_dof_indices (dof_indices_parent);
}
}
}
-
+
internal::MatrixSelector<VECTOR>::reinit(*prolongation_matrices[level],
- *prolongation_sparsities[level],
- level,
- csp,
- mg_dof);
+ *prolongation_sparsities[level],
+ level,
+ csp,
+ mg_dof);
csp.reinit(0,0);
-
+
FullMatrix<double> prolongation;
-
+
// now actually build the matrices
for (typename DoFHandler<dim,spacedim>::cell_iterator cell=mg_dof.begin(level);
cell != mg_dof.end(level); ++cell)
if (cell->has_children() &&
(mg_dof.get_tria().locally_owned_subdomain()==numbers::invalid_subdomain_id
|| cell->level_subdomain_id()==mg_dof.get_tria().locally_owned_subdomain())
- )
+ )
{
cell->get_mg_dof_indices (dof_indices_parent);
prolongation
= mg_dof.get_fe().get_prolongation_matrix (child,
cell->refinement_case());
-
- if (mg_constrained_dofs != 0 && mg_constrained_dofs->set_boundary_values())
- for (unsigned int j=0;j<dofs_per_cell; ++j)
- if (mg_constrained_dofs->is_boundary_index(level, dof_indices_parent[j]))
- for (unsigned int i=0; i<dofs_per_cell; ++i)
- prolongation(i,j) = 0.;
+
+ if (mg_constrained_dofs != 0 && mg_constrained_dofs->set_boundary_values())
+ for (unsigned int j=0; j<dofs_per_cell; ++j)
+ if (mg_constrained_dofs->is_boundary_index(level, dof_indices_parent[j]))
+ for (unsigned int i=0; i<dofs_per_cell; ++i)
+ prolongation(i,j) = 0.;
cell->child(child)->get_mg_dof_indices (dof_indices_child);
// of the global and mgdof, so that we later not access non-local elements
// in copy_to/from_mg.
// We keep track in the bitfield dof_touched which global dof has
- // been processed already (on the current level). This is the same as
+ // been processed already (on the current level). This is the same as
// the multigrid running in serial.
- // Only entering on the finest level gives wrong results (why?)
+ // Only entering on the finest level gives wrong results (why?)
copy_indices.resize(n_levels);
copy_indices_from_me.resize(n_levels);
{
if (mg_dof.get_tria().locally_owned_subdomain()!=numbers::invalid_subdomain_id
&& (level_cell->level_subdomain_id()==numbers::artificial_subdomain_id
- || level_cell->subdomain_id()==numbers::artificial_subdomain_id)
- )
+ || level_cell->subdomain_id()==numbers::artificial_subdomain_id)
+ )
continue;
// get the dof numbers of this cell for the global and the level-wise
if (global_mine && level_mine)
copy_indices[level].push_back(
- std::pair<unsigned int, unsigned int> (global_dof_indices[i], level_dof_indices[i]));
+ std::pair<unsigned int, unsigned int> (global_dof_indices[i], level_dof_indices[i]));
else if (level_mine)
copy_indices_from_me[level].push_back(
- std::pair<unsigned int, unsigned int> (global_dof_indices[i], level_dof_indices[i]));
+ std::pair<unsigned int, unsigned int> (global_dof_indices[i], level_dof_indices[i]));
else if (global_mine)
copy_indices_to_me[level].push_back(
- std::pair<unsigned int, unsigned int> (global_dof_indices[i], level_dof_indices[i]));
+ std::pair<unsigned int, unsigned int> (global_dof_indices[i], level_dof_indices[i]));
else
continue;
// more reliable output for regression texts
#ifdef DEBUG
std::less<std::pair<types::global_dof_index, unsigned int> > compare;
- for (unsigned int level=0;level<copy_indices.size();++level)
+ for (unsigned int level=0; level<copy_indices.size(); ++level)
std::sort(copy_indices[level].begin(), copy_indices[level].end(), compare);
- for (unsigned int level=0;level<copy_indices_from_me.size();++level)
+ for (unsigned int level=0; level<copy_indices_from_me.size(); ++level)
std::sort(copy_indices_from_me[level].begin(), copy_indices_from_me[level].end(), compare);
- for (unsigned int level=0;level<copy_indices_to_me.size();++level)
+ for (unsigned int level=0; level<copy_indices_to_me.size(); ++level)
std::sort(copy_indices_to_me[level].begin(), copy_indices_to_me[level].end(), compare);
#endif
}
template <class VECTOR>
void
-MGTransferPrebuilt<VECTOR>::print_matrices (std::ostream& os) const
+MGTransferPrebuilt<VECTOR>::print_matrices (std::ostream &os) const
{
- for (unsigned int level = 0;level<prolongation_matrices.size();++level)
+ for (unsigned int level = 0; level<prolongation_matrices.size(); ++level)
{
os << "Level " << level << std::endl;
prolongation_matrices[level]->print(os);
template <class VECTOR>
void
-MGTransferPrebuilt<VECTOR>::print_indices (std::ostream& os) const
+MGTransferPrebuilt<VECTOR>::print_indices (std::ostream &os) const
{
- for (unsigned int level = 0;level<copy_indices.size();++level)
+ for (unsigned int level = 0; level<copy_indices.size(); ++level)
{
- for (unsigned int i=0;i<copy_indices[level].size();++i)
- os << "copy_indices[" << level
- << "]\t" << copy_indices[level][i].first << '\t' << copy_indices[level][i].second << std::endl;
+ for (unsigned int i=0; i<copy_indices[level].size(); ++i)
+ os << "copy_indices[" << level
+ << "]\t" << copy_indices[level][i].first << '\t' << copy_indices[level][i].second << std::endl;
}
-
- for (unsigned int level = 0;level<copy_indices_from_me.size();++level)
+
+ for (unsigned int level = 0; level<copy_indices_from_me.size(); ++level)
{
- for (unsigned int i=0;i<copy_indices_from_me[level].size();++i)
- os << "copy_ifrom [" << level
- << "]\t" << copy_indices_from_me[level][i].first << '\t' << copy_indices_from_me[level][i].second << std::endl;
+ for (unsigned int i=0; i<copy_indices_from_me[level].size(); ++i)
+ os << "copy_ifrom [" << level
+ << "]\t" << copy_indices_from_me[level][i].first << '\t' << copy_indices_from_me[level][i].second << std::endl;
}
- for (unsigned int level = 0;level<copy_indices_to_me.size();++level)
+ for (unsigned int level = 0; level<copy_indices_to_me.size(); ++level)
{
- for (unsigned int i=0;i<copy_indices_to_me[level].size();++i)
- os << "copy_ito [" << level
- << "]\t" << copy_indices_to_me[level][i].first << '\t' << copy_indices_to_me[level][i].second << std::endl;
+ for (unsigned int i=0; i<copy_indices_to_me[level].size(); ++i)
+ os << "copy_ito [" << level
+ << "]\t" << copy_indices_to_me[level][i].first << '\t' << copy_indices_to_me[level][i].second << std::endl;
}
}
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (V1 : VECTORS_WITH_MATRIX)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/lac/vector.h>
-//---------------------------------------------------------------------------
-// $Id: vector_tools.inst.in 26105 2012-08-23 22:10:05Z heister $
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2012 by the deal.II authors
+// Copyright (C) 2012 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (VEC : SERIAL_VECTORS)
{
-#####
+## ---------------------------------------------------------------------
+## $Id$
##
-## Copyright (C) 2012 by the deal.II authors
+## Copyright (C) 2012 - 2013 by the deal.II authors
##
## This file is part of the deal.II library.
##
-## <TODO: Full License information>
-## This file is dual licensed under QPL 1.0 and LGPL 2.1 or any later
-## version of the LGPL license.
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE at
+## the top level of the deal.II distribution.
##
-## Author: Matthias Maier <matthias.maier@iwr.uni-heidelberg.de>
-##
-#####
+## ---------------------------------------------------------------------
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
-FILE(GLOB _header
- ${CMAKE_SOURCE_DIR}/include/deal.II/numerics/*.h
- )
-
SET(_src
data_out.cc
+ data_out_dof_data.cc
data_out_faces.cc
data_out_rotation.cc
data_out_stack.cc
data_postprocessor.cc
derivative_approximation.cc
dof_output_operator.cc
+ error_estimator_1d.cc
error_estimator.cc
fe_field_function.cc
- matrix_tools.cc
histogram.cc
+ matrix_tools.cc
point_value_history.cc
solution_transfer.cc
solution_transfer_inst2.cc
+ solution_transfer_inst3.cc
+ solution_transfer_inst4.cc
time_dependent.cc
- vector_tools.cc
+ vector_tools_boundary.cc
+ vector_tools_constraints.cc
+ vector_tools_integrate_difference.cc
+ vector_tools_interpolate.cc
+ vector_tools_mean_value.cc
+ vector_tools_point_value.cc
+ vector_tools_project.cc
+ vector_tools_rhs.cc
)
SET(_inst
+ data_out_dof_data.inst.in
data_out_faces.inst.in
data_out.inst.in
data_out_rotation.inst.in
data_postprocessor.inst.in
derivative_approximation.inst.in
dof_output_operator.inst.in
+ error_estimator_1d.inst.in
error_estimator.inst.in
fe_field_function.inst.in
matrix_tools.inst.in
point_value_history.inst.in
solution_transfer.inst.in
time_dependent.inst.in
- vector_tools.inst.in
+ vector_tools_boundary.inst.in
+ vector_tools_constraints.inst.in
+ vector_tools_integrate_difference.inst.in
+ vector_tools_interpolate.inst.in
+ vector_tools_mean_value.inst.in
+ vector_tools_point_value.inst.in
+ vector_tools_project.inst.in
+ vector_tools_rhs.inst.in
+ )
+
+FILE(GLOB _header
+ ${CMAKE_SOURCE_DIR}/include/deal.II/numerics/*.h
)
DEAL_II_ADD_LIBRARY(obj_numerics OBJECT ${_src} ${_header} ${_inst})
EXPAND_INSTANTIATIONS(obj_numerics "${_inst}")
-
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
-#include <deal.II/base/quadrature_lib.h>
#include <deal.II/base/work_stream.h>
-#include <deal.II/base/memory_consumption.h>
-#include <deal.II/lac/vector.h>
-#include <deal.II/lac/block_vector.h>
-#include <deal.II/lac/parallel_vector.h>
-#include <deal.II/lac/parallel_block_vector.h>
-#include <deal.II/lac/petsc_vector.h>
-#include <deal.II/lac/petsc_block_vector.h>
-#include <deal.II/lac/trilinos_vector.h>
-#include <deal.II/lac/trilinos_block_vector.h>
#include <deal.II/numerics/data_out.h>
#include <deal.II/grid/tria.h>
#include <deal.II/dofs/dof_handler.h>
#include <deal.II/hp/dof_handler.h>
#include <deal.II/grid/tria_iterator.h>
#include <deal.II/fe/fe.h>
+#include <deal.II/fe/fe_dgq.h>
#include <deal.II/fe/fe_values.h>
#include <deal.II/hp/fe_values.h>
#include <deal.II/fe/mapping_q1.h>
namespace DataOut
{
template <int dim, int spacedim>
- template <class FE>
ParallelData<dim,spacedim>::
- ParallelData (const Quadrature<dim> &quadrature,
- const unsigned int n_components,
- const unsigned int n_datasets,
+ ParallelData (const unsigned int n_datasets,
const unsigned int n_subdivisions,
const std::vector<unsigned int> &n_postprocessor_outputs,
const Mapping<dim,spacedim> &mapping,
- const std::vector<std::vector<unsigned int> > &cell_to_patch_index_map,
- const FE &finite_elements,
- const UpdateFlags update_flags)
+ const std::vector<std_cxx1x::shared_ptr<dealii::hp::FECollection<dim,spacedim> > > &finite_elements,
+ const UpdateFlags update_flags,
+ const std::vector<std::vector<unsigned int> > &cell_to_patch_index_map)
:
- ParallelDataBase<dim,spacedim> (n_components,
- n_datasets,
+ ParallelDataBase<dim,spacedim> (n_datasets,
n_subdivisions,
- quadrature.size(),
n_postprocessor_outputs,
- finite_elements),
- q_collection (quadrature),
- mapping_collection (mapping),
- x_fe_values (this->mapping_collection,
- this->fe_collection,
- q_collection,
- update_flags),
+ mapping,
+ finite_elements,
+ update_flags,
+ false),
cell_to_patch_index_map (&cell_to_patch_index_map)
{}
-
/**
- * In a WorkStream context, use
- * this function to append the
- * patch computed by the parallel
- * stage to the array of patches.
+ * In a WorkStream context, use this function to append the patch computed
+ * by the parallel stage to the array of patches.
*/
template <int dim, int spacedim>
void
}
-namespace internal
-{
- namespace DataOut
- {
- template <class DH>
- DataEntryBase<DH>::DataEntryBase (const std::vector<std::string> &names_in,
- const std::vector<DataComponentInterpretation::DataComponentInterpretation> &data_component_interpretation)
- :
- names(names_in),
- data_component_interpretation (data_component_interpretation),
- postprocessor(0, typeid(*this).name()),
- n_output_variables(names.size())
- {
- Assert (names.size() == data_component_interpretation.size(),
- ExcDimensionMismatch(data_component_interpretation.size(),
- names.size()));
-
- // check that the names use only allowed
- // characters
- // check names for invalid characters
- for (unsigned int i=0; i<names.size(); ++i)
- Assert (names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "0123456789_<>()") == std::string::npos,
- typename dealii::DataOut<DH::dimension>::
- ExcInvalidCharacter (names[i],
- names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "0123456789_<>()")));
- }
-
-
-
- template <class DH>
- DataEntryBase<DH>::DataEntryBase (const DataPostprocessor<DH::space_dimension> *data_postprocessor)
- :
- names(data_postprocessor->get_names()),
- data_component_interpretation (data_postprocessor->get_data_component_interpretation()),
- postprocessor(data_postprocessor, typeid(*this).name()),
- n_output_variables(names.size())
- {
- Assert (data_postprocessor->get_names().size()
- ==
- data_postprocessor->get_data_component_interpretation().size(),
- ExcDimensionMismatch (data_postprocessor->get_names().size(),
- data_postprocessor->get_data_component_interpretation().size()));
-
- // check that the names use only allowed
- // characters
- for (unsigned int i=0; i<names.size(); ++i)
- Assert (names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "0123456789_<>()") == std::string::npos,
- typename dealii::DataOut<DH::dimension>::
- ExcInvalidCharacter (names[i],
- names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "0123456789_<>()")));
- }
-
-
-
- template <class DH>
- DataEntryBase<DH>::~DataEntryBase ()
- {}
-
-
-
- /**
- * Class that stores a pointer to a
- * vector of type equal to the template
- * argument, and provides the functions
- * to extract data from it.
- *
- * @author Wolfgang Bangerth, 2004
- */
- template <class DH, typename VectorType>
- class DataEntry : public DataEntryBase<DH>
- {
- public:
- /**
- * Constructor. Give a list of names
- * for the individual components of
- * the vector and their
- * interpretation as scalar or vector
- * data. This constructor assumes
- * that no postprocessor is going to
- * be used.
- */
- DataEntry (const VectorType *data,
- const std::vector<std::string> &names,
- const std::vector<DataComponentInterpretation::DataComponentInterpretation> &data_component_interpretation);
-
- /**
- * Constructor when a data
- * postprocessor is going to be
- * used. In that case, the names and
- * vector declarations are going to
- * be acquired from the postprocessor.
- */
- DataEntry (const VectorType *data,
- const DataPostprocessor<DH::space_dimension> *data_postprocessor);
-
- /**
- * Assuming that the stored vector is
- * a cell vector, extract the given
- * element from it.
- */
- virtual
- double
- get_cell_data_value (const unsigned int cell_number) const;
-
- /**
- * Given a FEValuesBase object,
- * extract the values on the present
- * cell from the vector we actually
- * store.
- */
- virtual
- void
- get_function_values (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
- std::vector<double> &patch_values) const;
-
- /**
- * Given a FEValuesBase object,
- * extract the values on the present
- * cell from the vector we actually
- * store. This function does the same
- * as the one above but for
- * vector-valued finite elements.
- */
- virtual
- void
- get_function_values (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
- std::vector<dealii::Vector<double> > &patch_values_system) const;
-
- /**
- * Given a FEValuesBase object,
- * extract the gradients on the present
- * cell from the vector we actually
- * store.
- */
- virtual
- void
- get_function_gradients (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
- std::vector<Tensor<1,DH::space_dimension> > &patch_gradients) const;
-
- /**
- * Given a FEValuesBase object,
- * extract the gradients on the present
- * cell from the vector we actually
- * store. This function does the same
- * as the one above but for
- * vector-valued finite elements.
- */
- virtual
- void
- get_function_gradients (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
- std::vector<std::vector<Tensor<1,DH::space_dimension> > > &patch_gradients_system) const;
-
- /**
- * Given a FEValuesBase object, extract
- * the second derivatives on the
- * present cell from the vector we
- * actually store.
- */
- virtual
- void
- get_function_hessians (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
- std::vector<Tensor<2,DH::space_dimension> > &patch_hessians) const;
-
- /**
- * Given a FEValuesBase object, extract
- * the second derivatives on the
- * present cell from the vector we
- * actually store. This function does
- * the same as the one above but for
- * vector-valued finite elements.
- */
- virtual
- void
- get_function_hessians (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
- std::vector<std::vector< Tensor<2,DH::space_dimension> > > &patch_hessians_system) const;
-
- /**
- * Clear all references to the
- * vectors.
- */
- virtual void clear ();
-
- /**
- * Determine an estimate for
- * the memory consumption (in
- * bytes) of this object.
- */
- virtual std::size_t memory_consumption () const;
-
- private:
- /**
- * Pointer to the data
- * vector. Note that
- * ownership of the vector
- * pointed to remains with
- * the caller of this class.
- */
- const VectorType *vector;
- };
-
-
-
- template <class DH, class VectorType>
- DataEntry<DH,VectorType>::
- DataEntry (const VectorType *data,
- const std::vector<std::string> &names,
- const std::vector<DataComponentInterpretation::DataComponentInterpretation> &data_component_interpretation)
- :
- DataEntryBase<DH> (names, data_component_interpretation),
- vector (data)
- {}
-
-
-
- template <class DH, class VectorType>
- DataEntry<DH,VectorType>::
- DataEntry (const VectorType *data,
- const DataPostprocessor<DH::space_dimension> *data_postprocessor)
- :
- DataEntryBase<DH> (data_postprocessor),
- vector (data)
- {}
-
-
- namespace
- {
- template <class VectorType>
- double
- get_vector_element (const VectorType &vector,
- const unsigned int cell_number)
- {
- return vector[cell_number];
- }
-
-
- double
- get_vector_element (const IndexSet &is,
- const unsigned int cell_number)
- {
- return (is.is_element(cell_number) ? 1 : 0);
- }
- }
-
-
-
- template <class DH, class VectorType>
- double
- DataEntry<DH,VectorType>::
- get_cell_data_value (const unsigned int cell_number) const
- {
- return get_vector_element(*vector, cell_number);
- }
-
-
-
- template <class DH, class VectorType>
- void
- DataEntry<DH,VectorType>::
- get_function_values (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
- std::vector<dealii::Vector<double> > &patch_values_system) const
- {
- fe_patch_values.get_function_values (*vector, patch_values_system);
- }
-
-
-
- template <class DH, typename VectorType>
- void
- DataEntry<DH,VectorType>::
- get_function_values (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
- std::vector<double> &patch_values) const
- {
- fe_patch_values.get_function_values (*vector, patch_values);
- }
-
-
-
- template <class DH, class VectorType>
- void
- DataEntry<DH,VectorType>::
- get_function_gradients (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
- std::vector<std::vector<Tensor<1,DH::space_dimension> > > &patch_gradients_system) const
- {
- fe_patch_values.get_function_gradients (*vector, patch_gradients_system);
- }
-
-
-
- template <class DH, typename VectorType>
- void
- DataEntry<DH,VectorType>::
- get_function_gradients (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
- std::vector<Tensor<1,DH::space_dimension> > &patch_gradients) const
- {
- fe_patch_values.get_function_gradients (*vector, patch_gradients);
- }
-
-
-
- template <class DH, class VectorType>
- void
- DataEntry<DH,VectorType>::
- get_function_hessians (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
- std::vector<std::vector<Tensor<2,DH::space_dimension> > > &patch_hessians_system) const
- {
- fe_patch_values.get_function_hessians (*vector, patch_hessians_system);
- }
-
-
-
- template <class DH, typename VectorType>
- void
- DataEntry<DH,VectorType>::
- get_function_hessians (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
- std::vector<Tensor<2,DH::space_dimension> > &patch_hessians) const
- {
- fe_patch_values.get_function_hessians (*vector, patch_hessians);
- }
-
-
-
- template <class DH, typename VectorType>
- std::size_t
- DataEntry<DH,VectorType>::memory_consumption () const
- {
- return (sizeof (vector) +
- MemoryConsumption::memory_consumption (this->names));
- }
-
-
-
- template <class DH, class VectorType>
- void
- DataEntry<DH,VectorType>::clear ()
- {
- vector = 0;
- }
- }
-}
-
-
-
-template <class DH,
- int patch_dim, int patch_space_dim>
-DataOut_DoFData<DH,patch_dim,patch_space_dim>::DataOut_DoFData ()
- :
- dofs(0,typeid(*this).name())
-{}
-
-
-
-template <class DH, int patch_dim, int patch_space_dim>
-DataOut_DoFData<DH,patch_dim,patch_space_dim>::~DataOut_DoFData ()
-{
- clear ();
-}
-
-
-
-template <class DH, int patch_dim, int patch_space_dim>
-void
-DataOut_DoFData<DH,patch_dim,patch_space_dim>::
-attach_dof_handler (const DH &d)
-{
- Assert (dof_data.size() == 0, ExcOldDataStillPresent());
- Assert (cell_data.size() == 0, ExcOldDataStillPresent());
-
- dofs = &d;
-}
-
-
-
-
-template <class DH,
- int patch_dim, int patch_space_dim>
-template <class VECTOR>
-void
-DataOut_DoFData<DH,patch_dim,patch_space_dim>::
-add_data_vector (const VECTOR &vec,
- const std::string &name,
- const DataVectorType type,
- const std::vector<DataComponentInterpretation::DataComponentInterpretation> &data_component_interpretation)
-{
- Assert (dofs != 0, ExcNoDoFHandlerSelected ());
- const unsigned int n_components = dofs->get_fe().n_components ();
-
- std::vector<std::string> names;
- // if only one component or vector
- // is cell vector: we only need one
- // name
- if ((n_components == 1) ||
- (vec.size() == dofs->get_tria().n_active_cells()))
- {
- names.resize (1, name);
- }
- else
- // otherwise append _i to the
- // given name
- {
- names.resize (n_components);
- for (unsigned int i=0; i<n_components; ++i)
- {
- std::ostringstream namebuf;
- namebuf << '_' << i;
- names[i] = name + namebuf.str();
- }
- }
-
- add_data_vector (vec, names, type, data_component_interpretation);
-}
-
-
-
-template <class DH,
- int patch_dim, int patch_space_dim>
-template <class VECTOR>
-void
-DataOut_DoFData<DH,patch_dim,patch_space_dim>::
-add_data_vector (const VECTOR &vec,
- const std::vector<std::string> &names,
- const DataVectorType type,
- const std::vector<DataComponentInterpretation::DataComponentInterpretation> &data_component_interpretation_)
-{
- Assert (dofs != 0, ExcNoDoFHandlerSelected ());
-
- const std::vector<DataComponentInterpretation::DataComponentInterpretation> &
- data_component_interpretation
- = (data_component_interpretation_.size() != 0
- ?
- data_component_interpretation_
- :
- std::vector<DataComponentInterpretation::DataComponentInterpretation>
- (names.size(), DataComponentInterpretation::component_is_scalar));
-
- // either cell data and one name,
- // or dof data and n_components names
- DataVectorType actual_type = type;
- if (type == type_automatic)
- {
- if (vec.size() == dofs->get_tria().n_active_cells())
- actual_type = type_cell_data;
- else
- actual_type = type_dof_data;
- }
-
- switch (actual_type)
- {
- case type_cell_data:
- Assert (vec.size() == dofs->get_tria().n_active_cells(),
- ExcInvalidVectorSize (vec.size(),
- dofs->n_dofs(),
- dofs->get_tria().n_active_cells()));
- Assert (names.size() == 1,
- ExcInvalidNumberOfNames (names.size(), 1));
- break;
-
- case type_dof_data:
- Assert (vec.size() == dofs->n_dofs(),
- ExcInvalidVectorSize (vec.size(),
- dofs->n_dofs(),
- dofs->get_tria().n_active_cells()));
- Assert (names.size() == dofs->get_fe().n_components(),
- ExcInvalidNumberOfNames (names.size(), dofs->get_fe().n_components()));
- break;
-
- case type_automatic:
- // this case should have
- // been handled above...
- Assert (false, ExcInternalError());
- }
-
- internal::DataOut::DataEntryBase<DH> *new_entry
- = new internal::DataOut::DataEntry<DH,VECTOR>(&vec, names,
- data_component_interpretation);
- if (actual_type == type_dof_data)
- dof_data.push_back (std_cxx1x::shared_ptr<internal::DataOut::DataEntryBase<DH> >(new_entry));
- else
- cell_data.push_back (std_cxx1x::shared_ptr<internal::DataOut::DataEntryBase<DH> >(new_entry));
-}
-
-
-
-template <class DH,
- int patch_dim, int patch_space_dim>
-template <class VECTOR>
-void
-DataOut_DoFData<DH,patch_dim,patch_space_dim>::
-add_data_vector (const VECTOR &vec,
- const DataPostprocessor<DH::space_dimension> &data_postprocessor)
-{
- // this is a specialized version of the
- // other function where we have a
- // postprocessor. if we do, we know that we
- // have type_dof_data, which makes things a
- // bit simpler, we also don't need to deal
- // with some of the other stuff and use a
- // different constructor of DataEntry
-
- Assert (dofs != 0, ExcNoDoFHandlerSelected ());
-
- Assert (vec.size() == dofs->n_dofs(),
- ExcInvalidVectorSize (vec.size(),
- dofs->n_dofs(),
- dofs->get_tria().n_active_cells()));
-
- internal::DataOut::DataEntryBase<DH> *new_entry
- = new internal::DataOut::DataEntry<DH,VECTOR>(&vec, &data_postprocessor);
- dof_data.push_back (std_cxx1x::shared_ptr<internal::DataOut::DataEntryBase<DH> >(new_entry));
-}
-
-
-
-template <class DH,
- int patch_dim, int patch_space_dim>
-void DataOut_DoFData<DH,patch_dim,patch_space_dim>::clear_data_vectors ()
-{
- dof_data.erase (dof_data.begin(), dof_data.end());
- cell_data.erase (cell_data.begin(), cell_data.end());
-
- // delete patches
- std::vector<Patch> dummy;
- patches.swap (dummy);
-}
-
-
-
-template <class DH,
- int patch_dim, int patch_space_dim>
-void
-DataOut_DoFData<DH,patch_dim,patch_space_dim>::
-clear_input_data_references ()
-{
- for (unsigned int i=0; i<dof_data.size(); ++i)
- dof_data[i]->clear ();
-
- for (unsigned int i=0; i<cell_data.size(); ++i)
- cell_data[i]->clear ();
-
- if (dofs != 0)
- dofs = 0;
-}
-
-
-
-template <class DH,
- int patch_dim, int patch_space_dim>
-void
-DataOut_DoFData<DH,patch_dim,patch_space_dim>::clear ()
-{
- dof_data.erase (dof_data.begin(), dof_data.end());
- cell_data.erase (cell_data.begin(), cell_data.end());
-
- if (dofs != 0)
- dofs = 0;
-
- // delete patches
- std::vector<Patch> dummy;
- patches.swap (dummy);
-}
-
-
-
-template <class DH,
- int patch_dim, int patch_space_dim>
-std::vector<std::string>
-DataOut_DoFData<DH,patch_dim,patch_space_dim>::
-get_dataset_names () const
-{
- std::vector<std::string> names;
- // collect the names of dof
- // and cell data
- typedef
- typename std::vector<std_cxx1x::shared_ptr<internal::DataOut::DataEntryBase<DH> > >::const_iterator
- data_iterator;
-
- for (data_iterator d=dof_data.begin();
- d!=dof_data.end(); ++d)
- for (unsigned int i=0; i<(*d)->names.size(); ++i)
- names.push_back ((*d)->names[i]);
- for (data_iterator d=cell_data.begin(); d!=cell_data.end(); ++d)
- {
- Assert ((*d)->names.size() == 1, ExcInternalError());
- names.push_back ((*d)->names[0]);
- }
-
- return names;
-}
-
-
-
-template <class DH,
- int patch_dim, int patch_space_dim>
-std::vector<std_cxx1x::tuple<unsigned int, unsigned int, std::string> >
-DataOut_DoFData<DH,patch_dim,patch_space_dim>::get_vector_data_ranges () const
-{
- std::vector<std_cxx1x::tuple<unsigned int, unsigned int, std::string> >
- ranges;
-
- // collect the ranges of dof
- // and cell data
- typedef
- typename std::vector<std_cxx1x::shared_ptr<internal::DataOut::DataEntryBase<DH> > >::const_iterator
- data_iterator;
-
- unsigned int output_component = 0;
- for (data_iterator d=dof_data.begin();
- d!=dof_data.end(); ++d)
- for (unsigned int i=0; i<(*d)->n_output_variables;
- ++i, ++output_component)
- // see what kind of data we have
- // here. note that for the purpose of
- // the current function all we care
- // about is vector data
- if ((*d)->data_component_interpretation[i] ==
- DataComponentInterpretation::component_is_part_of_vector)
- {
- // ensure that there is a
- // continuous number of next
- // space_dim components that all
- // deal with vectors
- Assert (i+patch_space_dim <=
- (*d)->n_output_variables,
- ExcInvalidVectorDeclaration (i,
- (*d)->names[i]));
- for (unsigned int dd=1; dd<patch_space_dim; ++dd)
- Assert ((*d)->data_component_interpretation[i+dd]
- ==
- DataComponentInterpretation::component_is_part_of_vector,
- ExcInvalidVectorDeclaration (i,
- (*d)->names[i]));
-
- // all seems alright, so figure out
- // whether there is a common name
- // to these components. if not,
- // leave the name empty and let the
- // output format writer decide what
- // to do here
- std::string name = (*d)->names[i];
- for (unsigned int dd=1; dd<patch_space_dim; ++dd)
- if (name != (*d)->names[i+dd])
- {
- name = "";
- break;
- }
-
- // finally add a corresponding
- // range
- std_cxx1x::tuple<unsigned int, unsigned int, std::string>
- range (output_component,
- output_component+patch_space_dim-1,
- name);
-
- ranges.push_back (range);
-
- // increase the 'component' counter
- // by the appropriate amount, same
- // for 'i', since we have already
- // dealt with all these components
- output_component += patch_space_dim-1;
- i += patch_space_dim-1;
- }
-
- // note that we do not have to traverse the
- // list of cell data here because cell data
- // is one value per (logical) cell and
- // therefore cannot be a vector
-
- // as a final check, the 'component'
- // counter should be at the total number of
- // components added up now
-#ifdef DEBUG
- unsigned int n_output_components = 0;
- for (data_iterator d=dof_data.begin();
- d!=dof_data.end(); ++d)
- n_output_components += (*d)->n_output_variables;
- Assert (output_component == n_output_components,
- ExcInternalError());
-#endif
-
- return ranges;
-}
-
-
-
-template <class DH,
- int patch_dim, int patch_space_dim>
-const std::vector< dealii::DataOutBase::Patch<patch_dim, patch_space_dim> > &
-DataOut_DoFData<DH,patch_dim,patch_space_dim>::get_patches () const
-{
- return patches;
-}
-
-
-
-template <class DH,
- int patch_dim, int patch_space_dim>
-std::size_t
-DataOut_DoFData<DH,patch_dim,patch_space_dim>::memory_consumption () const
-{
- return (DataOutInterface<patch_dim,patch_space_dim>::memory_consumption () +
- MemoryConsumption::memory_consumption (dofs) +
- MemoryConsumption::memory_consumption (patches));
-}
-
-
-
-/* ---------------------------------------------------------------------- */
-
template <int dim, class DH>
void
DataOutBase::Patch<DH::dimension, DH::space_dimension> &patch,
const CurvedCellRegion curved_cell_region)
{
- // use ucd_to_deal map as patch vertices
- // are in the old, unnatural ordering. if
- // the mapping does not preserve locations
- // (e.g. MappingQEulerian), we need to
- // compute the offset of the vertex for the
- // graphical output. Otherwise, we can just
- // use the vertex info.
+ // use ucd_to_deal map as patch vertices are in the old, unnatural
+ // ordering. if the mapping does not preserve locations
+ // (e.g. MappingQEulerian), we need to compute the offset of the vertex for
+ // the graphical output. Otherwise, we can just use the vertex info.
for (unsigned int vertex=0; vertex<GeometryInfo<DH::dimension>::vertices_per_cell; ++vertex)
if (data.mapping_collection[0].preserves_vertex_locations())
patch.vertices[vertex] = cell_and_index->first->vertex(vertex);
if (data.n_datasets > 0)
{
- data.x_fe_values.reinit (cell_and_index->first);
- const FEValues<DH::dimension,DH::space_dimension> &fe_patch_values
- = data.x_fe_values.get_present_fe_values ();
+ // create DH::active_cell_iterator and initialize FEValues
+ data.reinit_all_fe_values(this->dof_data, cell_and_index->first);
+
+ const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values
+ = data.get_present_fe_values (0);
const unsigned int n_q_points = fe_patch_values.n_quadrature_points;
- // depending on the requested output
- // of curved cells, if necessary
- // append the quadrature points to
- // the last rows of the patch.data
- // member. This is the case if we
- // want to produce curved cells at
- // the boundary and this cell
- // actually is at the boundary, or
- // else if we want to produce curved
- // cells everywhere
+ // depending on the requested output of curved cells, if necessary
+ // append the quadrature points to the last rows of the patch.data
+ // member. This is the case if we want to produce curved cells at the
+ // boundary and this cell actually is at the boundary, or else if we
+ // want to produce curved cells everywhere
//
- // note: a cell is *always* at
- // the boundary if dim<spacedim
+ // note: a cell is *always* at the boundary if dim<spacedim
if (curved_cell_region==curved_inner_cells
||
(curved_cell_region==curved_boundary
{
Assert(patch.space_dim==DH::space_dimension, ExcInternalError());
const std::vector<Point<DH::space_dimension> > &q_points=fe_patch_values.get_quadrature_points();
- // resize the patch.data member
- // in order to have enough memory
- // for the quadrature points as
- // well
+ // resize the patch.data member in order to have enough memory for
+ // the quadrature points as well
patch.data.reinit (data.n_datasets+DH::space_dimension, n_q_points);
- // set the flag indicating that
- // for this cell the points are
+ // set the flag indicating that for this cell the points are
// explicitly given
patch.points_are_available=true;
// copy points to patch.data
// first fill dof_data
for (unsigned int dataset=0; dataset<this->dof_data.size(); ++dataset)
{
+ const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values
+ = data.get_present_fe_values (dataset);
+ const unsigned int n_components =
+ fe_patch_values.get_fe().n_components();
+
const DataPostprocessor<DH::space_dimension> *postprocessor=this->dof_data[dataset]->postprocessor;
if (postprocessor != 0)
{
- // we have to postprocess the
- // data, so determine, which
- // fields have to be updated
+ // we have to postprocess the data, so determine, which fields
+ // have to be updated
const UpdateFlags update_flags=postprocessor->get_needed_update_flags();
- if (data.n_components == 1)
+ if (n_components == 1)
{
- // at each point there is
- // only one component of
- // value, gradient etc.
+ // at each point there is only one component of value,
+ // gradient etc.
if (update_flags & update_values)
this->dof_data[dataset]->get_function_values (fe_patch_values,
data.patch_values);
}
else
{
- // at each point there is
- // a vector valued
- // function and its
+ data.resize_system_vectors (n_components);
+
+ // at each point there is a vector valued function and its
// derivative...
if (update_flags & update_values)
this->dof_data[dataset]->get_function_values (fe_patch_values,
= data.postprocessed_values[dataset][q](component);
}
else
- // now we use the given data
- // vector without
- // modifications. again, we
- // treat single component
- // functions separately for
- // efficiency reasons.
- if (data.n_components == 1)
+ // now we use the given data vector without modifications. again,
+ // we treat single component functions separately for efficiency
+ // reasons.
+ if (n_components == 1)
{
this->dof_data[dataset]->get_function_values (fe_patch_values,
data.patch_values);
}
else
{
+ data.resize_system_vectors(n_components);
this->dof_data[dataset]->get_function_values (fe_patch_values,
data.patch_values_system);
- for (unsigned int component=0; component<data.n_components;
+ for (unsigned int component=0; component<n_components;
++component)
for (unsigned int q=0; q<n_q_points; ++q)
patch.data(offset+component,q) =
data.patch_values_system[q](component);
}
- // increment the counter for the
- // actual data record
+ // increment the counter for the actual data record
offset+=this->dof_data[dataset]->n_output_variables;
}
- // then do the cell data. only
- // compute the number of a cell if
- // needed; also make sure that we
- // only access cell data if the
- // first_cell/next_cell functions
- // only return active cells
+ // then do the cell data. only compute the number of a cell if needed;
+ // also make sure that we only access cell data if the
+ // first_cell/next_cell functions only return active cells
if (this->cell_data.size() != 0)
{
Assert (!cell_and_index->first->has_children(), ExcNotImplemented());
for (unsigned int f=0; f<GeometryInfo<DH::dimension>::faces_per_cell; ++f)
{
- // let's look up whether
- // the neighbor behind that
- // face is noted in the
- // table of cells which we
- // treat. this can only
- // happen if the neighbor
- // exists, and is on the
- // same level as this cell,
- // but it may also happen
- // that the neighbor is not
- // a member of the range of
- // cells over which we
- // loop, in which case the
- // respective entry in the
- // cell_to_patch_index_map
- // will have the value
- // no_neighbor. (note that
- // since we allocated only
- // as much space in this
- // array as the maximum
- // index of the cells we
- // loop over, not every
- // neighbor may have its
- // space in it, so we have
- // to assume that it is
- // extended by values
+ // let's look up whether the neighbor behind that face is noted in the
+ // table of cells which we treat. this can only happen if the neighbor
+ // exists, and is on the same level as this cell, but it may also happen
+ // that the neighbor is not a member of the range of cells over which we
+ // loop, in which case the respective entry in the
+ // cell_to_patch_index_map will have the value no_neighbor. (note that
+ // since we allocated only as much space in this array as the maximum
+ // index of the cells we loop over, not every neighbor may have its
+ // space in it, so we have to assume that it is extended by values
// no_neighbor)
if (cell_and_index->first->at_boundary(f)
||
continue;
}
- // now, there is a
- // neighbor, so get its
- // patch number and set it
- // for the neighbor index
+ // now, there is a neighbor, so get its patch number and set it for the
+ // neighbor index
patch.neighbors[f]
= (*data.cell_to_patch_index_map)[neighbor->level()][neighbor->index()];
}
}
+
template <int dim, class DH>
void DataOut<dim,DH>::build_patches (const Mapping<DH::dimension,DH::space_dimension> &mapping,
const unsigned int nnnn_subdivisions,
const CurvedCellRegion curved_region)
{
- // Check consistency of redundant
- // template parameter
+ // Check consistency of redundant template parameter
Assert (dim==DH::dimension, ExcDimensionMismatch(dim, DH::dimension));
typedef DataOut_DoFData<DH, DH::dimension, DH::space_dimension> BaseClass;
- Assert (this->dofs != 0, typename BaseClass::ExcNoDoFHandlerSelected());
+ Assert (this->triangulation != 0,
+ typename BaseClass::ExcNoTriangulationSelected());
const unsigned int n_subdivisions = (nnnn_subdivisions != 0)
? nnnn_subdivisions
Assert (n_subdivisions >= 1,
ExcInvalidNumberOfSubdivisions(n_subdivisions));
- // first count the cells we want to
- // create patches of. also fill the
- // object that maps the cell
- // indices to the patch numbers, as
- // this will be needed for
- // generation of neighborship
- // information
+ // first count the cells we want to create patches of. also fill the object
+ // that maps the cell indices to the patch numbers, as this will be needed
+ // for generation of neighborship information
std::vector<std::vector<unsigned int> > cell_to_patch_index_map;
- cell_to_patch_index_map.resize (this->dofs->get_tria().n_levels());
- for (unsigned int l=0; l<this->dofs->get_tria().n_levels(); ++l)
+ cell_to_patch_index_map.resize (this->triangulation->n_levels());
+ for (unsigned int l=0; l<this->triangulation->n_levels(); ++l)
{
unsigned int max_index = 0;
- for (cell_iterator cell=first_locally_owned_cell(); cell != this->dofs->end();
+ for (cell_iterator cell=first_locally_owned_cell(); cell != this->triangulation->end();
cell = next_locally_owned_cell(cell))
if (static_cast<unsigned int>(cell->level()) == l)
max_index = std::max (max_index,
std::vector<std::pair<cell_iterator, unsigned int> > all_cells;
{
- // set the index of the first
- // cell. if
- // first_locally_owned_cell /
- // next_locally_owned_cell
- // returns non-active cells, then
- // the index is not usable
- // anyway, but otherwise we
- // should keep track where we are
+ // set the index of the first cell. if first_locally_owned_cell /
+ // next_locally_owned_cell returns non-active cells, then the index is not
+ // usable anyway, but otherwise we should keep track where we are
unsigned int index;
- if ((first_locally_owned_cell() == this->dofs->end())
+ cell_iterator cell = first_locally_owned_cell();
+ if ((cell == this->triangulation->end())
||
- (first_locally_owned_cell()->has_children()))
+ (cell->has_children()))
index = 0;
else
- index = std::distance (this->dofs->begin_active(),
- active_cell_iterator(first_locally_owned_cell()));
- for (cell_iterator cell=first_locally_owned_cell(); cell != this->dofs->end();
- cell = next_locally_owned_cell(cell))
+ index = std::distance (this->triangulation->begin_active(),
+ active_cell_iterator(cell));
+ for ( ; cell != this->triangulation->end(); )
{
Assert (static_cast<unsigned int>(cell->level()) <
cell_to_patch_index_map.size(),
all_cells.push_back (std::make_pair(cell, index));
- // if both this and the next
- // cell are active, then
- // increment the index that
- // keeps track on which
- // active cell we are sitting
- // correctly. if one of the
- // cells is not active, then
- // this index doesn't mean
- // anything anyway, so just
- // ignore it. same if we are
- // at the end of the range
+ // if both this and the next cell are active, then increment the index
+ // that keeps track on which active cell we are sitting correctly. if
+ // one of the cells is not active, then this index doesn't mean
+ // anything anyway, so just ignore it. same if we are at the end of
+ // the range
+ cell_iterator next = next_locally_owned_cell(cell);
if (!cell->has_children() &&
- next_locally_owned_cell(cell) != this->dofs->end() &&
- !next_locally_owned_cell(cell)->has_children())
+ next != this->triangulation->end() &&
+ !next->has_children())
index += std::distance (active_cell_iterator(cell),
- active_cell_iterator(next_locally_owned_cell(cell)));
+ active_cell_iterator(next));
+ cell = next;
}
}
this->patches.reserve (all_cells.size());
Assert (this->patches.size() == 0, ExcInternalError());
- // now create a default patch and a
- // default object for the
- // WorkStream object to work with
- const QTrapez<1> q_trapez;
- const QIterated<DH::dimension> patch_points (q_trapez, n_subdivisions);
-
- const unsigned int n_components = this->dofs->get_fe().n_components();
+ // now create a default object for the WorkStream object to work with
unsigned int n_datasets=this->cell_data.size();
for (unsigned int i=0; i<this->dof_data.size(); ++i)
n_datasets += this->dof_data[i]->n_output_variables;
for (unsigned int i=0; i<this->dof_data.size(); ++i)
if (this->dof_data[i]->postprocessor)
update_flags |= this->dof_data[i]->postprocessor->get_needed_update_flags();
- // perhaps update_normal_vectors is present,
- // which would only be useful on faces, but
- // we may not use it here.
+ // perhaps update_normal_vectors is present, which would only be useful on
+ // faces, but we may not use it here.
Assert (!(update_flags & update_normal_vectors),
ExcMessage("The update of normal vectors may not be requested for evaluation of "
"data on cells via DataPostprocessor."));
internal::DataOut::ParallelData<DH::dimension, DH::space_dimension>
- thread_data (patch_points,
- n_components, n_datasets, n_subdivisions,
+ thread_data (n_datasets, n_subdivisions,
n_postprocessor_outputs,
mapping,
- cell_to_patch_index_map,
- this->dofs->get_fe(),
- update_flags);
+ this->get_finite_elements(),
+ update_flags,
+ cell_to_patch_index_map);
::dealii::DataOutBase::Patch<DH::dimension, DH::space_dimension> sample_patch;
sample_patch.n_subdivisions = n_subdivisions;
- sample_patch.data.reinit (n_datasets, patch_points.size());
-
+ sample_patch.data.reinit (n_datasets,
+ Utilities::fixed_power<DH::dimension>(n_subdivisions+1));
// now build the patches in parallel
typename DataOut<dim,DH>::cell_iterator
DataOut<dim,DH>::first_cell ()
{
- return this->dofs->begin_active ();
+ return this->triangulation->begin_active ();
}
typename DataOut<dim,DH>::cell_iterator
DataOut<dim,DH>::next_cell (const typename DataOut<dim,DH>::cell_iterator &cell)
{
- // convert the iterator to an
- // active_iterator and advance
- // this to the next active cell
- typename DH::active_cell_iterator active_cell = cell;
+ // convert the iterator to an active_iterator and advance this to the next
+ // active cell
+ typename Triangulation<DH::dimension,DH::space_dimension>::
+ active_cell_iterator active_cell = cell;
++active_cell;
return active_cell;
}
DataOut<dim,DH>::first_locally_owned_cell ()
{
typename DataOut<dim,DH>::cell_iterator
- cell = this->dofs->begin_active ();
+ cell = this->triangulation->begin_active ();
- // skip cells if the current one
- // has no children (is active) and
- // is a ghost or artificial cell
- while ((cell != this->dofs->end()) &&
+ // skip cells if the current one has no children (is active) and is a ghost
+ // or artificial cell
+ while ((cell != this->triangulation->end()) &&
(cell->has_children() == false) &&
!cell->is_locally_owned())
cell = next_cell(cell);
{
typename DataOut<dim,DH>::cell_iterator
cell = next_cell(old_cell);
- while ((cell != this->dofs->end()) &&
+ while ((cell != this->triangulation->end()) &&
(cell->has_children() == false) &&
!cell->is_locally_owned())
cell = next_cell(cell);
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
-for (VEC : SERIAL_VECTORS; DH : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENSIONS)
-{
-// codim=0
-
- template void
- DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension,deal_II_dimension>::
- add_data_vector<VEC> (const VEC &,
- const std::string &,
- const DataVectorType,
- const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
-
- template void
- DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension,deal_II_dimension>::
- add_data_vector<VEC> (const VEC &,
- const std::vector<std::string> &,
- const DataVectorType,
- const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
-
- template void
- DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension,deal_II_dimension>::
- add_data_vector<VEC> (const VEC &,
- const DataPostprocessor<DH<deal_II_dimension,deal_II_dimension>::space_dimension> &);
-
-// stuff needed for face data
-
- template void
- DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension-1,deal_II_dimension>::
- add_data_vector<VEC> (const VEC &,
- const std::string &,
- const DataVectorType,
- const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
-
- template void
- DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension-1,deal_II_dimension>::
- add_data_vector<VEC> (const VEC &,
- const std::vector<std::string> &,
- const DataVectorType,
- const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
-
- template void
- DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension-1,deal_II_dimension>::
- add_data_vector<VEC> (const VEC &,
- const DataPostprocessor<DH<deal_II_dimension,deal_II_dimension>::space_dimension> &);
-
-// things for DataOutRotation
-
- template void
- DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension+1,deal_II_dimension+1>::
- add_data_vector<VEC> (const VEC &,
- const std::string &,
- const DataVectorType,
- const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
-
- template void
- DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension+1,deal_II_dimension+1>::
- add_data_vector<VEC> (const VEC &,
- const std::vector<std::string> &,
- const DataVectorType,
- const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
-
- template void
- DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension+1,deal_II_dimension+1>::
- add_data_vector<VEC> (const VEC &,
- const DataPostprocessor<DH<deal_II_dimension,deal_II_dimension>::space_dimension> &);
-
-// codim 1
-
- #if deal_II_dimension < 3
- template void
- DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension+1>,deal_II_dimension,deal_II_dimension+1>::
- add_data_vector<VEC> (const VEC &,
- const std::string &,
- const DataVectorType,
- const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
-
- template void
- DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension+1>,deal_II_dimension,deal_II_dimension+1>::
- add_data_vector<VEC> (const VEC &,
- const std::vector<std::string> &,
- const DataVectorType,
- const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
-
- template void
- DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension+1>,deal_II_dimension,deal_II_dimension+1>::
- add_data_vector<VEC> (const VEC &,
- const DataPostprocessor<DH<deal_II_dimension,deal_II_dimension+1>::space_dimension> &);
- #endif
-
-
-
-// codim 2
-
- #if deal_II_dimension == 3
- template void
- DataOut_DoFData<DH<1,3>,1,3>::
- add_data_vector<VEC> (const VEC &,
- const std::string &,
- const DataVectorType,
- const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
-
- template void
- DataOut_DoFData<DH<1,3>,1,3>::
- add_data_vector<VEC> (const VEC &,
- const std::vector<std::string> &,
- const DataVectorType,
- const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
-
- template void
- DataOut_DoFData<DH<1,3>,1,3>::
- add_data_vector<VEC> (const VEC &,
- const DataPostprocessor<DH<1,3>::space_dimension> &);
- #endif
-
-}
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
-for (DH : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENSIONS)
+for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : DIMENSIONS)
{
-// codim=0
-
- template void
- DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension,deal_II_dimension>::
- add_data_vector<IndexSet> (const IndexSet &,
- const std::string &,
- const DataVectorType,
- const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
-
- template void
- DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension,deal_II_dimension>::
- add_data_vector<IndexSet> (const IndexSet &,
- const std::vector<std::string> &,
- const DataVectorType,
- const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
-
- template void
- DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension,deal_II_dimension>::
- add_data_vector<IndexSet> (const IndexSet &,
- const DataPostprocessor<DH<deal_II_dimension,deal_II_dimension>::space_dimension> &);
-
-// stuff needed for face data
-
- template void
- DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension-1,deal_II_dimension>::
- add_data_vector<IndexSet> (const IndexSet &,
- const std::string &,
- const DataVectorType,
- const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
-
- template void
- DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension-1,deal_II_dimension>::
- add_data_vector<IndexSet> (const IndexSet &,
- const std::vector<std::string> &,
- const DataVectorType,
- const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
-
- template void
- DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension-1,deal_II_dimension>::
- add_data_vector<IndexSet> (const IndexSet &,
- const DataPostprocessor<DH<deal_II_dimension,deal_II_dimension>::space_dimension> &);
-
-// things for DataOutRotation
-
- template void
- DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension+1,deal_II_dimension+1>::
- add_data_vector<IndexSet> (const IndexSet &,
- const std::string &,
- const DataVectorType,
- const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
-
- template void
- DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension+1,deal_II_dimension+1>::
- add_data_vector<IndexSet> (const IndexSet &,
- const std::vector<std::string> &,
- const DataVectorType,
- const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
-
- template void
- DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension+1,deal_II_dimension+1>::
- add_data_vector<IndexSet> (const IndexSet &,
- const DataPostprocessor<DH<deal_II_dimension,deal_II_dimension>::space_dimension> &);
-
-// codim 1
-
- #if deal_II_dimension < 3
- template void
- DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension+1>,deal_II_dimension,deal_II_dimension+1>::
- add_data_vector<IndexSet> (const IndexSet &,
- const std::string &,
- const DataVectorType,
- const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
-
- template void
- DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension+1>,deal_II_dimension,deal_II_dimension+1>::
- add_data_vector<IndexSet> (const IndexSet &,
- const std::vector<std::string> &,
- const DataVectorType,
- const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
-
- template void
- DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension+1>,deal_II_dimension,deal_II_dimension+1>::
- add_data_vector<IndexSet> (const IndexSet &,
- const DataPostprocessor<DH<deal_II_dimension,deal_II_dimension+1>::space_dimension> &);
- #endif
-
+ namespace internal \{
+ namespace DataOut \{
+#if deal_II_dimension <= deal_II_space_dimension
+ template struct ParallelData<deal_II_dimension,deal_II_space_dimension>;
+#endif
+ \}
+ \}
}
-
for (DH : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENSIONS)
{
- template class DataOut_DoFData<DH<deal_II_dimension>,deal_II_dimension>;
- template class DataOut_DoFData<DH<deal_II_dimension>,deal_II_dimension+1>;
-
- #if deal_II_dimension < 3
- template class DataOut_DoFData<DH<deal_II_dimension>,deal_II_dimension,deal_II_dimension+1>;
- template class DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension+1>,deal_II_dimension,deal_II_dimension+1>;
- #endif
-
- #if deal_II_dimension >= 2
- template class DataOut_DoFData<DH<deal_II_dimension>,deal_II_dimension-1,deal_II_dimension>;
- #endif
-
template class DataOut<deal_II_dimension, DH<deal_II_dimension> >;
#if deal_II_dimension < 3
template class DataOut<deal_II_dimension, DH<deal_II_dimension,deal_II_dimension+1> >;
#endif
#if deal_II_dimension == 3
- template class DataOut_DoFData<DH<1>,1,3>;
- template class DataOut_DoFData<DH<1,3>,1,3>;
template class DataOut<1, DH<1,3> >;
#endif
-
-}
+}
\ No newline at end of file
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1999 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+#include <deal.II/base/quadrature_lib.h>
+#include <deal.II/base/work_stream.h>
+#include <deal.II/base/memory_consumption.h>
+#include <deal.II/lac/vector.h>
+#include <deal.II/lac/block_vector.h>
+#include <deal.II/lac/parallel_vector.h>
+#include <deal.II/lac/parallel_block_vector.h>
+#include <deal.II/lac/petsc_vector.h>
+#include <deal.II/lac/petsc_block_vector.h>
+#include <deal.II/lac/trilinos_vector.h>
+#include <deal.II/lac/trilinos_block_vector.h>
+#include <deal.II/numerics/data_out.h>
+#include <deal.II/numerics/data_out_dof_data.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/dofs/dof_accessor.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/fe/fe.h>
+#include <deal.II/fe/fe_dgq.h>
+#include <deal.II/fe/fe_values.h>
+#include <deal.II/hp/dof_handler.h>
+#include <deal.II/hp/fe_values.h>
+#include <deal.II/fe/mapping_q1.h>
+
+#include <sstream>
+
+DEAL_II_NAMESPACE_OPEN
+
+
+namespace internal
+{
+ namespace DataOut
+ {
+ template <int dim, int spacedim>
+ ParallelDataBase<dim,spacedim>::
+ ParallelDataBase (const unsigned int n_datasets,
+ const unsigned int n_subdivisions,
+ const std::vector<unsigned int> &n_postprocessor_outputs,
+ const Mapping<dim,spacedim> &mapping,
+ const std::vector<std_cxx1x::shared_ptr<dealii::hp::FECollection<dim,spacedim> > > &finite_elements,
+ const UpdateFlags update_flags,
+ const bool use_face_values)
+ :
+ n_datasets (n_datasets),
+ n_subdivisions (n_subdivisions),
+ postprocessed_values (n_postprocessor_outputs.size()),
+ mapping_collection (mapping),
+ finite_elements (finite_elements),
+ update_flags (update_flags)
+ {
+ unsigned int n_q_points = 0;
+ if (use_face_values == false)
+ {
+ dealii::hp::QCollection<dim>
+ quadrature(QIterated<dim>(QTrapez<1>(), n_subdivisions));
+ n_q_points = quadrature[0].size();
+ x_fe_values.resize(this->finite_elements.size());
+ for (unsigned int i=0; i<this->finite_elements.size(); ++i)
+ {
+ // check if there is a finite element that is equal to the
+ // present one, then we can re-use the FEValues object
+ for (unsigned int j=0; j<i; ++j)
+ if (this->finite_elements[i].get() ==
+ this->finite_elements[j].get())
+ {
+ x_fe_values[i] = x_fe_values[j];
+ break;
+ }
+ if (x_fe_values[i].get() == 0)
+ x_fe_values[i].reset(new dealii::hp::FEValues<dim,spacedim>
+ (this->mapping_collection,
+ *this->finite_elements[i],
+ quadrature,
+ this->update_flags));
+ }
+ }
+ else
+ {
+ dealii::hp::QCollection<dim-1>
+ quadrature(QIterated<dim-1>(QTrapez<1>(), n_subdivisions));
+ n_q_points = quadrature[0].size();
+ x_fe_face_values.resize(this->finite_elements.size());
+ for (unsigned int i=0; i<this->finite_elements.size(); ++i)
+ {
+ // check if there is a finite element that is equal to the
+ // present one, then we can re-use the FEValues object
+ for (unsigned int j=0; j<i; ++j)
+ if (this->finite_elements[i].get() ==
+ this->finite_elements[j].get())
+ {
+ x_fe_face_values[i] = x_fe_face_values[j];
+ break;
+ }
+ if (x_fe_face_values[i].get() == 0)
+ x_fe_face_values[i].reset(new dealii::hp::FEFaceValues<dim,spacedim>
+ (this->mapping_collection,
+ *this->finite_elements[i],
+ quadrature,
+ this->update_flags));
+ }
+ }
+
+ patch_values.resize (n_q_points);
+ patch_values_system.resize (n_q_points);
+ patch_gradients.resize (n_q_points);
+ patch_gradients_system.resize (n_q_points);
+ patch_hessians.resize (n_q_points);
+ patch_hessians_system.resize (n_q_points);
+
+ for (unsigned int dataset=0; dataset<n_postprocessor_outputs.size(); ++dataset)
+ if (n_postprocessor_outputs[dataset] != 0)
+ postprocessed_values[dataset]
+ .resize(n_q_points,
+ dealii::Vector<double>(n_postprocessor_outputs[dataset]));
+ }
+
+
+
+
+
+ // implement copy constructor to create a thread's own version of
+ // x_fe_values
+ template <int dim, int spacedim>
+ ParallelDataBase<dim,spacedim>::
+ ParallelDataBase (const ParallelDataBase<dim,spacedim> &data)
+ :
+ n_datasets (data.n_datasets),
+ n_subdivisions (data.n_subdivisions),
+ patch_values (data.patch_values),
+ patch_values_system (data.patch_values_system),
+ patch_gradients (data.patch_gradients),
+ patch_gradients_system (data.patch_gradients_system),
+ patch_hessians (data.patch_hessians),
+ patch_hessians_system (data.patch_hessians_system),
+ postprocessed_values (data.postprocessed_values),
+ mapping_collection (data.mapping_collection),
+ finite_elements (data.finite_elements),
+ update_flags (data.update_flags)
+ {
+ if (data.x_fe_values.empty() == false)
+ {
+ Assert(data.x_fe_face_values.empty() == true, ExcInternalError());
+ dealii::hp::QCollection<dim>
+ quadrature(QIterated<dim>(QTrapez<1>(), n_subdivisions));
+ x_fe_values.resize(this->finite_elements.size());
+ for (unsigned int i=0; i<this->finite_elements.size(); ++i)
+ {
+ // check if there is a finite element that is equal to the
+ // present one, then we can re-use the FEValues object
+ for (unsigned int j=0; j<i; ++j)
+ if (this->finite_elements[i].get() ==
+ this->finite_elements[j].get())
+ {
+ x_fe_values[i] = x_fe_values[j];
+ break;
+ }
+ if (x_fe_values[i].get() == 0)
+ x_fe_values[i].reset(new dealii::hp::FEValues<dim,spacedim>
+ (this->mapping_collection,
+ *this->finite_elements[i],
+ quadrature,
+ this->update_flags));
+ }
+ }
+ else
+ {
+ dealii::hp::QCollection<dim-1>
+ quadrature(QIterated<dim-1>(QTrapez<1>(), n_subdivisions));
+ x_fe_face_values.resize(this->finite_elements.size());
+ for (unsigned int i=0; i<this->finite_elements.size(); ++i)
+ {
+ // check if there is a finite element that is equal to the
+ // present one, then we can re-use the FEValues object
+ for (unsigned int j=0; j<i; ++j)
+ if (this->finite_elements[i].get() ==
+ this->finite_elements[j].get())
+ {
+ x_fe_face_values[i] = x_fe_face_values[j];
+ break;
+ }
+ if (x_fe_face_values[i].get() == 0)
+ x_fe_face_values[i].reset(new dealii::hp::FEFaceValues<dim,spacedim>
+ (this->mapping_collection,
+ *this->finite_elements[i],
+ quadrature,
+ this->update_flags));
+ }
+ }
+ }
+
+
+
+ template <int dim, int spacedim>
+ template <typename DH>
+ void
+ ParallelDataBase<dim,spacedim>::
+ reinit_all_fe_values(std::vector<std_cxx1x::shared_ptr<DataEntryBase<DH> > > &dof_data,
+ const typename dealii::Triangulation<dim,spacedim>::cell_iterator &cell,
+ const unsigned int face)
+ {
+ for (unsigned int dataset=0; dataset<dof_data.size(); ++dataset)
+ {
+ bool duplicate = false;
+ for (unsigned int j=0; j<dataset; ++j)
+ if (finite_elements[dataset].get() == finite_elements[j].get())
+ duplicate = true;
+ if (duplicate == false)
+ {
+ typename DH::active_cell_iterator dh_cell(&cell->get_triangulation(),
+ cell->level(),
+ cell->index(),
+ dof_data[dataset]->dof_handler);
+ if (x_fe_values.empty())
+ {
+ AssertIndexRange(face,
+ GeometryInfo<dim>::faces_per_cell);
+ x_fe_face_values[dataset]->reinit(dh_cell, face);
+ }
+ else
+ x_fe_values[dataset]->reinit (dh_cell);
+ }
+ }
+ if (dof_data.empty())
+ {
+ if (x_fe_values.empty())
+ {
+ AssertIndexRange(face,
+ GeometryInfo<dim>::faces_per_cell);
+ x_fe_face_values[0]->reinit(cell, face);
+ }
+ else
+ x_fe_values[0]->reinit (cell);
+ }
+ }
+
+
+
+ template <int dim, int spacedim>
+ const FEValuesBase<dim,spacedim> &
+ ParallelDataBase<dim,spacedim>::
+ get_present_fe_values(const unsigned int dataset) const
+ {
+ AssertIndexRange(dataset, finite_elements.size());
+ if (x_fe_values.empty())
+ return x_fe_face_values[dataset]->get_present_fe_values();
+ else
+ return x_fe_values[dataset]->get_present_fe_values();
+ }
+
+
+
+ template <int dim, int spacedim>
+ void
+ ParallelDataBase<dim,spacedim>::
+ resize_system_vectors(const unsigned int n_components)
+ {
+ Assert(patch_values_system.size() > 0, ExcInternalError());
+ AssertDimension(patch_values_system.size(),
+ patch_gradients_system.size());
+ AssertDimension(patch_values_system.size(),
+ patch_hessians_system.size());
+ if (patch_values_system[0].size() == n_components)
+ return;
+ for (unsigned int k=0; k<patch_values_system.size(); ++k)
+ {
+ patch_values_system[k].reinit(n_components);
+ patch_gradients_system[k].resize(n_components);
+ patch_hessians_system[k].resize(n_components);
+ }
+ }
+
+
+
+
+ /**
+ * In a WorkStream context, use this function to append the patch computed
+ * by the parallel stage to the array of patches.
+ */
+ template <int dim, int spacedim>
+ void
+ append_patch_to_list (const DataOutBase::Patch<dim,spacedim> &patch,
+ std::vector<DataOutBase::Patch<dim,spacedim> > &patches)
+ {
+ patches.push_back (patch);
+ patches.back().patch_index = patches.size()-1;
+ }
+ }
+}
+
+namespace internal
+{
+ namespace DataOut
+ {
+ template <class DH>
+ DataEntryBase<DH>::DataEntryBase (const DH *dofs,
+ const std::vector<std::string> &names_in,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &data_component_interpretation)
+ :
+ dof_handler (dofs, typeid(dealii::DataOut_DoFData<DH,DH::dimension,DH::space_dimension>).name()),
+ names(names_in),
+ data_component_interpretation (data_component_interpretation),
+ postprocessor(0, typeid(*this).name()),
+ n_output_variables(names.size())
+ {
+ Assert (names.size() == data_component_interpretation.size(),
+ ExcDimensionMismatch(data_component_interpretation.size(),
+ names.size()));
+
+ // check that the names use only allowed characters
+ for (unsigned int i=0; i<names.size(); ++i)
+ Assert (names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789_<>()") == std::string::npos,
+ typename dealii::DataOut<DH::dimension>::
+ ExcInvalidCharacter (names[i],
+ names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789_<>()")));
+ }
+
+
+
+ template <class DH>
+ DataEntryBase<DH>::DataEntryBase (const DH *dofs,
+ const DataPostprocessor<DH::space_dimension> *data_postprocessor)
+ :
+ dof_handler (dofs, typeid(dealii::DataOut_DoFData<DH,DH::dimension,DH::space_dimension>).name()),
+ names(data_postprocessor->get_names()),
+ data_component_interpretation (data_postprocessor->get_data_component_interpretation()),
+ postprocessor(data_postprocessor, typeid(*this).name()),
+ n_output_variables(names.size())
+ {
+ Assert (data_postprocessor->get_names().size()
+ ==
+ data_postprocessor->get_data_component_interpretation().size(),
+ ExcDimensionMismatch (data_postprocessor->get_names().size(),
+ data_postprocessor->get_data_component_interpretation().size()));
+
+ // check that the names use only allowed characters
+ for (unsigned int i=0; i<names.size(); ++i)
+ Assert (names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789_<>()") == std::string::npos,
+ typename dealii::DataOut<DH::dimension>::
+ ExcInvalidCharacter (names[i],
+ names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789_<>()")));
+ }
+
+
+
+ template <class DH>
+ DataEntryBase<DH>::~DataEntryBase ()
+ {}
+
+
+
+ /**
+ * Class that stores a pointer to a vector of type equal to the template
+ * argument, and provides the functions to extract data from it.
+ *
+ * @author Wolfgang Bangerth, 2004
+ */
+ template <class DH, typename VectorType>
+ class DataEntry : public DataEntryBase<DH>
+ {
+ public:
+ /**
+ * Constructor. Give a list of names for the individual components of
+ * the vector and their interpretation as scalar or vector data. This
+ * constructor assumes that no postprocessor is going to be used.
+ */
+ DataEntry (const DH *dofs,
+ const VectorType *data,
+ const std::vector<std::string> &names,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &data_component_interpretation);
+
+ /**
+ * Constructor when a data postprocessor is going to be used. In that
+ * case, the names and vector declarations are going to be acquired from
+ * the postprocessor.
+ */
+ DataEntry (const DH *dofs,
+ const VectorType *data,
+ const DataPostprocessor<DH::space_dimension> *data_postprocessor);
+
+ /**
+ * Assuming that the stored vector is a cell vector, extract the given
+ * element from it.
+ */
+ virtual
+ double
+ get_cell_data_value (const unsigned int cell_number) const;
+
+ /**
+ * Given a FEValuesBase object, extract the values on the present cell
+ * from the vector we actually store.
+ */
+ virtual
+ void
+ get_function_values (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
+ std::vector<double> &patch_values) const;
+
+ /**
+ * Given a FEValuesBase object, extract the values on the present cell
+ * from the vector we actually store. This function does the same as the
+ * one above but for vector-valued finite elements.
+ */
+ virtual
+ void
+ get_function_values (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
+ std::vector<dealii::Vector<double> > &patch_values_system) const;
+
+ /**
+ * Given a FEValuesBase object, extract the gradients on the present
+ * cell from the vector we actually store.
+ */
+ virtual
+ void
+ get_function_gradients (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
+ std::vector<Tensor<1,DH::space_dimension> > &patch_gradients) const;
+
+ /**
+ * Given a FEValuesBase object, extract the gradients on the present
+ * cell from the vector we actually store. This function does the same
+ * as the one above but for vector-valued finite elements.
+ */
+ virtual
+ void
+ get_function_gradients (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
+ std::vector<std::vector<Tensor<1,DH::space_dimension> > > &patch_gradients_system) const;
+
+ /**
+ * Given a FEValuesBase object, extract the second derivatives on the
+ * present cell from the vector we actually store.
+ */
+ virtual
+ void
+ get_function_hessians (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
+ std::vector<Tensor<2,DH::space_dimension> > &patch_hessians) const;
+
+ /**
+ * Given a FEValuesBase object, extract the second derivatives on the
+ * present cell from the vector we actually store. This function does
+ * the same as the one above but for vector-valued finite elements.
+ */
+ virtual
+ void
+ get_function_hessians (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
+ std::vector<std::vector< Tensor<2,DH::space_dimension> > > &patch_hessians_system) const;
+
+ /**
+ * Clear all references to the vectors.
+ */
+ virtual void clear ();
+
+ /**
+ * Determine an estimate for the memory consumption (in bytes) of this
+ * object.
+ */
+ virtual std::size_t memory_consumption () const;
+
+ private:
+ /**
+ * Pointer to the data vector. Note that ownership of the vector pointed
+ * to remains with the caller of this class.
+ */
+ const VectorType *vector;
+ };
+
+
+
+ template <class DH, class VectorType>
+ DataEntry<DH,VectorType>::
+ DataEntry (const DH *dofs,
+ const VectorType *data,
+ const std::vector<std::string> &names,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &data_component_interpretation)
+ :
+ DataEntryBase<DH> (dofs, names, data_component_interpretation),
+ vector (data)
+ {}
+
+
+
+ template <class DH, class VectorType>
+ DataEntry<DH,VectorType>::
+ DataEntry (const DH *dofs,
+ const VectorType *data,
+ const DataPostprocessor<DH::space_dimension> *data_postprocessor)
+ :
+ DataEntryBase<DH> (dofs, data_postprocessor),
+ vector (data)
+ {}
+
+
+ namespace
+ {
+ template <class VectorType>
+ double
+ get_vector_element (const VectorType &vector,
+ const unsigned int cell_number)
+ {
+ return vector[cell_number];
+ }
+
+
+ double
+ get_vector_element (const IndexSet &is,
+ const unsigned int cell_number)
+ {
+ return (is.is_element(cell_number) ? 1 : 0);
+ }
+ }
+
+
+
+ template <class DH, class VectorType>
+ double
+ DataEntry<DH,VectorType>::
+ get_cell_data_value (const unsigned int cell_number) const
+ {
+ return get_vector_element(*vector, cell_number);
+ }
+
+
+
+ template <class DH, class VectorType>
+ void
+ DataEntry<DH,VectorType>::
+ get_function_values (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
+ std::vector<dealii::Vector<double> > &patch_values_system) const
+ {
+ fe_patch_values.get_function_values (*vector, patch_values_system);
+ }
+
+
+
+ template <class DH, typename VectorType>
+ void
+ DataEntry<DH,VectorType>::
+ get_function_values (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
+ std::vector<double> &patch_values) const
+ {
+ fe_patch_values.get_function_values (*vector, patch_values);
+ }
+
+
+
+ template <class DH, class VectorType>
+ void
+ DataEntry<DH,VectorType>::
+ get_function_gradients (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
+ std::vector<std::vector<Tensor<1,DH::space_dimension> > > &patch_gradients_system) const
+ {
+ fe_patch_values.get_function_gradients (*vector, patch_gradients_system);
+ }
+
+
+
+ template <class DH, typename VectorType>
+ void
+ DataEntry<DH,VectorType>::
+ get_function_gradients (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
+ std::vector<Tensor<1,DH::space_dimension> > &patch_gradients) const
+ {
+ fe_patch_values.get_function_gradients (*vector, patch_gradients);
+ }
+
+
+
+ template <class DH, class VectorType>
+ void
+ DataEntry<DH,VectorType>::
+ get_function_hessians (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
+ std::vector<std::vector<Tensor<2,DH::space_dimension> > > &patch_hessians_system) const
+ {
+ fe_patch_values.get_function_hessians (*vector, patch_hessians_system);
+ }
+
+
+
+ template <class DH, typename VectorType>
+ void
+ DataEntry<DH,VectorType>::
+ get_function_hessians (const FEValuesBase<DH::dimension,DH::space_dimension> &fe_patch_values,
+ std::vector<Tensor<2,DH::space_dimension> > &patch_hessians) const
+ {
+ fe_patch_values.get_function_hessians (*vector, patch_hessians);
+ }
+
+
+
+ template <class DH, typename VectorType>
+ std::size_t
+ DataEntry<DH,VectorType>::memory_consumption () const
+ {
+ return (sizeof (vector) +
+ MemoryConsumption::memory_consumption (this->names));
+ }
+
+
+
+ template <class DH, class VectorType>
+ void
+ DataEntry<DH,VectorType>::clear ()
+ {
+ vector = 0;
+ this->dof_handler = 0;
+ }
+ }
+}
+
+
+
+template <class DH,
+ int patch_dim, int patch_space_dim>
+DataOut_DoFData<DH,patch_dim,patch_space_dim>::DataOut_DoFData ()
+ :
+ triangulation(0,typeid(*this).name()),
+ dofs(0,typeid(*this).name())
+{}
+
+
+
+template <class DH, int patch_dim, int patch_space_dim>
+DataOut_DoFData<DH,patch_dim,patch_space_dim>::~DataOut_DoFData ()
+{
+ clear ();
+}
+
+
+
+template <class DH, int patch_dim, int patch_space_dim>
+void
+DataOut_DoFData<DH,patch_dim,patch_space_dim>::
+attach_dof_handler (const DH &d)
+{
+ Assert (dof_data.size() == 0, ExcOldDataStillPresent());
+ Assert (cell_data.size() == 0, ExcOldDataStillPresent());
+
+ triangulation = SmartPointer<const Triangulation<DH::dimension,DH::space_dimension> >(&d.get_tria(), typeid(*this).name());
+ dofs = SmartPointer<const DH>(&d, typeid(*this).name());
+}
+
+
+
+template <class DH, int patch_dim, int patch_space_dim>
+void
+DataOut_DoFData<DH,patch_dim,patch_space_dim>::
+attach_triangulation (const Triangulation<DH::dimension,DH::space_dimension> &tria)
+{
+ Assert (dof_data.size() == 0, ExcOldDataStillPresent());
+ Assert (cell_data.size() == 0, ExcOldDataStillPresent());
+
+ triangulation = SmartPointer<const Triangulation<DH::dimension,DH::space_dimension> >(&tria, typeid(*this).name());
+}
+
+
+
+
+template <class DH,
+ int patch_dim, int patch_space_dim>
+template <class VECTOR>
+void
+DataOut_DoFData<DH,patch_dim,patch_space_dim>::
+add_data_vector (const VECTOR &vec,
+ const std::string &name,
+ const DataVectorType type,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &data_component_interpretation)
+{
+ Assert (triangulation != 0, ExcNoTriangulationSelected ());
+ const unsigned int n_components =
+ dofs != 0 ? dofs->get_fe().n_components () : 1;
+
+ std::vector<std::string> names;
+ // if only one component or vector is cell vector: we only need one name
+ if ((n_components == 1) ||
+ (vec.size() == triangulation->n_active_cells()))
+ {
+ names.resize (1, name);
+ }
+ else
+ // otherwise append _i to the given name
+ {
+ names.resize (n_components);
+ for (unsigned int i=0; i<n_components; ++i)
+ {
+ std::ostringstream namebuf;
+ namebuf << '_' << i;
+ names[i] = name + namebuf.str();
+ }
+ }
+
+ add_data_vector (vec, names, type, data_component_interpretation);
+}
+
+
+
+template <class DH,
+ int patch_dim, int patch_space_dim>
+template <class VECTOR>
+void
+DataOut_DoFData<DH,patch_dim,patch_space_dim>::
+add_data_vector (const VECTOR &vec,
+ const std::vector<std::string> &names,
+ const DataVectorType type,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &data_component_interpretation_)
+{
+ Assert (triangulation != 0, ExcNoTriangulationSelected ());
+
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &
+ data_component_interpretation
+ = (data_component_interpretation_.size() != 0
+ ?
+ data_component_interpretation_
+ :
+ std::vector<DataComponentInterpretation::DataComponentInterpretation>
+ (names.size(), DataComponentInterpretation::component_is_scalar));
+
+ // either cell data and one name,
+ // or dof data and n_components names
+ DataVectorType actual_type = type;
+ if (type == type_automatic)
+ {
+ if (vec.size() == triangulation->n_active_cells())
+ actual_type = type_cell_data;
+ else
+ actual_type = type_dof_data;
+ }
+
+ switch (actual_type)
+ {
+ case type_cell_data:
+ Assert (vec.size() == triangulation->n_active_cells(),
+ ExcDimensionMismatch (vec.size(),
+ triangulation->n_active_cells()));
+ Assert (names.size() == 1,
+ ExcInvalidNumberOfNames (names.size(), 1));
+ break;
+
+ case type_dof_data:
+ Assert (dofs != 0, ExcNoDoFHandlerSelected ());
+ Assert (vec.size() == dofs->n_dofs(),
+ ExcInvalidVectorSize (vec.size(),
+ dofs->n_dofs(),
+ triangulation->n_active_cells()));
+ Assert (names.size() == dofs->get_fe().n_components(),
+ ExcInvalidNumberOfNames (names.size(), dofs->get_fe().n_components()));
+ break;
+
+ case type_automatic:
+ // this case should have been handled above...
+ Assert (false, ExcInternalError());
+ }
+
+ internal::DataOut::DataEntryBase<DH> *new_entry
+ = new internal::DataOut::DataEntry<DH,VECTOR>(dofs, &vec, names,
+ data_component_interpretation);
+ if (actual_type == type_dof_data)
+ dof_data.push_back (std_cxx1x::shared_ptr<internal::DataOut::DataEntryBase<DH> >(new_entry));
+ else
+ cell_data.push_back (std_cxx1x::shared_ptr<internal::DataOut::DataEntryBase<DH> >(new_entry));
+}
+
+
+
+template <class DH,
+ int patch_dim, int patch_space_dim>
+template <class VECTOR>
+void
+DataOut_DoFData<DH,patch_dim,patch_space_dim>::
+add_data_vector (const VECTOR &vec,
+ const DataPostprocessor<DH::space_dimension> &data_postprocessor)
+{
+ // this is a specialized version of the other function where we have a
+ // postprocessor. if we do, we know that we have type_dof_data, which makes
+ // things a bit simpler, we also don't need to deal with some of the other
+ // stuff and use a different constructor of DataEntry
+
+ Assert (dofs != 0, ExcNoDoFHandlerSelected ());
+
+ Assert (vec.size() == dofs->n_dofs(),
+ ExcInvalidVectorSize (vec.size(),
+ dofs->n_dofs(),
+ dofs->get_tria().n_active_cells()));
+
+ internal::DataOut::DataEntryBase<DH> *new_entry
+ = new internal::DataOut::DataEntry<DH,VECTOR>(dofs, &vec, &data_postprocessor);
+ dof_data.push_back (std_cxx1x::shared_ptr<internal::DataOut::DataEntryBase<DH> >(new_entry));
+}
+
+
+
+template <class DH,
+ int patch_dim, int patch_space_dim>
+template <class VECTOR>
+void
+DataOut_DoFData<DH,patch_dim,patch_space_dim>::
+add_data_vector (const DH &dof_handler,
+ const VECTOR &vec,
+ const DataPostprocessor<DH::space_dimension> &data_postprocessor)
+{
+ // this is a specialized version of the other function where we have a
+ // postprocessor. if we do, we know that we have type_dof_data, which makes
+ // things a bit simpler, we also don't need to deal with some of the other
+ // stuff and use a different constructor of DataEntry
+
+ AssertDimension (vec.size(), dof_handler.n_dofs());
+
+ internal::DataOut::DataEntryBase<DH> *new_entry
+ = new internal::DataOut::DataEntry<DH,VECTOR>(&dof_handler, &vec, &data_postprocessor);
+ dof_data.push_back (std_cxx1x::shared_ptr<internal::DataOut::DataEntryBase<DH> >(new_entry));
+}
+
+
+
+template <class DH,
+ int patch_dim, int patch_space_dim>
+template <class VECTOR>
+void
+DataOut_DoFData<DH,patch_dim,patch_space_dim>::
+add_data_vector (const DH &dof_handler,
+ const VECTOR &data,
+ const std::string &name,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &data_component_interpretation)
+{
+ const unsigned int n_components = dof_handler.get_fe().n_components ();
+
+ std::vector<std::string> names;
+ // if only one component: we only need one name
+ if (n_components == 1)
+ names.resize (1, name);
+ else
+ // otherwise append _i to the given name
+ {
+ names.resize (n_components);
+ for (unsigned int i=0; i<n_components; ++i)
+ {
+ std::ostringstream namebuf;
+ namebuf << '_' << i;
+ names[i] = name + namebuf.str();
+ }
+ }
+
+ add_data_vector (dof_handler, data, names, data_component_interpretation);
+}
+
+
+
+template <class DH,
+ int patch_dim, int patch_space_dim>
+template <class VECTOR>
+void
+DataOut_DoFData<DH,patch_dim,patch_space_dim>::
+add_data_vector (const DH &dof_handler,
+ const VECTOR &data,
+ const std::vector<std::string> &names,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &data_component_interpretation_)
+{
+ // this is an extended version of the other functions where we pass a vector
+ // together with its DoFHandler. if we do, we know that we have
+ // type_dof_data, which makes things a bit simpler
+ if (triangulation == 0)
+ triangulation = SmartPointer<const Triangulation<DH::dimension,DH::space_dimension> >(&dof_handler.get_tria(), typeid(*this).name());
+
+ Assert (&dof_handler.get_tria() == triangulation,
+ ExcMessage("The triangulation attached to the DoFHandler does not "
+ "match with the one set previously"));
+
+ Assert (data.size() == dof_handler.n_dofs(),
+ ExcDimensionMismatch (data.size(), dof_handler.n_dofs()));
+
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &
+ data_component_interpretation
+ = (data_component_interpretation_.size() != 0
+ ?
+ data_component_interpretation_
+ :
+ std::vector<DataComponentInterpretation::DataComponentInterpretation>
+ (names.size(), DataComponentInterpretation::component_is_scalar));
+
+ internal::DataOut::DataEntryBase<DH> *new_entry
+ = new internal::DataOut::DataEntry<DH,VECTOR>(&dof_handler, &data, names,
+ data_component_interpretation);
+ dof_data.push_back (std_cxx1x::shared_ptr<internal::DataOut::DataEntryBase<DH> >(new_entry));
+}
+
+
+
+template <class DH,
+ int patch_dim, int patch_space_dim>
+void DataOut_DoFData<DH,patch_dim,patch_space_dim>::clear_data_vectors ()
+{
+ dof_data.erase (dof_data.begin(), dof_data.end());
+ cell_data.erase (cell_data.begin(), cell_data.end());
+
+ // delete patches
+ std::vector<Patch> dummy;
+ patches.swap (dummy);
+}
+
+
+
+template <class DH,
+ int patch_dim, int patch_space_dim>
+void
+DataOut_DoFData<DH,patch_dim,patch_space_dim>::
+clear_input_data_references ()
+{
+ for (unsigned int i=0; i<dof_data.size(); ++i)
+ dof_data[i]->clear ();
+
+ for (unsigned int i=0; i<cell_data.size(); ++i)
+ cell_data[i]->clear ();
+
+ if (dofs != 0)
+ dofs = 0;
+}
+
+
+
+template <class DH,
+ int patch_dim, int patch_space_dim>
+void
+DataOut_DoFData<DH,patch_dim,patch_space_dim>::clear ()
+{
+ dof_data.erase (dof_data.begin(), dof_data.end());
+ cell_data.erase (cell_data.begin(), cell_data.end());
+
+ if (dofs != 0)
+ dofs = 0;
+
+ // delete patches
+ std::vector<Patch> dummy;
+ patches.swap (dummy);
+}
+
+
+
+template <class DH,
+ int patch_dim, int patch_space_dim>
+std::vector<std::string>
+DataOut_DoFData<DH,patch_dim,patch_space_dim>::
+get_dataset_names () const
+{
+ std::vector<std::string> names;
+ // collect the names of dof
+ // and cell data
+ typedef
+ typename std::vector<std_cxx1x::shared_ptr<internal::DataOut::DataEntryBase<DH> > >::const_iterator
+ data_iterator;
+
+ for (data_iterator d=dof_data.begin();
+ d!=dof_data.end(); ++d)
+ for (unsigned int i=0; i<(*d)->names.size(); ++i)
+ names.push_back ((*d)->names[i]);
+ for (data_iterator d=cell_data.begin(); d!=cell_data.end(); ++d)
+ {
+ Assert ((*d)->names.size() == 1, ExcInternalError());
+ names.push_back ((*d)->names[0]);
+ }
+
+ return names;
+}
+
+
+
+template <class DH,
+ int patch_dim, int patch_space_dim>
+std::vector<std_cxx1x::tuple<unsigned int, unsigned int, std::string> >
+DataOut_DoFData<DH,patch_dim,patch_space_dim>::get_vector_data_ranges () const
+{
+ std::vector<std_cxx1x::tuple<unsigned int, unsigned int, std::string> >
+ ranges;
+
+ // collect the ranges of dof
+ // and cell data
+ typedef
+ typename std::vector<std_cxx1x::shared_ptr<internal::DataOut::DataEntryBase<DH> > >::const_iterator
+ data_iterator;
+
+ unsigned int output_component = 0;
+ for (data_iterator d=dof_data.begin();
+ d!=dof_data.end(); ++d)
+ for (unsigned int i=0; i<(*d)->n_output_variables;
+ ++i, ++output_component)
+ // see what kind of data we have
+ // here. note that for the purpose of
+ // the current function all we care
+ // about is vector data
+ if ((*d)->data_component_interpretation[i] ==
+ DataComponentInterpretation::component_is_part_of_vector)
+ {
+ // ensure that there is a
+ // continuous number of next
+ // space_dim components that all
+ // deal with vectors
+ Assert (i+patch_space_dim <=
+ (*d)->n_output_variables,
+ ExcInvalidVectorDeclaration (i,
+ (*d)->names[i]));
+ for (unsigned int dd=1; dd<patch_space_dim; ++dd)
+ Assert ((*d)->data_component_interpretation[i+dd]
+ ==
+ DataComponentInterpretation::component_is_part_of_vector,
+ ExcInvalidVectorDeclaration (i,
+ (*d)->names[i]));
+
+ // all seems alright, so figure out
+ // whether there is a common name
+ // to these components. if not,
+ // leave the name empty and let the
+ // output format writer decide what
+ // to do here
+ std::string name = (*d)->names[i];
+ for (unsigned int dd=1; dd<patch_space_dim; ++dd)
+ if (name != (*d)->names[i+dd])
+ {
+ name = "";
+ break;
+ }
+
+ // finally add a corresponding
+ // range
+ std_cxx1x::tuple<unsigned int, unsigned int, std::string>
+ range (output_component,
+ output_component+patch_space_dim-1,
+ name);
+
+ ranges.push_back (range);
+
+ // increase the 'component' counter
+ // by the appropriate amount, same
+ // for 'i', since we have already
+ // dealt with all these components
+ output_component += patch_space_dim-1;
+ i += patch_space_dim-1;
+ }
+
+ // note that we do not have to traverse the
+ // list of cell data here because cell data
+ // is one value per (logical) cell and
+ // therefore cannot be a vector
+
+ // as a final check, the 'component'
+ // counter should be at the total number of
+ // components added up now
+#ifdef DEBUG
+ unsigned int n_output_components = 0;
+ for (data_iterator d=dof_data.begin();
+ d!=dof_data.end(); ++d)
+ n_output_components += (*d)->n_output_variables;
+ Assert (output_component == n_output_components,
+ ExcInternalError());
+#endif
+
+ return ranges;
+}
+
+
+
+template <class DH,
+ int patch_dim, int patch_space_dim>
+const std::vector< dealii::DataOutBase::Patch<patch_dim, patch_space_dim> > &
+DataOut_DoFData<DH,patch_dim,patch_space_dim>::get_patches () const
+{
+ return patches;
+}
+
+
+
+template <class DH,
+ int patch_dim, int patch_space_dim>
+std::vector<std_cxx1x::shared_ptr<dealii::hp::FECollection<DH::dimension,DH::space_dimension> > >
+DataOut_DoFData<DH,patch_dim,patch_space_dim>::get_finite_elements() const
+{
+ const unsigned int dhdim = DH::dimension;
+ const unsigned int dhspacedim = DH::space_dimension;
+ std::vector<std_cxx1x::shared_ptr<dealii::hp::FECollection<dhdim,dhspacedim> > >
+ finite_elements(this->dof_data.size());
+ for (unsigned int i=0; i<this->dof_data.size(); ++i)
+ {
+ Assert (dof_data[i]->dof_handler != 0, ExcNoDoFHandlerSelected ());
+
+ // avoid creating too many finite elements and doing a lot of work on
+ // initializing FEValues downstream: if two DoFHandlers are the same
+ // (checked by pointer comparison), we can re-use the shared_ptr object
+ // for the second one. We cannot check for finite element equalities
+ // because we need different FEValues objects for different dof
+ // handlers.
+ bool duplicate = false;
+ for (unsigned int j=0; j<i; ++j)
+ if (dof_data[i]->dof_handler == dof_data[j]->dof_handler)
+ {
+ finite_elements[i] = finite_elements[j];
+ duplicate = true;
+ }
+ if (duplicate == false)
+ finite_elements[i].reset(new dealii::hp::FECollection<dhdim,dhspacedim>
+ (this->dof_data[i]->dof_handler->get_fe()));
+ }
+ if (this->dof_data.empty())
+ {
+ finite_elements.resize(1);
+ finite_elements[0].reset(new dealii::hp::FECollection<dhdim,dhspacedim>
+ (FE_DGQ<dhdim,dhspacedim>(0)));
+ }
+ return finite_elements;
+}
+
+
+
+template <class DH,
+ int patch_dim, int patch_space_dim>
+std::size_t
+DataOut_DoFData<DH,patch_dim,patch_space_dim>::memory_consumption () const
+{
+ return (DataOutInterface<patch_dim,patch_space_dim>::memory_consumption () +
+ MemoryConsumption::memory_consumption (dofs) +
+ MemoryConsumption::memory_consumption (patches));
+}
+
+// explicit instantiations
+#ifndef PETSC_USE_COMPLEX
+ #include "data_out_dof_data.inst"
+#endif
+
+DEAL_II_NAMESPACE_CLOSE
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 2010 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+for (VEC : SERIAL_VECTORS; DH : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENSIONS)
+{
+// codim=0
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension,deal_II_dimension>::
+ add_data_vector<VEC> (const VEC &,
+ const std::string &,
+ const DataVectorType,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension,deal_II_dimension>::
+ add_data_vector<VEC> (const VEC &,
+ const std::vector<std::string> &,
+ const DataVectorType,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension,deal_II_dimension>::
+ add_data_vector<VEC> (const VEC &,
+ const DataPostprocessor<DH<deal_II_dimension,deal_II_dimension>::space_dimension> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension,deal_II_dimension>::
+ add_data_vector<VEC> (const DH<deal_II_dimension,deal_II_dimension> &,
+ const VEC &,
+ const std::string &,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension,deal_II_dimension>::
+ add_data_vector<VEC> (const DH<deal_II_dimension,deal_II_dimension> &,
+ const VEC &,
+ const std::vector<std::string> &,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension,deal_II_dimension>::
+ add_data_vector<VEC> (const DH<deal_II_dimension,deal_II_dimension> &,
+ const VEC &,
+ const DataPostprocessor<DH<deal_II_dimension,deal_II_dimension>::space_dimension> &);
+
+
+
+// stuff needed for face data
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension-1,deal_II_dimension>::
+ add_data_vector<VEC> (const VEC &,
+ const std::string &,
+ const DataVectorType,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension-1,deal_II_dimension>::
+ add_data_vector<VEC> (const VEC &,
+ const std::vector<std::string> &,
+ const DataVectorType,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension-1,deal_II_dimension>::
+ add_data_vector<VEC> (const VEC &,
+ const DataPostprocessor<DH<deal_II_dimension,deal_II_dimension>::space_dimension> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension-1,deal_II_dimension>::
+ add_data_vector<VEC> (const DH<deal_II_dimension,deal_II_dimension> &,
+ const VEC &,
+ const std::string &,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension-1,deal_II_dimension>::
+ add_data_vector<VEC> (const DH<deal_II_dimension,deal_II_dimension> &,
+ const VEC &,
+ const std::vector<std::string> &,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension-1,deal_II_dimension>::
+ add_data_vector<VEC> (const DH<deal_II_dimension,deal_II_dimension> &,
+ const VEC &,
+ const DataPostprocessor<DH<deal_II_dimension,deal_II_dimension>::space_dimension> &);
+
+
+
+// things for DataOutRotation
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension+1,deal_II_dimension+1>::
+ add_data_vector<VEC> (const VEC &,
+ const std::string &,
+ const DataVectorType,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension+1,deal_II_dimension+1>::
+ add_data_vector<VEC> (const VEC &,
+ const std::vector<std::string> &,
+ const DataVectorType,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension+1,deal_II_dimension+1>::
+ add_data_vector<VEC> (const VEC &,
+ const DataPostprocessor<DH<deal_II_dimension,deal_II_dimension>::space_dimension> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension+1,deal_II_dimension+1>::
+ add_data_vector<VEC> (const DH<deal_II_dimension,deal_II_dimension> &,
+ const VEC &,
+ const std::string &,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension+1,deal_II_dimension+1>::
+ add_data_vector<VEC> (const DH<deal_II_dimension,deal_II_dimension> &,
+ const VEC &,
+ const std::vector<std::string> &,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension+1,deal_II_dimension+1>::
+ add_data_vector<VEC> (const DH<deal_II_dimension,deal_II_dimension> &,
+ const VEC &,
+ const DataPostprocessor<DH<deal_II_dimension,deal_II_dimension>::space_dimension> &);
+
+
+
+// codim 1
+
+ #if deal_II_dimension < 3
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension+1>,deal_II_dimension,deal_II_dimension+1>::
+ add_data_vector<VEC> (const VEC &,
+ const std::string &,
+ const DataVectorType,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension+1>,deal_II_dimension,deal_II_dimension+1>::
+ add_data_vector<VEC> (const VEC &,
+ const std::vector<std::string> &,
+ const DataVectorType,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension+1>,deal_II_dimension,deal_II_dimension+1>::
+ add_data_vector<VEC> (const VEC &,
+ const DataPostprocessor<DH<deal_II_dimension,deal_II_dimension+1>::space_dimension> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension+1>,deal_II_dimension,deal_II_dimension+1>::
+ add_data_vector<VEC> (const DH<deal_II_dimension,deal_II_dimension+1> &,
+ const VEC &,
+ const std::string &,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension+1>,deal_II_dimension,deal_II_dimension+1>::
+ add_data_vector<VEC> (const DH<deal_II_dimension,deal_II_dimension+1> &,
+ const VEC &,
+ const std::vector<std::string> &,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension+1>,deal_II_dimension,deal_II_dimension+1>::
+ add_data_vector<VEC> (const DH<deal_II_dimension,deal_II_dimension+1> &,
+ const VEC &,
+ const DataPostprocessor<DH<deal_II_dimension,deal_II_dimension+1>::space_dimension> &);
+ #endif
+
+
+
+// codim 2
+
+ #if deal_II_dimension == 3
+ template void
+ DataOut_DoFData<DH<1,3>,1,3>::
+ add_data_vector<VEC> (const VEC &,
+ const std::string &,
+ const DataVectorType,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<1,3>,1,3>::
+ add_data_vector<VEC> (const VEC &,
+ const std::vector<std::string> &,
+ const DataVectorType,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<1,3>,1,3>::
+ add_data_vector<VEC> (const VEC &,
+ const DataPostprocessor<DH<1,3>::space_dimension> &);
+
+ template void
+ DataOut_DoFData<DH<1,3>,1,3>::
+ add_data_vector<VEC> (const DH<1,3> &,
+ const VEC &,
+ const std::string &,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<1,3>,1,3>::
+ add_data_vector<VEC> (const DH<1,3> &,
+ const VEC &,
+ const std::vector<std::string> &,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<1,3>,1,3>::
+ add_data_vector<VEC> (const DH<1,3> &,
+ const VEC &,
+ const DataPostprocessor<DH<1,3>::space_dimension> &);
+ #endif
+
+}
+
+
+
+for (DH : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENSIONS)
+{
+// codim=0
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension,deal_II_dimension>::
+ add_data_vector<IndexSet> (const IndexSet &,
+ const std::string &,
+ const DataVectorType,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension,deal_II_dimension>::
+ add_data_vector<IndexSet> (const IndexSet &,
+ const std::vector<std::string> &,
+ const DataVectorType,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension,deal_II_dimension>::
+ add_data_vector<IndexSet> (const DH<deal_II_dimension,deal_II_dimension> &,
+ const IndexSet &,
+ const std::string &,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension,deal_II_dimension>::
+ add_data_vector<IndexSet> (const DH<deal_II_dimension,deal_II_dimension> &,
+ const IndexSet &,
+ const std::vector<std::string> &,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension,deal_II_dimension>::
+ add_data_vector<IndexSet> (const IndexSet &,
+ const DataPostprocessor<DH<deal_II_dimension,deal_II_dimension>::space_dimension> &);
+
+
+
+// stuff needed for face data
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension-1,deal_II_dimension>::
+ add_data_vector<IndexSet> (const IndexSet &,
+ const std::string &,
+ const DataVectorType,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension-1,deal_II_dimension>::
+ add_data_vector<IndexSet> (const IndexSet &,
+ const std::vector<std::string> &,
+ const DataVectorType,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension-1,deal_II_dimension>::
+ add_data_vector<IndexSet> (const IndexSet &,
+ const DataPostprocessor<DH<deal_II_dimension,deal_II_dimension>::space_dimension> &);
+
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension-1,deal_II_dimension>::
+ add_data_vector<IndexSet> (const DH<deal_II_dimension,deal_II_dimension> &,
+ const IndexSet &,
+ const std::string &,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension-1,deal_II_dimension>::
+ add_data_vector<IndexSet> (const DH<deal_II_dimension,deal_II_dimension> &,
+ const IndexSet &,
+ const std::vector<std::string> &,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+// things for DataOutRotation
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension+1,deal_II_dimension+1>::
+ add_data_vector<IndexSet> (const IndexSet &,
+ const std::string &,
+ const DataVectorType,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension+1,deal_II_dimension+1>::
+ add_data_vector<IndexSet> (const IndexSet &,
+ const std::vector<std::string> &,
+ const DataVectorType,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension+1,deal_II_dimension+1>::
+ add_data_vector<IndexSet> (const IndexSet &,
+ const DataPostprocessor<DH<deal_II_dimension,deal_II_dimension>::space_dimension> &);
+
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension+1,deal_II_dimension+1>::
+ add_data_vector<IndexSet> (const DH<deal_II_dimension,deal_II_dimension> &,
+ const IndexSet &,
+ const std::string &,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension>,deal_II_dimension+1,deal_II_dimension+1>::
+ add_data_vector<IndexSet> (const DH<deal_II_dimension,deal_II_dimension> &,
+ const IndexSet &,
+ const std::vector<std::string> &,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+// codim 1
+
+ #if deal_II_dimension < 3
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension+1>,deal_II_dimension,deal_II_dimension+1>::
+ add_data_vector<IndexSet> (const IndexSet &,
+ const std::string &,
+ const DataVectorType,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension+1>,deal_II_dimension,deal_II_dimension+1>::
+ add_data_vector<IndexSet> (const IndexSet &,
+ const std::vector<std::string> &,
+ const DataVectorType,
+ const std::vector<DataComponentInterpretation::DataComponentInterpretation> &);
+
+ template void
+ DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension+1>,deal_II_dimension,deal_II_dimension+1>::
+ add_data_vector<IndexSet> (const IndexSet &,
+ const DataPostprocessor<DH<deal_II_dimension,deal_II_dimension+1>::space_dimension> &);
+ #endif
+
+}
+
+
+
+for (DH : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENSIONS)
+{
+ template class DataOut_DoFData<DH<deal_II_dimension>,deal_II_dimension>;
+ template class DataOut_DoFData<DH<deal_II_dimension>,deal_II_dimension+1>;
+
+ #if deal_II_dimension < 3
+ template class DataOut_DoFData<DH<deal_II_dimension>,deal_II_dimension,deal_II_dimension+1>;
+ template class DataOut_DoFData<DH<deal_II_dimension,deal_II_dimension+1>,deal_II_dimension,deal_II_dimension+1>;
+ #endif
+
+ #if deal_II_dimension >= 2
+ template class DataOut_DoFData<DH<deal_II_dimension>,deal_II_dimension-1,deal_II_dimension>;
+ #endif
+
+ #if deal_II_dimension == 3
+ template class DataOut_DoFData<DH<1>,1,3>;
+ template class DataOut_DoFData<DH<1,3>,1,3>;
+ #endif
+
+}
+
+
+for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : DIMENSIONS)
+{
+ namespace internal \{
+ namespace DataOut \{
+#if deal_II_dimension <= deal_II_space_dimension
+ template struct ParallelDataBase<deal_II_dimension,deal_II_space_dimension>;
+#endif
+ \}
+ \}
+}
+
+
+for (DH : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENSIONS; deal_II_space_dimension : DIMENSIONS)
+{
+ namespace internal \{
+ namespace DataOut \{
+#if deal_II_dimension <= deal_II_space_dimension
+ template
+ void
+ ParallelDataBase<deal_II_dimension,deal_II_space_dimension>::
+ reinit_all_fe_values<dealii::DH<deal_II_dimension,deal_II_space_dimension> >
+ (std::vector<std_cxx1x::shared_ptr<DataEntryBase<dealii::DH<deal_II_dimension,deal_II_space_dimension> > > > &dof_data,
+ const dealii::Triangulation<deal_II_dimension,deal_II_space_dimension>::cell_iterator &cell,
+ const unsigned int face);
+#endif
+ \}
+ \}
+}
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/quadrature_lib.h>
#include <deal.II/base/work_stream.h>
namespace DataOutFaces
{
template <int dim, int spacedim>
- template <class FE>
ParallelData<dim,spacedim>::
- ParallelData (const Quadrature<dim-1> &quadrature,
- const unsigned int n_components,
- const unsigned int n_datasets,
+ ParallelData (const unsigned int n_datasets,
const unsigned int n_subdivisions,
const std::vector<unsigned int> &n_postprocessor_outputs,
const Mapping<dim,spacedim> &mapping,
- const FE &finite_elements,
+ const std::vector<std_cxx1x::shared_ptr<dealii::hp::FECollection<dim,spacedim> > > &finite_elements,
const UpdateFlags update_flags)
:
internal::DataOut::
- ParallelDataBase<dim,spacedim> (n_components,
- n_datasets,
+ ParallelDataBase<dim,spacedim> (n_datasets,
n_subdivisions,
- quadrature.size(),
n_postprocessor_outputs,
- finite_elements),
- q_collection (quadrature),
- mapping_collection (mapping),
- x_fe_values (this->mapping_collection,
- this->fe_collection,
- q_collection,
- update_flags)
+ mapping,
+ finite_elements,
+ update_flags,
+ true)
{}
+
/**
- * In a WorkStream context, use
- * this function to append the
- * patch computed by the parallel
- * stage to the array of patches.
+ * In a WorkStream context, use this function to append the patch computed
+ * by the parallel stage to the array of patches.
*/
template <int dim, int spacedim>
void
}
+
template <int dim, class DH>
DataOutFaces<dim,DH>::DataOutFaces(const bool so)
:
{}
+
template <int dim, class DH>
void
DataOutFaces<dim,DH>::
Assert (cell_and_face->first->is_locally_owned(),
ExcNotImplemented());
- // we use the mapping to transform the
- // vertices. However, the mapping works on
- // cells, not faces, so transform the face
- // vertex to a cell vertex, that to a unit
- // cell vertex and then, finally, that to
- // the mapped vertex. In most cases this
- // complicated procedure will be the
- // identity.
+ // we use the mapping to transform the vertices. However, the mapping works
+ // on cells, not faces, so transform the face vertex to a cell vertex, that
+ // to a unit cell vertex and then, finally, that to the mapped vertex. In
+ // most cases this complicated procedure will be the identity.
for (unsigned int vertex=0; vertex<GeometryInfo<DH::dimension-1>::vertices_per_cell; ++vertex)
patch.vertices[vertex] = data.mapping_collection[0].transform_unit_to_real_cell
(cell_and_face->first,
if (data.n_datasets > 0)
{
- data.x_fe_values.reinit (cell_and_face->first, cell_and_face->second);
- const FEFaceValues<DH::dimension> &fe_patch_values
- = data.x_fe_values.get_present_fe_values ();
+ data.reinit_all_fe_values(this->dof_data, cell_and_face->first,
+ cell_and_face->second);
+ const FEValuesBase<DH::dimension> &fe_patch_values
+ = data.get_present_fe_values (0);
const unsigned int n_q_points = fe_patch_values.n_quadrature_points;
// store the intermediate points
Assert(patch.space_dim==DH::dimension, ExcInternalError());
const std::vector<Point<DH::dimension> > &q_points=fe_patch_values.get_quadrature_points();
- // resize the patch.data member
- // in order to have enough memory
- // for the quadrature points as
- // well
+ // resize the patch.data member in order to have enough memory for the
+ // quadrature points as well
patch.data.reinit(data.n_datasets+DH::dimension,
patch.data.size(1));
- // set the flag indicating that
- // for this cell the points are
- // explicitly given
+ // set the flag indicating that for this cell the points are explicitly
+ // given
patch.points_are_available=true;
// copy points to patch.data
for (unsigned int i=0; i<DH::dimension; ++i)
// first fill dof_data
for (unsigned int dataset=0; dataset<this->dof_data.size(); ++dataset)
{
+ const FEValuesBase<DH::dimension> &fe_patch_values
+ = data.get_present_fe_values (dataset);
+ const unsigned int n_components
+ = fe_patch_values.get_fe().n_components();
const DataPostprocessor<dim> *postprocessor=this->dof_data[dataset]->postprocessor;
if (postprocessor != 0)
{
- // we have to postprocess the
- // data, so determine, which
- // fields have to be updated
+ // we have to postprocess the data, so determine, which fields
+ // have to be updated
const UpdateFlags update_flags=postprocessor->get_needed_update_flags();
- // get normals, if
- // needed. this is a
- // geometrical information
- // and thus does not depend
- // on the number of
- // components of the data
+ // get normals, if needed. this is a geometrical information and
+ // thus does not depend on the number of components of the data
// vector
if (update_flags & update_normal_vectors)
data.patch_normals=fe_patch_values.get_normal_vectors();
- if (data.n_components == 1)
+ if (n_components == 1)
{
- // at each point there is
- // only one component of
- // value, gradient etc.
+ // at each point there is only one component of value,
+ // gradient etc.
if (update_flags & update_values)
this->dof_data[dataset]->get_function_values (fe_patch_values,
data.patch_values);
}
else
{
- // at each point there is
- // a vector valued
- // function and its
+ // at each point there is a vector valued function and its
// derivative...
+ data.resize_system_vectors(n_components);
if (update_flags & update_values)
this->dof_data[dataset]->get_function_values (fe_patch_values,
data.patch_values_system);
= data.postprocessed_values[dataset][q](component);
}
else
- // now we use the given data
- // vector without
- // modifications. again, we
- // treat single component
- // functions separately for
- // efficiency reasons.
- if (data.n_components == 1)
+ // now we use the given data vector without modifications. again,
+ // we treat single component functions separately for efficiency
+ // reasons.
+ if (n_components == 1)
{
this->dof_data[dataset]->get_function_values (fe_patch_values,
data.patch_values);
}
else
{
+ data.resize_system_vectors(n_components);
this->dof_data[dataset]->get_function_values (fe_patch_values,
data.patch_values_system);
- for (unsigned int component=0; component<data.n_components;
+ for (unsigned int component=0; component<n_components;
++component)
for (unsigned int q=0; q<n_q_points; ++q)
patch.data(offset+component,q) =
data.patch_values_system[q](component);
}
- // increment the counter for the
- // actual data record
+ // increment the counter for the actual data record
offset+=this->dof_data[dataset]->n_output_variables;
}
// then do the cell data
for (unsigned int dataset=0; dataset<this->cell_data.size(); ++dataset)
{
- // we need to get at
- // the number of the
- // cell to which this
- // face belongs in
- // order to access the
- // cell data. this is
- // not readily
- // available, so choose
- // the following rather
- // inefficient way:
+ // we need to get at the number of the cell to which this face
+ // belongs in order to access the cell data. this is not readily
+ // available, so choose the following rather inefficient way:
Assert (cell_and_face->first->active(), ExcCellNotActiveForCellData());
const unsigned int cell_number
- = std::distance (this->dofs->begin_active(),
- typename DH::active_cell_iterator(cell_and_face->first));
+ = std::distance (this->triangulation->begin_active(),
+ typename Triangulation<DH::dimension,DH::space_dimension>::active_cell_iterator(cell_and_face->first));
const double value
= this->cell_data[dataset]->get_cell_data_value (cell_number);
void DataOutFaces<dim,DH>::build_patches (const Mapping<DH::dimension> &mapping,
const unsigned int n_subdivisions_)
{
- // Check consistency of redundant
- // template parameter
+ // Check consistency of redundant template parameter
Assert (dim==DH::dimension, ExcDimensionMismatch(dim, DH::dimension));
const unsigned int n_subdivisions = (n_subdivisions_ != 0)
ExcInvalidNumberOfSubdivisions(n_subdivisions));
typedef DataOut_DoFData<DH,DH::dimension+1> BaseClass;
- Assert (this->dofs != 0, typename BaseClass::ExcNoDoFHandlerSelected());
-
- // before we start the loop:
- // create a quadrature rule that
- // actually has the points on this
- // patch
- const QTrapez<1> q_trapez;
- const QIterated<DH::dimension-1> patch_points (q_trapez, n_subdivisions);
-
- const unsigned int n_components = this->dofs->get_fe().n_components();
+ Assert (this->triangulation != 0,
+ typename BaseClass::ExcNoTriangulationSelected());
unsigned int n_datasets = this->cell_data.size();
for (unsigned int i=0; i<this->dof_data.size(); ++i)
n_datasets += this->dof_data[i]->n_output_variables;
- // first count the cells we want to
- // create patches of and make sure
- // there is enough memory for that
+ // first count the cells we want to create patches of and make sure there is
+ // enough memory for that
std::vector<FaceDescriptor> all_faces;
for (FaceDescriptor face=first_face();
- face.first != this->dofs->end();
+ face.first != this->triangulation->end();
face = next_face(face))
all_faces.push_back (face);
- // clear the patches array and
- // allocate the right number of
- // elements
+ // clear the patches array and allocate the right number of elements
this->patches.clear ();
this->patches.reserve (all_faces.size());
Assert (this->patches.size() == 0, ExcInternalError());
update_flags |= this->dof_data[i]->postprocessor->get_needed_update_flags();
update_flags |= update_quadrature_points;
- internal::DataOutFaces::ParallelData<DH::dimension, DH::dimension>
- thread_data (patch_points, n_components, n_datasets,
+ internal::DataOutFaces::ParallelData<DH::dimension, DH::space_dimension>
+ thread_data (n_datasets,
n_subdivisions,
n_postprocessor_outputs,
mapping,
- this->dofs->get_fe(),
+ this->get_finite_elements(),
update_flags);
DataOutBase::Patch<DH::dimension-1,DH::space_dimension> sample_patch;
sample_patch.n_subdivisions = n_subdivisions;
sample_patch.data.reinit (n_datasets,
- patch_points.size());
+ Utilities::fixed_power<DH::dimension-1>(n_subdivisions+1));
// now build the patches in parallel
WorkStream::run (&all_faces[0],
{
// simply find first active cell
// with a face on the boundary
- typename DH::active_cell_iterator cell = this->dofs->begin_active();
- for (; cell != this->dofs->end(); ++cell)
+ typename Triangulation<DH::dimension,DH::space_dimension>::active_cell_iterator cell = this->triangulation->begin_active();
+ for (; cell != this->triangulation->end(); ++cell)
for (unsigned int f=0; f<GeometryInfo<DH::dimension>::faces_per_cell; ++f)
if (!surface_only || cell->face(f)->at_boundary())
return FaceDescriptor(cell, f);
{
FaceDescriptor face = old_face;
- // first check whether the present
- // cell has more faces on the
- // boundary
+ // first check whether the present cell has more faces on the boundary
for (unsigned int f=face.second+1; f<GeometryInfo<DH::dimension>::faces_per_cell; ++f)
if (!surface_only || face.first->face(f)->at_boundary())
// yup, that is so, so return it
return face;
};
- // otherwise find the next active
- // cell that has a face on the
- // boundary
+ // otherwise find the next active cell that has a face on the boundary
- // convert the iterator to an
- // active_iterator and advance
- // this to the next active cell
- typename DH::active_cell_iterator active_cell = face.first;
+ // convert the iterator to an active_iterator and advance this to the next
+ // active cell
+ typename Triangulation<DH::dimension,DH::space_dimension>::active_cell_iterator active_cell = face.first;
// increase face pointer by one
++active_cell;
// while there are active cells
- while (active_cell != this->dofs->end())
+ while (active_cell != this->triangulation->end())
{
- // check all the faces of this
- // active cell
+ // check all the faces of this active cell
for (unsigned int f=0; f<GeometryInfo<DH::dimension>::faces_per_cell; ++f)
if (!surface_only || active_cell->face(f)->at_boundary())
{
face.second = f;
return face;
};
- // the present cell had no
- // faces on the boundary, so
- // check next cell
+ // the present cell had no faces on the boundary, so check next cell
++active_cell;
};
- // we fell off the edge, so return
- // with invalid pointer
- face.first = this->dofs->end();
+ // we fell off the edge, so return with invalid pointer
+ face.first = this->triangulation->end();
face.second = 0;
return face;
}
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
{
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/quadrature_lib.h>
#include <deal.II/base/work_stream.h>
namespace DataOutRotation
{
template <int dim, int spacedim>
- template <class FE>
ParallelData<dim,spacedim>::
- ParallelData (const Quadrature<dim> &quadrature,
- const unsigned int n_components,
- const unsigned int n_datasets,
+ ParallelData (const unsigned int n_datasets,
const unsigned int n_subdivisions,
const unsigned int n_patches_per_circle,
const std::vector<unsigned int> &n_postprocessor_outputs,
- const FE &finite_elements,
+ const Mapping<dim,spacedim> &mapping,
+ const std::vector<std_cxx1x::shared_ptr<dealii::hp::FECollection<dim,spacedim> > > &finite_elements,
const UpdateFlags update_flags)
:
internal::DataOut::
- ParallelDataBase<dim,spacedim> (n_components,
- n_datasets,
+ ParallelDataBase<dim,spacedim> (n_datasets,
n_subdivisions,
- quadrature.size(),
n_postprocessor_outputs,
- finite_elements),
- n_patches_per_circle (n_patches_per_circle),
- q_collection (quadrature),
- x_fe_values (this->fe_collection,
- q_collection,
- update_flags)
+ mapping,
+ finite_elements,
+ update_flags,
+ false),
+ n_patches_per_circle (n_patches_per_circle)
{}
+
/**
- * In a WorkStream context, use
- * this function to append the
- * patch computed by the parallel
- * stage to the array of patches.
+ * In a WorkStream context, use this function to append the patch computed
+ * by the parallel stage to the array of patches.
*/
template <int dim, int spacedim>
void
{
if (dim == 3)
{
- // would this function make any
- // sense after all? who would want
- // to output/compute in four space
- // dimensions?
+ // would this function make any sense after all? who would want to
+ // output/compute in four space dimensions?
Assert (false, ExcNotImplemented());
return;
}
const unsigned int n_patches_per_circle = data.n_patches_per_circle;
- // another abbreviation denoting
- // the number of q_points in each
- // direction
+ // another abbreviation denoting the number of q_points in each direction
const unsigned int n_points = data.n_subdivisions+1;
- // set up an array that holds the
- // directions in the plane of
- // rotation in which we will put
- // points in the whole domain (not
- // the rotationally reduced one in
- // which the computation took
- // place. for simplicity add the
- // initial direction at the end
- // again
+ // set up an array that holds the directions in the plane of rotation in
+ // which we will put points in the whole domain (not the rotationally
+ // reduced one in which the computation took place. for simplicity add the
+ // initial direction at the end again
std::vector<Point<DH::dimension+1> > angle_directions (n_patches_per_circle+1);
for (unsigned int i=0; i<=n_patches_per_circle; ++i)
{
for (unsigned int angle=0; angle<n_patches_per_circle; ++angle)
{
- // first compute the
- // vertices of the
- // patch. note that they
- // will have to be computed
- // from the vertices of the
- // cell, which has one
- // dimension less, however.
+ // first compute the vertices of the patch. note that they will have to
+ // be computed from the vertices of the cell, which has one dimension
+ // less, however.
switch (DH::dimension)
{
case 1:
{
const Point<DH::dimension> v = (*cell)->vertex(vertex);
- // make sure that the
- // radial variable does
- // attain negative
+ // make sure that the radial variable does attain negative
// values
Assert (v(0) >= 0, ExcRadialVariableHasNegativeValues(v(0)));
- // now set the vertices
- // of the patch
+ // now set the vertices of the patch
patches[angle].vertices[vertex] = v(0) * angle_directions[angle];
patches[angle].vertices[vertex][0] = v(1);
// then fill in data
if (data.n_datasets > 0)
{
- data.x_fe_values.reinit (*cell);
- const FEValues<DH::dimension> &fe_patch_values
- = data.x_fe_values.get_present_fe_values ();
-
+ data.reinit_all_fe_values(this->dof_data, *cell);
// first fill dof_data
for (unsigned int dataset=0; dataset<this->dof_data.size(); ++dataset)
{
+ const FEValuesBase<DH::dimension> & fe_patch_values
+ = data.get_present_fe_values(dataset);
+ const unsigned int n_components
+ = fe_patch_values.get_fe().n_components();
const DataPostprocessor<dim> *postprocessor=this->dof_data[dataset]->postprocessor;
if (postprocessor != 0)
{
// fields have to be updated
const UpdateFlags update_flags=postprocessor->get_needed_update_flags();
- if (data.n_components == 1)
+ if (n_components == 1)
{
// at each point there is
// only one component of
}
else
{
- // at each point there is
- // a vector valued
- // function and its
- // derivative...
+ data.resize_system_vectors(n_components);
+
+ // at each point there is a vector valued function and
+ // its derivative...
if (update_flags & update_values)
this->dof_data[dataset]->get_function_values (fe_patch_values,
data.patch_values_system);
}
}
}
- else if (data.n_components == 1)
+ else if (n_components == 1)
{
this->dof_data[dataset]->get_function_values (fe_patch_values,
data.patch_values);
else
// system of components
{
+ data.resize_system_vectors(n_components);
this->dof_data[dataset]->get_function_values (fe_patch_values,
data.patch_values_system);
- for (unsigned int component=0; component<data.n_components;
+ for (unsigned int component=0; component<n_components;
++component)
{
switch (DH::dimension)
// then do the cell data
for (unsigned int dataset=0; dataset<this->cell_data.size(); ++dataset)
{
- // we need to get at
- // the number of the
- // cell to which this
- // face belongs in
- // order to access the
- // cell data. this is
- // not readily
- // available, so choose
- // the following rather
- // inefficient way:
+ // we need to get at the number of the cell to which this face
+ // belongs in order to access the cell data. this is not readily
+ // available, so choose the following rather inefficient way:
Assert ((*cell)->active(),
ExcMessage("Cell must be active for cell data"));
const unsigned int cell_number
- = std::distance (this->dofs->begin_active(),
- typename DH::active_cell_iterator(*cell));
+ = std::distance (this->triangulation->begin_active(),
+ typename Triangulation<DH::dimension,DH::space_dimension>::active_cell_iterator(*cell));
const double value
= this->cell_data[dataset]->get_cell_data_value (cell_number);
switch (DH::dimension)
// template parameter
Assert (dim==DH::dimension, ExcDimensionMismatch(dim, DH::dimension));
typedef DataOut_DoFData<DH,DH::dimension+1> BaseClass;
- Assert (this->dofs != 0, typename BaseClass::ExcNoDoFHandlerSelected());
+ Assert (this->triangulation != 0,
+ typename BaseClass::ExcNoTriangulationSelected());
const unsigned int n_subdivisions = (nnnn_subdivisions != 0)
? nnnn_subdivisions
Assert (n_subdivisions >= 1,
ExcInvalidNumberOfSubdivisions(n_subdivisions));
- const QTrapez<1> q_trapez;
- const QIterated<DH::dimension> patch_points (q_trapez, n_subdivisions);
-
- const unsigned int n_components = this->dofs->get_fe().n_components();
unsigned int n_datasets=this->cell_data.size();
for (unsigned int i=0; i<this->dof_data.size(); ++i)
n_datasets+= this->dof_data[i]->n_output_variables;
// create patches of and make sure
// there is enough memory for that
std::vector<cell_iterator> all_cells;
- for (cell_iterator cell=first_cell(); cell != this->dofs->end();
+ for (cell_iterator cell=first_cell(); cell != this->triangulation->end();
cell = next_cell(cell))
all_cells.push_back (cell);
else
n_postprocessor_outputs[dataset] = 0;
+ const MappingQ1<DH::dimension, DH::space_dimension> mapping;
internal::DataOutRotation::ParallelData<DH::dimension, DH::space_dimension>
- thread_data (patch_points, n_components, n_datasets,
+ thread_data (n_datasets,
n_subdivisions, n_patches_per_circle,
- n_postprocessor_outputs, this->dofs->get_fe(),
+ n_postprocessor_outputs, mapping, this->get_finite_elements(),
update_flags);
std::vector<DataOutBase::Patch<DH::dimension+1,DH::space_dimension+1> >
new_patches (n_patches_per_circle);
{
new_patches[i].n_subdivisions = n_subdivisions;
new_patches[i].data.reinit (n_datasets,
- patch_points.size()
- * (n_subdivisions+1));
+ Utilities::fixed_power<DH::dimension+1>(n_subdivisions+1));
}
// now build the patches in parallel
typename DataOutRotation<dim,DH>::cell_iterator
DataOutRotation<dim,DH>::first_cell ()
{
- return this->dofs->begin_active ();
+ return this->triangulation->begin_active ();
}
// convert the iterator to an
// active_iterator and advance
// this to the next active cell
- typename DH::active_cell_iterator active_cell = cell;
+ typename Triangulation<DH::dimension,DH::space_dimension>::active_cell_iterator active_cell = cell;
++active_cell;
return active_cell;
}
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
{
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/numerics/data_out_stack.h>
#include <deal.II/base/quadrature_lib.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
{
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2007, 2010, 2012 by the deal.II authors
+// Copyright (C) 2007 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/numerics/data_postprocessor.h>
DEAL_II_NAMESPACE_OPEN
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
{
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012, 2013 by the deal.II authors
+// Copyright (C) 2000 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/quadrature_lib.h>
#include <deal.II/base/thread_management.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS ; VEC : SERIAL_VECTORS ; DH : DOFHANDLER_TEMPLATES)
{
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/base/parameter_handler.h>
#include <deal.II/base/logstream.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (VEC : SERIAL_VECTORS ; deal_II_dimension : DIMENSIONS)
{
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/thread_management.h>
#include <deal.II/base/quadrature.h>
namespace
{
- inline
- double sqr (const double x)
- {
- return x*x;
- }
-
-
template <typename CellIterator>
inline
void advance_by_n (CellIterator &cell,
const unsigned int n)
{
- // store a pointer to the end
- // iterator, since we can't get at
- // it any more once cell is already
- // the end iterator (in that case
- // dereferencing cell-> triggers an
- // assertion)
+ // store a pointer to the end iterator, since we can't get at it any more
+ // once cell is already the end iterator (in that case dereferencing
+ // cell-> triggers an assertion)
const CellIterator endc = cell->get_dof_handler().end();
for (unsigned int t=0; ((t<n) && (cell!=endc)); ++t, ++cell)
;
namespace
{
/**
- * All small temporary data
- * objects that are needed once
- * per thread by the several
- * functions of the error
- * estimator are gathered in this
- * struct. The reason for this
- * structure is mainly that we
- * have a number of functions
- * that operate on cells or faces
- * and need a number of small
- * temporary data objects. Since
- * these functions may run in
- * parallel, we cannot make these
- * objects member variables of
- * the enclosing class. On the
- * other hand, declaring them
- * locally in each of these
- * functions would require their
- * reallocating every time we
- * visit the next cell or face,
- * which we found can take a
- * significant amount of time if
- * it happens often even in the
- * single threaded case (10-20
- * per cent in our measurements);
- * however, most importantly,
- * memory allocation requires
- * synchronisation in
- * multithreaded mode. While that
- * is done by the C++ library and
- * has not to be handcoded, it
- * nevertheless seriously damages
- * the ability to efficiently run
- * the functions of this class in
- * parallel, since they are quite
- * often blocked by these
- * synchronisation points,
- * slowing everything down by a
- * factor of two or three.
+ * All small temporary data objects that are needed once per thread by the
+ * several functions of the error estimator are gathered in this
+ * struct. The reason for this structure is mainly that we have a number
+ * of functions that operate on cells or faces and need a number of small
+ * temporary data objects. Since these functions may run in parallel, we
+ * cannot make these objects member variables of the enclosing class. On
+ * the other hand, declaring them locally in each of these functions would
+ * require their reallocating every time we visit the next cell or face,
+ * which we found can take a significant amount of time if it happens
+ * often even in the single threaded case (10-20 per cent in our
+ * measurements); however, most importantly, memory allocation requires
+ * synchronisation in multithreaded mode. While that is done by the C++
+ * library and has not to be handcoded, it nevertheless seriously damages
+ * the ability to efficiently run the functions of this class in parallel,
+ * since they are quite often blocked by these synchronisation points,
+ * slowing everything down by a factor of two or three.
*
- * Thus, every thread gets an
- * instance of this class to work
- * with and needs not allocate
- * memory itself, or synchronise
- * with other threads.
+ * Thus, every thread gets an instance of this class to work with and
+ * needs not allocate memory itself, or synchronise with other threads.
*
- * The sizes of the arrays are
- * initialized with the maximal number of
- * entries necessary for the hp
- * case. Within the loop over individual
- * cells, we then resize the arrays as
- * necessary. Since for std::vector
- * resizing to a smaller size doesn't
- * imply memory allocation, this is fast.
+ * The sizes of the arrays are initialized with the maximal number of
+ * entries necessary for the hp case. Within the loop over individual
+ * cells, we then resize the arrays as necessary. Since for std::vector
+ * resizing to a smaller size doesn't imply memory allocation, this is
+ * fast.
*/
template <class DH>
struct ParallelData
const dealii::hp::FECollection<dim,spacedim> finite_element;
/**
- * The quadrature formulas to be used for
- * the faces.
+ * The quadrature formulas to be used for the faces.
*/
const dealii::hp::QCollection<dim-1> face_quadratures;
/**
- * FEFaceValues objects to integrate over
- * the faces of the current and
+ * FEFaceValues objects to integrate over the faces of the current and
* potentially of neighbor cells.
*/
dealii::hp::FEFaceValues<dim,spacedim> fe_face_values_cell;
dealii::hp::FESubfaceValues<dim,spacedim> fe_subface_values;
/**
- * A vector to store the jump
- * of the normal vectors in
- * the quadrature points for
- * each of the solution
- * vectors (i.e. a temporary
- * value). This vector is not
- * allocated inside the
- * functions that use it, but
- * rather globally, since
- * memory allocation is slow,
- * in particular in presence
- * of multiple threads where
- * synchronisation makes
- * things even slower.
+ * A vector to store the jump of the normal vectors in the quadrature
+ * points for each of the solution vectors (i.e. a temporary
+ * value). This vector is not allocated inside the functions that use
+ * it, but rather globally, since memory allocation is slow, in
+ * particular in presence of multiple threads where synchronisation
+ * makes things even slower.
*/
std::vector<std::vector<std::vector<double> > > phi;
/**
- * A vector for the gradients of
- * the finite element function
- * on one cell
+ * A vector for the gradients of the finite element function on one cell
*
- * Let psi be a short name
- * for <tt>a grad u_h</tt>, where
- * the third index be the
- * component of the finite
- * element, and the second
- * index the number of the
- * quadrature point. The
- * first index denotes the
- * index of the solution
- * vector.
+ * Let psi be a short name for <tt>a grad u_h</tt>, where the third
+ * index be the component of the finite element, and the second index
+ * the number of the quadrature point. The first index denotes the index
+ * of the solution vector.
*/
std::vector<std::vector<std::vector<Tensor<1,spacedim> > > > psi;
std::vector<std::vector<std::vector<Tensor<1,spacedim> > > > neighbor_psi;
/**
- * The normal vectors of the finite
- * element function on one face
+ * The normal vectors of the finite element function on one face
*/
std::vector<Point<spacedim> > normal_vectors;
/**
- * Two arrays needed for the
- * values of coefficients in
- * the jumps, if they are
- * given.
+ * Two arrays needed for the values of coefficients in the jumps, if
+ * they are given.
*/
std::vector<double> coefficient_values1;
std::vector<dealii::Vector<double> > coefficient_values;
/**
- * Array for the products of
- * Jacobian determinants and
- * weights of quadraturs
- * points.
+ * Array for the products of Jacobian determinants and weights of
+ * quadraturs points.
*/
std::vector<double> JxW_values;
/**
- * The subdomain id we are to care
- * for.
+ * The subdomain id we are to care for.
*/
const types::subdomain_id subdomain_id;
/**
- * The material id we are to care
- * for.
+ * The material id we are to care for.
*/
const types::material_id material_id;
/**
- * Some more references to input data to
- * the KellyErrorEstimator::estimate()
- * function.
+ * Some more references to input data to the
+ * KellyErrorEstimator::estimate() function.
*/
const typename FunctionMap<spacedim>::type *neumann_bc;
const ComponentMask component_mask;
const Function<spacedim> *coefficients);
/**
- * Resize the arrays so that they fit the
- * number of quadrature points associated
- * with the given finite element index
- * into the hp collections.
+ * Resize the arrays so that they fit the number of quadrature points
+ * associated with the given finite element index into the hp
+ * collections.
*/
void resize (const unsigned int active_fe_index);
};
/**
- * Copy data from the
- * local_face_integrals map of a single
- * ParallelData object into a global such
- * map. This is the copier stage of a
- * WorkStream pipeline.
+ * Copy data from the local_face_integrals map of a single ParallelData
+ * object into a global such map. This is the copier stage of a WorkStream
+ * pipeline.
*/
template <class DH>
void
std::map<typename DH::face_iterator,std::vector<double> > &face_integrals)
{
- // now copy locally computed elements
- // into the global map
+ // now copy locally computed elements into the global map
for (typename std::map<typename DH::face_iterator,std::vector<double> >::const_iterator
p=local_face_integrals.begin();
p!=local_face_integrals.end();
++p)
{
- // double check that the
- // element does not already
- // exists in the global map
+ // double check that the element does not already exists in the
+ // global map
Assert (face_integrals.find (p->first) == face_integrals.end(),
ExcInternalError());
/**
- * Actually do the computation on
- * a face which has no hanging
- * nodes (it is regular), i.e.
- * either on the other side there
- * is nirvana (face is at
- * boundary), or the other side's
- * refinement level is the same
- * as that of this side, then
- * handle the integration of
- * these both cases together.
+ * Actually do the computation based on the evaluated gradients in
+ * ParallelData.
*/
- template <typename InputVector, class DH>
- void
- integrate_over_regular_face (const std::vector<const InputVector *> &solutions,
- ParallelData<DH> ¶llel_data,
- std::map<typename DH::face_iterator,std::vector<double> > &local_face_integrals,
- const typename DH::active_cell_iterator &cell,
- const unsigned int face_no,
- dealii::hp::FEFaceValues<DH::dimension, DH::space_dimension> &fe_face_values_cell,
- dealii::hp::FEFaceValues<DH::dimension, DH::space_dimension> &fe_face_values_neighbor)
+ template <class DH>
+ std::vector<double>
+ integrate_over_face (ParallelData<DH> ¶llel_data,
+ const typename DH::face_iterator &face,
+ dealii::hp::FEFaceValues<DH::dimension, DH::space_dimension> &fe_face_values_cell)
{
- const unsigned int dim = DH::dimension;
-
- const typename DH::face_iterator face = cell->face(face_no);
- const unsigned int n_q_points = parallel_data.face_quadratures[cell->active_fe_index()].size(),
+ const unsigned int n_q_points = parallel_data.psi[0].size(),
n_components = parallel_data.finite_element.n_components(),
- n_solution_vectors = solutions.size();
-
+ n_solution_vectors = parallel_data.psi.size();
- // initialize data of the restriction
- // of this cell to the present face
- fe_face_values_cell.reinit (cell, face_no,
- cell->active_fe_index());
-
- // get gradients of the finite element
- // function on this cell
- for (unsigned int n=0; n<n_solution_vectors; ++n)
- fe_face_values_cell.get_present_fe_values()
- .get_function_gradients (*solutions[n], parallel_data.psi[n]);
-
- // now compute over the other side of
- // the face
if (face->at_boundary() == false)
- // internal face; integrate jump
- // of gradient across this face
{
- Assert (cell->neighbor(face_no).state() == IteratorState::valid,
- ExcInternalError());
-
- const typename DH::active_cell_iterator neighbor = cell->neighbor(face_no);
-
- // find which number the
- // current face has relative to
- // the neighboring cell
- const unsigned int neighbor_neighbor
- = cell->neighbor_of_neighbor (face_no);
- Assert (neighbor_neighbor<GeometryInfo<dim>::faces_per_cell,
- ExcInternalError());
-
- // get restriction of finite element
- // function of @p{neighbor} to the
- // common face. in the hp case, use the
- // quadrature formula that matches the
- // one we would use for the present
- // cell
- fe_face_values_neighbor.reinit (neighbor, neighbor_neighbor,
- cell->active_fe_index());
-
- // get gradients on neighbor cell
+ // compute the jump in the gradients
for (unsigned int n=0; n<n_solution_vectors; ++n)
- {
- fe_face_values_neighbor.get_present_fe_values()
- .get_function_gradients (*solutions[n],
- parallel_data.neighbor_psi[n]);
-
- // compute the jump in the gradients
- for (unsigned int component=0; component<n_components; ++component)
- for (unsigned int p=0; p<n_q_points; ++p)
- parallel_data.psi[n][p][component] -= parallel_data.neighbor_psi[n][p][component];
- }
+ for (unsigned int component=0; component<n_components; ++component)
+ for (unsigned int p=0; p<n_q_points; ++p)
+ parallel_data.psi[n][p][component] -= parallel_data.neighbor_psi[n][p][component];
}
-
// now psi contains the following:
// - for an internal face, psi=[grad u]
- // - for a neumann boundary face,
- // psi=grad u
- // each component being the
- // mentioned value at one of the
- // quadrature points
-
- // next we have to multiply this with
- // the normal vector. Since we have
- // taken the difference of gradients
- // for internal faces, we may chose
- // the normal vector of one cell,
- // taking that of the neighbor
- // would only change the sign. We take
- // the outward normal.
+ // - for a neumann boundary face, psi=grad u
+ // each component being the mentioned value at one of the quadrature
+ // points
+
+ // next we have to multiply this with the normal vector. Since we have
+ // taken the difference of gradients for internal faces, we may chose
+ // the normal vector of one cell, taking that of the neighbor would only
+ // change the sign. We take the outward normal.
parallel_data.normal_vectors =
fe_face_values_cell.get_present_fe_values().get_normal_vectors();
= (parallel_data.psi[n][point][component] *
parallel_data.normal_vectors[point]);
- // if a coefficient was given: use that
- // to scale the jump in the gradient
+ // if a coefficient was given: use that to scale the jump in the
+ // gradient
if (parallel_data.coefficients != 0)
{
// scalar coefficient
if (parallel_data.coefficients->n_components == 1)
{
-
parallel_data.coefficients
->value_list (fe_face_values_cell.get_present_fe_values()
.get_quadrature_points(),
if (face->at_boundary() == true)
- // neumann boundary face. compute
- // difference between normal
- // derivative and boundary function
+ // neumann boundary face. compute difference between normal derivative
+ // and boundary function
{
const types::boundary_id boundary_indicator = face->boundary_indicator();
Assert (parallel_data.neumann_bc->find(boundary_indicator) !=
parallel_data.neumann_bc->end(),
ExcInternalError ());
- // get the values of the boundary
- // function at the quadrature
- // points
+ // get the values of the boundary function at the quadrature points
if (n_components == 1)
{
std::vector<double> g(n_q_points);
// now phi contains the following:
// - for an internal face, phi=[a du/dn]
- // - for a neumann boundary face,
- // phi=a du/dn-g
- // each component being the
- // mentioned value at one of the
- // quadrature points
+ // - for a neumann boundary face, phi=a du/dn-g
+ // each component being the mentioned value at one of the quadrature
+ // points
parallel_data.JxW_values
= fe_face_values_cell.get_present_fe_values().get_JxW_values();
- // take the square of the phi[i]
- // for integration, and sum up
+ // take the square of the phi[i] for integration, and sum up
std::vector<double> face_integral (n_solution_vectors, 0);
for (unsigned int n=0; n<n_solution_vectors; ++n)
for (unsigned int component=0; component<n_components; ++component)
if (parallel_data.component_mask[component] == true)
for (unsigned int p=0; p<n_q_points; ++p)
- face_integral[n] += dealii::sqr(parallel_data.phi[n][p][component]) *
+ face_integral[n] += Utilities::fixed_power<2>(parallel_data.phi[n][p][component]) *
parallel_data.JxW_values[p];
- local_face_integrals[face] = face_integral;
+ return face_integral;
+ }
+
+
+
+ /**
+ * Actually do the computation on a face which has no hanging nodes (it is
+ * regular), i.e. either on the other side there is nirvana (face is at
+ * boundary), or the other side's refinement level is the same as that of
+ * this side, then handle the integration of these both cases together.
+ */
+ template <typename InputVector, class DH>
+ void
+ integrate_over_regular_face (const std::vector<const InputVector *> &solutions,
+ ParallelData<DH> ¶llel_data,
+ std::map<typename DH::face_iterator,std::vector<double> > &local_face_integrals,
+ const typename DH::active_cell_iterator &cell,
+ const unsigned int face_no,
+ dealii::hp::FEFaceValues<DH::dimension, DH::space_dimension> &fe_face_values_cell,
+ dealii::hp::FEFaceValues<DH::dimension, DH::space_dimension> &fe_face_values_neighbor)
+ {
+ const unsigned int dim = DH::dimension;
+
+ const typename DH::face_iterator face = cell->face(face_no);
+ const unsigned int n_solution_vectors = solutions.size();
+
+
+ // initialize data of the restriction
+ // of this cell to the present face
+ fe_face_values_cell.reinit (cell, face_no,
+ cell->active_fe_index());
+
+ // get gradients of the finite element
+ // function on this cell
+ for (unsigned int n=0; n<n_solution_vectors; ++n)
+ fe_face_values_cell.get_present_fe_values()
+ .get_function_gradients (*solutions[n], parallel_data.psi[n]);
+
+ // now compute over the other side of the face
+ if (face->at_boundary() == false)
+ // internal face; integrate jump of gradient across this face
+ {
+ Assert (cell->neighbor(face_no).state() == IteratorState::valid,
+ ExcInternalError());
+
+ const typename DH::active_cell_iterator neighbor = cell->neighbor(face_no);
+
+ // find which number the current face has relative to the
+ // neighboring cell
+ const unsigned int neighbor_neighbor
+ = cell->neighbor_of_neighbor (face_no);
+ Assert (neighbor_neighbor<GeometryInfo<dim>::faces_per_cell,
+ ExcInternalError());
+
+ // get restriction of finite element function of @p{neighbor} to the
+ // common face. in the hp case, use the quadrature formula that
+ // matches the one we would use for the present cell
+ fe_face_values_neighbor.reinit (neighbor, neighbor_neighbor,
+ cell->active_fe_index());
+
+ // get gradients on neighbor cell
+ for (unsigned int n=0; n<n_solution_vectors; ++n)
+ {
+ fe_face_values_neighbor.get_present_fe_values()
+ .get_function_gradients (*solutions[n],
+ parallel_data.neighbor_psi[n]);
+ }
+ }
+
+ // now go to the generic function that does all the other things
+ local_face_integrals[face] =
+ integrate_over_face (parallel_data, face, fe_face_values_cell);
}
*/
template <typename InputVector, class DH>
void
- integrate_over_irregular_face (const std::vector<const InputVector *> &solutions,
- ParallelData<DH> ¶llel_data,
+ integrate_over_irregular_face (const std::vector<const InputVector *> &solutions,
+ ParallelData<DH> ¶llel_data,
std::map<typename DH::face_iterator,std::vector<double> > &local_face_integrals,
const typename DH::active_cell_iterator &cell,
const unsigned int face_no,
const unsigned int dim = DH::dimension;
const typename DH::cell_iterator neighbor = cell->neighbor(face_no);
- const unsigned int n_q_points = parallel_data.face_quadratures[cell->active_fe_index()].size(),
- n_components = parallel_data.finite_element.n_components(),
- n_solution_vectors = solutions.size();
+ const unsigned int n_solution_vectors = solutions.size();
const typename DH::face_iterator
face=cell->face(face_no);
Assert (neighbor.state() == IteratorState::valid, ExcInternalError());
Assert (face->has_children(), ExcInternalError());
- // set up a vector of the gradients
- // of the finite element function
- // on this cell at the quadrature
- // points
+
+ // set up a vector of the gradients of the finite element function on
+ // this cell at the quadrature points
//
- // let psi be a short name for
- // [a grad u_h], where the second
- // index be the component of the
- // finite element, and the first
- // index the number of the
- // quadrature point
-
- // store which number @p{cell} has
- // in the list of neighbors of
+ // let psi be a short name for [a grad u_h], where the second index be
+ // the component of the finite element, and the first index the number
+ // of the quadrature point
+
+ // store which number @p{cell} has in the list of neighbors of
// @p{neighbor}
const unsigned int neighbor_neighbor
= cell->neighbor_of_neighbor (face_no);
// loop over all subfaces
for (unsigned int subface_no=0; subface_no<face->n_children(); ++subface_no)
{
- // get an iterator pointing to the
- // cell behind the present subface
+ // get an iterator pointing to the cell behind the present subface
const typename DH::active_cell_iterator neighbor_child
= cell->neighbor_child_on_subface (face_no, subface_no);
Assert (!neighbor_child->has_children(),
ExcInternalError());
- // restrict the finite element
- // on the present cell to the
- // subface
+ // restrict the finite element on the present cell to the subface
fe_subface_values.reinit (cell, face_no, subface_no,
cell->active_fe_index());
- // restrict the finite element
- // on the neighbor cell to the
- // common @p{subface}.
+ // restrict the finite element on the neighbor cell to the common
+ // @p{subface}.
fe_face_values.reinit (neighbor_child, neighbor_neighbor,
cell->active_fe_index());
- // store the gradient of the
- // solution in psi
+ // store the gradient of the solution in psi
for (unsigned int n=0; n<n_solution_vectors; ++n)
fe_subface_values.get_present_fe_values()
.get_function_gradients (*solutions[n], parallel_data.psi[n]);
- // store the gradient from the
- // neighbor's side in
- // @p{neighbor_psi}
+ // store the gradient from the neighbor's side in @p{neighbor_psi}
for (unsigned int n=0; n<n_solution_vectors; ++n)
fe_face_values.get_present_fe_values()
.get_function_gradients (*solutions[n], parallel_data.neighbor_psi[n]);
- // compute the jump in the gradients
- for (unsigned int n=0; n<n_solution_vectors; ++n)
- for (unsigned int component=0; component<n_components; ++component)
- for (unsigned int p=0; p<n_q_points; ++p)
- parallel_data.psi[n][p][component] -=
- parallel_data.neighbor_psi[n][p][component];
-
- // note that unlike for the
- // case of regular faces
- // (treated in the other
- // function of this class), we
- // have not to take care of
- // boundary faces here, since
- // they always are regular.
-
- // next we have to multiply this with
- // the normal vector. Since we have
- // taken the difference of gradients
- // for internal faces, we may chose
- // the normal vector of one cell,
- // taking that of the neighbor
- // would only change the sign. We take
- // the outward normal.
- //
- // let phi be the name of the integrand
-
- parallel_data.normal_vectors
- = fe_face_values.get_present_fe_values().get_normal_vectors();
-
-
- for (unsigned int n=0; n<n_solution_vectors; ++n)
- for (unsigned int component=0; component<n_components; ++component)
- for (unsigned int point=0; point<n_q_points; ++point)
- parallel_data.phi[n][point][component] = (parallel_data.psi[n][point][component]*
- parallel_data.normal_vectors[point]);
-
- // if a coefficient was given: use that
- // to scale the jump in the gradient
- if (parallel_data.coefficients != 0)
- {
- // scalar coefficient
- if (parallel_data.coefficients->n_components == 1)
- {
- parallel_data.coefficients
- ->value_list (fe_face_values.get_present_fe_values()
- .get_quadrature_points(),
- parallel_data.coefficient_values1);
- for (unsigned int n=0; n<n_solution_vectors; ++n)
- for (unsigned int component=0; component<n_components; ++component)
- for (unsigned int point=0; point<n_q_points; ++point)
- parallel_data.phi[n][point][component] *=
- parallel_data.coefficient_values1[point];
- }
- else
- // vector-valued coefficient
- {
- parallel_data.coefficients
- ->vector_value_list (fe_face_values.get_present_fe_values()
- .get_quadrature_points(),
- parallel_data.coefficient_values);
- for (unsigned int n=0; n<n_solution_vectors; ++n)
- for (unsigned int component=0; component<n_components; ++component)
- for (unsigned int point=0; point<n_q_points; ++point)
- parallel_data.phi[n][point][component] *=
- parallel_data.coefficient_values[point](component);
- }
- }
-
- // get the weights for the
- // integration. note that it
- // does not matter whether we
- // take the JxW values from the
- // fe_face_values or the
- // fe_subface_values, as the
- // first is on the small
- // neighbor cell, while the
- // latter is on the refined
- // face of the big cell here
- parallel_data.JxW_values
- = fe_face_values.get_present_fe_values().get_JxW_values();
-
- // take the square of the phi[i]
- // for integration, and sum up
- std::vector<double> face_integral (n_solution_vectors, 0);
- for (unsigned int n=0; n<n_solution_vectors; ++n)
- for (unsigned int component=0; component<n_components; ++component)
- if (parallel_data.component_mask[component] == true)
- for (unsigned int p=0; p<n_q_points; ++p)
- face_integral[n] += dealii::sqr(parallel_data.phi[n][p][component]) *
- parallel_data.JxW_values[p];
-
- local_face_integrals[neighbor_child->face(neighbor_neighbor)]
- = face_integral;
+ // call generic evaluate function
+ local_face_integrals[neighbor_child->face(neighbor_neighbor)] =
+ integrate_over_face (parallel_data, face, fe_face_values);
}
-
- // finally loop over all subfaces to
- // collect the contributions of the
- // subfaces and store them with the
- // mother face
+ // finally loop over all subfaces to collect the contributions of the
+ // subfaces and store them with the mother face
std::vector<double> sum (n_solution_vectors, 0);
for (unsigned int subface_no=0; subface_no<face->n_children(); ++subface_no)
{
/**
- * Computate the error on the faces of a
- * single cell.
+ * Computate the error on the faces of a single cell.
*
- * This function is only needed
- * in two or three dimensions.
- * The error estimator in one
- * dimension is implemented
- * seperatly.
+ * This function is only needed in two or three dimensions. The error
+ * estimator in one dimension is implemented separately.
*/
- template <int dim, int spacedim, typename InputVector, class DH>
+ template <typename InputVector, class DH>
void
estimate_one_cell (const typename DH::active_cell_iterator &cell,
ParallelData<DH> ¶llel_data,
std::map<typename DH::face_iterator,std::vector<double> > &local_face_integrals,
const std::vector<const InputVector *> &solutions)
{
+ const unsigned int dim = DH::dimension;
const unsigned int n_solution_vectors = solutions.size();
const types::subdomain_id subdomain_id = parallel_data.subdomain_id;
const unsigned int material_id = parallel_data.material_id;
- // empty our own copy of the local face
- // integrals
+ // empty our own copy of the local face integrals
local_face_integrals.clear();
// loop over all faces of this cell
const typename DH::face_iterator
face=cell->face(face_no);
- // make sure we do work
- // only once: this face
- // may either be regular
- // or irregular. if it is
- // regular and has a
- // neighbor, then we
- // visit the face twice,
- // once from every
- // side. let the one with
- // the lower index do the
- // work. if it is at the
- // boundary, or if the
- // face is irregular,
- // then do the work below
+ // make sure we do work only once: this face may either be regular
+ // or irregular. if it is regular and has a neighbor, then we visit
+ // the face twice, once from every side. let the one with the lower
+ // index do the work. if it is at the boundary, or if the face is
+ // irregular, then do the work below
if ((face->has_children() == false) &&
!cell->at_boundary(face_no) &&
(!cell->neighbor_is_coarser(face_no) &&
cell->neighbor(face_no)->level() < cell->level()))))
continue;
- // if the neighboring cell is less
- // refined than the present one,
- // then do nothing since we
- // integrate over the subfaces when
- // we visit the coarse cells.
+ // if the neighboring cell is less refined than the present one,
+ // then do nothing since we integrate over the subfaces when we
+ // visit the coarse cells.
if (face->at_boundary() == false)
if (cell->neighbor_is_coarser(face_no))
continue;
- // if this face is part of the
- // boundary but not of the neumann
- // boundary -> nothing to
- // do. However, to make things
- // easier when summing up the
- // contributions of the faces of
- // cells, we enter this face into
- // the list of faces with
- // contribution zero.
+ // if this face is part of the boundary but not of the neumann
+ // boundary -> nothing to do. However, to make things easier when
+ // summing up the contributions of the faces of cells, we enter this
+ // face into the list of faces with contribution zero.
if (face->at_boundary()
&&
(parallel_data.neumann_bc->find(face->boundary_indicator()) ==
continue;
}
- // finally: note that we only have
- // to do something if either the
- // present cell is on the subdomain
- // we care for (and the same for
- // material_id), or if one of the
- // neighbors behind the face is on
+ // finally: note that we only have to do something if either the
+ // present cell is on the subdomain we care for (and the same for
+ // material_id), or if one of the neighbors behind the face is on
// the subdomain we care for
if ( ! ( ((subdomain_id == numbers::invalid_subdomain_id)
||
||
(cell->material_id() == material_id))) )
{
- // ok, cell is unwanted, but
- // maybe its neighbor behind
- // the face we presently work
- // on? oh is there a face at
- // all?
+ // ok, cell is unwanted, but maybe its neighbor behind the face
+ // we presently work on? oh is there a face at all?
if (face->at_boundary())
continue;
}
}
- // so if none of the neighbors
- // cares for this subdomain or
- // material either, then try
- // next face
+ // so if none of the neighbors cares for this subdomain or
+ // material either, then try next face
if (care_for_cell == false)
continue;
}
- // so now we know that we care for
- // this face, let's do something
- // about it. first re-size the
- // arrays we may use to the correct
+ // so now we know that we care for this face, let's do something
+ // about it. first re-size the arrays we may use to the correct
// size:
parallel_data.resize (cell->active_fe_index());
// then do the actual integration
if (face->has_children() == false)
- // if the face is a regular one,
- // i.e. either on the other side
- // there is nirvana (face is at
- // boundary), or the other side's
- // refinement level is the same
- // as that of this side, then
- // handle the integration of
- // these both cases together
+ // if the face is a regular one, i.e. either on the other side
+ // there is nirvana (face is at boundary), or the other side's
+ // refinement level is the same as that of this side, then handle
+ // the integration of these both cases together
integrate_over_regular_face (solutions,
parallel_data,
local_face_integrals,
parallel_data.fe_face_values_neighbor);
else
- // otherwise we need to do some
- // special computations which do
- // not fit into the framework of
- // the above function
+ // otherwise we need to do some special computations which do not
+ // fit into the framework of the above function
integrate_over_irregular_face (solutions,
parallel_data,
local_face_integrals,
-
-
-template <int spacedim>
-template <typename InputVector, class DH>
-void
-KellyErrorEstimator<1,spacedim>::
-estimate (const Mapping<1,spacedim> &mapping,
- const DH &dof_handler,
- const Quadrature<0> &quadrature,
- const typename FunctionMap<spacedim>::type &neumann_bc,
- const InputVector &solution,
- Vector<float> &error,
- const ComponentMask &component_mask,
- const Function<spacedim> *coefficients,
- const unsigned int n_threads,
- const types::subdomain_id subdomain_id,
- const types::material_id material_id)
-{
- // just pass on to the other function
- const std::vector<const InputVector *> solutions (1, &solution);
- std::vector<Vector<float>*> errors (1, &error);
- estimate (mapping, dof_handler, quadrature, neumann_bc, solutions, errors,
- component_mask, coefficients, n_threads, subdomain_id, material_id);
-}
-
-
-
-template <int spacedim>
-template <typename InputVector, class DH>
-void
-KellyErrorEstimator<1,spacedim>::
-estimate (const DH &dof_handler,
- const Quadrature<0> &quadrature,
- const typename FunctionMap<spacedim>::type &neumann_bc,
- const InputVector &solution,
- Vector<float> &error,
- const ComponentMask &component_mask,
- const Function<spacedim> *coefficients,
- const unsigned int n_threads,
- const types::subdomain_id subdomain_id,
- const types::material_id material_id)
-{
- estimate(StaticMappingQ1<1,spacedim>::mapping, dof_handler, quadrature, neumann_bc, solution,
- error, component_mask, coefficients, n_threads, subdomain_id, material_id);
-}
-
-
-
-template <int spacedim>
-template <typename InputVector, class DH>
-void
-KellyErrorEstimator<1,spacedim>::
-estimate (const DH &dof_handler,
- const Quadrature<0> &quadrature,
- const typename FunctionMap<spacedim>::type &neumann_bc,
- const std::vector<const InputVector *> &solutions,
- std::vector<Vector<float>*> &errors,
- const ComponentMask &component_mask,
- const Function<spacedim> *coefficients,
- const unsigned int n_threads,
- const types::subdomain_id subdomain_id,
- const types::material_id material_id)
-{
- estimate(StaticMappingQ1<1,spacedim>::mapping, dof_handler, quadrature, neumann_bc, solutions,
- errors, component_mask, coefficients, n_threads, subdomain_id, material_id);
-}
-
-
-
-template <int spacedim>
-template <typename InputVector, class DH>
-void
-KellyErrorEstimator<1,spacedim>::
-estimate (const Mapping<1,spacedim> &mapping,
- const DH &dof_handler,
- const hp::QCollection<0> &quadrature,
- const typename FunctionMap<spacedim>::type &neumann_bc,
- const InputVector &solution,
- Vector<float> &error,
- const ComponentMask &component_mask,
- const Function<spacedim> *coefficients,
- const unsigned int n_threads,
- const types::subdomain_id subdomain_id,
- const types::material_id material_id)
-{
- // just pass on to the other function
- const std::vector<const InputVector *> solutions (1, &solution);
- std::vector<Vector<float>*> errors (1, &error);
- estimate (mapping, dof_handler, quadrature, neumann_bc, solutions, errors,
- component_mask, coefficients, n_threads, subdomain_id, material_id);
-}
-
-
-template <int spacedim>
-template <typename InputVector, class DH>
-void
-KellyErrorEstimator<1,spacedim>::
-estimate (const DH &dof_handler,
- const hp::QCollection<0> &quadrature,
- const typename FunctionMap<spacedim>::type &neumann_bc,
- const InputVector &solution,
- Vector<float> &error,
- const ComponentMask &component_mask,
- const Function<spacedim> *coefficients,
- const unsigned int n_threads,
- const types::subdomain_id subdomain_id,
- const types::material_id material_id)
-{
- estimate(StaticMappingQ1<1,spacedim>::mapping, dof_handler, quadrature, neumann_bc, solution,
- error, component_mask, coefficients, n_threads, subdomain_id, material_id);
-}
-
-
-
-template <int spacedim>
-template <typename InputVector, class DH>
-void
-KellyErrorEstimator<1,spacedim>::
-estimate (const DH &dof_handler,
- const hp::QCollection<0> &quadrature,
- const typename FunctionMap<spacedim>::type &neumann_bc,
- const std::vector<const InputVector *> &solutions,
- std::vector<Vector<float>*> &errors,
- const ComponentMask &component_mask,
- const Function<spacedim> *coefficients,
- const unsigned int n_threads,
- const types::subdomain_id subdomain_id,
- const types::material_id material_id)
-{
- estimate(StaticMappingQ1<1,spacedim>::mapping, dof_handler, quadrature, neumann_bc, solutions,
- errors, component_mask, coefficients, n_threads, subdomain_id, material_id);
-}
-
-
-
-
-template <int spacedim>
-template <typename InputVector, class DH>
-void KellyErrorEstimator<1,spacedim>::
-estimate (const Mapping<1,spacedim> &/*mapping*/,
- const DH &/*dof_handler*/,
- const hp::QCollection<0> &,
- const typename FunctionMap<spacedim>::type &/*neumann_bc*/,
- const std::vector<const InputVector *> &/*solutions*/,
- std::vector<Vector<float>*> &/*errors*/,
- const ComponentMask &/*component_mask_*/,
- const Function<spacedim> */*coefficient*/,
- const unsigned int,
- const types::subdomain_id /*subdomain_id*/,
- const types::material_id /*material_id*/)
-{
- Assert (false, ExcInternalError());
-}
-
-
-
-template <int spacedim>
-template <typename InputVector, class DH>
-void KellyErrorEstimator<1,spacedim>::
-estimate (const Mapping<1,spacedim> &mapping,
- const DH &dof_handler,
- const Quadrature<0> &,
- const typename FunctionMap<spacedim>::type &neumann_bc,
- const std::vector<const InputVector *> &solutions,
- std::vector<Vector<float>*> &errors,
- const ComponentMask &component_mask,
- const Function<spacedim> *coefficient,
- const unsigned int,
- const types::subdomain_id subdomain_id_,
- const types::material_id material_id)
-{
-#ifdef DEAL_II_WITH_P4EST
- if (dynamic_cast<const parallel::distributed::Triangulation<1,spacedim>*>
- (&dof_handler.get_tria())
- != 0)
- Assert ((subdomain_id_ == numbers::invalid_subdomain_id)
- ||
- (subdomain_id_ ==
- dynamic_cast<const parallel::distributed::Triangulation<1,spacedim>&>
- (dof_handler.get_tria()).locally_owned_subdomain()),
- ExcMessage ("For parallel distributed triangulations, the only "
- "valid subdomain_id that can be passed here is the "
- "one that corresponds to the locally owned subdomain id."));
-
- const types::subdomain_id subdomain_id
- = ((dynamic_cast<const parallel::distributed::Triangulation<1,spacedim>*>
- (&dof_handler.get_tria())
- != 0)
- ?
- dynamic_cast<const parallel::distributed::Triangulation<1,spacedim>&>
- (dof_handler.get_tria()).locally_owned_subdomain()
- :
- subdomain_id_);
-#else
- const types::subdomain_id subdomain_id
- = subdomain_id_;
-#endif
-
- const unsigned int n_components = dof_handler.get_fe().n_components();
- const unsigned int n_solution_vectors = solutions.size();
-
- // sanity checks
- Assert (neumann_bc.find(numbers::internal_face_boundary_id) == neumann_bc.end(),
- ExcInvalidBoundaryIndicator());
-
- for (typename FunctionMap<spacedim>::type::const_iterator i=neumann_bc.begin();
- i!=neumann_bc.end(); ++i)
- Assert (i->second->n_components == n_components, ExcInvalidBoundaryFunction());
-
- Assert (component_mask.represents_n_components(n_components),
- ExcInvalidComponentMask());
- Assert (component_mask.n_selected_components(n_components) > 0,
- ExcInvalidComponentMask());
-
- Assert ((coefficient == 0) ||
- (coefficient->n_components == n_components) ||
- (coefficient->n_components == 1),
- ExcInvalidCoefficient());
-
- Assert (solutions.size() > 0,
- ExcNoSolutions());
- Assert (solutions.size() == errors.size(),
- ExcIncompatibleNumberOfElements(solutions.size(), errors.size()));
- for (unsigned int n=0; n<solutions.size(); ++n)
- Assert (solutions[n]->size() == dof_handler.n_dofs(),
- ExcInvalidSolutionVector());
-
- Assert ((coefficient == 0) ||
- (coefficient->n_components == n_components) ||
- (coefficient->n_components == 1),
- ExcInvalidCoefficient());
-
- for (typename FunctionMap<spacedim>::type::const_iterator i=neumann_bc.begin();
- i!=neumann_bc.end(); ++i)
- Assert (i->second->n_components == n_components,
- ExcInvalidBoundaryFunction());
-
- // reserve one slot for each cell and set
- // it to zero
- for (unsigned int n=0; n<n_solution_vectors; ++n)
- (*errors[n]).reinit (dof_handler.get_tria().n_active_cells());
-
- // fields to get the gradients on
- // the present and the neighbor cell.
- //
- // for the neighbor gradient, we
- // need several auxiliary fields,
- // depending on the way we get it
- // (see below)
- std::vector<std::vector<std::vector<Tensor<1,spacedim> > > >
- gradients_here (n_solution_vectors,
- std::vector<std::vector<Tensor<1,spacedim> > >(2, std::vector<Tensor<1,spacedim> >(n_components)));
- std::vector<std::vector<std::vector<Tensor<1,spacedim> > > >
- gradients_neighbor (gradients_here);
- std::vector<Vector<double> >
- grad_neighbor (n_solution_vectors, Vector<double>(n_components));
-
- // reserve some space for
- // coefficient values at one point.
- // if there is no coefficient, then
- // we fill it by unity once and for
- // all and don't set it any more
- Vector<double> coefficient_values (n_components);
- if (coefficient == 0)
- for (unsigned int c=0; c<n_components; ++c)
- coefficient_values(c) = 1;
-
- const QTrapez<1> quadrature;
- const hp::QCollection<1> q_collection(quadrature);
-
- const hp::FECollection<1,spacedim> fe (dof_handler.get_fe());
-
- hp::MappingCollection<1,spacedim> mapping_collection;
- mapping_collection.push_back (mapping);
-
- hp::FEValues<1,spacedim> fe_values (mapping_collection, fe, q_collection,
- update_gradients);
-
- // loop over all cells and do something on
- // the cells which we're told to work
- // on. note that the error indicator is
- // only a sum over the two contributions
- // from the two vertices of each cell.
- typename DH::active_cell_iterator cell = dof_handler.begin_active();
- for (unsigned int cell_index=0; cell != dof_handler.end();
- ++cell, ++cell_index)
- if (((subdomain_id == numbers::invalid_subdomain_id)
- ||
- (cell->subdomain_id() == subdomain_id))
- &&
- ((material_id == numbers::invalid_material_id)
- ||
- (cell->material_id() == material_id)))
- {
- for (unsigned int n=0; n<n_solution_vectors; ++n)
- (*errors[n])(cell_index) = 0;
-
- // loop over the two points bounding
- // this line. n==0 is left point,
- // n==1 is right point
- for (unsigned int n=0; n<2; ++n)
- {
- // find left or right active
- // neighbor
- typename DH::cell_iterator neighbor = cell->neighbor(n);
- if (neighbor.state() == IteratorState::valid)
- while (neighbor->has_children())
- neighbor = neighbor->child(n==0 ? 1 : 0);
-
- // now get the gradients on the
- // both sides of the point
- fe_values.reinit (cell);
-
- for (unsigned int s=0; s<n_solution_vectors; ++s)
- fe_values.get_present_fe_values()
- .get_function_gradients (*solutions[s], gradients_here[s]);
-
- if (neighbor.state() == IteratorState::valid)
- {
- fe_values.reinit (neighbor);
-
- for (unsigned int s=0; s<n_solution_vectors; ++s)
- fe_values.get_present_fe_values()
- .get_function_gradients (*solutions[s],
- gradients_neighbor[s]);
-
- // extract the
- // gradients of all the
- // components. [0]
- // means: x-derivative,
- // which is the only
- // one here
- for (unsigned int s=0; s<n_solution_vectors; ++s)
- for (unsigned int c=0; c<n_components; ++c)
- grad_neighbor[s](c)
- = gradients_neighbor[s][n==0 ? 1 : 0][c][0];
- }
- else if (neumann_bc.find(n) != neumann_bc.end())
- // if Neumann b.c., then fill
- // the gradients field which
- // will be used later on.
- {
- if (n_components==1)
- {
- const double
- v = neumann_bc.find(n)->second->value(cell->vertex(0));
-
- for (unsigned int s=0; s<n_solution_vectors; ++s)
- grad_neighbor[s](0) = v;
- }
- else
- {
- Vector<double> v(n_components);
- neumann_bc.find(n)->second->vector_value(cell->vertex(0), v);
-
- for (unsigned int s=0; s<n_solution_vectors; ++s)
- grad_neighbor[s] = v;
- }
- }
- else
- // fill with zeroes.
- for (unsigned int s=0; s<n_solution_vectors; ++s)
- grad_neighbor[s] = 0;
-
- // if there is a
- // coefficient, then
- // evaluate it at the
- // present position. if
- // there is none, reuse the
- // preset values.
- if (coefficient != 0)
- {
- if (coefficient->n_components == 1)
- {
- const double c_value = coefficient->value (cell->vertex(n));
- for (unsigned int c=0; c<n_components; ++c)
- coefficient_values(c) = c_value;
- }
- else
- coefficient->vector_value(cell->vertex(n),
- coefficient_values);
- }
-
-
- for (unsigned int s=0; s<n_solution_vectors; ++s)
- for (unsigned int component=0; component<n_components; ++component)
- if (component_mask[component] == true)
- {
- // get gradient
- // here. [0] means
- // x-derivative
- // (there is no
- // other component
- // in 1d)
- const double grad_here = gradients_here[s][n][component][0];
-
- const double jump = ((grad_here - grad_neighbor[s](component)) *
- coefficient_values(component));
- (*errors[s])(cell_index) += jump*jump * cell->diameter();
- }
- }
-
- for (unsigned int s=0; s<n_solution_vectors; ++s)
- (*errors[s])(cell_index) = std::sqrt((*errors[s])(cell_index));
- }
-}
-
-
-
-
-
-
// the following function is still independent of dimension, but it
// calls dimension dependent functions
template <int dim, int spacedim>
const unsigned int n_solution_vectors = solutions.size();
- // Map of integrals indexed by
- // the corresponding face. In this map
- // we store the integrated jump of the
- // gradient for each face.
- // At the end of the function, we again
- // loop over the cells and collect the
- // contributions of the different faces
- // of the cell.
+ // Map of integrals indexed by the corresponding face. In this map we store
+ // the integrated jump of the gradient for each face. At the end of the
+ // function, we again loop over the cells and collect the contributions of
+ // the different faces of the cell.
std::map<typename DH::face_iterator,std::vector<double> > face_integrals;
- // all the data needed in the error
- // estimator by each of the threads
- // is gathered in the following
- // stuctures
+ // all the data needed in the error estimator by each of the threads is
+ // gathered in the following structures
const hp::MappingCollection<dim,spacedim> mapping_collection(mapping);
const internal::ParallelData<DH>
parallel_data (dof_handler.get_fe(),
// now let's work on all those cells:
WorkStream::run (dof_handler.begin_active(),
static_cast<typename DH::active_cell_iterator>(dof_handler.end()),
- std_cxx1x::bind (&internal::estimate_one_cell<dim,spacedim,InputVector,DH>,
+ std_cxx1x::bind (&internal::estimate_one_cell<InputVector,DH>,
std_cxx1x::_1, std_cxx1x::_2, std_cxx1x::_3, std_cxx1x::ref(solutions)),
std_cxx1x::bind (&internal::copy_local_to_global<DH>,
std_cxx1x::_1, std_cxx1x::ref(face_integrals)),
parallel_data,
sample_local_face_integrals);
- // finally add up the contributions of the
- // faces for each cell
+ // finally add up the contributions of the faces for each cell
- // reserve one slot for each cell and set
- // it to zero
+ // reserve one slot for each cell and set it to zero
for (unsigned int n=0; n<n_solution_vectors; ++n)
{
(*errors[n]).reinit (dof_handler.get_tria().n_active_cells());
(*errors[n])(i)=0;
}
- // now walk over all cells and collect
- // information from the faces. only do
- // something if this is a cell we care for
- // based on the subdomain id
+ // now walk over all cells and collect information from the faces. only do
+ // something if this is a cell we care for based on the subdomain id
unsigned int present_cell=0;
for (typename DH::active_cell_iterator cell=dof_handler.begin_active();
cell!=dof_handler.end();
for (unsigned int n=0; n<n_solution_vectors; ++n)
{
- // make sure that we have
- // written a meaningful value
- // into this slot
+ // make sure that we have written a meaningful value into this
+ // slot
Assert (face_integrals[cell->face(face_no)][n] >= 0,
ExcInternalError());
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS ; deal_II_space_dimension : SPACE_DIMENSIONS)
{
for (VEC : SERIAL_VECTORS ; deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS; DH : DOFHANDLER_TEMPLATES )
{
-#if deal_II_dimension <= deal_II_space_dimension
+#if deal_II_dimension != 1 && deal_II_dimension <= deal_II_space_dimension
template
void
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1998 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+#include <deal.II/base/thread_management.h>
+#include <deal.II/base/quadrature.h>
+#include <deal.II/base/quadrature_lib.h>
+#include <deal.II/base/work_stream.h>
+#include <deal.II/lac/vector.h>
+#include <deal.II/lac/parallel_vector.h>
+#include <deal.II/lac/block_vector.h>
+#include <deal.II/lac/parallel_block_vector.h>
+#include <deal.II/lac/petsc_vector.h>
+#include <deal.II/lac/petsc_block_vector.h>
+#include <deal.II/lac/trilinos_vector.h>
+#include <deal.II/lac/trilinos_block_vector.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/base/geometry_info.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/dofs/dof_accessor.h>
+#include <deal.II/fe/fe.h>
+#include <deal.II/fe/fe_values.h>
+#include <deal.II/hp/fe_values.h>
+#include <deal.II/fe/fe_update_flags.h>
+#include <deal.II/fe/mapping_q1.h>
+#include <deal.II/hp/q_collection.h>
+#include <deal.II/hp/mapping_collection.h>
+#include <deal.II/numerics/error_estimator.h>
+
+#include <deal.II/base/std_cxx1x/bind.h>
+
+#include <numeric>
+#include <algorithm>
+#include <cmath>
+#include <vector>
+
+DEAL_II_NAMESPACE_OPEN
+
+
+
+template <int spacedim>
+template <typename InputVector, class DH>
+void
+KellyErrorEstimator<1,spacedim>::
+estimate (const Mapping<1,spacedim> &mapping,
+ const DH &dof_handler,
+ const Quadrature<0> &quadrature,
+ const typename FunctionMap<spacedim>::type &neumann_bc,
+ const InputVector &solution,
+ Vector<float> &error,
+ const ComponentMask &component_mask,
+ const Function<spacedim> *coefficients,
+ const unsigned int n_threads,
+ const types::subdomain_id subdomain_id,
+ const types::material_id material_id)
+{
+ // just pass on to the other function
+ const std::vector<const InputVector *> solutions (1, &solution);
+ std::vector<Vector<float>*> errors (1, &error);
+ estimate (mapping, dof_handler, quadrature, neumann_bc, solutions, errors,
+ component_mask, coefficients, n_threads, subdomain_id, material_id);
+}
+
+
+
+template <int spacedim>
+template <typename InputVector, class DH>
+void
+KellyErrorEstimator<1,spacedim>::
+estimate (const DH &dof_handler,
+ const Quadrature<0> &quadrature,
+ const typename FunctionMap<spacedim>::type &neumann_bc,
+ const InputVector &solution,
+ Vector<float> &error,
+ const ComponentMask &component_mask,
+ const Function<spacedim> *coefficients,
+ const unsigned int n_threads,
+ const types::subdomain_id subdomain_id,
+ const types::material_id material_id)
+{
+ estimate(StaticMappingQ1<1,spacedim>::mapping, dof_handler, quadrature, neumann_bc, solution,
+ error, component_mask, coefficients, n_threads, subdomain_id, material_id);
+}
+
+
+
+template <int spacedim>
+template <typename InputVector, class DH>
+void
+KellyErrorEstimator<1,spacedim>::
+estimate (const DH &dof_handler,
+ const Quadrature<0> &quadrature,
+ const typename FunctionMap<spacedim>::type &neumann_bc,
+ const std::vector<const InputVector *> &solutions,
+ std::vector<Vector<float>*> &errors,
+ const ComponentMask &component_mask,
+ const Function<spacedim> *coefficients,
+ const unsigned int n_threads,
+ const types::subdomain_id subdomain_id,
+ const types::material_id material_id)
+{
+ estimate(StaticMappingQ1<1,spacedim>::mapping, dof_handler, quadrature, neumann_bc, solutions,
+ errors, component_mask, coefficients, n_threads, subdomain_id, material_id);
+}
+
+
+
+template <int spacedim>
+template <typename InputVector, class DH>
+void
+KellyErrorEstimator<1,spacedim>::
+estimate (const Mapping<1,spacedim> &mapping,
+ const DH &dof_handler,
+ const hp::QCollection<0> &quadrature,
+ const typename FunctionMap<spacedim>::type &neumann_bc,
+ const InputVector &solution,
+ Vector<float> &error,
+ const ComponentMask &component_mask,
+ const Function<spacedim> *coefficients,
+ const unsigned int n_threads,
+ const types::subdomain_id subdomain_id,
+ const types::material_id material_id)
+{
+ // just pass on to the other function
+ const std::vector<const InputVector *> solutions (1, &solution);
+ std::vector<Vector<float>*> errors (1, &error);
+ estimate (mapping, dof_handler, quadrature, neumann_bc, solutions, errors,
+ component_mask, coefficients, n_threads, subdomain_id, material_id);
+}
+
+
+template <int spacedim>
+template <typename InputVector, class DH>
+void
+KellyErrorEstimator<1,spacedim>::
+estimate (const DH &dof_handler,
+ const hp::QCollection<0> &quadrature,
+ const typename FunctionMap<spacedim>::type &neumann_bc,
+ const InputVector &solution,
+ Vector<float> &error,
+ const ComponentMask &component_mask,
+ const Function<spacedim> *coefficients,
+ const unsigned int n_threads,
+ const types::subdomain_id subdomain_id,
+ const types::material_id material_id)
+{
+ estimate(StaticMappingQ1<1,spacedim>::mapping, dof_handler, quadrature, neumann_bc, solution,
+ error, component_mask, coefficients, n_threads, subdomain_id, material_id);
+}
+
+
+
+template <int spacedim>
+template <typename InputVector, class DH>
+void
+KellyErrorEstimator<1,spacedim>::
+estimate (const DH &dof_handler,
+ const hp::QCollection<0> &quadrature,
+ const typename FunctionMap<spacedim>::type &neumann_bc,
+ const std::vector<const InputVector *> &solutions,
+ std::vector<Vector<float>*> &errors,
+ const ComponentMask &component_mask,
+ const Function<spacedim> *coefficients,
+ const unsigned int n_threads,
+ const types::subdomain_id subdomain_id,
+ const types::material_id material_id)
+{
+ estimate(StaticMappingQ1<1,spacedim>::mapping, dof_handler, quadrature, neumann_bc, solutions,
+ errors, component_mask, coefficients, n_threads, subdomain_id, material_id);
+}
+
+
+
+
+template <int spacedim>
+template <typename InputVector, class DH>
+void KellyErrorEstimator<1,spacedim>::
+estimate (const Mapping<1,spacedim> &/*mapping*/,
+ const DH &/*dof_handler*/,
+ const hp::QCollection<0> &,
+ const typename FunctionMap<spacedim>::type &/*neumann_bc*/,
+ const std::vector<const InputVector *> &/*solutions*/,
+ std::vector<Vector<float>*> &/*errors*/,
+ const ComponentMask &/*component_mask_*/,
+ const Function<spacedim> */*coefficient*/,
+ const unsigned int,
+ const types::subdomain_id /*subdomain_id*/,
+ const types::material_id /*material_id*/)
+{
+ Assert (false, ExcInternalError());
+}
+
+
+
+template <int spacedim>
+template <typename InputVector, class DH>
+void KellyErrorEstimator<1,spacedim>::
+estimate (const Mapping<1,spacedim> &mapping,
+ const DH &dof_handler,
+ const Quadrature<0> &,
+ const typename FunctionMap<spacedim>::type &neumann_bc,
+ const std::vector<const InputVector *> &solutions,
+ std::vector<Vector<float>*> &errors,
+ const ComponentMask &component_mask,
+ const Function<spacedim> *coefficient,
+ const unsigned int,
+ const types::subdomain_id subdomain_id_,
+ const types::material_id material_id)
+{
+#ifdef DEAL_II_WITH_P4EST
+ if (dynamic_cast<const parallel::distributed::Triangulation<1,spacedim>*>
+ (&dof_handler.get_tria())
+ != 0)
+ Assert ((subdomain_id_ == numbers::invalid_subdomain_id)
+ ||
+ (subdomain_id_ ==
+ dynamic_cast<const parallel::distributed::Triangulation<1,spacedim>&>
+ (dof_handler.get_tria()).locally_owned_subdomain()),
+ ExcMessage ("For parallel distributed triangulations, the only "
+ "valid subdomain_id that can be passed here is the "
+ "one that corresponds to the locally owned subdomain id."));
+
+ const types::subdomain_id subdomain_id
+ = ((dynamic_cast<const parallel::distributed::Triangulation<1,spacedim>*>
+ (&dof_handler.get_tria())
+ != 0)
+ ?
+ dynamic_cast<const parallel::distributed::Triangulation<1,spacedim>&>
+ (dof_handler.get_tria()).locally_owned_subdomain()
+ :
+ subdomain_id_);
+#else
+ const types::subdomain_id subdomain_id
+ = subdomain_id_;
+#endif
+
+ const unsigned int n_components = dof_handler.get_fe().n_components();
+ const unsigned int n_solution_vectors = solutions.size();
+
+ // sanity checks
+ Assert (neumann_bc.find(numbers::internal_face_boundary_id) == neumann_bc.end(),
+ ExcInvalidBoundaryIndicator());
+
+ for (typename FunctionMap<spacedim>::type::const_iterator i=neumann_bc.begin();
+ i!=neumann_bc.end(); ++i)
+ Assert (i->second->n_components == n_components, ExcInvalidBoundaryFunction());
+
+ Assert (component_mask.represents_n_components(n_components),
+ ExcInvalidComponentMask());
+ Assert (component_mask.n_selected_components(n_components) > 0,
+ ExcInvalidComponentMask());
+
+ Assert ((coefficient == 0) ||
+ (coefficient->n_components == n_components) ||
+ (coefficient->n_components == 1),
+ ExcInvalidCoefficient());
+
+ Assert (solutions.size() > 0,
+ ExcNoSolutions());
+ Assert (solutions.size() == errors.size(),
+ ExcIncompatibleNumberOfElements(solutions.size(), errors.size()));
+ for (unsigned int n=0; n<solutions.size(); ++n)
+ Assert (solutions[n]->size() == dof_handler.n_dofs(),
+ ExcInvalidSolutionVector());
+
+ Assert ((coefficient == 0) ||
+ (coefficient->n_components == n_components) ||
+ (coefficient->n_components == 1),
+ ExcInvalidCoefficient());
+
+ for (typename FunctionMap<spacedim>::type::const_iterator i=neumann_bc.begin();
+ i!=neumann_bc.end(); ++i)
+ Assert (i->second->n_components == n_components,
+ ExcInvalidBoundaryFunction());
+
+ // reserve one slot for each cell and set it to zero
+ for (unsigned int n=0; n<n_solution_vectors; ++n)
+ (*errors[n]).reinit (dof_handler.get_tria().n_active_cells());
+
+ // fields to get the gradients on the present and the neighbor cell.
+ //
+ // for the neighbor gradient, we need several auxiliary fields, depending on
+ // the way we get it (see below)
+ std::vector<std::vector<std::vector<Tensor<1,spacedim> > > >
+ gradients_here (n_solution_vectors,
+ std::vector<std::vector<Tensor<1,spacedim> > >(2, std::vector<Tensor<1,spacedim> >(n_components)));
+ std::vector<std::vector<std::vector<Tensor<1,spacedim> > > >
+ gradients_neighbor (gradients_here);
+ std::vector<Vector<double> >
+ grad_neighbor (n_solution_vectors, Vector<double>(n_components));
+
+ // reserve some space for coefficient values at one point. if there is no
+ // coefficient, then we fill it by unity once and for all and don't set it
+ // any more
+ Vector<double> coefficient_values (n_components);
+ if (coefficient == 0)
+ for (unsigned int c=0; c<n_components; ++c)
+ coefficient_values(c) = 1;
+
+ const QTrapez<1> quadrature;
+ const hp::QCollection<1> q_collection(quadrature);
+
+ const hp::FECollection<1,spacedim> fe (dof_handler.get_fe());
+
+ hp::MappingCollection<1,spacedim> mapping_collection;
+ mapping_collection.push_back (mapping);
+
+ hp::FEValues<1,spacedim> fe_values (mapping_collection, fe, q_collection,
+ update_gradients);
+
+ // loop over all cells and do something on the cells which we're told to
+ // work on. note that the error indicator is only a sum over the two
+ // contributions from the two vertices of each cell.
+ typename DH::active_cell_iterator cell = dof_handler.begin_active();
+ for (unsigned int cell_index=0; cell != dof_handler.end();
+ ++cell, ++cell_index)
+ if (((subdomain_id == numbers::invalid_subdomain_id)
+ ||
+ (cell->subdomain_id() == subdomain_id))
+ &&
+ ((material_id == numbers::invalid_material_id)
+ ||
+ (cell->material_id() == material_id)))
+ {
+ for (unsigned int n=0; n<n_solution_vectors; ++n)
+ (*errors[n])(cell_index) = 0;
+
+ // loop over the two points bounding this line. n==0 is left point,
+ // n==1 is right point
+ for (unsigned int n=0; n<2; ++n)
+ {
+ // find left or right active neighbor
+ typename DH::cell_iterator neighbor = cell->neighbor(n);
+ if (neighbor.state() == IteratorState::valid)
+ while (neighbor->has_children())
+ neighbor = neighbor->child(n==0 ? 1 : 0);
+
+ // now get the gradients on the both sides of the point
+ fe_values.reinit (cell);
+
+ for (unsigned int s=0; s<n_solution_vectors; ++s)
+ fe_values.get_present_fe_values()
+ .get_function_gradients (*solutions[s], gradients_here[s]);
+
+ if (neighbor.state() == IteratorState::valid)
+ {
+ fe_values.reinit (neighbor);
+
+ for (unsigned int s=0; s<n_solution_vectors; ++s)
+ fe_values.get_present_fe_values()
+ .get_function_gradients (*solutions[s],
+ gradients_neighbor[s]);
+
+ // extract the gradients of all the components. [0] means:
+ // x-derivative, which is the only one here
+ for (unsigned int s=0; s<n_solution_vectors; ++s)
+ for (unsigned int c=0; c<n_components; ++c)
+ grad_neighbor[s](c)
+ = gradients_neighbor[s][n==0 ? 1 : 0][c][0];
+ }
+ else if (neumann_bc.find(n) != neumann_bc.end())
+ // if Neumann b.c., then fill the gradients field which will be
+ // used later on.
+ {
+ if (n_components==1)
+ {
+ const double
+ v = neumann_bc.find(n)->second->value(cell->vertex(0));
+
+ for (unsigned int s=0; s<n_solution_vectors; ++s)
+ grad_neighbor[s](0) = v;
+ }
+ else
+ {
+ Vector<double> v(n_components);
+ neumann_bc.find(n)->second->vector_value(cell->vertex(0), v);
+
+ for (unsigned int s=0; s<n_solution_vectors; ++s)
+ grad_neighbor[s] = v;
+ }
+ }
+ else
+ // fill with zeroes.
+ for (unsigned int s=0; s<n_solution_vectors; ++s)
+ grad_neighbor[s] = 0;
+
+ // if there is a coefficient, then evaluate it at the present
+ // position. if there is none, reuse the preset values.
+ if (coefficient != 0)
+ {
+ if (coefficient->n_components == 1)
+ {
+ const double c_value = coefficient->value (cell->vertex(n));
+ for (unsigned int c=0; c<n_components; ++c)
+ coefficient_values(c) = c_value;
+ }
+ else
+ coefficient->vector_value(cell->vertex(n),
+ coefficient_values);
+ }
+
+
+ for (unsigned int s=0; s<n_solution_vectors; ++s)
+ for (unsigned int component=0; component<n_components; ++component)
+ if (component_mask[component] == true)
+ {
+ // get gradient here. [0] means x-derivative (there is no
+ // other component in 1d)
+ const double grad_here = gradients_here[s][n][component][0];
+
+ const double jump = ((grad_here - grad_neighbor[s](component)) *
+ coefficient_values(component));
+ (*errors[s])(cell_index) += jump*jump * cell->diameter();
+ }
+ }
+
+ for (unsigned int s=0; s<n_solution_vectors; ++s)
+ (*errors[s])(cell_index) = std::sqrt((*errors[s])(cell_index));
+ }
+}
+
+
+// explicit instantiations
+#include "error_estimator_1d.inst"
+
+
+DEAL_II_NAMESPACE_CLOSE
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 2010 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+for (VEC : SERIAL_VECTORS ; deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS; DH : DOFHANDLER_TEMPLATES )
+{
+#if deal_II_dimension == 1 && deal_II_dimension <= deal_II_space_dimension
+
+template
+void
+KellyErrorEstimator<deal_II_dimension, deal_II_space_dimension>::
+estimate<VEC,DH<deal_II_dimension,deal_II_space_dimension> > (const Mapping<deal_II_dimension, deal_II_space_dimension> &,
+ const DH<deal_II_dimension,deal_II_space_dimension> &,
+ const Quadrature<deal_II_dimension-1> &,
+ const FunctionMap<deal_II_space_dimension>::type &,
+ const VEC &,
+ Vector<float> &,
+ const ComponentMask &,
+ const Function<deal_II_space_dimension> *,
+ const unsigned int ,
+ const unsigned int ,
+ const types::material_id);
+
+template
+void
+KellyErrorEstimator<deal_II_dimension, deal_II_space_dimension>::
+estimate<VEC,DH<deal_II_dimension,deal_II_space_dimension> > (
+ const DH<deal_II_dimension,deal_II_space_dimension> &,
+ const Quadrature<deal_II_dimension-1> &,
+ const FunctionMap<deal_II_space_dimension>::type &,
+ const VEC &,
+ Vector<float> &,
+ const ComponentMask &,
+ const Function<deal_II_space_dimension> *,
+ const unsigned int ,
+ const unsigned int ,
+ const types::material_id);
+
+template
+void
+KellyErrorEstimator<deal_II_dimension, deal_II_space_dimension>::
+estimate<VEC,DH<deal_II_dimension,deal_II_space_dimension> > (const Mapping<deal_II_dimension, deal_II_space_dimension> &,
+ const DH<deal_II_dimension,deal_II_space_dimension> &,
+ const Quadrature<deal_II_dimension-1> &,
+ const FunctionMap<deal_II_space_dimension>::type &,
+ const std::vector<const VEC *> &,
+ std::vector<Vector<float> *> &,
+ const ComponentMask &,
+ const Function<deal_II_space_dimension> *,
+ const unsigned int ,
+ const unsigned int ,
+ const types::material_id);
+
+template
+void
+KellyErrorEstimator<deal_II_dimension, deal_II_space_dimension>::
+estimate<VEC,DH<deal_II_dimension,deal_II_space_dimension> > (
+ const DH<deal_II_dimension,deal_II_space_dimension> &,
+ const Quadrature<deal_II_dimension-1> &,
+ const FunctionMap<deal_II_space_dimension>::type &,
+ const std::vector<const VEC *> &,
+ std::vector<Vector<float> *> &,
+ const ComponentMask &,
+ const Function<deal_II_space_dimension> *,
+ const unsigned int ,
+ const unsigned int ,
+ const types::material_id);
+
+template
+void
+KellyErrorEstimator<deal_II_dimension, deal_II_space_dimension>::
+estimate<VEC,DH<deal_II_dimension,deal_II_space_dimension> > (const Mapping<deal_II_dimension, deal_II_space_dimension> &,
+ const DH<deal_II_dimension,deal_II_space_dimension> &,
+ const hp::QCollection<deal_II_dimension-1> &,
+ const FunctionMap<deal_II_space_dimension>::type &,
+ const VEC &,
+ Vector<float> &,
+ const ComponentMask &,
+ const Function<deal_II_space_dimension> *,
+ const unsigned int ,
+ const unsigned int ,
+ const types::material_id);
+
+template
+void
+KellyErrorEstimator<deal_II_dimension, deal_II_space_dimension>::
+estimate<VEC,DH<deal_II_dimension,deal_II_space_dimension> > (
+ const DH<deal_II_dimension,deal_II_space_dimension> &,
+ const hp::QCollection<deal_II_dimension-1> &,
+ const FunctionMap<deal_II_space_dimension>::type &,
+ const VEC &,
+ Vector<float> &,
+ const ComponentMask &,
+ const Function<deal_II_space_dimension> *,
+ const unsigned int ,
+ const unsigned int ,
+ const types::material_id);
+
+template
+void
+KellyErrorEstimator<deal_II_dimension, deal_II_space_dimension>::
+estimate<VEC,DH<deal_II_dimension,deal_II_space_dimension> > (const Mapping<deal_II_dimension, deal_II_space_dimension> &,
+ const DH<deal_II_dimension,deal_II_space_dimension> &,
+ const hp::QCollection<deal_II_dimension-1> &,
+ const FunctionMap<deal_II_space_dimension>::type &,
+ const std::vector<const VEC *> &,
+ std::vector<Vector<float> *> &,
+ const ComponentMask &,
+ const Function<deal_II_space_dimension> *,
+ const unsigned int ,
+ const unsigned int ,
+ const types::material_id);
+
+template
+void
+KellyErrorEstimator<deal_II_dimension, deal_II_space_dimension>::
+estimate<VEC,DH<deal_II_dimension,deal_II_space_dimension> > (
+ const DH<deal_II_dimension,deal_II_space_dimension> &,
+ const hp::QCollection<deal_II_dimension-1> &,
+ const FunctionMap<deal_II_space_dimension>::type &,
+ const std::vector<const VEC *> &,
+ std::vector<Vector<float> *> &,
+ const ComponentMask &,
+ const Function<deal_II_space_dimension> *,
+ const unsigned int ,
+ const unsigned int ,
+ const types::material_id);
+
+#endif
+}
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2007, 2008, 2012 by the deal.II authors
+// Copyright (C) 2007 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/numerics/fe_field_function.templates.h>
#include <deal.II/multigrid/mg_dof_handler.h>
-//---------------------------------------------------------------------------
-// $Id$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2007, 2008, 2009, 2012 by the deal.II authors
+// Copyright (C) 2007 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (VECTOR : SERIAL_VECTORS ; deal_II_dimension : DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/memory_consumption.h>
#include <deal.II/lac/vector.h>
template <typename number>
-inline
bool Histogram::logarithmic_less (const number n1,
const number n2)
{
values[i].end(),
logarithmic_less_function),
logarithmic_less_function);
- };
+ }
break;
- };
+ }
default:
Assert (false, ExcInternalError());
- };
+ }
// move right bound arbitrarily if
// necessary. sometimes in logarithmic
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/function.h>
#include <deal.II/base/quadrature.h>
std::vector<double> rhs_values;
std::vector<dealii::Vector<double> > rhs_vector_values;
- std::vector<double> old_JxW;
-
const Function<spacedim> *coefficient;
const Function<spacedim> *rhs_function;
UpdateFlags update_flags = UpdateFlags (update_values |
update_JxW_values |
update_quadrature_points);
- hp::FEFaceValues<dim> x_fe_values (mapping, fe_collection, q, update_flags);
+ hp::FEFaceValues<dim,spacedim> x_fe_values (mapping, fe_collection, q, update_flags);
// two variables for the coefficient,
// one for the two cases indicated in
std::map<types::global_dof_index,double>::const_iterator dof = boundary_values.begin(),
- endd = boundary_values.end();
+ endd = boundary_values.end();
for (; dof != endd; ++dof)
{
Assert (dof->first < n_dofs, ExcInternalError());
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2010, 2012 by the deal.II authors
+// Copyright (C) 2010 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
{
#if deal_II_dimension <= deal_II_space_dimension
const Function<deal_II_space_dimension> * const a,
std::vector<unsigned int>);
+ template
+ void
+ MatrixCreator::create_boundary_mass_matrix<deal_II_dimension,deal_II_space_dimension>
+ (const hp::MappingCollection<deal_II_dimension,deal_II_space_dimension>&,
+ const hp::DoFHandler<deal_II_dimension,deal_II_space_dimension>&,
+ const hp::QCollection<deal_II_dimension-1>&,
+ SparseMatrix<double>&,
+ const FunctionMap<deal_II_space_dimension>::type&,
+ Vector<double>&,
+ std::vector<types::global_dof_index>&,
+ const Function<deal_II_space_dimension> * const,
+ std::vector<unsigned int>);
-
+ template
+ void MatrixCreator::create_boundary_mass_matrix<deal_II_dimension,deal_II_space_dimension>
+ (const hp::DoFHandler<deal_II_dimension,deal_II_space_dimension>&,
+ const hp::QCollection<deal_II_dimension-1>&,
+ SparseMatrix<double>&,
+ const FunctionMap<deal_II_space_dimension>::type&,
+ Vector<double>&,
+ std::vector<types::global_dof_index>&,
+ const Function<deal_II_space_dimension> * const,
+ std::vector<unsigned int>);
#endif
}
// where applicable and move to codimension cases above also when applicable
for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
{
-#if deal_II_dimension == deal_II_space_dimension
-
+#if deal_II_dimension <= deal_II_space_dimension
// hp versions of functions
template
- void MatrixCreator::create_mass_matrix<deal_II_dimension>
- (const hp::MappingCollection<deal_II_dimension> &mapping,
- const hp::DoFHandler<deal_II_dimension> &dof,
+ void MatrixCreator::create_mass_matrix<deal_II_dimension,double,deal_II_space_dimension>
+ (const hp::MappingCollection<deal_II_dimension,deal_II_space_dimension> &mapping,
+ const hp::DoFHandler<deal_II_dimension,deal_II_space_dimension> &dof,
const hp::QCollection<deal_II_dimension> &q,
SparseMatrix<double> &matrix,
- const Function<deal_II_dimension> * const coefficient,
+ const Function<deal_II_space_dimension> * const coefficient,
const ConstraintMatrix &constraints);
+
template
- void MatrixCreator::create_mass_matrix<deal_II_dimension>
- (const hp::DoFHandler<deal_II_dimension> &dof,
+ void MatrixCreator::create_mass_matrix<deal_II_dimension,double,deal_II_space_dimension>
+ (const hp::MappingCollection<deal_II_dimension,deal_II_space_dimension> &mapping,
+ const hp::DoFHandler<deal_II_dimension,deal_II_space_dimension> &dof,
const hp::QCollection<deal_II_dimension> &q,
SparseMatrix<double> &matrix,
- const Function<deal_II_dimension> * const coefficient,
+ const Function<deal_II_space_dimension> &rhs,
+ Vector<double> &rhs_vector,
+ const Function<deal_II_space_dimension> * const coefficient,
const ConstraintMatrix &constraints);
+
template
void MatrixCreator::create_mass_matrix<deal_II_dimension>
- (const hp::MappingCollection<deal_II_dimension> &mapping,
- const hp::DoFHandler<deal_II_dimension> &dof,
+ (const hp::MappingCollection<deal_II_dimension,deal_II_space_dimension> &mapping,
+ const hp::DoFHandler<deal_II_dimension,deal_II_space_dimension> &dof,
const hp::QCollection<deal_II_dimension> &q,
- SparseMatrix<double> &matrix,
- const Function<deal_II_dimension> &rhs,
+ SparseMatrix<float> &matrix,
+ const Function<deal_II_space_dimension> &rhs,
Vector<double> &rhs_vector,
- const Function<deal_II_dimension> * const coefficient,
+ const Function<deal_II_space_dimension> * const coefficient,
const ConstraintMatrix &constraints);
+
template
void MatrixCreator::create_mass_matrix<deal_II_dimension>
- (const hp::DoFHandler<deal_II_dimension> &dof,
+ (const hp::DoFHandler<deal_II_dimension,deal_II_space_dimension> &dof,
const hp::QCollection<deal_II_dimension> &q,
- SparseMatrix<double> &matrix,
- const Function<deal_II_dimension> &rhs,
+ SparseMatrix<float> &matrix,
+ const Function<deal_II_space_dimension> &rhs,
Vector<double> &rhs_vector,
- const Function<deal_II_dimension> * const coefficient,
+ const Function<deal_II_space_dimension> * const coefficient,
const ConstraintMatrix &constraints);
+#endif
+#if deal_II_dimension == deal_II_space_dimension
+
+
template
void MatrixCreator::create_mass_matrix<deal_II_dimension>
- (const hp::MappingCollection<deal_II_dimension> &mapping,
- const hp::DoFHandler<deal_II_dimension> &dof,
+ (const hp::DoFHandler<deal_II_dimension,deal_II_space_dimension> &dof,
const hp::QCollection<deal_II_dimension> &q,
- SparseMatrix<float> &matrix,
- const Function<deal_II_dimension> * const coefficient,
+ SparseMatrix<double> &matrix,
+ const Function<deal_II_space_dimension> * const coefficient,
const ConstraintMatrix &constraints);
+
template
void MatrixCreator::create_mass_matrix<deal_II_dimension>
- (const hp::DoFHandler<deal_II_dimension> &dof,
+ (const hp::DoFHandler<deal_II_dimension,deal_II_space_dimension> &dof,
const hp::QCollection<deal_II_dimension> &q,
- SparseMatrix<float> &matrix,
- const Function<deal_II_dimension> * const coefficient,
+ SparseMatrix<double> &matrix,
+ const Function<deal_II_space_dimension> &rhs,
+ Vector<double> &rhs_vector,
+ const Function<deal_II_space_dimension> * const coefficient,
const ConstraintMatrix &constraints);
+
template
void MatrixCreator::create_mass_matrix<deal_II_dimension>
- (const hp::MappingCollection<deal_II_dimension> &mapping,
- const hp::DoFHandler<deal_II_dimension> &dof,
+ (const hp::MappingCollection<deal_II_dimension,deal_II_space_dimension> &mapping,
+ const hp::DoFHandler<deal_II_dimension,deal_II_space_dimension> &dof,
const hp::QCollection<deal_II_dimension> &q,
SparseMatrix<float> &matrix,
- const Function<deal_II_dimension> &rhs,
- Vector<double> &rhs_vector,
- const Function<deal_II_dimension> * const coefficient,
+ const Function<deal_II_space_dimension> * const coefficient,
const ConstraintMatrix &constraints);
+
template
void MatrixCreator::create_mass_matrix<deal_II_dimension>
- (const hp::DoFHandler<deal_II_dimension> &dof,
+ (const hp::DoFHandler<deal_II_dimension,deal_II_space_dimension> &dof,
const hp::QCollection<deal_II_dimension> &q,
SparseMatrix<float> &matrix,
- const Function<deal_II_dimension> &rhs,
- Vector<double> &rhs_vector,
- const Function<deal_II_dimension> * const coefficient,
- const ConstraintMatrix &constraints);
-
-
-#if deal_II_dimension != 1
-
-
-
- template
- void
- MatrixCreator::create_boundary_mass_matrix<deal_II_dimension>
- (const hp::MappingCollection<deal_II_dimension>&,
- const hp::DoFHandler<deal_II_dimension>&,
- const hp::QCollection<deal_II_dimension-1>&,
- SparseMatrix<double>&,
- const FunctionMap<deal_II_dimension>::type&,
- Vector<double>&,
- std::vector<types::global_dof_index>&,
- const Function<deal_II_dimension> * const,
- std::vector<unsigned int>);
-
- template
- void MatrixCreator::create_boundary_mass_matrix<deal_II_dimension>
- (const hp::DoFHandler<deal_II_dimension>&,
- const hp::QCollection<deal_II_dimension-1>&,
- SparseMatrix<double>&,
- const FunctionMap<deal_II_dimension>::type&,
- Vector<double>&,
- std::vector<types::global_dof_index>&,
- const Function<deal_II_dimension> * const,
- std::vector<unsigned int>);
-
-#endif
-
+ const Function<deal_II_space_dimension> * const coefficient,
+ const ConstraintMatrix &constraints);
// non-hp versions of create_laplace_matrix
template
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009, 2010, 2012 by Michael Rapson and the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
#include <deal.II/lac/vector.h>
#include <deal.II/lac/block_vector.h>
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2009 by Michael Rapson and the deal.II authors
+// Copyright (C) 2009 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/base/memory_consumption.h>
#include <deal.II/grid/tria.h>
{
matrices(i,j).reinit (fe[i].dofs_per_cell, fe[j].dofs_per_cell);
- // see if we can get the
- // interpolation matrices
- // for this combination
- // of elements. if not,
- // reset the matrix sizes
- // to zero to indicate
- // that this particular
- // combination isn't
- // supported. this isn't
- // an outright error
- // right away since we
- // may never need to
- // actually interpolate
- // between these two
- // elements on actual
- // cells; we simply have
- // to trigger an error if
- // someone actually tries
+ // see if we can get the interpolation matrices for this
+ // combination of elements. if not, reset the matrix sizes to zero
+ // to indicate that this particular combination isn't
+ // supported. this isn't an outright error right away since we may
+ // never need to actually interpolate between these two elements
+ // on actual cells; we simply have to trigger an error if someone
+ // actually tries
try
{
fe[i].get_interpolation_matrix (fe[j], matrices(i,j));
local_values.reinit (cell->has_children() ?
cell->child(0)->get_fe().dofs_per_cell
: cell->get_fe().dofs_per_cell, true);
- AssertDimension (local_values.size(),
- interpolation_hp(new_fe_index,old_index).m());
+ // do the interpolation. we get into trouble if the
+ // interpolation_hp(new,old) matrix hasn't been computed.
+ // this can happen if the respective elements don't support
+ // the corresponding interpolation; if that's the case, then
+ // the computation of the matrix simply sets the matrix
+ // back to size zero. so if we get here and that is
+ // the wrong size, then this may be because the elements
+ // haven't implemented the correct function yet
+ //
+ // there is one wrinkle. we would like to only error out if
+ // the size of the matrix is 0 times 0 but at least one
+ // of the elements has more than one dof per cell. the
+ // problem is that if you reinit a matrix to 4x0, it automatically
+ // sets its size to 0x0. so we can only execute the following
+ // test if *both* elements have dofs_per_cell>0, not if *at
+ // least one* have.
+ Assert (! ((interpolation_hp(new_fe_index,old_index).m() == 0)
+ &&
+ (interpolation_hp(new_fe_index,old_index).n() == 0)
+ &&
+ ((dof_handler->get_fe()[new_fe_index].dofs_per_cell > 0)
+ &&
+ (dof_handler->get_fe()[old_index].dofs_per_cell > 0))),
+ ExcMessage ("The interpolation between two different "
+ "elements you are trying to use here has "
+ "not been implemented for this pair of "
+ "elements!"));
+
// simple case where all children have the
// same FE index: just interpolate to their FE
// first and then use the standard routines
- interpolation_hp(new_fe_index,old_index).vmult (local_values, tmp);
+ if (tmp.size() > 0)
+ interpolation_hp(new_fe_index,old_index).vmult (local_values, tmp);
+ else
+ local_values = 0;
}
if (cell->has_children() == false)
AssertDimension (tmp.size(),
interpolation_hp(c_index,old_index).n());
local_values.reinit(cell->child(child)->get_fe().dofs_per_cell, true);
- AssertDimension (local_values.size(),
- interpolation_hp(c_index,old_index).m());
- interpolation_hp(c_index,old_index).vmult (local_values, tmp);
+
+ // do the interpolation. same problem as above
+ Assert (! ((interpolation_hp(c_index,old_index).m() == 0)
+ &&
+ (interpolation_hp(c_index,old_index).n() == 0)
+ &&
+ ((dof_handler->get_fe()[c_index].dofs_per_cell > 0)
+ &&
+ (dof_handler->get_fe()[old_index].dofs_per_cell > 0))),
+ ExcMessage ("The interpolation between two different "
+ "elements you are trying to use here has "
+ "not been implemented for this pair of "
+ "elements!"));
+
+ if (tmp.size() > 0)
+ interpolation_hp(c_index,old_index).vmult (local_values, tmp);
+ else
+ local_values = 0;
}
else
local_values = tmp;
#define DIM_B 2
#endif
+// This file compiles the first quarter of the instantiations from solution_transfer.cc
+// to reduce the compilation unit (and memory consumption)
#include "solution_transfer.inst"
DEAL_II_NAMESPACE_CLOSE
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (VEC : SERIAL_VECTORS; deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
{
#if deal_II_dimension <= deal_II_space_dimension
#if (deal_II_space_dimension == DIM_A) || (deal_II_space_dimension == DIM_B)
+#ifndef INSTANTIATE_HP_DH
template class SolutionTransfer<deal_II_dimension, VEC, DoFHandler<deal_II_dimension, deal_II_space_dimension> >;
+#else
template class SolutionTransfer<deal_II_dimension, VEC, hp::DoFHandler<deal_II_dimension, deal_II_space_dimension> >;
#endif
#endif
+#endif
}
-//---------------------------------------------------------------------------
-// $Id: $
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 2013 by the deal.II authors
+// Copyright (C) 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
-// This file compiles the second half of the instantiations from solution_transfer.cc
-// to get the memory consumption below 1.5gb with gcc (if compiling with PETSc and Trilinos).
+// This file compiles the second quarter of the instantiations from solution_transfer.cc
+// to reduce the compilation unit (and memory consumption)
+//#define INSTANTIATE_HP_DH
#define SOLUTION_TRANSFER_INSTANTIATE_PART_TWO
#include "solution_transfer.cc"
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+// This file compiles the third quarter of the instantiations from solution_transfer.cc
+// to reduce the compilation unit (and memory consumption)
+
+#define INSTANTIATE_HP_DH
+//#define SOLUTION_TRANSFER_INSTANTIATE_PART_TWO
+
+#include "solution_transfer.cc"
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+// This file compiles the fourth quarter of the instantiations from solution_transfer.cc
+// to reduce the compilation unit (and memory consumption)
+
+#define INSTANTIATE_HP_DH
+#define SOLUTION_TRANSFER_INSTANTIATE_PART_TWO
+
+#include "solution_transfer.cc"
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors
+// Copyright (C) 1999 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
-
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
#include <deal.II/numerics/time_dependent.h>
#include <deal.II/base/memory_consumption.h>
void (TimeDependent::*p) (const unsigned int, const unsigned int)
= &TimeDependent::end_sweep;
parallel::apply_to_subranges (0U, timesteps.size(),
- std_cxx1x::bind (p, this, std_cxx1x::_1, std_cxx1x::_2),
- 1);
+ std_cxx1x::bind (p, this, std_cxx1x::_1, std_cxx1x::_2),
+ 1);
}
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
+// ---------------------------------------------------------------------
+// $Id$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2011, 2012 by the deal.II authors
+// Copyright (C) 1998 - 2013 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.
+// This file is part of the deal.II library.
//
-//---------------------------------------------------------------------------
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
for (deal_II_dimension : DIMENSIONS)
{
+++ /dev/null
-//---------------------------------------------------------------------------
-// $Id$
-// Version: $Name$
-//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011, 2012 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 <deal.II/numerics/vector_tools.templates.h>
-
-DEAL_II_NAMESPACE_OPEN
-
-// ---------------------------- explicit instantiations --------------------
-#include "vector_tools.inst"
-
-DEAL_II_NAMESPACE_CLOSE
+++ /dev/null
-//---------------------------------------------------------------------------
-// $Id$
-//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2011, 2012 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.
-//
-//---------------------------------------------------------------------------
-
-for (VEC : SERIAL_VECTORS ; deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
- {
-#if deal_II_dimension <= deal_II_space_dimension
- namespace VectorTools \{
-
- template
- void integrate_difference<deal_II_dimension, VEC, Vector<float>, deal_II_space_dimension>
- (const DoFHandler<deal_II_dimension, deal_II_space_dimension>&,
- const VEC&,
- const Function<deal_II_space_dimension>&,
- Vector<float>&,
- const Quadrature<deal_II_dimension>&,
- const NormType&,
- const Function<deal_II_space_dimension>*,
- const double);
-
- template
- void integrate_difference<deal_II_dimension, VEC, Vector<double>, deal_II_space_dimension >
- (const DoFHandler<deal_II_dimension, deal_II_space_dimension>&,
- const VEC&,
- const Function<deal_II_space_dimension>&,
- Vector<double>&,
- const Quadrature<deal_II_dimension>&,
- const NormType&,
- const Function<deal_II_space_dimension>*,
- const double);
-
- template
- void integrate_difference<deal_II_dimension, VEC, Vector<float>, deal_II_space_dimension>
- (const Mapping<deal_II_dimension, deal_II_space_dimension>&,
- const DoFHandler<deal_II_dimension, deal_II_space_dimension>&,
- const VEC&,
- const Function<deal_II_space_dimension>&,
- Vector<float>&,
- const Quadrature<deal_II_dimension>&,
- const NormType&,
- const Function<deal_II_space_dimension>*,
- const double);
-
- template
- void integrate_difference<deal_II_dimension, VEC, Vector<double>, deal_II_space_dimension >
- (const Mapping<deal_II_dimension, deal_II_space_dimension>&,
- const DoFHandler<deal_II_dimension, deal_II_space_dimension>&,
- const VEC&,
- const Function<deal_II_space_dimension>&,
- Vector<double>&,
- const Quadrature<deal_II_dimension>&,
- const NormType&,
- const Function<deal_II_space_dimension>*,
- const double);
-
-
-
- template
- double compute_mean_value<deal_II_dimension>
- (const Mapping<deal_II_dimension,deal_II_space_dimension>&,
- const DoFHandler<deal_II_dimension,deal_II_space_dimension>&,
- const Quadrature<deal_II_dimension>&,
- const VEC&,
- const unsigned int);
-
- template
- double compute_mean_value<deal_II_dimension>
- (const DoFHandler<deal_II_dimension,deal_II_space_dimension>&,
- const Quadrature<deal_II_dimension>&,
- const VEC&,
- const unsigned int);
-
- template
- void interpolate
- (const Mapping<deal_II_dimension,deal_II_space_dimension>&,
- const DoFHandler<deal_II_dimension,deal_II_space_dimension>&,
- const Function<deal_II_space_dimension>&,
- VEC&);
-
- template
- void interpolate
- (const DoFHandler<deal_II_dimension,deal_II_space_dimension>&,
- const Function<deal_II_space_dimension>&,
- VEC&);
-
- template
- void project
- (const Mapping<deal_II_dimension,deal_II_space_dimension> &,
- const DoFHandler<deal_II_dimension,deal_II_space_dimension> &,
- const ConstraintMatrix &,
- const Quadrature<deal_II_dimension> &,
- const Function<deal_II_space_dimension> &,
- VEC &,
- const bool,
- const Quadrature<deal_II_dimension-1> &,
- const bool);
-
- template
- void project
- (const DoFHandler<deal_II_dimension,deal_II_space_dimension> &,
- const ConstraintMatrix &,
- const Quadrature<deal_II_dimension> &,
- const Function<deal_II_space_dimension> &,
- VEC &,
- const bool,
- const Quadrature<deal_II_dimension-1> &,
- const bool);
- \}
-#endif
- }
-
-
-
-//TODO[SP]: replace <deal_II_dimension> by <deal_II_dimension, deal_II_space_dimension>
-// where applicable and move to codimension cases above also when applicable
-for (VEC : SERIAL_VECTORS ; deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
- {
-#if deal_II_dimension == deal_II_space_dimension
-
- namespace VectorTools \{
-
- template
- void point_value<deal_II_dimension> (
- const hp::DoFHandler<deal_II_dimension>&,
- const VEC&,
- const Point<deal_II_dimension>&,
- Vector<double>&);
-
- template
- void interpolate
- (const Mapping<deal_II_dimension>&,
- const hp::DoFHandler<deal_II_dimension>&,
- const Function<deal_II_dimension>&,
- VEC&);
- template
- void interpolate
- (const hp::DoFHandler<deal_II_dimension>&,
- const Function<deal_II_dimension>&,
- VEC&);
-
- template
- double point_value<deal_II_dimension> (
- const hp::DoFHandler<deal_II_dimension>&,
- const VEC&,
- const Point<deal_II_dimension>&);
-
- template
- void point_value<deal_II_dimension> (
- const hp::MappingCollection<deal_II_dimension>&,
- const hp::DoFHandler<deal_II_dimension>&,
- const VEC&,
- const Point<deal_II_dimension>&,
- Vector<double>&);
-
- template
- void interpolate
- (const DoFHandler<deal_II_dimension>&,
- const DoFHandler<deal_II_dimension>&,
- const FullMatrix<double>&,
- const VEC&,
- VEC&);
-
- template
- double point_value<deal_II_dimension> (
- const hp::MappingCollection<deal_II_dimension>&,
- const hp::DoFHandler<deal_II_dimension>&,
- const VEC&,
- const Point<deal_II_dimension>&);
-
- template
- void integrate_difference<deal_II_dimension>
- (const hp::DoFHandler<deal_II_dimension>&,
- const VEC&,
- const Function<deal_II_dimension>&,
- Vector<double>&,
- const hp::QCollection<deal_II_dimension>&,
- const NormType&,
- const Function<deal_II_dimension>*,
- const double);
- template
- void integrate_difference<deal_II_dimension>
- (const hp::DoFHandler<deal_II_dimension>&,
- const VEC&,
- const Function<deal_II_dimension>&,
- Vector<float>&,
- const hp::QCollection<deal_II_dimension>&,
- const NormType&,
- const Function<deal_II_dimension>*,
- const double);
- template
- void integrate_difference<deal_II_dimension>
- (const hp::MappingCollection<deal_II_dimension>&,
- const hp::DoFHandler<deal_II_dimension>&,
- const VEC&,
- const Function<deal_II_dimension>&,
- Vector<double>&,
- const hp::QCollection<deal_II_dimension>&,
- const NormType&,
- const Function<deal_II_dimension>*,
- const double);
- template
- void integrate_difference<deal_II_dimension>
- (const hp::MappingCollection<deal_II_dimension>&,
- const hp::DoFHandler<deal_II_dimension>&,
- const VEC&,
- const Function<deal_II_dimension>&,
- Vector<float>&,
- const hp::QCollection<deal_II_dimension>&,
- const NormType&,
- const Function<deal_II_dimension>*,
- const double);
-
- template
- void point_difference<deal_II_dimension> (
- const DoFHandler<deal_II_dimension>&,
- const VEC&,
- const Function<deal_II_dimension>&,
- Vector<double>&,
- const Point<deal_II_dimension>&);
-
- template
- void point_difference<deal_II_dimension> (
- const Mapping<deal_II_dimension>&,
- const DoFHandler<deal_II_dimension>&,
- const VEC&,
- const Function<deal_II_dimension>&,
- Vector<double>&,
- const Point<deal_II_dimension>&);
-
- template
- void point_value<deal_II_dimension> (
- const DoFHandler<deal_II_dimension>&,
- const VEC&,
- const Point<deal_II_dimension>&,
- Vector<double>&);
-
- template
- double point_value<deal_II_dimension> (
- const DoFHandler<deal_II_dimension>&,
- const VEC&,
- const Point<deal_II_dimension>&);
-
- template
- void point_value<deal_II_dimension> (
- const Mapping<deal_II_dimension>&,
- const DoFHandler<deal_II_dimension>&,
- const VEC&,
- const Point<deal_II_dimension>&,
- Vector<double>&);
-
- template
- double point_value<deal_II_dimension> (
- const Mapping<deal_II_dimension>&,
- const DoFHandler<deal_II_dimension>&,
- const VEC&,
- const Point<deal_II_dimension>&);
-
- \}
-#endif
- }
-
-
-for (VEC : SERIAL_VECTORS)
-{
- namespace VectorTools \{
- template
- void subtract_mean_value(VEC &, const std::vector<bool> &);
- \}
-}
-
-
-for (deal_II_dimension : DIMENSIONS)
-{
- namespace VectorTools \{
- template
- void interpolate_boundary_values (
- const MGDoFHandler<deal_II_dimension> &,
- const types::boundary_id,
- const Function<deal_II_dimension> &,
- ConstraintMatrix&,
- const ComponentMask &);
-
- template
- void interpolate_boundary_values (
- const MGDoFHandler<deal_II_dimension> &,
- const types::boundary_id,
- const Function<deal_II_dimension> &,
- std::map<types::global_dof_index,double> &,
- const ComponentMask &);
- \}
-}
-
-
-for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS; DH : DOFHANDLER_TEMPLATES)
- {
-#if deal_II_dimension <= deal_II_space_dimension
- namespace VectorTools \{
- template
- void interpolate_boundary_values
- (const Mapping<deal_II_dimension,deal_II_space_dimension> &,
- const DH<deal_II_dimension,deal_II_space_dimension> &,
- const FunctionMap<deal_II_space_dimension>::type &,
- std::map<types::global_dof_index,double> &,
- const ComponentMask &);
-
- template
- void interpolate_boundary_values
- (const Mapping<deal_II_dimension,deal_II_space_dimension> &,
- const DH<deal_II_dimension,deal_II_space_dimension> &,
- const types::boundary_id,
- const Function<deal_II_space_dimension> &,
- std::map<types::global_dof_index,double> &,
- const ComponentMask &);
-
- template
- void interpolate_boundary_values (
- const DH<deal_II_dimension,deal_II_space_dimension> &,
- const types::boundary_id,
- const Function<deal_II_space_dimension> &,
- std::map<types::global_dof_index,double> &,
- const ComponentMask &);
-
- template
- void interpolate_boundary_values
- (const DH<deal_II_dimension,deal_II_space_dimension> &,
- const FunctionMap<deal_II_space_dimension>::type &,
- std::map<types::global_dof_index,double> &,
- const ComponentMask &);
-
- template
- void interpolate_boundary_values (
- const Mapping<deal_II_dimension,deal_II_space_dimension> &,
- const DH<deal_II_dimension,deal_II_space_dimension> &,
- const FunctionMap<deal_II_space_dimension>::type &,
- ConstraintMatrix &,
- const ComponentMask &);
-
- template
- void interpolate_boundary_values
- (const Mapping<deal_II_dimension,deal_II_space_dimension> &,
- const DH<deal_II_dimension,deal_II_space_dimension> &,
- const types::boundary_id,
- const Function<deal_II_space_dimension> &,
- ConstraintMatrix &,
- const ComponentMask &);
-
- template
- void interpolate_boundary_values (
- const DH<deal_II_dimension,deal_II_space_dimension> &,
- const types::boundary_id,
- const Function<deal_II_space_dimension> &,
- ConstraintMatrix &,
- const ComponentMask &);
-
- template
- void interpolate_boundary_values (
- const DH<deal_II_dimension,deal_II_space_dimension> &,
- const FunctionMap<deal_II_space_dimension>::type &,
- ConstraintMatrix &,
- const ComponentMask &);
-
- \}
-#endif
- }
-
-
-for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
- {
-#if deal_II_dimension <= deal_II_space_dimension
- namespace VectorTools \{
- template
- void create_right_hand_side<deal_II_dimension,deal_II_space_dimension>
- (const Mapping<deal_II_dimension,deal_II_space_dimension> &,
- const DoFHandler<deal_II_dimension,deal_II_space_dimension> &,
- const Quadrature<deal_II_dimension> &,
- const Function<deal_II_space_dimension> &,
- Vector<double> &);
-
- template
- void create_right_hand_side<deal_II_dimension,deal_II_space_dimension>
- (const DoFHandler<deal_II_dimension,deal_II_space_dimension> &,
- const Quadrature<deal_II_dimension> &,
- const Function<deal_II_space_dimension> &,
- Vector<double> &);
-
- \}
-#endif
- }
-
-//TODO[SP]: replace <deal_II_dimension> by <deal_II_dimension, deal_II_space_dimension>
-// where applicable and move to codimension cases above also when applicable
-for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
- {
-#if deal_II_dimension == deal_II_space_dimension
- namespace VectorTools \{
- template
- void create_right_hand_side<deal_II_dimension>
- (const hp::MappingCollection<deal_II_dimension> &,
- const hp::DoFHandler<deal_II_dimension> &,
- const hp::QCollection<deal_II_dimension> &,
- const Function<deal_II_dimension> &,
- Vector<double> &);
-
- template
- void create_right_hand_side<deal_II_dimension>
- (const hp::DoFHandler<deal_II_dimension> &,
- const hp::QCollection<deal_II_dimension> &,
- const Function<deal_II_dimension> &,
- Vector<double> &);
-
- template
- void create_point_source_vector<deal_II_dimension>
- (const Mapping<deal_II_dimension> &,
- const DoFHandler<deal_II_dimension> &,
- const Point<deal_II_dimension> &,
- Vector<double> &);
- template
- void create_point_source_vector<deal_II_dimension>
- (const DoFHandler<deal_II_dimension> &,
- const Point<deal_II_dimension> &,
- Vector<double> &);
-
- template
- void create_point_source_vector<deal_II_dimension>
- (const hp::MappingCollection<deal_II_dimension> &,
- const hp::DoFHandler<deal_II_dimension> &,
- const Point<deal_II_dimension> &,
- Vector<double> &);
- template
- void create_point_source_vector<deal_II_dimension>
- (const hp::DoFHandler<deal_II_dimension> &,
- const Point<deal_II_dimension> &,
- Vector<double> &);
- template
- void create_point_source_vector<deal_II_dimension>
- (const Mapping<deal_II_dimension> &,
- const DoFHandler<deal_II_dimension> &,
- const Point<deal_II_dimension> &,
- const Point<deal_II_dimension> &,
- Vector<double> &);
- template
- void create_point_source_vector<deal_II_dimension>
- (const DoFHandler<deal_II_dimension> &,
- const Point<deal_II_dimension> &,
- const Point<deal_II_dimension> &,
- Vector<double> &);
-
- template
- void create_point_source_vector<deal_II_dimension>
- (const hp::MappingCollection<deal_II_dimension> &,
- const hp::DoFHandler<deal_II_dimension> &,
- const Point<deal_II_dimension> &,
- const Point<deal_II_dimension> &,
- Vector<double> &);
- template
- void create_point_source_vector<deal_II_dimension>
- (const hp::DoFHandler<deal_II_dimension> &,
- const Point<deal_II_dimension> &,
- const Point<deal_II_dimension> &,
- Vector<double> &);
-
-#if deal_II_dimension > 1
- template
- void
- create_boundary_right_hand_side<deal_II_dimension>
- (const Mapping<deal_II_dimension> &,
- const DoFHandler<deal_II_dimension> &,
- const Quadrature<deal_II_dimension-1> &,
- const Function<deal_II_dimension> &,
- Vector<double> &,
- const std::set<types::boundary_id> &);
-#endif
-
- template
- void
- create_boundary_right_hand_side<deal_II_dimension>
- (const DoFHandler<deal_II_dimension> &,
- const Quadrature<deal_II_dimension-1> &,
- const Function<deal_II_dimension> &,
- Vector<double> &,
- const std::set<types::boundary_id> &);
-
-#if deal_II_dimension > 1
- template
- void
- create_boundary_right_hand_side<deal_II_dimension>
- (const hp::MappingCollection<deal_II_dimension> &,
- const hp::DoFHandler<deal_II_dimension> &,
- const hp::QCollection<deal_II_dimension-1> &,
- const Function<deal_II_dimension> &,
- Vector<double> &,
- const std::set<types::boundary_id> &);
-#endif
-
- template
- void
- create_boundary_right_hand_side<deal_II_dimension>
- (const hp::DoFHandler<deal_II_dimension> &,
- const hp::QCollection<deal_II_dimension-1> &,
- const Function<deal_II_dimension> &,
- Vector<double> &,
- const std::set<types::boundary_id> &);
-
-
-
-
-
-#if deal_II_dimension > 1
- template
- void project_boundary_values<deal_II_dimension>
- (const Mapping<deal_II_dimension> &,
- const DoFHandler<deal_II_dimension> &,
- const FunctionMap<deal_II_dimension>::type &,
- const Quadrature<deal_II_dimension-1>&,
- std::map<types::global_dof_index,double>&, std::vector<unsigned int>);
-#endif
-
- template
- void project_boundary_values<deal_II_dimension>
- (const DoFHandler<deal_II_dimension> &,
- const FunctionMap<deal_II_dimension>::type &,
- const Quadrature<deal_II_dimension-1>&,
- std::map<types::global_dof_index,double>&, std::vector<unsigned int>);
-
-
- template
- void project_boundary_values<deal_II_dimension>
- (const Mapping<deal_II_dimension> &,
- const DoFHandler<deal_II_dimension> &,
- const FunctionMap<deal_II_dimension>::type &,
- const Quadrature<deal_II_dimension-1>&,
- ConstraintMatrix&, std::vector<unsigned int>);
-
- template
- void project_boundary_values<deal_II_dimension>
- (const DoFHandler<deal_II_dimension> &,
- const FunctionMap<deal_II_dimension>::type &,
- const Quadrature<deal_II_dimension-1>&,
- ConstraintMatrix&, std::vector<unsigned int>);
-
-
-#if deal_II_dimension != 1
- template
- void project_boundary_values_curl_conforming<deal_II_dimension>
- (const DoFHandler<deal_II_dimension>&,
- const unsigned int,
- const Function<deal_II_dimension>&,
- const types::boundary_id,
- ConstraintMatrix&,
- const Mapping<deal_II_dimension>&);
- template
- void project_boundary_values_curl_conforming<deal_II_dimension>
- (const hp::DoFHandler<deal_II_dimension>&,
- const unsigned int,
- const Function<deal_II_dimension>&,
- const types::boundary_id,
- ConstraintMatrix&,
- const hp::MappingCollection<deal_II_dimension>&);
- template
- void project_boundary_values_div_conforming<deal_II_dimension>
- (const DoFHandler<deal_II_dimension>&,
- const unsigned int,
- const Function<deal_II_dimension>&,
- const types::boundary_id,
- ConstraintMatrix&,
- const Mapping<deal_II_dimension>&);
- template
- void project_boundary_values_div_conforming<deal_II_dimension>
- (const hp::DoFHandler<deal_II_dimension>&,
- const unsigned int,
- const Function<deal_II_dimension>&,
- const types::boundary_id,
- ConstraintMatrix&,
- const hp::MappingCollection<deal_II_dimension>&);
- template
- void
- compute_no_normal_flux_constraints (const DoFHandler<deal_II_dimension> &dof_handler,
- const unsigned int first_vector_component,
- const std::set<types::boundary_id> &boundary_ids,
- ConstraintMatrix &constraints,
- const Mapping<deal_II_dimension> &mapping);
- template
- void
- compute_no_normal_flux_constraints (const hp::DoFHandler<deal_II_dimension> &dof_handler,
- const unsigned int first_vector_component,
- const std::set<types::boundary_id> &boundary_ids,
- ConstraintMatrix &constraints,
- const Mapping<deal_II_dimension> &mapping);
-#endif
- \}
-#endif
- }
-
-
-
-for (deal_II_dimension : DIMENSIONS)
-{
- namespace VectorTools \{
-
- template
- void interpolate_to_different_mesh
- (const DoFHandler<deal_II_dimension> &,
- const Vector<float> &,
- const DoFHandler<deal_II_dimension> &,
- Vector<float> &);
-
- template
- void interpolate_to_different_mesh
- (const DoFHandler<deal_II_dimension> &,
- const Vector<float> &,
- const DoFHandler<deal_II_dimension> &,
- const ConstraintMatrix &,
- Vector<float> &);
-
- template
- void interpolate_to_different_mesh
- (const InterGridMap<DoFHandler<deal_II_dimension> > &,
- const Vector<float> &,
- const ConstraintMatrix &,
- Vector<float> &);
-
- template
- void interpolate_to_different_mesh
- (const DoFHandler<deal_II_dimension> &,
- const Vector<double> &,
- const DoFHandler<deal_II_dimension> &,
- Vector<double> &);
-
- template
- void interpolate_to_different_mesh
- (const DoFHandler<deal_II_dimension> &,
- const Vector<double> &,
- const DoFHandler<deal_II_dimension> &,
- const ConstraintMatrix &,
- Vector<double> &);
-
- template
- void interpolate_to_different_mesh
- (const InterGridMap<DoFHandler<deal_II_dimension> > &,
- const Vector<double> &,
- const ConstraintMatrix &,
- Vector<double> &);
-
- \}
-}
-
-
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1998 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+#include <deal.II/numerics/vector_tools.templates.h>
+
+DEAL_II_NAMESPACE_OPEN
+
+// ---------------------------- explicit instantiations --------------------
+#include "vector_tools_boundary.inst"
+
+DEAL_II_NAMESPACE_CLOSE
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1998 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+for (deal_II_dimension : DIMENSIONS)
+{
+ namespace VectorTools \{
+ template
+ void interpolate_boundary_values (
+ const MGDoFHandler<deal_II_dimension> &,
+ const types::boundary_id,
+ const Function<deal_II_dimension> &,
+ ConstraintMatrix&,
+ const ComponentMask &);
+
+ template
+ void interpolate_boundary_values (
+ const MGDoFHandler<deal_II_dimension> &,
+ const types::boundary_id,
+ const Function<deal_II_dimension> &,
+ std::map<types::global_dof_index,double> &,
+ const ComponentMask &);
+ \}
+}
+
+
+for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS; DH : DOFHANDLER_TEMPLATES)
+ {
+#if deal_II_dimension <= deal_II_space_dimension
+ namespace VectorTools \{
+ template
+ void interpolate_boundary_values
+ (const Mapping<deal_II_dimension,deal_II_space_dimension> &,
+ const DH<deal_II_dimension,deal_II_space_dimension> &,
+ const FunctionMap<deal_II_space_dimension>::type &,
+ std::map<types::global_dof_index,double> &,
+ const ComponentMask &);
+
+ template
+ void interpolate_boundary_values
+ (const Mapping<deal_II_dimension,deal_II_space_dimension> &,
+ const DH<deal_II_dimension,deal_II_space_dimension> &,
+ const types::boundary_id,
+ const Function<deal_II_space_dimension> &,
+ std::map<types::global_dof_index,double> &,
+ const ComponentMask &);
+
+ template
+ void interpolate_boundary_values (
+ const DH<deal_II_dimension,deal_II_space_dimension> &,
+ const types::boundary_id,
+ const Function<deal_II_space_dimension> &,
+ std::map<types::global_dof_index,double> &,
+ const ComponentMask &);
+
+ template
+ void interpolate_boundary_values
+ (const DH<deal_II_dimension,deal_II_space_dimension> &,
+ const FunctionMap<deal_II_space_dimension>::type &,
+ std::map<types::global_dof_index,double> &,
+ const ComponentMask &);
+
+ template
+ void interpolate_boundary_values (
+ const Mapping<deal_II_dimension,deal_II_space_dimension> &,
+ const DH<deal_II_dimension,deal_II_space_dimension> &,
+ const FunctionMap<deal_II_space_dimension>::type &,
+ ConstraintMatrix &,
+ const ComponentMask &);
+
+ template
+ void interpolate_boundary_values
+ (const Mapping<deal_II_dimension,deal_II_space_dimension> &,
+ const DH<deal_II_dimension,deal_II_space_dimension> &,
+ const types::boundary_id,
+ const Function<deal_II_space_dimension> &,
+ ConstraintMatrix &,
+ const ComponentMask &);
+
+ template
+ void interpolate_boundary_values (
+ const DH<deal_II_dimension,deal_II_space_dimension> &,
+ const types::boundary_id,
+ const Function<deal_II_space_dimension> &,
+ ConstraintMatrix &,
+ const ComponentMask &);
+
+ template
+ void interpolate_boundary_values (
+ const DH<deal_II_dimension,deal_II_space_dimension> &,
+ const FunctionMap<deal_II_space_dimension>::type &,
+ ConstraintMatrix &,
+ const ComponentMask &);
+ \}
+#endif
+}
+
+for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
+ {
+ namespace VectorTools \{
+#if deal_II_dimension == deal_II_space_dimension
+
+ template
+ void project_boundary_values<deal_II_dimension>
+ (const Mapping<deal_II_dimension> &,
+ const DoFHandler<deal_II_dimension> &,
+ const FunctionMap<deal_II_dimension>::type &,
+ const Quadrature<deal_II_dimension-1>&,
+ std::map<types::global_dof_index,double>&, std::vector<unsigned int>);
+
+ template
+ void project_boundary_values<deal_II_dimension>
+ (const DoFHandler<deal_II_dimension> &,
+ const FunctionMap<deal_II_dimension>::type &,
+ const Quadrature<deal_II_dimension-1>&,
+ std::map<types::global_dof_index,double>&,
+ std::vector<unsigned int>);
+
+ template
+ void project_boundary_values<deal_II_dimension>
+ (const Mapping<deal_II_dimension> &,
+ const DoFHandler<deal_II_dimension> &,
+ const FunctionMap<deal_II_dimension>::type &,
+ const Quadrature<deal_II_dimension-1>&,
+ ConstraintMatrix&, std::vector<unsigned int>);
+
+ template
+ void project_boundary_values<deal_II_dimension>
+ (const DoFHandler<deal_II_dimension> &,
+ const FunctionMap<deal_II_dimension>::type &,
+ const Quadrature<deal_II_dimension-1>&,
+ ConstraintMatrix&,
+ std::vector<unsigned int>);
+
+
+
+#if deal_II_dimension != 1
+ template
+ void project_boundary_values_curl_conforming<deal_II_dimension>
+ (const DoFHandler<deal_II_dimension>&,
+ const unsigned int,
+ const Function<deal_II_dimension>&,
+ const types::boundary_id,
+ ConstraintMatrix&,
+ const Mapping<deal_II_dimension>&);
+ template
+ void project_boundary_values_curl_conforming<deal_II_dimension>
+ (const hp::DoFHandler<deal_II_dimension>&,
+ const unsigned int,
+ const Function<deal_II_dimension>&,
+ const types::boundary_id,
+ ConstraintMatrix&,
+ const hp::MappingCollection<deal_II_dimension>&);
+ template
+ void project_boundary_values_div_conforming<deal_II_dimension>
+ (const DoFHandler<deal_II_dimension>&,
+ const unsigned int,
+ const Function<deal_II_dimension>&,
+ const types::boundary_id,
+ ConstraintMatrix&,
+ const Mapping<deal_II_dimension>&);
+ template
+ void project_boundary_values_div_conforming<deal_II_dimension>
+ (const hp::DoFHandler<deal_II_dimension>&,
+ const unsigned int,
+ const Function<deal_II_dimension>&,
+ const types::boundary_id,
+ ConstraintMatrix&,
+ const hp::MappingCollection<deal_II_dimension>&);
+#endif
+#endif
+ \}
+ }
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1998 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+#include <deal.II/numerics/vector_tools.templates.h>
+
+DEAL_II_NAMESPACE_OPEN
+
+// ---------------------------- explicit instantiations --------------------
+#include "vector_tools_constraints.inst"
+
+DEAL_II_NAMESPACE_CLOSE
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1998 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+//TODO[SP]: replace <deal_II_dimension> by <deal_II_dimension, deal_II_space_dimension>
+// where applicable and move to codimension cases above also when applicable
+for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
+ {
+ namespace VectorTools \{
+
+#if deal_II_dimension == deal_II_space_dimension
+#if deal_II_dimension != 1
+ template
+ void
+ compute_no_normal_flux_constraints (const DoFHandler<deal_II_dimension> &dof_handler,
+ const unsigned int first_vector_component,
+ const std::set<types::boundary_id> &boundary_ids,
+ ConstraintMatrix &constraints,
+ const Mapping<deal_II_dimension> &mapping);
+ template
+ void
+ compute_no_normal_flux_constraints (const hp::DoFHandler<deal_II_dimension> &dof_handler,
+ const unsigned int first_vector_component,
+ const std::set<types::boundary_id> &boundary_ids,
+ ConstraintMatrix &constraints,
+ const Mapping<deal_II_dimension> &mapping);
+
+ template
+ void
+ compute_normal_flux_constraints (const DoFHandler<deal_II_dimension> &dof_handler,
+ const unsigned int first_vector_component,
+ const std::set<types::boundary_id> &boundary_ids,
+ ConstraintMatrix &constraints,
+ const Mapping<deal_II_dimension> &mapping);
+ template
+ void
+ compute_normal_flux_constraints (const hp::DoFHandler<deal_II_dimension> &dof_handler,
+ const unsigned int first_vector_component,
+ const std::set<types::boundary_id> &boundary_ids,
+ ConstraintMatrix &constraints,
+ const Mapping<deal_II_dimension> &mapping);
+#endif
+#endif
+ \}
+ }
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1998 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+#include <deal.II/numerics/vector_tools.templates.h>
+
+DEAL_II_NAMESPACE_OPEN
+
+// ---------------------------- explicit instantiations --------------------
+#include "vector_tools_integrate_difference.inst"
+
+DEAL_II_NAMESPACE_CLOSE
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1998 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+for (VEC : SERIAL_VECTORS ; deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
+ {
+#if deal_II_dimension <= deal_II_space_dimension
+ namespace VectorTools \{
+
+ template
+ void integrate_difference<deal_II_dimension, VEC, Vector<float>, deal_II_space_dimension>
+ (const Mapping<deal_II_dimension, deal_II_space_dimension>&,
+ const DoFHandler<deal_II_dimension, deal_II_space_dimension>&,
+ const VEC&,
+ const Function<deal_II_space_dimension>&,
+ Vector<float>&,
+ const Quadrature<deal_II_dimension>&,
+ const NormType&,
+ const Function<deal_II_space_dimension>*,
+ const double);
+
+ template
+ void integrate_difference<deal_II_dimension, VEC, Vector<float>, deal_II_space_dimension>
+ (const DoFHandler<deal_II_dimension, deal_II_space_dimension>&,
+ const VEC&,
+ const Function<deal_II_space_dimension>&,
+ Vector<float>&,
+ const Quadrature<deal_II_dimension>&,
+ const NormType&,
+ const Function<deal_II_space_dimension>*,
+ const double);
+
+ template
+ void integrate_difference<deal_II_dimension, VEC, Vector<double>, deal_II_space_dimension >
+ (const Mapping<deal_II_dimension, deal_II_space_dimension>&,
+ const DoFHandler<deal_II_dimension, deal_II_space_dimension>&,
+ const VEC&,
+ const Function<deal_II_space_dimension>&,
+ Vector<double>&,
+ const Quadrature<deal_II_dimension>&,
+ const NormType&,
+ const Function<deal_II_space_dimension>*,
+ const double);
+
+ template
+ void integrate_difference<deal_II_dimension, VEC, Vector<double>, deal_II_space_dimension >
+ (const DoFHandler<deal_II_dimension, deal_II_space_dimension>&,
+ const VEC&,
+ const Function<deal_II_space_dimension>&,
+ Vector<double>&,
+ const Quadrature<deal_II_dimension>&,
+ const NormType&,
+ const Function<deal_II_space_dimension>*,
+ const double);
+
+ template
+ void integrate_difference<deal_II_dimension, VEC, Vector<double>, deal_II_space_dimension>
+ (const hp::MappingCollection<deal_II_dimension,deal_II_space_dimension>&,
+ const hp::DoFHandler<deal_II_dimension,deal_II_space_dimension>&,
+ const VEC&,
+ const Function<deal_II_space_dimension>&,
+ Vector<double>&,
+ const hp::QCollection<deal_II_dimension>&,
+ const NormType&,
+ const Function<deal_II_space_dimension>*,
+ const double);
+
+ template
+ void integrate_difference<deal_II_dimension, VEC, Vector<double>, deal_II_space_dimension>
+ (const hp::DoFHandler<deal_II_dimension,deal_II_space_dimension>&,
+ const VEC&,
+ const Function<deal_II_space_dimension>&,
+ Vector<double>&,
+ const hp::QCollection<deal_II_dimension>&,
+ const NormType&,
+ const Function<deal_II_space_dimension>*,
+ const double);
+
+ template
+ void integrate_difference<deal_II_dimension, VEC, Vector<float>, deal_II_space_dimension>
+ (const hp::MappingCollection<deal_II_dimension,deal_II_space_dimension>&,
+ const hp::DoFHandler<deal_II_dimension,deal_II_space_dimension>&,
+ const VEC&,
+ const Function<deal_II_space_dimension>&,
+ Vector<float>&,
+ const hp::QCollection<deal_II_dimension>&,
+ const NormType&,
+ const Function<deal_II_space_dimension>*,
+ const double);
+
+ template
+ void integrate_difference<deal_II_dimension, VEC, Vector<float>, deal_II_space_dimension>
+ (const hp::DoFHandler<deal_II_dimension,deal_II_space_dimension>&,
+ const VEC&,
+ const Function<deal_II_space_dimension>&,
+ Vector<float>&,
+ const hp::QCollection<deal_II_dimension>&,
+ const NormType&,
+ const Function<deal_II_space_dimension>*,
+ const double);
+
+ \}
+#endif
+ }
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1998 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+#include <deal.II/numerics/vector_tools.templates.h>
+
+DEAL_II_NAMESPACE_OPEN
+
+// ---------------------------- explicit instantiations --------------------
+#include "vector_tools_interpolate.inst"
+
+DEAL_II_NAMESPACE_CLOSE
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1998 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+for (VEC : SERIAL_VECTORS ; deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
+ {
+#if deal_II_dimension <= deal_II_space_dimension
+ namespace VectorTools \{
+
+ template
+ void interpolate
+ (const Mapping<deal_II_dimension,deal_II_space_dimension>&,
+ const DoFHandler<deal_II_dimension,deal_II_space_dimension>&,
+ const Function<deal_II_space_dimension>&,
+ VEC&);
+
+ template
+ void interpolate
+ (const DoFHandler<deal_II_dimension,deal_II_space_dimension>&,
+ const Function<deal_II_space_dimension>&,
+ VEC&);
+ \}
+#endif
+ }
+
+
+
+//TODO[SP]: replace <deal_II_dimension> by <deal_II_dimension, deal_II_space_dimension>
+// where applicable and move to codimension cases above also when applicable
+for (VEC : SERIAL_VECTORS ; deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
+ {
+#if deal_II_dimension == deal_II_space_dimension
+
+ namespace VectorTools \{
+
+ template
+ void interpolate
+ (const Mapping<deal_II_dimension>&,
+ const hp::DoFHandler<deal_II_dimension>&,
+ const Function<deal_II_dimension>&,
+ VEC&);
+ template
+ void interpolate
+ (const hp::DoFHandler<deal_II_dimension>&,
+ const Function<deal_II_dimension>&,
+ VEC&);
+
+ template
+ void interpolate
+ (const DoFHandler<deal_II_dimension>&,
+ const DoFHandler<deal_II_dimension>&,
+ const FullMatrix<double>&,
+ const VEC&,
+ VEC&);
+ \}
+#endif
+ }
+
+
+for (deal_II_dimension : DIMENSIONS)
+{
+ namespace VectorTools \{
+
+ template
+ void interpolate_to_different_mesh
+ (const DoFHandler<deal_II_dimension> &,
+ const Vector<float> &,
+ const DoFHandler<deal_II_dimension> &,
+ Vector<float> &);
+
+ template
+ void interpolate_to_different_mesh
+ (const DoFHandler<deal_II_dimension> &,
+ const Vector<float> &,
+ const DoFHandler<deal_II_dimension> &,
+ const ConstraintMatrix &,
+ Vector<float> &);
+
+ template
+ void interpolate_to_different_mesh
+ (const InterGridMap<DoFHandler<deal_II_dimension> > &,
+ const Vector<float> &,
+ const ConstraintMatrix &,
+ Vector<float> &);
+
+ template
+ void interpolate_to_different_mesh
+ (const DoFHandler<deal_II_dimension> &,
+ const Vector<double> &,
+ const DoFHandler<deal_II_dimension> &,
+ Vector<double> &);
+
+ template
+ void interpolate_to_different_mesh
+ (const DoFHandler<deal_II_dimension> &,
+ const Vector<double> &,
+ const DoFHandler<deal_II_dimension> &,
+ const ConstraintMatrix &,
+ Vector<double> &);
+
+ template
+ void interpolate_to_different_mesh
+ (const InterGridMap<DoFHandler<deal_II_dimension> > &,
+ const Vector<double> &,
+ const ConstraintMatrix &,
+ Vector<double> &);
+
+ \}
+}
+
+
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1998 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+#include <deal.II/numerics/vector_tools.templates.h>
+
+DEAL_II_NAMESPACE_OPEN
+
+// ---------------------------- explicit instantiations --------------------
+#include "vector_tools_mean_value.inst"
+
+DEAL_II_NAMESPACE_CLOSE
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1998 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+for (VEC : SERIAL_VECTORS ; deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
+ {
+#if deal_II_dimension <= deal_II_space_dimension
+ namespace VectorTools \{
+
+ template
+ double compute_mean_value<deal_II_dimension>
+ (const Mapping<deal_II_dimension,deal_II_space_dimension>&,
+ const DoFHandler<deal_II_dimension,deal_II_space_dimension>&,
+ const Quadrature<deal_II_dimension>&,
+ const VEC&,
+ const unsigned int);
+
+ template
+ double compute_mean_value<deal_II_dimension>
+ (const DoFHandler<deal_II_dimension,deal_II_space_dimension>&,
+ const Quadrature<deal_II_dimension>&,
+ const VEC&,
+ const unsigned int);
+
+ \}
+#endif
+ }
+
+
+
+for (VEC : SERIAL_VECTORS)
+{
+ namespace VectorTools \{
+ template
+ void subtract_mean_value(VEC &, const std::vector<bool> &);
+ \}
+}
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1998 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+#include <deal.II/numerics/vector_tools.templates.h>
+
+DEAL_II_NAMESPACE_OPEN
+
+// ---------------------------- explicit instantiations --------------------
+#include "vector_tools_point_value.inst"
+
+DEAL_II_NAMESPACE_CLOSE
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1998 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+//TODO[SP]: replace <deal_II_dimension> by <deal_II_dimension, deal_II_space_dimension>
+// where applicable and move to codimension cases above also when applicable
+for (VEC : SERIAL_VECTORS ; deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
+ {
+#if deal_II_dimension == deal_II_space_dimension
+
+ namespace VectorTools \{
+
+ template
+ void point_value<deal_II_dimension> (
+ const hp::DoFHandler<deal_II_dimension>&,
+ const VEC&,
+ const Point<deal_II_dimension>&,
+ Vector<double>&);
+
+ template
+ double point_value<deal_II_dimension> (
+ const hp::DoFHandler<deal_II_dimension>&,
+ const VEC&,
+ const Point<deal_II_dimension>&);
+
+ template
+ void point_value<deal_II_dimension> (
+ const hp::MappingCollection<deal_II_dimension>&,
+ const hp::DoFHandler<deal_II_dimension>&,
+ const VEC&,
+ const Point<deal_II_dimension>&,
+ Vector<double>&);
+
+ template
+ double point_value<deal_II_dimension> (
+ const hp::MappingCollection<deal_II_dimension>&,
+ const hp::DoFHandler<deal_II_dimension>&,
+ const VEC&,
+ const Point<deal_II_dimension>&);
+
+ template
+ void point_difference<deal_II_dimension> (
+ const DoFHandler<deal_II_dimension>&,
+ const VEC&,
+ const Function<deal_II_dimension>&,
+ Vector<double>&,
+ const Point<deal_II_dimension>&);
+
+ template
+ void point_difference<deal_II_dimension> (
+ const Mapping<deal_II_dimension>&,
+ const DoFHandler<deal_II_dimension>&,
+ const VEC&,
+ const Function<deal_II_dimension>&,
+ Vector<double>&,
+ const Point<deal_II_dimension>&);
+
+ template
+ void point_value<deal_II_dimension> (
+ const DoFHandler<deal_II_dimension>&,
+ const VEC&,
+ const Point<deal_II_dimension>&,
+ Vector<double>&);
+
+ template
+ double point_value<deal_II_dimension> (
+ const DoFHandler<deal_II_dimension>&,
+ const VEC&,
+ const Point<deal_II_dimension>&);
+
+ template
+ void point_value<deal_II_dimension> (
+ const Mapping<deal_II_dimension>&,
+ const DoFHandler<deal_II_dimension>&,
+ const VEC&,
+ const Point<deal_II_dimension>&,
+ Vector<double>&);
+
+ template
+ double point_value<deal_II_dimension> (
+ const Mapping<deal_II_dimension>&,
+ const DoFHandler<deal_II_dimension>&,
+ const VEC&,
+ const Point<deal_II_dimension>&);
+
+ \}
+#endif
+ }
+
+
+
+//TODO[SP]: replace <deal_II_dimension> by <deal_II_dimension, deal_II_space_dimension>
+// where applicable and move to codimension cases above also when applicable
+for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
+ {
+ namespace VectorTools \{
+
+#if deal_II_dimension == deal_II_space_dimension
+
+ template
+ void create_point_source_vector<deal_II_dimension>
+ (const Mapping<deal_II_dimension> &,
+ const DoFHandler<deal_II_dimension> &,
+ const Point<deal_II_dimension> &,
+ Vector<double> &);
+ template
+ void create_point_source_vector<deal_II_dimension>
+ (const DoFHandler<deal_II_dimension> &,
+ const Point<deal_II_dimension> &,
+ Vector<double> &);
+
+ template
+ void create_point_source_vector<deal_II_dimension>
+ (const hp::MappingCollection<deal_II_dimension> &,
+ const hp::DoFHandler<deal_II_dimension> &,
+ const Point<deal_II_dimension> &,
+ Vector<double> &);
+ template
+ void create_point_source_vector<deal_II_dimension>
+ (const hp::DoFHandler<deal_II_dimension> &,
+ const Point<deal_II_dimension> &,
+ Vector<double> &);
+ template
+ void create_point_source_vector<deal_II_dimension>
+ (const Mapping<deal_II_dimension> &,
+ const DoFHandler<deal_II_dimension> &,
+ const Point<deal_II_dimension> &,
+ const Point<deal_II_dimension> &,
+ Vector<double> &);
+ template
+ void create_point_source_vector<deal_II_dimension>
+ (const DoFHandler<deal_II_dimension> &,
+ const Point<deal_II_dimension> &,
+ const Point<deal_II_dimension> &,
+ Vector<double> &);
+
+ template
+ void create_point_source_vector<deal_II_dimension>
+ (const hp::MappingCollection<deal_II_dimension> &,
+ const hp::DoFHandler<deal_II_dimension> &,
+ const Point<deal_II_dimension> &,
+ const Point<deal_II_dimension> &,
+ Vector<double> &);
+ template
+ void create_point_source_vector<deal_II_dimension>
+ (const hp::DoFHandler<deal_II_dimension> &,
+ const Point<deal_II_dimension> &,
+ const Point<deal_II_dimension> &,
+ Vector<double> &);
+#endif
+ \}
+ }
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1998 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+#include <deal.II/numerics/vector_tools.templates.h>
+
+DEAL_II_NAMESPACE_OPEN
+
+// ---------------------------- explicit instantiations --------------------
+#include "vector_tools_project.inst"
+
+DEAL_II_NAMESPACE_CLOSE
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1998 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+for (VEC : SERIAL_VECTORS ; deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
+ {
+#if deal_II_dimension <= deal_II_space_dimension
+ namespace VectorTools \{
+
+ template
+ void project
+ (const Mapping<deal_II_dimension,deal_II_space_dimension> &,
+ const DoFHandler<deal_II_dimension,deal_II_space_dimension> &,
+ const ConstraintMatrix &,
+ const Quadrature<deal_II_dimension> &,
+ const Function<deal_II_space_dimension> &,
+ VEC &,
+ const bool,
+ const Quadrature<deal_II_dimension-1> &,
+ const bool);
+
+ template
+ void project
+ (const DoFHandler<deal_II_dimension,deal_II_space_dimension> &,
+ const ConstraintMatrix &,
+ const Quadrature<deal_II_dimension> &,
+ const Function<deal_II_space_dimension> &,
+ VEC &,
+ const bool,
+ const Quadrature<deal_II_dimension-1> &,
+ const bool);
+
+ template
+ void project
+ (const hp::MappingCollection<deal_II_dimension,deal_II_space_dimension> &,
+ const hp::DoFHandler<deal_II_dimension,deal_II_space_dimension> &,
+ const ConstraintMatrix &,
+ const hp::QCollection<deal_II_dimension> &,
+ const Function<deal_II_space_dimension> &,
+ VEC &,
+ const bool,
+ const hp::QCollection<deal_II_dimension-1> &,
+ const bool);
+
+ template
+ void project
+ (const hp::DoFHandler<deal_II_dimension,deal_II_space_dimension> &,
+ const ConstraintMatrix &,
+ const hp::QCollection<deal_II_dimension> &,
+ const Function<deal_II_space_dimension> &,
+ VEC &,
+ const bool,
+ const hp::QCollection<deal_II_dimension-1> &,
+ const bool);
+ \}
+#endif
+ }
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1998 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+#include <deal.II/numerics/vector_tools.templates.h>
+
+DEAL_II_NAMESPACE_OPEN
+
+
+namespace VectorTools
+{
+
+// separate implementation for 1D because otherwise we get linker errors since
+// (hp::)FEFaceValues<1> is not compiled
+ template <>
+ void
+ create_boundary_right_hand_side (const Mapping<1,1> &,
+ const DoFHandler<1,1> &,
+ const Quadrature<0> &,
+ const Function<1> &,
+ Vector<double> &,
+ const std::set<types::boundary_id> &)
+ {
+ Assert (false, ExcImpossibleInDim(1));
+ }
+
+
+
+ template <>
+ void
+ create_boundary_right_hand_side (const Mapping<1,2> &,
+ const DoFHandler<1,2> &,
+ const Quadrature<0> &,
+ const Function<2> &,
+ Vector<double> &,
+ const std::set<types::boundary_id> &)
+ {
+ Assert (false, ExcImpossibleInDim(1));
+ }
+
+
+
+ template <>
+ void
+ create_boundary_right_hand_side (const hp::MappingCollection<1,1> &,
+ const hp::DoFHandler<1,1> &,
+ const hp::QCollection<0> &,
+ const Function<1> &,
+ Vector<double> &,
+ const std::set<types::boundary_id> &)
+ {
+ Assert (false, ExcImpossibleInDim(1));
+ }
+
+
+
+ template <>
+ void
+ create_boundary_right_hand_side (const hp::MappingCollection<1,2> &,
+ const hp::DoFHandler<1,2> &,
+ const hp::QCollection<0> &,
+ const Function<2> &,
+ Vector<double> &,
+ const std::set<types::boundary_id> &)
+ {
+ Assert (false, ExcImpossibleInDim(1));
+ }
+}
+
+// ---------------------------- explicit instantiations --------------------
+#include "vector_tools_rhs.inst"
+
+DEAL_II_NAMESPACE_CLOSE
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id$
+//
+// Copyright (C) 1998 - 2013 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
+ {
+#if deal_II_dimension <= deal_II_space_dimension
+ namespace VectorTools \{
+ template
+ void create_right_hand_side<deal_II_dimension,deal_II_space_dimension>
+ (const Mapping<deal_II_dimension,deal_II_space_dimension> &,
+ const DoFHandler<deal_II_dimension,deal_II_space_dimension> &,
+ const Quadrature<deal_II_dimension> &,
+ const Function<deal_II_space_dimension> &,
+ Vector<double> &);
+
+ template
+ void create_right_hand_side<deal_II_dimension,deal_II_space_dimension>
+ (const DoFHandler<deal_II_dimension,deal_II_space_dimension> &,
+ const Quadrature<deal_II_dimension> &,
+ const Function<deal_II_space_dimension> &,
+ Vector<double> &);
+
+ \}
+#endif
+ }
+
+//TODO[SP]: replace <deal_II_dimension> by <deal_II_dimension, deal_II_space_dimension>
+// where applicable and move to codimension cases above also when applicable
+for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
+ {
+ namespace VectorTools \{
+
+#if deal_II_dimension == deal_II_space_dimension
+ template
+ void create_right_hand_side<deal_II_dimension>
+ (const hp::MappingCollection<deal_II_dimension> &,
+ const hp::DoFHandler<deal_II_dimension> &,
+ const hp::QCollection<deal_II_dimension> &,
+ const Function<deal_II_dimension> &,
+ Vector<double> &);
+
+ template
+ void create_right_hand_side<deal_II_dimension>
+ (const hp::DoFHandler<deal_II_dimension> &,
+ const hp::QCollection<deal_II_dimension> &,
+ const Function<deal_II_dimension> &,
+ Vector<double> &);
+
+#if deal_II_dimension > 1
+ template
+ void
+ create_boundary_right_hand_side<deal_II_dimension>
+ (const Mapping<deal_II_dimension> &,
+ const DoFHandler<deal_II_dimension> &,
+ const Quadrature<deal_II_dimension-1> &,
+ const Function<deal_II_dimension> &,
+ Vector<double> &,
+ const std::set<types::boundary_id> &);
+#endif
+
+ template
+ void
+ create_boundary_right_hand_side<deal_II_dimension>
+ (const DoFHandler<deal_II_dimension> &,
+ const Quadrature<deal_II_dimension-1> &,
+ const Function<deal_II_dimension> &,
+ Vector<double> &,
+ const std::set<types::boundary_id> &);
+
+#if deal_II_dimension > 1
+ template
+ void
+ create_boundary_right_hand_side<deal_II_dimension>
+ (const hp::MappingCollection<deal_II_dimension> &,
+ const hp::DoFHandler<deal_II_dimension> &,
+ const hp::QCollection<deal_II_dimension-1> &,
+ const Function<deal_II_dimension> &,
+ Vector<double> &,
+ const std::set<types::boundary_id> &);
+#endif
+
+ template
+ void
+ create_boundary_right_hand_side<deal_II_dimension>
+ (const hp::DoFHandler<deal_II_dimension> &,
+ const hp::QCollection<deal_II_dimension-1> &,
+ const Function<deal_II_dimension> &,
+ Vector<double> &,
+ const std::set<types::boundary_id> &);
+
+
+#endif
+ \}
+ }