Attempting to resize or push_back into a std::vector<Functions::ParsedFunction> throws an error within TBB and/or mu::Parser, e.g.:
In file included from /usr/include/c++/4.8/vector:64:0,
from /usr/include/c++/4.8/bits/random.h:34,
from /usr/include/c++/4.8/random:50,
from /usr/include/c++/4.8/bits/stl_algo.h:65,
from /usr/include/c++/4.8/algorithm:62,
from /home/zimmerman/installed/deal.ii-candi/deal.II-v8.4.2/include/deal.II/bundled/tbb/concurrent_vector.h:48,
from /home/zimmerman/installed/deal.ii-candi/deal.II-v8.4.2/include/deal.II/bundled/tbb/enumerable_thread_specific.h:32,
from /home/zimmerman/installed/deal.ii-candi/deal.II-v8.4.2/include/deal.II/base/thread_local_storage.h:23,
from /home/zimmerman/installed/deal.ii-candi/deal.II-v8.4.2/include/deal.II/base/logstream.h:23,
from /home/zimmerman/installed/deal.ii-candi/deal.II-v8.4.2/include/deal.II/lac/vector.h:21,
from /mnt/c/Users/Alex/UbuntuShared/nsb-pcm/tests/peclet_data.cc:1:
/usr/include/c++/4.8/bits/stl_vector.h: In instantiation of ‘std::_Vector_base<_Tp, _Alloc>::~_Vector_base() [with _Tp = mu::Parser; _Alloc = std::allocatormu::Parser]’:
/usr/include/c++/4.8/bits/stl_vector.h:416:33: required from ‘std::vector<_Tp, _Alloc>::~vector() [with _Tp = mu::Parser; _Alloc = std::allocatormu::Parser]’
/home/zimmerman/installed/deal.ii-candi/deal.II-v8.4.2/include/deal.II/bundled/tbb/enumerable_thread_specific.h:659:17: required from ‘void tbb::interface6::internal::ets_element<U, ModularSize>::unconstruct() [with U = std::vectormu::Parser; long unsigned int ModularSize = 24ul]’
/home/zimmerman/installed/deal.ii-candi/deal.II-v8.4.2/include/deal.II/bundled/tbb/enumerable_thread_specific.h:729:17: required from ‘void tbb::interface6::enumerable_thread_specific<T, Allocator, ETS_key_type>::unconstruct_locals() [with T = std::vectormu::Parser; Allocator = tbb::cache_aligned_allocator<std::vectormu::Parser >; tbb::ets_key_usage_type ETS_key_type = (tbb::ets_key_usage_type)1u]’
Because of this issue, the number of boundaries on the domain must be known at compile time (i.e. they can't be set in the input parameter file), so that the proper number of ParsedFunction objects can be allocated.
Maybe ParsedFunction does not mean these requirements: http://stackoverflow.com/questions/12251368/type-requirements-for-stdvectortype
#include <deal.II/base/parsed_function.h>
#include <iostream>
#include <assert.h>
int main(int /*argc*/, char** /*argv*/)
{
const unsigned int dim = 2;
const unsigned int function_count = 4;
std::vector<std::shared_ptr<dealii::Functions::ParsedFunction<dim>>>
function_pointers;
function_pointers.resize(function_count);
dealii::ParameterHandler prm;
for (unsigned int f = 0; f < function_count; ++f)
{
prm.enter_subsection("parsed_function_"+std::to_string(f));
{
function_pointers[f]->declare_parameters(prm);
}
prm.leave_subsection();
}
prm.read_input("default.prm", false, true);
for (unsigned int f = 0; f < function_count; ++f)
{
prm.enter_subsection("parsed_function_"+std::to_string(f));
{
function_pointers[f]->parse_parameters(prm);
}
prm.leave_subsection();
}
return 0;
}
#include <deal.II/base/parsed_function.h>
#include <iostream>
#include <assert.h>
int main(int /*argc*/, char** /*argv*/)
{
const unsigned int dim = 2;
const unsigned int function_count = 4;
std::vector<std::shared_ptr<dealii::Functions::ParsedFunction<dim>>>
function_pointers;
dealii::ParameterHandler prm;
dealii::Point<dim> point;
double value;
for (unsigned int f = 0; f < function_count; ++f)
{
function_pointers.push_back(
std::shared_ptr<dealii::Functions::ParsedFunction<dim>>(new dealii::Functions::ParsedFunction<dim>()));
prm.enter_subsection("parsed_function_"+std::to_string(f));
{
function_pointers[f]->declare_parameters(prm);
function_pointers[f]->parse_parameters(prm);
}
prm.leave_subsection();
function_pointers[f]->value(point, value);
std::cout << "f(" << point << ") = " << value << std::endl;
}
return 0;
}