two questions

325 views
Skip to first unread message

guanheng zhang

unread,
Sep 25, 2017, 5:55:19 PM9/25/17
to moose-users
1. Load velocity by "addRequiredParam". How can I use the gradient of velocity in computeQpResidual ?
2. Have a postprocessor as an integrator and the output is scalar variable (i.e. change with time). How can I use the output in a ScalarKernel? Any ways I can load this postprocessor, like a coupled variable or required parameter?

Thank you. Just start learning MOOSE.

G

Alexander Lindsay

unread,
Sep 25, 2017, 9:15:19 PM9/25/17
to moose...@googlegroups.com
On Mon, Sep 25, 2017 at 3:55 PM, guanheng zhang <zhangg...@gmail.com> wrote:
1. Load velocity by "addRequiredParam". How can I use the gradient of velocity in computeQpResidual ?
Didn't Andy answer this question on a thread last week? Is this velocity just a function of space and time or is it a function of coupled variables? If the latter, you should look into DerivativeParsedMaterial. If the former, and you are supplying your velocity through a Function, then you should do the derivative of the velocity (with respect to space) by hand and pass that in as another function. It could be interesting to have a utility that allows us to get partial derivatives of a function with respect to x,y,z,t within kernels etc. but I don't think we currently have that capability.

2. Have a postprocessor as an integrator and the output is scalar variable (i.e. change with time). How can I use the output in a ScalarKernel? Any ways I can load this postprocessor, like a coupled variable or required parameter?
Postprocessor values are single scalars. You can choose to calculate them on linear, non-linear iterations, on timestep_begin or timestep_end (see documentation here: http://mooseframework.org/wiki/MooseSystems/Postprocessors/). You load the Postprocessor into a ScalarKernel (or regular Kernel or many other moose objects) with params.addParam<PostprocessorName>. See the DefaultPostprocessorDiffusion.C  in the test/src/kernels directory for an example.

Alex

Thank you. Just start learning MOOSE.

G

--
You received this message because you are subscribed to the Google Groups "moose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to moose-users+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/moose-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/moose-users/404042c7-6d19-4286-a4e2-17dcc88563ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

guanheng zhang

unread,
Sep 25, 2017, 9:23:17 PM9/25/17
to moose-users
Hi Alex, thank you for replying my questions. The second one is clear now and I will test it tomorrow. For the first question, the velocity will come from T/H calculations so it is the derivative of the velocity with respect to space. For the initial test, I can use a function of space. But finally, I have to load velocity as a coupled parameter from T/H kernel and the first order derivative of the velocity is what I need for the local kernel. So I should use DerivativeParsedMaterial, right?

Thanks.

George


On Monday, September 25, 2017 at 8:15:19 PM UTC-5, Alexander Lindsay wrote:
On Mon, Sep 25, 2017 at 3:55 PM, guanheng zhang <zhangg...@gmail.com> wrote:
1. Load velocity by "addRequiredParam". How can I use the gradient of velocity in computeQpResidual ?
Didn't Andy answer this question on a thread last week? Is this velocity just a function of space and time or is it a function of coupled variables? If the latter, you should look into DerivativeParsedMaterial. If the former, and you are supplying your velocity through a Function, then you should do the derivative of the velocity (with respect to space) by hand and pass that in as another function. It could be interesting to have a utility that allows us to get partial derivatives of a function with respect to x,y,z,t within kernels etc. but I don't think we currently have that capability.

2. Have a postprocessor as an integrator and the output is scalar variable (i.e. change with time). How can I use the output in a ScalarKernel? Any ways I can load this postprocessor, like a coupled variable or required parameter?
Postprocessor values are single scalars. You can choose to calculate them on linear, non-linear iterations, on timestep_begin or timestep_end (see documentation here: http://mooseframework.org/wiki/MooseSystems/Postprocessors/). You load the Postprocessor into a ScalarKernel (or regular Kernel or many other moose objects) with params.addParam<PostprocessorName>. See the DefaultPostprocessorDiffusion.C  in the test/src/kernels directory for an example.

Alex

Thank you. Just start learning MOOSE.

G

--
You received this message because you are subscribed to the Google Groups "moose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to moose-users...@googlegroups.com.

Alexander Lindsay

unread,
Sep 26, 2017, 10:24:18 AM9/26/17
to moose...@googlegroups.com
So your velocity will be a variable that you're solving for or it will be an auxiliary variable (AuxVariable)? If so then you can just use params.addRequiredCoupledVar and get the gradient by using `coupledGradient` in the kernel (or whatever MooseObject) constructor

To unsubscribe from this group and stop receiving emails from it, send an email to moose-users+unsubscribe@googlegroups.com.

guanheng zhang

unread,
Sep 26, 2017, 10:59:17 AM9/26/17
to moose-users
I guess it is an auxiliary variable. I need the gradient to solve my problem.

Thank you

George

guanheng zhang

unread,
Sep 26, 2017, 6:10:44 PM9/26/17
to moose-users
Following the second question, can I save the postprocessors as a vector?  I'm now using     

const PostprocessorValue & _C = getPostprocessorValue("postprocessor");

and it gives me a Real value. But I have multiple postprocessors and actually, I don't know how many. I want to load them together for the kernel.


Another question is that I have to solve multiple PDE (using kernels) and one ODE (use scalar kernel).  I use coupled variables to communicate between different kernels. Moose shows difficulties to converge the calculation. Will MOOSE solve the kernels and scalar kernels at the same time? If I choose postprocessors to communicate, could this be improved?

Thanks.

George










On Monday, September 25, 2017 at 8:15:19 PM UTC-5, Alexander Lindsay wrote:
On Mon, Sep 25, 2017 at 3:55 PM, guanheng zhang <zhangg...@gmail.com> wrote:
1. Load velocity by "addRequiredParam". How can I use the gradient of velocity in computeQpResidual ?
Didn't Andy answer this question on a thread last week? Is this velocity just a function of space and time or is it a function of coupled variables? If the latter, you should look into DerivativeParsedMaterial. If the former, and you are supplying your velocity through a Function, then you should do the derivative of the velocity (with respect to space) by hand and pass that in as another function. It could be interesting to have a utility that allows us to get partial derivatives of a function with respect to x,y,z,t within kernels etc. but I don't think we currently have that capability.

2. Have a postprocessor as an integrator and the output is scalar variable (i.e. change with time). How can I use the output in a ScalarKernel? Any ways I can load this postprocessor, like a coupled variable or required parameter?
Postprocessor values are single scalars. You can choose to calculate them on linear, non-linear iterations, on timestep_begin or timestep_end (see documentation here: http://mooseframework.org/wiki/MooseSystems/Postprocessors/). You load the Postprocessor into a ScalarKernel (or regular Kernel or many other moose objects) with params.addParam<PostprocessorName>. See the DefaultPostprocessorDiffusion.C  in the test/src/kernels directory for an example.

Alex

Thank you. Just start learning MOOSE.

G

--
You received this message because you are subscribed to the Google Groups "moose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to moose-users...@googlegroups.com.

Alexander Lindsay

unread,
Sep 27, 2017, 9:32:09 AM9/27/17
to moose...@googlegroups.com
You could do params.addParam<std::vector<PostprocessorName>> and then something like `_postprocessor_values.push_back(&getPostprocessorValueByName(pps_name))`. See moose/framework/src/vectorpostprocessors/VectorOfPostprocessors.C for an example of this.

Convergence depends on a ton of things. If you're using a lot of postprocessors in your calculations, then I'm guessing you cannot code perfect Jacobians which makes convergence less efficient. You are using PJFNK I hope? Have you been diligent about adding as accurate Jacobian methods as you can for your preconditioning matrix?

Moose by default performs monolithic solves, so yes all variables (both your PDE and ODE variables) are solved at the same time.

To unsubscribe from this group and stop receiving emails from it, send an email to moose-users+unsubscribe@googlegroups.com.

guanheng zhang

unread,
Sep 27, 2017, 9:42:34 AM9/27/17
to moose-users
Thank you Alex,

Instead of using coupled variables, I could put them into the postprocessors. In that way, the scalar kernels and kernels are set up based on the conditions from last time step (if my understanding is correct). Do you think this will help with the convergence issue? 

Cody Permann

unread,
Sep 27, 2017, 11:05:35 AM9/27/17
to moose-users
One more suggestion: If you have multiple related Postprocessor values, you might look into the VectorPostprocessor capability. Each one of these objects can produce multiple (a vector) of values that can be access from your other objects.

Alexander Lindsay

unread,
Sep 27, 2017, 1:27:27 PM9/27/17
to moose...@googlegroups.com
So you're proposing just using old data in your kernels? That would remove the coupling yes. But now it sounds like you're just doing an explicit solve. MOOSE does have some explicit capabilities.

To unsubscribe from this group and stop receiving emails from it, send an email to moose-users+unsubscribe@googlegroups.com.

guanheng zhang

unread,
Sep 27, 2017, 4:16:08 PM9/27/17
to moose-users
Thanks. I will test it.

George
Reply all
Reply to author
Forward
0 new messages