- Thank you received: 0
Integral over product space
4 years 5 months ago - 4 years 5 months ago #2735
by philipp
Integral over product space was created by philipp
Dear NGSolve community,
I am having the (maybe little unusual) integral expression in a weak formulation of a problem I am interested in:
[tex]
\int_\Omega \int_\Omega f(x,y,\phi(y)) u(x) v(x) d^3y d^3x.
[/tex]
It is part of a system of equations of a time-dependent problem and both \phi and u are trial functions and v is a test function. I employ a semi-implicit Euler-scheme with Newton's methods for time integration.
To make things a little easier, I decided to take \phi explicitely, but still the only method I can think of
is to encode an integration scheme for the inner integral in the symbolic expression I give the symbolic integrator in NGSolve. I can imagine that such odd situations are not accounted for right now in NGSolve,
but still wanted to make sure I am not missing a short workaround.
I appreciate any hint, what I might do instead.
All the best,
Philipp
I am having the (maybe little unusual) integral expression in a weak formulation of a problem I am interested in:
[tex]
\int_\Omega \int_\Omega f(x,y,\phi(y)) u(x) v(x) d^3y d^3x.
[/tex]
It is part of a system of equations of a time-dependent problem and both \phi and u are trial functions and v is a test function. I employ a semi-implicit Euler-scheme with Newton's methods for time integration.
To make things a little easier, I decided to take \phi explicitely, but still the only method I can think of
is to encode an integration scheme for the inner integral in the symbolic expression I give the symbolic integrator in NGSolve. I can imagine that such odd situations are not accounted for right now in NGSolve,
but still wanted to make sure I am not missing a short workaround.
I appreciate any hint, what I might do instead.
All the best,
Philipp
Last edit: 4 years 5 months ago by philipp.
- christopher
- Offline
- Administrator
Less
More
- Thank you received: 101
4 years 5 months ago - 4 years 5 months ago #2737
by christopher
Replied by christopher on topic Integral over product space
If you take phi explicitly you can just use the gridfunction instead of the trialfunction and integrate it to get the coefficient in your form or am I missing something?
Best
Christopher
Best
Christopher
Last edit: 4 years 5 months ago by christopher.
4 years 5 months ago - 4 years 5 months ago #2738
by philipp
Replied by philipp on topic Integral over product space
Thanks for your fast reply. Since f depends on both x and y, I need the inner integral to be a coefficient function in x. I don't know a way to do this, but symbolically write down the quadrature in y.
Maybe there is confusion because I named the points x and y which collides with the
notation in NGSolve, where x and y are coordinates. I am sorry for this. Maybe I should edit the post.
All the best,
Philipp
Maybe there is confusion because I named the points x and y which collides with the
notation in NGSolve, where x and y are coordinates. I am sorry for this. Maybe I should edit the post.
All the best,
Philipp
Last edit: 4 years 5 months ago by philipp.
- christopher
- Offline
- Administrator
Less
More
- Thank you received: 101
4 years 5 months ago #2739
by christopher
Replied by christopher on topic Integral over product space
Ah now I got you, sry.
I guess this is an example where you would likely need to write a c++ coefficientfunction to have it somehow performant.
You can use the tutorial here:
ngsolve.org/docu/latest/mylittlengs/1_Ba...FEM/coefficient.html
from mylittlengsolve ( ngsolve.org/docu/latest/mylittlengs/1_Ba...FEM/coefficient.html )
In the evaluate you need to integrate f over the mesh with the fixed x from the mip that you get in the evaluate.
Hope this helps, if you have questions or run into problems with the cpp extension let us know.
Best
I guess this is an example where you would likely need to write a c++ coefficientfunction to have it somehow performant.
You can use the tutorial here:
ngsolve.org/docu/latest/mylittlengs/1_Ba...FEM/coefficient.html
from mylittlengsolve ( ngsolve.org/docu/latest/mylittlengs/1_Ba...FEM/coefficient.html )
In the evaluate you need to integrate f over the mesh with the fixed x from the mip that you get in the evaluate.
Hope this helps, if you have questions or run into problems with the cpp extension let us know.
Best
4 years 5 months ago - 4 years 5 months ago #2749
by philipp
Replied by philipp on topic Integral over product space
I got to work on your suggestion, but sadly got stuck on the following error
that occurs when I import myngspy that I build from the code of "mylittlengsolve":
I modified the example to only implement the MyCoefficient class, so my myngspy.cpp file is slightly different (attached), but that shouldn't be the problem as far as I understand.
After some digging I suspect that it is related to the pybind-export code for CoefficientFunction not
being executed before my import, but I can't figure out how I enforce this.
Do you have any suggestions?
Thank you very much
Philipp
that occurs when I import myngspy that I build from the code of "mylittlengsolve":
Code:
ImportError: generic_type: type "MyCoefficient" referenced unknown base type "ngfem::CoefficientFunction"
After some digging I suspect that it is related to the pybind-export code for CoefficientFunction not
being executed before my import, but I can't figure out how I enforce this.
Do you have any suggestions?
Thank you very much
Philipp
Attachments:
Last edit: 4 years 5 months ago by philipp.
- christopher
- Offline
- Administrator
Less
More
- Thank you received: 101
4 years 5 months ago #2750
by christopher
Replied by christopher on topic Integral over product space
Hi,
usually the statement py::module::import("ngsolve"); sould execute the ngsolve python export.
Another option would be to do the "import ngsolve" before importing your module.
Can you zip your whole example and attach it?
usually the statement py::module::import("ngsolve"); sould execute the ngsolve python export.
Another option would be to do the "import ngsolve" before importing your module.
Can you zip your whole example and attach it?
Time to create page: 0.111 seconds