- Thank you received: 0
Creating CoefficientFunctions or GridFunctions Using Integration
5 years 6 months ago #1583
by kelley
Hello!
I am new to NGSolve and would like to follow up on a similar question .
I am solving a three dimensional problem and as part of my weak form, I need to implement a vector valued quantity that arises through integration of a coefficient function defined on the bottom of my domain. The integration is wrt z and the result should be a CoefficientFunction or a GridFunction defined on the whole domain.
To do this, I am trying to implement numerical integration myself and essentially create a CoefficientFunction holding the result (though I am not certain this is the most convenient way to do this either). Therefore I would need to create a CoefficientFunction or a GridFunction from a vector or array holding the values from the numerical integration.
My questions are:
Thanks in advance,
Josie
I am new to NGSolve and would like to follow up on a similar question .
I am solving a three dimensional problem and as part of my weak form, I need to implement a vector valued quantity that arises through integration of a coefficient function defined on the bottom of my domain. The integration is wrt z and the result should be a CoefficientFunction or a GridFunction defined on the whole domain.
To do this, I am trying to implement numerical integration myself and essentially create a CoefficientFunction holding the result (though I am not certain this is the most convenient way to do this either). Therefore I would need to create a CoefficientFunction or a GridFunction from a vector or array holding the values from the numerical integration.
My questions are:
- Is there a better way to do this numerical integration?
- How could I go about setting a GridFunction or CoefficientFunction containing the results if there is no better way?
Thanks in advance,
Josie
- christopher
- Offline
- Administrator
Less
More
- Thank you received: 101
5 years 6 months ago - 5 years 6 months ago #1587
by christopher
Replied by christopher on topic Creating CoefficientFunctions or GridFunctions Using Integration
Could you provide a short mathematical description of what you want to do? Maybe with a sketch or something? From what I would understand you can do something like:
Best
Christopher
Code:
integration_val = Parameter(0)
# use this integration val in some SymbolicBFI or so...
a +=SymbolicBFI(integration_val * u * v)
# then in some loop, etc...
integration_val.Set(Integrate(cf, mesh, definedon=mesh.Boundaries("bottom"))
# use the new val in the bf,...
a.Assemble()
Best
Christopher
Last edit: 5 years 6 months ago by christopher.
5 years 6 months ago #1606
by kelley
Replied by kelley on topic Creating CoefficientFunctions or GridFunctions Using Integration
Hello Christopher,
sorry for being unclear. A rough explanation of my problem is that my bilinear form is a convection operator and I was having trouble implementing the vector that acts as the wind.
This is because each component of the wind arises through integration of a function (that we will call phi), i.e.
The expression for the wind is actually more complicated, but my question is about evaluating this type of integral: Is there a nicer way to evaluate this integral using NGSolve than by writing a numerical integration scheme myself?
Thanks,
Josie
sorry for being unclear. A rough explanation of my problem is that my bilinear form is a convection operator and I was having trouble implementing the vector that acts as the wind.
Code:
wind = ???
a = SymbolicBFI( InnerProduct( grad(u) * wind, v ) )
Code:
wind_i(x,y,z) = \int_0^z \phi_i (x,y,\tilde{z}) d\tilde{z}, i = 1,...,3
Thanks,
Josie
- christopher
- Offline
- Administrator
Less
More
- Thank you received: 101
5 years 6 months ago #1607
by christopher
Replied by christopher on topic Creating CoefficientFunctions or GridFunctions Using Integration
Hi Josie,
you could use another Python package, for example scipy.integrate for that.
Best Christopher
you could use another Python package, for example scipy.integrate for that.
Best Christopher
Time to create page: 0.099 seconds