Re: [deal.II] Reading a Tensor from parameter file

2020-08-05 Thread Luca Heltai
> Thank you. This really shortens the code. Is it also possible to set the > delimiter to a user desired value, say "|" instead of ",". All functions of the Convert class take a unique pointer to a pattern. You can specify your own pattern, and use that in the conversion. The code is all in de

Re: [deal.II] Reading a Tensor from parameter file

2020-08-05 Thread Paras Kumar
Dear Luca, Thank you. This really shortens the code. Is it also possible to set the delimiter to a user desired value, say "|" instead of ",". Also, where exactly is the procedure for conversion from string to deali::Tensor or some other type say std::vector defined? I could not find it in the

Re: [deal.II] Reading a Tensor from parameter file

2020-08-05 Thread luca.heltai
> Could you please provide an MWE to describe how the > Patterns::Convert::to_value() function would work in this case. In the dealii/tests/parameter_handler/patterns_05.cc there are many examples that show how to use these. > Is it must to use prm.add_parameter() to be able to do so? > I usua

Re: [deal.II] Reading a Tensor from parameter file

2020-08-04 Thread Paras Kumar
Hi, Could you please provide an MWE to describe how the Patterns::Convert::to_value() function would work in this case. Is it must to use prm.add_parameter() to be able to do so? I usually use prm.declare_entry() and prm.get(). Best regards, Paras On Wednesday, April 15, 2020 at 6:01:53 PM

Re: [deal.II] Reading a Tensor from parameter file

2020-04-15 Thread Luca Heltai
Currently, this is also the simplest way: Tensor tens; prm.add_parameter("Tensor", tens); Take a look at the documentation of the add parameter method. Patterns::Tools::to_string(tens); And Patterns::Tools::to_value Are also available to simplify what you want to achieve. Alternatively: P

Re: [deal.II] Reading a Tensor from parameter file

2020-04-15 Thread Ahmad Shahba
Ooops! The background was too dark :-) #include #include #include #include #include #include using namespace dealii; int main() { // Let's read this tensor from an istringstream. You may read it from istream in your // application std::istringstream is("set Tensor3x3 = 11, 1

Re: [deal.II] Reading a Tensor from parameter file

2020-04-15 Thread Ahmad Shahba
Here is the code that does what I explained. I just switched up step 5 with a much simpler approach. Note that you can simply make this into a function/class template so that you could read general tensors, not just 3x3 tensors. I leave that to you :-) #include #include #include #include #i

Re: [deal.II] Reading a Tensor from parameter file

2020-04-15 Thread Paras Kumar
Ahmad, On Tuesday, April 14, 2020 at 5:39:06 PM UTC+2, Ahmad Shahba wrote: > > I don't know if it is the optimal way but I would use the following > approach > >1. Read tensor components as Patterns::List >2. Use get > >

Re: [deal.II] Reading a Tensor from parameter file

2020-04-14 Thread Ahmad Shahba
I don't know if it is the optimal way but I would use the following approach 1. Read tensor components as Patterns::List 2. Use get method of ParameterHandler to read all ten

[deal.II] Reading a Tensor from parameter file

2020-04-14 Thread Paras Kumar
Dear deal.II community, I am trying to read a second order tensor from a .prm file using the ParameterHandler functionalities. The tensor (for dim=3) is set in .prm file as set macro def grad = 1.2|0.0|0.0|0.0|1.1|0.0|0.0|0.0|1.4 and is currently read as a string using parameterHandler.decl