visualisation functions and solution

41 views
Skip to first unread message

Tomas Svaton

unread,
Sep 19, 2013, 11:25:42 AM9/19/13
to herm...@googlegroups.com
Hello everybody,

Could someone give me a small hint on the following visualisation tasks, please? 

1) Howto visualize a function derived from Hermes2DFunction?

2) Howto visualise a special function derived from solution? For example I would like to see how is the solution of components of deformation E11 or stress S11. E11 depends on \partial u1_sol/\partial x and S11 on both \partial u/\partial x and \partial v/\partial y.
I have taken a look on the filters, but I do not know how to derive my proper method.

Any help welcome.

Thanks in advance,
Tomas.

Lukas Korous

unread,
Sep 19, 2013, 2:40:46 PM9/19/13
to herm...@googlegroups.com
Hi Tomas,

1) You can pretty much create a subclass and then an instance of
ExactSolution, and copy the body of your value method. Direct
visualization is not supported, as a matter of fact HermesFunctions
are probably going to be discontinued, as ExactSolution and related
can do the job as well.

2) Basically if you take a look at DXDYFilter, you can just copy this
class and only add your filter_fn definition, plus several small
upgrades.

There is a lot of pre-defined filter, if you have implemented your
derived class, and it should work - but it is not - send me the class
files, and I will take a look at it.

Regards,
Lukas

2013/9/19 Tomas Svaton <tsv...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups
> "hermes2d" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to hermes2d+u...@googlegroups.com.
> To post to this group, send email to herm...@googlegroups.com.
> Visit this group at http://groups.google.com/group/hermes2d.
> For more options, visit https://groups.google.com/groups/opt_out.



--
Lukáš Korous

Tomas Svaton

unread,
Sep 24, 2013, 5:50:38 PM9/24/13
to herm...@googlegroups.com
Hi Lukas,

Thank you very much. I am sorry about the later response. I done everything you adviced me and it works well. 

To the point 1) everything OKa.

To the point 2) just one complementary question about the parameters in the CustomFilterS11(...). I have the nonconstant coeffitions mu and lamnda. I created the ExactFunction and then Hermes2DFunction (this one I use it in the weak form) which uses the values of the first one.

Now I would like to pass to the Custom FilterS11(...) the values of my ExactFunction or Hermes2DFunction. When passing the Exact function I do not have any x,y input to obtain val(x,y). I thought to bypass by Hermes2DFunction, but this requests "Geom<double>* e" and I do not know how to pass it from the main.cpp function.

Could you give me some direction?

Thank you in advance.

Kind regards,
Tomas.

PS These are the codes, which are working well:

definitions.h
// Custom filter S11
class CustomFilterS11 : public Hermes::Hermes2D::DXDYFilter<double>
{
public:
  CustomFilterS11(Hermes::vector<Solution<double>*> solutions, double mu, double lambda) : Hermes::Hermes2D::DXDYFilter<double>(solutions), mu(mu), lambda(lambda)
{
}
virtual MeshFunction<double>* clone() const
{
  Hermes::vector<Solution<double>*> slns;
  Hermes::vector<int> items;
  for(int i = 0; i < this->num; i++)
  {
    slns.push_back(dynamic_cast<Solution<double>*>(this->sln[i]->clone()));
  }
  CustomFilterS11* filter = new CustomFilterS11(slns, mu, lambda);
  return filter;
}
private:
virtual void filter_fn(int n, Hermes::vector<double *> values, Hermes::vector<double *> dx, Hermes::vector<double *> dy, double* rslt, double* rslt_dx, double* rslt_dy);
double mu;
double lambda;
};

definitions.cpp
// Custom filter S11
void CustomFilterS11::filter_fn(int n, Hermes::vector<double*> values, Hermes::vector<double*> dx, Hermes::vector<double*> dy,
                      double* out, double* outdx, double* outdy)
{
  for (int i = 0; i < n; i++)
  {
out[i] = 2.0 * mu * dx.at(0)[i] + lambda * (dx.at(0)[i] + dy.at(1)[i]);
outdx[i] = 0.0;
outdy[i] = 0.0;
  }
}

main.cpp
// First Lame constant.
double lambda = (E * nu) / ((1 + nu) * (1 - 2*nu));
// Second Lame constant.
double mu = E / (2*(1 + nu));

ScalarView viewS11("S11 [Pa]", new WinGeom(0, 260, 530, 350));
CustomFilterS11 S11(Hermes::vector<Solution<double> *>(&u1_sln, &u2_sln), mu, lambda);
viewS11.show_mesh(false);
viewS11.show(&S11, HERMES_EPS_HIGH, H2D_FN_VAL_0, &u1_sln, &u2_sln, 1.0);

Lukas Korous

unread,
Sep 25, 2013, 3:30:14 AM9/25/13
to herm...@googlegroups.com
I see, so what you are after is a filter that takes not only function
values, but not only derivatives either, but both at the same time.

If I am correct, I will put this in the requests list for the next
release. You may also think about trying to do that yourself
(basically all the pieces are there - classes SimpleFilter, and
DXDYFilter, one just needs to "merge" it).

What do you think?

Lukas

2013/9/24 Tomas Svaton <tsv...@gmail.com>:

Tomas Svaton

unread,
Sep 25, 2013, 4:04:37 AM9/25/13
to hermes2d
Hi Lukas,

I want to try it. I am not so much experienced with cpp. Hence probably I will need to be directed sometimes.

Kind regards,
Tomas.


You received this message because you are subscribed to a topic in the Google Groups "hermes2d" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/hermes2d/HNSqEcZHres/unsubscribe.
To unsubscribe from this group and all its topics, send an email to hermes2d+u...@googlegroups.com.

Tomas Svaton

unread,
Sep 28, 2013, 9:12:37 AM9/28/13
to hermes2d
Hi Lukas,

I have studied the files hermes/hermes2d/src/function/filter.cpp and hermes/hermes2d/include/function/filter.h I would like to test some changes without touching the original hermes structure. Could you please advice me the simpliest way how to do it?

Thank you.

Kind regards,
Tomas.

Lukas Korous

unread,
Sep 28, 2013, 1:37:17 PM9/28/13
to herm...@googlegroups.com

Hi Tomas, basically if it compiles (preferably on linux and windows, but linux is fine), just send a pull request to the main repository - I will try to merge it and run tests.

Thanks,
Lukas

Tomas Svaton

unread,
Oct 6, 2013, 5:44:06 PM10/6/13
to herm...@googlegroups.com
Hi Lukas,

I am sorry about the later response. I did what you adviced me - pulled the request to the main repository (I made the changes in hermes-tutorial). I followed the schema on http://hpfem.org/hermes-doc/hermes/html/src/collaboration.html

You will see in 
void CustomFilterS11::filter_fn(int n, Hermes::vector<double*> values, Hermes::vector<double*> dx, Hermes::vector<double*> dy, double* out, double* outdx, double* outdy)

the line
out[i] = 2.0 * mu * dx.at(0)[i] + lambda * (dx.at(0)[i] + dy.at(1)[i]);

where at the place of "mu" and "lambda" I would like to use the variables "cefMu = new CustomExactFunctionMu(E, nu);" and "cefLambda = new CustomExactFunctionLambda(E, nu);" respectively or something more suitable if do you think.

I would be glad to closeup this task. Thank you very much in advance.

Kind regards,
Tomas.

Lukas Korous

unread,
Oct 6, 2013, 7:11:16 PM10/6/13
to herm...@googlegroups.com
Hi Tomas,

nice work, I will go through it and will get back to you soon.

Regards,
Lukas

Lukas Korous

unread,
Oct 7, 2013, 4:14:13 AM10/7/13
to herm...@googlegroups.com
Hi Tomas,

I took a look at your code and I merged it to actual devel branch of
hermes-tutorial:

https://github.com/hpfem/hermes-tutorial/tree/devel

(I did this because it is better to use the latest version - though it
is not released, it is basically ready to be - documentation etc. is
missing).

Take a look at it, you also need the devel branch of the library -
where I did some small changes to reflect your needs - such as having
the coordinates (x, y) available to you in filter_fn.

I do not know if I did it right, please take a look at the code and tell me.

Best,
Lukas

Tomas Svaton

unread,
Oct 7, 2013, 4:00:53 PM10/7/13
to herm...@googlegroups.com
Hi Lukas,

Thank you for updating this functionality. I will take a look immediately as I will be able to update the hermes. I will give you a feedback.

Kind regards,
Tomas.

Tomas Svaton

unread,
Oct 7, 2013, 4:12:59 PM10/7/13
to herm...@googlegroups.com
Hi Lukas,

In fact, I forget to specify the reason is that the compilation is stopped on 86%. I guess the problem is quite obsolete hermes version I am using now.

Tomas.

Linking CXX executable D-10-transient-space-and-time
[ 84%] Built target D-10-transient-space-and-time
[ 86%] Building CXX object E-fvm-and-dg/01-linear-advection-dg/CMakeFiles/E-01-linear-advection-dg.dir/main.cpp.o
In file included from /home/tomas/workspace/hermes-tutorial/E-fvm-and-dg/01-linear-advection-dg/main.cpp:44:0:
/home/tomas/workspace/hermes-tutorial/E-fvm-and-dg/01-linear-advection-dg/euler_util.cpp: In member function ‘void KrivodonovaDiscontinuityDetector::calculate_jumps(Hermes::Hermes2D::Element*, int, double*)’:
/home/tomas/workspace/hermes-tutorial/E-fvm-and-dg/01-linear-advection-dg/euler_util.cpp:187:66: error: ‘class Hermes::Hermes2D::DiscontinuousFunc<double>’ has no member named ‘get_val_central’
/home/tomas/workspace/hermes-tutorial/E-fvm-and-dg/01-linear-advection-dg/euler_util.cpp:187:115: error: ‘class Hermes::Hermes2D::DiscontinuousFunc<double>’ has no member named ‘get_val_neighbor’
/home/tomas/workspace/hermes-tutorial/E-fvm-and-dg/01-linear-advection-dg/euler_util.cpp:188:72: error: ‘class Hermes::Hermes2D::DiscontinuousFunc<double>’ has no member named ‘get_val_central’
/home/tomas/workspace/hermes-tutorial/E-fvm-and-dg/01-linear-advection-dg/euler_util.cpp:188:127: error: ‘class Hermes::Hermes2D::DiscontinuousFunc<double>’ has no member named ‘get_val_neighbor’
/home/tomas/workspace/hermes-tutorial/E-fvm-and-dg/01-linear-advection-dg/euler_util.cpp:189:72: error: ‘class Hermes::Hermes2D::DiscontinuousFunc<double>’ has no member named ‘get_val_central’
/home/tomas/workspace/hermes-tutorial/E-fvm-and-dg/01-linear-advection-dg/euler_util.cpp:189:127: error: ‘class Hermes::Hermes2D::DiscontinuousFunc<double>’ has no member named ‘get_val_neighbor’
/home/tomas/workspace/hermes-tutorial/E-fvm-and-dg/01-linear-advection-dg/euler_util.cpp:190:65: error: ‘class Hermes::Hermes2D::DiscontinuousFunc<double>’ has no member named ‘get_val_central’
/home/tomas/workspace/hermes-tutorial/E-fvm-and-dg/01-linear-advection-dg/euler_util.cpp:190:113: error: ‘class Hermes::Hermes2D::DiscontinuousFunc<double>’ has no member named ‘get_val_neighbor’
make[2]: *** [E-fvm-and-dg/01-linear-advection-dg/CMakeFiles/E-01-linear-advection-dg.dir/main.cpp.o] Error 1
make[1]: *** [E-fvm-and-dg/01-linear-advection-dg/CMakeFiles/E-01-linear-advection-dg.dir/all] Error 2
make: *** [all] Error 2
tomas@tomas-VirtualBox:~/workspace/hermes-tutorial$ 

Tomas Svaton

unread,
Oct 8, 2013, 8:37:35 PM10/8/13
to herm...@googlegroups.com
Hi Lukas,

I have cloned the latest version of the hermes-tutorial (the devel one branch). Everything seems fine apart that in the file CMakeLists.txt are not right parentheses as you can see in the enclosed file. I hope I did every operation properly. Could you take a look on it, please?

Today afternoon I will take a look on the visualisation and will let you know.

Thank you very much.

Kind regards,
Tomas.
CMakeLists.txt

Lukas Korous

unread,
Oct 9, 2013, 3:43:35 AM10/9/13
to herm...@googlegroups.com
Hi, sure,

the library should be okay, as I said, that is being tested. On the
other hand, hermes-tutorial is not, but it will work fine before the
release.

Lukas
Reply all
Reply to author
Forward
0 new messages