From: Wolfgang Bangerth Date: Fri, 20 Feb 2015 23:38:13 +0000 (-0600) Subject: Add a testcase. X-Git-Tag: v8.3.0-rc1~433^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=faec3374ac323ab6d3f54ddc8ab4e757b56196f1;p=dealii.git Add a testcase. --- diff --git a/tests/fe/fe_system_from_list.cc b/tests/fe/fe_system_from_list.cc new file mode 100644 index 0000000000..ab903ec9ba --- /dev/null +++ b/tests/fe/fe_system_from_list.cc @@ -0,0 +1,151 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2015 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. +// +// --------------------------------------------------------------------- + +// verify that the idea discussed in the multiple-element constructor FESystem +// really works + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define PRECISION 2 + +template +struct MyFESystem +{ + MyFESystem (const std::vector*> &fes, + const std::vector &multiplicities) + { + deallog << "Constructing FESystem from list." << std::endl; + } +}; + + + +template +class MySimulator { +public: + MySimulator (const unsigned int polynomial_degree); + +private: + MyFESystem fe; + + struct VectorElementDestroyer { + const std::vector*> data; + VectorElementDestroyer (const std::vector*> &pointers); + ~VectorElementDestroyer (); // destructor to delete the pointers + const std::vector*> & get_data () const; + }; + + static std::vector*> + create_fe_list (const unsigned int polynomial_degree); + + static std::vector + create_fe_multiplicities (); +}; + + +template +std::vector*> +MySimulator::create_fe_list (const unsigned int polynomial_degree) +{ + std::vector*> fe_list; + fe_list.push_back (new FE_Q(1)); + fe_list.push_back (new FE_Q(2)); + fe_list.push_back (new FE_Q(3)); + fe_list.push_back (new FE_Q(4)); + deallog << "Created list of elements" << std::endl; + return fe_list; +} + +template +std::vector +MySimulator::create_fe_multiplicities () +{ + std::vector multiplicities; + multiplicities.push_back (1); + multiplicities.push_back (2); + multiplicities.push_back (3); + multiplicities.push_back (4); + return multiplicities; +} + +template +MySimulator::VectorElementDestroyer:: +VectorElementDestroyer (const std::vector*> &pointers) +: data(pointers) +{} + +template +MySimulator::VectorElementDestroyer:: +~VectorElementDestroyer () +{ + for (unsigned int i=0; iget_name() << std::endl; + delete data[i]; + } +} + +template +const std::vector*> & +MySimulator::VectorElementDestroyer:: +get_data () const +{ + return data; +} + + +template +MySimulator::MySimulator (const unsigned int polynomial_degree) +: +fe (VectorElementDestroyer(create_fe_list (polynomial_degree)).get_data(), + create_fe_multiplicities ()) +{} + + +int +main() +{ + std::ofstream logfile ("output"); + deallog << std::setprecision(PRECISION); + deallog << std::fixed; + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + MySimulator<1>(1); + MySimulator<2>(1); + MySimulator<3>(1); + + return 0; +} + + + diff --git a/tests/fe/fe_system_from_list.output b/tests/fe/fe_system_from_list.output new file mode 100644 index 0000000000..ac100ab274 --- /dev/null +++ b/tests/fe/fe_system_from_list.output @@ -0,0 +1,19 @@ + +DEAL::Created list of elements +DEAL::Constructing FESystem from list. +DEAL::Destroying element FE_Q<1>(1) +DEAL::Destroying element FE_Q<1>(2) +DEAL::Destroying element FE_Q<1>(3) +DEAL::Destroying element FE_Q<1>(4) +DEAL::Created list of elements +DEAL::Constructing FESystem from list. +DEAL::Destroying element FE_Q<2>(1) +DEAL::Destroying element FE_Q<2>(2) +DEAL::Destroying element FE_Q<2>(3) +DEAL::Destroying element FE_Q<2>(4) +DEAL::Created list of elements +DEAL::Constructing FESystem from list. +DEAL::Destroying element FE_Q<3>(1) +DEAL::Destroying element FE_Q<3>(2) +DEAL::Destroying element FE_Q<3>(3) +DEAL::Destroying element FE_Q<3>(4)