Commit bb9b82d4 authored by Praetorius, Simon's avatar Praetorius, Simon

Initfile cleaned up slightly

parent 0756da59
Pipeline #960 passed with stage
in 8 minutes and 8 seconds
......@@ -22,151 +22,34 @@
namespace AMDiS
{
namespace detail
{
// double mu_parser_eval(std::string const& valStr);
template <class T> inline T numeric_cast(double value)
{
return boost::numeric_cast< T >(value);
}
template <> inline bool numeric_cast<bool>(double value)
{
return value != 0.0;
}
/// convert string to intrinsic type
template <class T, class Enable = void>
struct Convert
{
static void eval(std::string valStr, T& value)
{
value = boost::lexical_cast<T>(valStr);
}
};
// template <class T>
// struct Convert<T, std::enable_if_t<std::is_arithmetic<T>::value> >
// {
// static void eval(std::string valStr, T& value)
// {
// try {
// value = numeric_cast< T >(mu_parser_eval(valStr));
// } catch(...) {
// error_exit("Could not parse '", valStr, "' to '", typeid(T).name(), "'\n");
// }
// }
// };
// template <class T>
// struct Convert<T, std::enable_if_t<std::is_enum<T>::value> >
// {
// static void eval(std::string valStr, T& value)
// {
// EnumParser<T>()(valStr, value);
// }
// };
// convert string to vector
template <class V, int dim>
struct Convert<Dune::FieldVector<V, dim>>
{
using T = Dune::FieldVector<V, dim>;
static void eval(std::string valStr, T& values)
{
using value_type = typename T::value_type;
using Tokenizer = boost::tokenizer<boost::char_separator<char>>;
boost::char_separator<char> sep(",; ");
Tokenizer tokens(valStr, sep);
int i = 0;
for (auto token : tokens)
{
test_exit(i < dim, "Vector data exceeds field-vector dimension!");
value_type v;
Convert<value_type>::eval(token, v);
values[i++] = v;
}
}
};
// convert string to vector
template <class V, std::size_t dim>
struct Convert<std::array<V, dim>>
{
using T = std::array<V, dim>;
static void eval(std::string valStr, T& values)
{
using value_type = typename T::value_type;
using Tokenizer = boost::tokenizer<boost::char_separator<char>>;
boost::char_separator<char> sep(",; ");
Tokenizer tokens(valStr, sep);
std::size_t i = 0;
for (auto token : tokens)
{
test_exit(i < dim, "Vector data exceeds array dimension!");
value_type v;
Convert<value_type>::eval(token, v);
values[i++] = v;
}
}
};
// convert string to vector
template <class T, class Alloc>
struct Convert<std::vector<T, Alloc>>
{
static void eval(std::string valStr, std::vector<T>& values)
{
using value_type = T;
using Tokenizer = boost::tokenizer<boost::char_separator<char>>;
boost::char_separator<char> sep(",; ");
Tokenizer tokens(valStr, sep);
for (auto token : tokens)
{
value_type v;
Convert<value_type>::eval(token, v);
values.push_back(v);
}
}
};
} // end namespace detail
/// output-stream for std::list
template <class T, class Alloc>
std::ostream& operator<<(std::ostream& out, std::list<T,Alloc> const& l)
{
auto it = l.begin();
out << "[";
if (l.size() > 0)
out << *it;
for (; it != l.end(); ++it)
out << ", " << *it;
out << "]";
return out;
}
/// output-stream for std::vector
template <class T, class Alloc>
std::ostream& operator<<(std::ostream& out, std::vector<T,Alloc> const& l)
{
auto it = l.begin();
out << "[";
if (l.size() > 0)
out << *it;
for (; it != l.end(); ++it)
out << ", " << *it;
out << "]";
return out;
}
// /// output-stream for std::list
// template <class T, class Alloc>
// std::ostream& operator<<(std::ostream& out, std::list<T,Alloc> const& l)
// {
// auto it = l.begin();
// out << "[";
// if (l.size() > 0)
// out << *it;
// for (; it != l.end(); ++it)
// out << ", " << *it;
// out << "]";
// return out;
// }
// /// output-stream for std::vector
// template <class T, class Alloc>
// std::ostream& operator<<(std::ostream& out, std::vector<T,Alloc> const& l)
// {
// auto it = l.begin();
// out << "[";
// if (l.size() > 0)
// out << *it;
// for (; it != l.end(); ++it)
// out << ", " << *it;
// out << "]";
// return out;
// }
inline void replaceAll(std::string& str, std::string const& from, std::string const& to)
{
......@@ -217,11 +100,10 @@ namespace AMDiS
* \param value: The result.
*/
template <class T>
static void get(std::string tag, T& value)
static void get(std::string key, T& value)
{
auto v = get<std::string>(tag);
if (v)
detail::Convert<T>::eval(v.value(), value);
replaceAll(key, "->", ".");
value = singlett().pt.get(key, value);
}
......
dimension of world = 2
[elliptMesh]
macro file name = ./macro/macro.stand.2d
global refinements = 5
[ellipt]
mesh = elliptMesh
[ellipt.solver]
name = cg
max iteration = 1000
absolute tolerance = 1e-6
info = 1
left precon = diag
[ellipt.output[0]]
filename = ellipt.2d
name = u
output directory = ./output
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment