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

Need of Help: HowTo designate explicitely unknown variables of a question?

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By akidess
  • 1 Post By akidess

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 29, 2016, 00:53
Question Solving Helmholtz Equations, HowTo calculate two fields' difference?
  #1
New Member
 
Democritus's Avatar
 
Xiaoqiu HE
Join Date: Mar 2016
Location: Wuhan, China
Posts: 29
Rep Power: 10
Democritus is on a distinguished road
Hi~ Dear Foamers,

I'm a PhD students in Huazhong University of Science and Technology and I am studying OpenFOAM for simulating the acoustic radiation force in microfludic chips.

My question:
1.In a fvMatrix class, how user explicite point out the unknown variables which is needed to be solved? Actually in all the documents, no one explicitly point out the "unknown variables" in a fvMatrix, so what is the mechanism OpenFOAM identify the "known variables" and "unknown variables" in a equation( fvMatrix ).

Update: Thanks for akidess's answer!
fvm operations comprise the unknown variable and it admits only one unknown variable;
fvc operations comprise the already known variables

2. Is there a way to have explicte calculate two fields' difference as one iteration's residual?

These two question is too abstract and I would like to objectify them in my studying case:
I would like to solve the helmholtz equation as following:
Code:
laplacian(P) - sqr(k)*P == 0
P is the pression and k is the wave number.
the pression and k is all complex number, so I decide to seperate them as follwing:
Code:
surfaceScalarField p_Re;
surfaceScalarField p_Im;
surfaceScalarField kSq_Re; // constant already known
surfaceScalarField kSq_Im; // constant already known
and the equations is derivated as follwing form:
Code:
fvScalarMatrix pReEqn
(
     fvm::laplacian(p_Re)
     +
     fvm::Sp(kSq_Re, p_Re)
     -
     fvc::Sp(kSq_Im, p_Im)
);

fvScalarMatrix pImEqn
(
        fvm::laplacian(p_Im)
        +
        fvc::Sp(kSq_Im, p_Re)
        +
        fvm::Sp(kSq_Re, p_Im)
);
My idea is solving this coupled equation with the iteration method:
1. the first equation is solved in order to get the new p_Re
2. substituting the new p_Re into second equation and then solve it in order to get the new p_Im.
3. check the differences between new and old p_Re and p_Im. If the differences are small enough, finish; if not go back to step 1.

If I set up two temporary variable as following:
Code:
surfaceScalarField pOld_Re;
surfaceScalarField pOld_Im;
Is there method in surfaceScalarField for evaluating the difference between pOld_Re and p_Re?

Thanks very much for reading till here, I am open for suggestion and advice,Thanks!

Last edited by Democritus; March 29, 2016 at 04:28. Reason: Update the result
Democritus is offline   Reply With Quote

Old   March 29, 2016, 03:33
Default
  #2
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30
akidess will become famous soon enough
Use fvm for your unknown, fvc for your known variables.

http://www.cfd-online.com/Forums/ope...g-fvm-fvc.html
Democritus likes this.
__________________
*On twitter @akidTwit
*Spend as much time formulating your questions as you expect people to spend on their answer.
akidess is offline   Reply With Quote

Old   March 29, 2016, 04:10
Default
  #3
New Member
 
Democritus's Avatar
 
Xiaoqiu HE
Join Date: Mar 2016
Location: Wuhan, China
Posts: 29
Rep Power: 10
Democritus is on a distinguished road
Thank you very much for your respond~!

In fvm operations, there may be two arguments, such as fvm::div(psi, phi)
The OpenFOAM treats phi as unknown variables by default and treats psi as known variable by default. In deduction, all the fvm operations only admit one argument as unknown and non-linear equations should be handled manually. Am I right? Thank you!
Democritus is offline   Reply With Quote

Old   March 29, 2016, 04:18
Default
  #4
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30
akidess will become famous soon enough
Yes, that's correct
Democritus likes this.
__________________
*On twitter @akidTwit
*Spend as much time formulating your questions as you expect people to spend on their answer.
akidess is offline   Reply With Quote

Old   March 29, 2016, 04:49
Default
  #5
New Member
 
Democritus's Avatar
 
Xiaoqiu HE
Join Date: Mar 2016
Location: Wuhan, China
Posts: 29
Rep Power: 10
Democritus is on a distinguished road
Quote:
Originally Posted by akidess View Post
Yes, that's correct
As a beginner of OpenFOAM, I really need the confirmed answer of such a basic question, thanks!

For the second question, is there a method within surfaceScalarField class for calculating the difference between two fields of the same mesh?

Thank you very much!
Democritus is offline   Reply With Quote

Old   March 31, 2016, 04:11
Default For the second question
  #6
New Member
 
Democritus's Avatar
 
Xiaoqiu HE
Join Date: Mar 2016
Location: Wuhan, China
Posts: 29
Rep Power: 10
Democritus is on a distinguished road
Quick Update~!

In the GeometricField< Type, PatchField, GeoMesh > Class Template,
there is a operator -= I think it means that
Code:
volScalarField p1
    (
        IOobject
        (
            "p1",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );

volScalarField p2
    (
        IOobject
        (
            "p2",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );

p1 -= p2; // p1 = p1 - p2
As there is no annotation for this operator, I will try it and update the result
Democritus is offline   Reply With Quote

Old   April 12, 2016, 09:38
Default It seems that the operator -= works!
  #7
New Member
 
Democritus's Avatar
 
Xiaoqiu HE
Join Date: Mar 2016
Location: Wuhan, China
Posts: 29
Rep Power: 10
Democritus is on a distinguished road
The operator seems working fine, the compiler has not threw any error.

Quote:
Originally Posted by Democritus View Post
Quick Update~!

In the GeometricField< Type, PatchField, GeoMesh > Class Template,
there is a operator -= I think it means that
Code:
volScalarField p1
    (
        IOobject
        (
            "p1",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );

volScalarField p2
    (
        IOobject
        (
            "p2",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );

p1 -= p2; // p1 = p1 - p2
As there is no annotation for this operator, I will try it and update the result
Democritus is offline   Reply With Quote

Reply

Tags
helmholtz, programming


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
OpenFOAM - Quick way to delete previous calculation & HowTo get access to variables kriz OpenFOAM 12 March 6, 2023 04:20
Dynamic simulation for unknown variables? fatb0y CFX 4 December 8, 2010 20:26
Question about CFX-Pre Variables seaharrier CFX 1 July 29, 2009 08:13
compressible two phase flow in CFX4.4 youngan CFX 0 July 2, 2003 00:32
Error message Pandu Sattvika CFX 0 March 1, 2002 16:28


All times are GMT -4. The time now is 20:24.