CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

How does "fvm::SuSp" work ?

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree7Likes
  • 1 Post By mAlletto
  • 1 Post By mAlletto
  • 1 Post By snak
  • 2 Post By mAlletto
  • 1 Post By mAlletto
  • 1 Post By snak

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 20, 2019, 11:35
Default How does "fvm::SuSp" work ?
  #1
Member
 
K
Join Date: Jul 2017
Posts: 97
Rep Power: 8
mkhm is on a distinguished road
Dear foamers,

I want to add source terms to my equations by using fvm::SuSp. However, whatever combination that I make fails. I have "no matching function for call" error*.

How we can have a source terms as following :
fvm::SuSp(VolScalarField, SurfaceScalarField)
fvm::SuSp(VolScalarField, SurfaceVectorField)

Thanks in advance for your help,

Mary

* For instance, one of the error is the following :
Code:
error: no matching function for call to ‘SuSp(Foam::volScalarField&, Foam::surfaceScalarField&)’
                   - fvc::SuSp(A,phi)
I know that we cannot multiply a surfaceScalarfield with volScalarField. I used also many combination of fvc::reconstruct and fvc::interpolate but I cannot make fvc::SuSp(A,B) works.

Last edited by mkhm; June 23, 2019 at 12:05.
mkhm is offline   Reply With Quote

Old   June 23, 2019, 05:58
Default
  #2
Member
 
K
Join Date: Jul 2017
Posts: 97
Rep Power: 8
mkhm is on a distinguished road
No one can help me ?
mkhm is offline   Reply With Quote

Old   June 24, 2019, 05:47
Default
  #3
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15
mAlletto will become famous soon enough
Looking at the programmer guide fvm::susp takes only volumetric fields as arguments. So you have to tranform your surfacefied in a volumetric field
rarnaunot likes this.
mAlletto is offline   Reply With Quote

Old   June 25, 2019, 05:24
Default
  #4
Member
 
K
Join Date: Jul 2017
Posts: 97
Rep Power: 8
mkhm is on a distinguished road
Quote:
Originally Posted by mAlletto View Post
Looking at the programmer guide fvm::susp takes only volumetric fields as arguments. So you have to tranform your surfacefied in a volumetric field
Thanks Michael for your reply. To transform surfacefied to volumetric field, we need to use fvc::reconstruct. So, I did :

fvm::SuSp(c1,fvc::reconstructMag(phi)) where c1 is a volScalarField and phi is surfaceScalarfied. However, I had the error :

Code:
 error: no matching function for call to ‘SuSp(const volScalarField&, Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >)’
                  - fvm::SuSp(c1,fvc::reconstructMag(phi))
Therefore, I dont really see how this conversion from surfacefied to volumetric field within the use of fvm::SuSp should be done to avoid such an error.



Thanks for helping me.
mkhm is offline   Reply With Quote

Old   June 25, 2019, 06:06
Default
  #5
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15
mAlletto will become famous soon enough
Can you try to contruct your field first and then pass it to the function. I think the Problem is the tmp template.

Something like this:

volScalarField phi1(fvc::reconstructMag(phi);

fvm::SuSp(c1,phi1);
mkhm likes this.
mAlletto is offline   Reply With Quote

Old   June 27, 2019, 06:39
Default
  #6
Senior Member
 
shinji nakagawa
Join Date: Mar 2009
Location: Japan
Posts: 113
Blog Entries: 1
Rep Power: 18
snak is on a distinguished road
What equation do you want to solve?

The second argument in the SuSp will be the variable which is solved in the equation. For example, epsilon_ is the second argument in SuSp of epsilon equation.

https://github.com/OpenFOAM/OpenFOAM...Epsilon.C#L262

https://github.com/OpenFOAM/OpenFOAM...Epsilon.C#L283


SuSp function sets both the diag and source components of the matrices.

https://github.com/OpenFOAM/OpenFOAM.../fvmSup.C#L210
mkhm likes this.
snak is offline   Reply With Quote

Old   June 27, 2019, 12:33
Default
  #7
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15
mAlletto will become famous soon enough
maybe the there are some misunderstandings how to uses fvm::susp(A,phi)

A... a volscalarphield

phi... is the variable you are solving for in the Matrix (can be a volScalarField, volVectorField or volTensorField)

so if youre unkown field is c1 and phi is you mass flux (it is per Definition a surfaceField) you can write:

fvm::SuSp(fvc::reconstructMag(phi),c1)
rarnaunot and SHUBHAM9595 like this.
mAlletto is offline   Reply With Quote

Old   June 28, 2019, 12:48
Default
  #8
Member
 
K
Join Date: Jul 2017
Posts: 97
Rep Power: 8
mkhm is on a distinguished road
Hi Michael, Hi Shinji,



Thanks to both of you to answer me. I am solving the density, momentum and energy equation. I add to all 3 a different term. I did it with fvc and the compilation was fine. However, the subsonic part of the solution was not converging. So, I though maybe I should add this term in another way where the sign of the latter is considered and based on the sign, the source term is treated explicitly or implicitly (please see Understanding fvm::Sp() ). By the way, I am not sure that the use of fvm::SuSp will solve the problem.


So, for instance I have the density equation :



Code:
        // --- Solve density 
        solve(fvm::ddt(rho) + fvc::div(phi) //native OF+
              ==
       - fvc::reconstructMag(phi*fvc::interpolate(A)) //added and works 
   );

Where Phi is Surface Scalar Field and is basically rho*velocity and A is a Vol scalar field (positive in supersonic part or negative in subsonic part). This modified version of solver is working (no compilation error and runs well). However, I have some issues for some subsonic cases. So, I wanted to try this fvm::SuSp. I have the following version based on Michael's suggestion :



Code:
volScalarField phi1 // construct your field first and then pass it to the function.
        (
            fvc::reconstructMag(phi) // fvc::reconstruct(surfScaField)
        );
        
        
// --- Solve density 
        solve(fvm::ddt(rho) + fvc::div(phi) //native OF+
              ==
           - fvm::SuSp(A,phi1) //added and works 
        );

This version of solver compiles well but after when I run on my case study, I have the following error :

Code:
--> FOAM FATAL ERROR: 
incompatible fields for operation 
    [rho] == [reconstruct(phi)]

I tried as well another version based on Michael's last comment as following :



Code:
// --- Solve density 
        solve(fvm::ddt(rho) + fvc::div(phi) //native OF+
              ==
       - fvm::SuSp(fvc::reconstructMag(phi),A) 
        );

This version does not seem correct to me as I am somehow solving the rho related field. And if I look at Shinji examples, the field that you solve is the second argument of fvm::SuSp (correct me if I am saying wrong stuffs).

This version compiles fine as well but when I run it, I have the following error:

Code:
--> FOAM FATAL ERROR: 
incompatible fields for operation 
    [rho] == [A]

Could you see what is wrong and did you have any experience to solve instability of your solvers by using fvm::SuSp ?


Thanks a lot for your help,

Best regards
mkhm is offline   Reply With Quote

Old   June 28, 2019, 14:04
Default
  #9
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15
mAlletto will become famous soon enough
The second argument to fvm::susp should be your unknown variable rho. This would work fvm::susp(A,rho)
mAlletto is offline   Reply With Quote

Old   June 28, 2019, 14:24
Default
  #10
Member
 
K
Join Date: Jul 2017
Posts: 97
Rep Power: 8
mkhm is on a distinguished road
But the term to be added to this equation is A*phi and not A*rho. You mean that I should separate the velocity from the density and instead of using their multiplication which is in phi, I should do something like : fvm::susp(A*velocity,rho)?
mkhm is offline   Reply With Quote

Old   June 28, 2019, 14:29
Default
  #11
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15
mAlletto will become famous soon enough
Yes this should compile and run
mAlletto is offline   Reply With Quote

Old   June 28, 2019, 14:34
Default
  #12
Senior Member
 
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 615
Rep Power: 15
mAlletto will become famous soon enough
A no take the magnitude of the velocity otherwise you Java a volVectorField on the left side
mkhm likes this.
mAlletto is offline   Reply With Quote

Old   July 1, 2019, 07:08
Default
  #13
Member
 
K
Join Date: Jul 2017
Posts: 97
Rep Power: 8
mkhm is on a distinguished road
Quote:
Originally Posted by mAlletto View Post
A no take the magnitude of the velocity otherwise you Java a volVectorField on the left side

Thanks Michael for your prompt response.

In this case, what about the energy equation ? :



Code:
solve
        (
            fvm::ddt(rhoE) //native OF
          + fvc::div(phiEp) //native OF
          - fvc::div(sigmaDotU) //native OF
          ==
            - fvm::SuSp(A,phiEp) 
        );

In this case the term to be added is A*phiEp. So again, I have the same problem. If I add something like :


Code:
volScalarField phiEp1 // construct your field first and then pass it to the function.
        (
            fvc::reconstructMag(phiEp) // fvc::reconstruct(surfScaField)
        );

this - fvm::SuSp(A,phiEp1) compiles without errors but when it is applied to my test cases, I have the following error:

Code:
--> FOAM FATAL ERROR: 
incompatible fields for operation 
    [rhoE] == [reconstruct(phiEp)]

With your comment, I conclude that I should do something like :

- fvm::SuSp(A*something,rhoE)

However, this is not straightforward. We might need something like

Code:
  fvm::SuSp(A,rhoE)+  fvc::reconstructMag(phiEp*fvc::interpolate(A))-
  fvm::SuSp(A,rhoE)

Which could be shortened to what I had before fvc::reconstructMag(phiEp*fvc::interpolate(A)). However, my purpose is to use fvm::SuSp to see if the stability problem could be solved.



Do you have any idea how to treat this issue ?


Best regards,

Mary
mkhm is offline   Reply With Quote

Old   July 1, 2019, 08:26
Default
  #14
Senior Member
 
shinji nakagawa
Join Date: Mar 2009
Location: Japan
Posts: 113
Blog Entries: 1
Rep Power: 18
snak is on a distinguished road
Hi Mary,


I'm not familiar with the rhoCentralFoam or other compressible solvers.
So, I don't understand physics, just looking the code...

If what you want to add is A*phiEp, then I guess the addition of something like the following will be work. Here, phiv is something similar to phiv_pos or phiv_neg. (or phiEp / rhoE)

Code:
+fvm::SuSp(fvc::reconstructMag(phiv*fvc::interpolate(A)), rhoE)

This will not be an exact expression.
mkhm likes this.
snak is offline   Reply With Quote

Old   July 1, 2019, 11:19
Default
  #15
Member
 
K
Join Date: Jul 2017
Posts: 97
Rep Power: 8
mkhm is on a distinguished road
Quote:
Originally Posted by snak View Post
Hi Mary,


I'm not familiar with the rhoCentralFoam or other compressible solvers.
So, I don't understand physics, just looking the code...

If what you want to add is A*phiEp, then I guess the addition of something like the following will be work. Here, phiv is something similar to phiv_pos or phiv_neg. (or phiEp / rhoE)

Code:
+fvm::SuSp(fvc::reconstructMag(phiv*fvc::interpolate(A)), rhoE)

This will not be an exact expression.
Thanks Shinji for your reply. It works.
mkhm is offline   Reply With Quote

Reply

Tags
fvm::susp, implicit/explicit, sources

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
RP_Set_Integer does not work in parallel 86lolo Fluent UDF and Scheme Programming 2 July 3, 2014 11:37
Does CX_Interpret_String work in parallel? 86lolo Fluent UDF and Scheme Programming 2 June 30, 2014 04:36
Companies that lease software & hardware for cloud-based work? Catthan ANSYS 0 June 18, 2014 10:53
Why do the Plant library cases don't work? Alumna Phoenics 6 June 22, 2004 12:08
why my In-Form doesn't work? green Phoenics 2 May 27, 2004 21:03


All times are GMT -4. The time now is 02:43.