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

[HOW TO] solve the velocity components (Ux and Uy) from 2 equations

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 17, 2020, 13:13
Question [HOW TO] solve the velocity components (Ux and Uy) from 2 equations
  #1
Senior Member
 
Kumaresh
Join Date: Oct 2016
Posts: 354
Rep Power: 12
Kummi is on a distinguished road
Send a message via Yahoo to Kummi
Hello Foamers,
Based on my previous thread, I'm continuing this new thread !!
Couldn't able to figure out the technique - NO problem with Compilation
I have defined a volVectorField U with two scalar fields Ux and Uy along x and y directions (2D). I want to extract Ux and Uy based on two equations given below.
Quote:
\left [ \frac{\delta v_{y}}{\delta {x}}-\frac{\delta v_{x}}{\delta {y}} \right ] -
\left \{ v_{x} \left [ \frac{\delta}{\delta {y}}(ln(f_{1}+f_{2}\left | \rho v_{x} \right |) \right ] -v_{y} \left [ \frac{\delta}{\delta {x}}(ln(f_{1}+f_{2}\left | \rho v_{x} \right |) \right ]\right \}=0 \ \ \ \ (Eq.3a)

\left [ \frac{\delta v_{y}}{\delta {x}}-\frac{\delta v_{x}}{\delta {y}} \right ] -
\left \{ v_{x} \left [ \frac{\delta}{\delta {y}}(ln(f_{1}+f_{2}\left |  \rho v_{y} \right |) \right ] -v_{y} \left [ \frac{\delta}{\delta  {x}}(ln(f_{1}+f_{2}\left | \rho v_{y} \right |) \right ]\right \}=0 \ \ \ \ (Eq.3b)
I tried defining the above two equations in many ways, but ends with no success. The pressure on the other hand is solved comfortably with no errors.
Equs. (3a and b) is defined in OpenFOAM as,
Quote:
(gradCurlUyx - gradCurlUxy) = (1/0.4343*(f1+(f2*rho*Ux)))*((Ux*gradUxy)-(Uy*gradUxx)); // (Eq.3a)
(gradCurlUyx - gradCurlUxy) = (1/0.4343*(f1+(f2*rho*Uy)))*((Ux*gradUyy)-(Uy*gradUyx)); // (Eq.3b)
//COMPILED WELL - but no change in velocity during post-processing (Attachments)
Previously, I got the comment from one of the foamers that I didn't defined the assignment operator appropriately. It looks to be trivial problem, but I couldn't figured it out so far.
Quote:
solve
(
(gradCurlUyx - gradCurlUxy) == (((Ux*gradUyy)-(Uy*gradUyx))/(0.4343*(f1+(f2*rho*Ux))))
); // Failed when I try to define the velocity equation based on equality operator
ERROR:
ergunFoam.C: In function ‘int main(int, char**)’:
ergunFoam.C:62:88: error: no match for ‘operator==’ in ‘Foam:perator-(const Foam::GeometricField<TypeR, PatchField, GeoMesh>&, const Foam::GeometricField<Type1, PatchField, GeoMesh>&) [with Type1 = double; Type2 = double; PatchField = Foam::fvPatchField; GeoMesh = Foam::volMesh; typename
I'm hereby attaching my code and case files.
If anyone have some ideas, kindly do share it to proceed further.
Thank you

**The above equations are referred from the following reference: Equ. (9) expanded as 2 Equs. [Equ. 21 - cylindrical coordinates]
https://aiche.onlinelibrary.wiley.co.../aic.690200519
Attached Images
File Type: png Velocity - no change.png (15.6 KB, 16 views)
File Type: png pressure.png (19.2 KB, 14 views)
Attached Files
File Type: gz ErgunFoam9.tar.gz (6.1 KB, 2 views)
Kummi is offline   Reply With Quote

Old   January 17, 2020, 14:02
Default
  #2
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 16
adhiraj is on a distinguished road
You have posted essentially the same question in three different threads now. I am sure that this is against forum etiquette, is kind of annoying, and will likely not get you help any faster.

You ask why your p field is being updated, and not your U field. I believe I have already answered that question in the other thread. If you did not fully understand the answer (which can happen), I am happy to continue the discussion in that thread.

Here's another hint: what do you think this statement will do?

Code:
(gradCurlUyx - gradCurlUxy) = (1/0.4343*(f1+(f2*rho*Ux)))*((Ux*gradUxy)-(Uy*gradUxx));

MODS: could you please merge the two threads?
adhiraj is offline   Reply With Quote

Old   January 17, 2020, 14:58
Default
  #3
Senior Member
 
Kumaresh
Join Date: Oct 2016
Posts: 354
Rep Power: 12
Kummi is on a distinguished road
Send a message via Yahoo to Kummi
Sorry Adhiraj. I'm in a rush to complete my work - deadlines in short. I have searched threads in CFD forums, but couldn't able to find a way. Even in my previous thread, I replied at last - but there is no response back and I thought you are even tired of responding me everytime. So, I thought not to annoy you further and posted a new thread here again to get response from other foamers. I'm happy if you help me further.
And coming to your question, yes you answered my query. But, I didn't understand it completely and I'm glad to continue the discussion in previous thread.
Quote:
(gradCurlUyx - gradCurlUxy) = (1/0.4343*(f1+(f2*rho*Ux)))*((Ux*gradUxy)-(Uy*gradUxx));
With assignment operator used, calculates and assigns the value of RHS to the LHS
And your last reply,
Quote:
You are trying to use an assignment statement, that too incorrectly. You need to create and solve a transport equation using OpenFOAM syntax. Look at your equation for {p}^{2} to get a feel for the syntax.
You asked me to use the assignment statement appropriately based on OF syntax. But, after reading OF threads, I thought that I should imply == equality operator to force the assignment and so, equation for velocity will be defined when I use == operator.

== operator

I tried using == operator but ends in error as shown above in comment and I'm looking forward to resolve this case.

MODS: could you please merge the two threads? -- I dont know, could you help me with it please...

Thank you for your patience..
Kummi is offline   Reply With Quote

Old   January 17, 2020, 15:50
Default
  #4
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 16
adhiraj is on a distinguished road
I am happy to help, but instead of posting the same question over and over again, you need to spend a little time to understand the responses and then you will arrive at a solution to your problem much quicker.

Quote:
Originally Posted by Kummi View Post
With assignment operator used, calculates and assigns the value of RHS to the LHS
So far so good. But now comes the tricky part: what exactly is (gradCurlUyx - gradCurlUxy)?

You created the variables gradCurlUyx and gradCurlUxy, but when the compiler sees (gradCurlUyx - gradCurlUxy), it creates a temporary variable to store the difference. This variable probably does not even have a name per se, and it is to this variable that the value of the right hand side is assigned. The variables gradCurlUyx and gradCurlUxy are not affected. See the problem?

Quote:
Originally Posted by Kummi View Post
You asked me to use the assignment statement appropriately based on OF syntax
No, I did not. I merely pointed out that instead of creating and solving an equation, you wrote an assignment statement, which is also incorrectly used, because of the reasons above.

Quote:
Originally Posted by Kummi View Post
solve
(
(gradCurlUyx - gradCurlUxy) == (((Ux*gradUyy)-(Uy*gradUyx))/(0.4343*(f1+(f2*rho*Ux))))
);
What is this supposed to do? As I explained above, (gradCurlUyx - gradCurlUxy) creates a temporary variable, for which the operator == is not defined. That is what the compiler is complaining about.

If you want to solve for Ux, you need to create the appropriate fvMatrix for it, using terms such as fvm::ddt(...), fvm::grad(...) and so on.
adhiraj is offline   Reply With Quote

Old   January 17, 2020, 17:39
Default
  #5
Senior Member
 
Kumaresh
Join Date: Oct 2016
Posts: 354
Rep Power: 12
Kummi is on a distinguished road
Send a message via Yahoo to Kummi
Dear Adhiraj,
Thank you for your clear-cut explanation.

My biggest mistake was that, I didn't assign any name to solve velocity in matrix form, as how I assigned for pressure (p):
Quote:
solve ( fvm::laplacian(p2) == - (2*T*R)*(((f1+(f2*rho*Ux))*RRg) + (rho*(Ux+Uy)*gradUxx)) );
As you mentioned, (gradCurlUyx - gradCurlUxy) returns some temporary variable and stores the value calculated by R.H.S. That's the reason why velocity is unaffected.

So, in order to solve velocities Ux and Uy - I need to create a fvScalarMatrix, something as such below:
Quote:
// Construct Ux equation
{
fvScalarMatrix UxEqn
(
(gradCurlUyx - gradCurlUxy)
- (((Ux*gradUxy)-(Uy*gradUxx))/(0.4343*(f1+(f2*rho*Ux))))
);
UxEqn.solve();

// Construct Uy equation
fvScalarMatrix UyEqn
(
(gradCurlUyx - gradCurlUxy)
- (((Ux*gradUyy)-(Uy*gradUyx))/(0.4343*(f1+(f2*rho*Uy))))
);
UyEqn.solve();
}
Here the names (UxEqn and UyEqn) are defined for calculating velocities in matrix form. Each matrices UxEqn and UyEqn solves both Ux and Uy. After compiling, it results in error. I'm in the process of resolving my error.
Quote:

Making dependency list for source file ergunFoam.C
SOURCE=ergunFoam.C ; g++-4.7 -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-100 -I/home/kumaresh/OpenFOAM/OpenFOAM-2.1.1/src/finiteVolume/lnInclude -IlnInclude -I. -I/home/kumaresh/OpenFOAM/OpenFOAM-2.1.1/src/OpenFOAM/lnInclude -I/home/kumaresh/OpenFOAM/OpenFOAM-2.1.1/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64Gcc47DPOpt/ergunFoam.o
In file included from ergunFoam.C:54:0:
UEqn.H: In function ‘int main(int, char**)’:
UEqn.H:9:5: error: no matching function for call to ‘Foam::fvMatrix<double>::fvMatrix(Foam::tmp<Foam:: GeometricField<double, Foam::fvPatchField, Foam::volMesh> >)’
UEqn.H:9:5: note: candidates are:
In file included from /home/kumaresh/OpenFOAM/OpenFOAM-2.1.1/src/finiteVolume/lnInclude/fvMatrix.H:1050:0,
from /home/kumaresh/OpenFOAM/OpenFOAM-2.1.1/src/finiteVolume/lnInclude/laplacianScheme.C:29,
from /home/kumaresh/OpenFOAM/OpenFOAM-2.1.1/src/finiteVolume/lnInclude/laplacianScheme.H:245,
from /home/kumaresh/OpenFOAM/OpenFOAM-2.1.1/src/finiteVolume/lnInclude/fvcLaplacian.C:28,
from /home/kumaresh/OpenFOAM/OpenFOAM-2.1.1/src/finiteVolume/lnInclude/fvcLaplacian.H:242,
from /home/kumaresh/OpenFOAM/OpenFOAM-2.1.1/src/finiteVolume/lnInclude/fvc.H:53,
from /home/kumaresh/OpenFOAM/OpenFOAM-2.1.1/src/finiteVolume/lnInclude/fvCFD.H:8,
from ergunFoam.C:32:
/home/kumaresh/OpenFOAM/OpenFOAM-2.1.1/src/finiteVolume/lnInclude/fvMatrix.C:418:1: note: Foam::fvMatrix<Type>::fvMatrix(const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>&, Foam::Istream&) [with Type = double]
/home/kumaresh/OpenFOAM/OpenFOAM-2.1.1/src/finiteVolume/lnInclude/fvMatrix.C:418:1: note: candidate expects 2 arguments, 1 provided
/home/kumaresh/OpenFOAM/OpenFOAM-2.1.1/src/finiteVolume/lnInclude/fvMatrix.C:361:1: note: Foam::fvMatrix<Type>::fvMatrix(const Foam::tmp<Foam::fvMatrix<Type> >&) [with Type = double]
/home/kumaresh/OpenFOAM/OpenFOAM-2.1.1/src/finiteVolume/lnInclude/fvMatrix.C:361:1: note: no known conversion for argument 1 from ‘Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >’ to ‘const Foam::tmp<Foam::fvMatrix<double> >&’
/home/kumaresh/OpenFOAM/OpenFOAM-2.1.1/src/finiteVolume/lnInclude/fvMatrix.C:330:1: note: Foam::fvMatrix<Type>::fvMatrix(const Foam::fvMatrix<Type>&) [with Type = double]
/home/kumaresh/OpenFOAM/OpenFOAM-2.1.1/src/finiteVolume/lnInclude/fvMatrix.C:330:1: note: no known conversion for argument 1 from ‘Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >’ to ‘const Foam::fvMatrix<double>&’
/home/kumaresh/OpenFOAM/OpenFOAM-2.1.1/src/finiteVolume/lnInclude/fvMatrix.C:273:1: note: Foam::fvMatrix<Type>::fvMatrix(const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>&, const Foam::dimensionSet&) [with Type = double]
/home/kumaresh/OpenFOAM/OpenFOAM-2.1.1/src/finiteVolume/lnInclude/fvMatrix.C:273:1: note: candidate expects 2 arguments, 1 provided
In file included from ergunFoam.C:54:0:
Kindly correct me if I'm wrong anywhere.
Thank you once again ^^

Last edited by Kummi; January 17, 2020 at 18:43.
Kummi is offline   Reply With Quote

Old   January 17, 2020, 19:36
Default
  #6
Senior Member
 
Kumaresh
Join Date: Oct 2016
Posts: 354
Rep Power: 12
Kummi is on a distinguished road
Send a message via Yahoo to Kummi
As stated in above error, when I looked into the fvMatrix.C file (see below), the constructors are based on fvm type

Quote:
template<class Type>
Foam::fvMatrix<Type>::fvMatrix(const fvMatrix<Type>& fvm)
:
refCount(),
lduMatrix(fvm),
psi_(fvm.psi_),
dimensions_(fvm.dimensions_),
source_(fvm.source_),
internalCoeffs_(fvm.internalCoeffs_),
boundaryCoeffs_(fvm.boundaryCoeffs_),
faceFluxCorrectionPtr_(NULL)
{
But my above velocity equations are solved based on fvc. fvc convert a field to another field, it does not make any matrix. There arises a question then how the appropriate fvMatrix will be created to solve velocity equations.

Kindly share some tips - which will be helpful to proceed further.
Thank you
Kummi is offline   Reply With Quote

Old   January 17, 2020, 19:39
Default
  #7
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 16
adhiraj is on a distinguished road
Now we are making a little progress, but a couple of issues still remain.

Quote:
Originally Posted by Kummi View Post
My biggest mistake was that, I didn't assign any name to solve velocity in matrix form, as how I assigned for pressure (p):
The name is not important; you did not name the matrix for p, but simply created and passed the fvMatrix object to the solve function.

You are constructing the fvScalarMatrix wrong:

Code:
fvScalarMatrix UxEqn
(
    (gradCurlUyx - gradCurlUxy) - (((Ux*gradUxy)-(Uy*gradUxx))/(0.4343*(f1+(f2*rho*Ux))))
);
Does this even look like a partial differential equation in any way? As I mentioned, you need to use some fvm operators. Otherwise the code does not even know what is the variable being solved for here.

Quote:
Originally Posted by Kummi View Post
Each matrices UxEqn and UyEqn solves both Ux and Uy.
No it does not. If you can successfully create the matrices, then UxEqn will solve for Ux, and UyEqn will solve for Uy.
Kummi likes this.
adhiraj is offline   Reply With Quote

Old   January 17, 2020, 22:14
Default
  #8
Senior Member
 
Kumaresh
Join Date: Oct 2016
Posts: 354
Rep Power: 12
Kummi is on a distinguished road
Send a message via Yahoo to Kummi
Dear Adhiraj,
Thank you. As you stated, to create the matrices, fvm operators are necessary. But in my case, the velocity equation contains only gradient terms.
I referred the following thread and got some ideas:
Gradient operator implicit discretization
Quote:
Considering an equation: s*grad(I) --> where I is a scalar and s a vector.
Here the scalar variable I is solved explicitly, in order to solve in implicit form -- some mathematical formulations are made.
Quote:
Gradient of the implicit function

div(s*I)= s*grad(I) + I*div(s)
s*grad(I)= div(s*I) - I*div(s)
MATRIX - FORM

fvScalarMatrix MyEqn
(
...
+ fvm::div(sf I) - fvm::Sp(fvc::div(s), I)
...
);
Should I want to use this kind of approach ?

However, even if I follow the above approach, if I need to solve the Ux and Uy components separately in 2 equations, I will be holding only the scalar variables (Ux, Uy) not vector variable. But, the above formula solved based on both scalar and vector variables. If you have some references, kindly do share.

Thank you
Kummi is offline   Reply With Quote

Old   January 18, 2020, 16:50
Default
  #9
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 16
adhiraj is on a distinguished road
Quote:
Originally Posted by Kummi View Post
But in my case, the velocity equation contains only gradient terms.
Wait a minute! Your velocity equations look like they have been derived using the curl operator, and not the gradient operator.

Using fvm::div(s) gives you the full gradient vector or matrix (depending on whether s is a scalar or a vector). Then you will have to extract the terms \frac{\partial s}{\partial x}, \frac{\partial s}{\partial y}, \frac{\partial s}{\partial z} and so on.

Please put some thought into how to best write your equations, and converting them into code. This step is often non-trivial.
Kummi likes this.
adhiraj is offline   Reply With Quote

Old   January 18, 2020, 20:47
Default
  #10
Senior Member
 
Kumaresh
Join Date: Oct 2016
Posts: 354
Rep Power: 12
Kummi is on a distinguished road
Send a message via Yahoo to Kummi
Dear Adhiraj,
Thank you. I have fully understood your above comments. Using fvm operator with divergence in hand, calculations are made firstly, and then followed by the extraction of necessary variables and finally converting into code.

I have a question. When we try to define divergence term implicitly using fvm, we adopt the format
∇ • (ρUU) =====> div(phi,U) and φ = ρU

But in my case, there is no necessity of phi. As you stated, "Using fvm::div(s) gives you the full gradient vector or matrix", then what may be the possibility to carry out the divergence of single term (s) using fvm operator ?

Quote:
  • // With divergence of single term (Ux or Uy), as expected in the below code THE SYNTAX IS COMPLETELY WRONG, SO IT WILL RESULT IN ERROR
  • If the below matrices are defined properly, as per your statement above and as per my understanding, the below matrices UxEqn and UyEqn calculates full gradient vectors along x, y and z directions, from which the necessary terms will be extracted.
{
fvScalarMatrix UxEqn
(
fvm::div(Ux)
+ fvm::div(GodX) // volScalarField GodX = f1+(f2*rho*mag(Ux));
);
UxEqn.solve();

fvScalarMatrix UyEqn
(
fvm::div(Uy)
+ fvm::div(GodY) // volScalarField GodY = f1+(f2*rho*mag(Uy));
);
UyEqn.solve();
}
And about this statement,
Quote:
Using fvm::div(s) gives you the full gradient vector or matrix (depending on whether s is a scalar or a vector).
Divergence of vector field is reasonable. If my understanding is right, divergence (or) curl of scalar field is just the bunch of numbers associated with each point in space - tells nothing about sense of direction, then how come you represented, "s is a scalar or a vector" ?. So, "s" should be only vector right ?
Kindly correct me if I'm wrong anywhere
Thank you

Last edited by Kummi; January 19, 2020 at 22:02.
Kummi is offline   Reply With Quote

Old   January 20, 2020, 14:36
Default
  #11
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 16
adhiraj is on a distinguished road
Quote:
Originally Posted by Kummi View Post
And about this statement
Quote:
Using fvm::div(s) gives you the full gradient vector or matrix (depending on whether s is a scalar or a vector).
You are right, I meant to write grad instead of div.

Quote:
Originally Posted by Kummi View Post
Using fvm operator with divergence in hand, calculations are made firstly, and then followed by the extraction of necessary variables and finally converting into code.
I'm not sure I understand what you want to do here.

I was trying to point out that your equations are not standard advection-diffusion equations.

For example, one of the equations look like this:

\left [ \frac{\partial v}{\partial {x}} - \frac{\partial u}{\partial {y}} \right ] - 
\left \{ u \left [ \frac{\partial}{\partial{y}}(ln(f_{1} + f_{2}\left | \rho u \right |) \right ] - v \left [ \frac{\partial}{\partial {x}}(ln(f_{1} + f_{2}\left | \rho u \right |) \right ]\right \} = 0,

where u and v are the x and y components of the velocity vector \mathbf{u}.

There are difficulties with this set of equations:
  • This is a coupled set of equations, because both u and v appear in the equations.
  • The equations do not appear to contain any terms that appear in a standard advection-diffusion equation. You don't have any divergence term like \nabla \cdot (\rho \mathbf{u} \mathbf{u}).

Thus you need to think carefully how to obtain \mathbf{u} from this set of equations. Maybe you should start with the vector form of the equation instead of the scalar forms?
adhiraj is offline   Reply With Quote

Old   January 21, 2020, 02:41
Question Convert the explicitly defined variables into implicit formulations
  #12
Senior Member
 
Kumaresh
Join Date: Oct 2016
Posts: 354
Rep Power: 12
Kummi is on a distinguished road
Send a message via Yahoo to Kummi
Dear Adhiraj,
Quote:
I'm not sure I understand what you want to do here.
I couldn't able to physically create the flowchart in my mind to resolve this particular case.
Quote:
Thus you need to think carefully how to obtain u from this set of equations. Maybe you should start with the vector form of the equation instead of the scalar forms?
To start with the vector form of equation:
\bigtriangledown \times \vee - \vee \times\bigtriangledown\left [ ln\left ( f_{1}+f_{2}\left | \rho U \right | \right ) \right ] = 0
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (Eq.1)
Quote:
volScalarField God = f1+(f2*rho*mag(U));
volVectorField gradU(fvc::grad(God));
(fvc::curl(U)) = ((U^gradU)/(0.4343*(God))); // explicitly defined
As mentioned in Programming Guide - Pg: 34, ==> Curl, gradient operators are explicitly defined.
But, in order to define the matrix form, the equations should implicitly defined with fvm operators as discussed above.

Quote:
fvVectorMatrix MyEqn
(
.......
);
MyEqn.solve();
}
Is there anyway to convert the explicitly defined variables into implicit formulations (to set the matrix form) without affecting the flow physics ?


problem with fvc:div
In the above link, there found a statement confessing that:

Quote:
If it is an explicit operator, then you cannot solve an equation with it. You really need an FVM:: method to create a matrix system.
More often than not, when a quantity is conserved, there is a way to generate a laplacian equation to enforce the conservation of this quantity. The member of this laplacian equation becomes a lagrangian multiplier to enforce conservation.
So, Im thinking to mathematically manipulate the explicit equation and fit it in implicit form..
Did I get it right until this point ?
Thank you

Last edited by Kummi; January 21, 2020 at 03:51.
Kummi is offline   Reply With Quote

Old   January 21, 2020, 10:02
Default
  #13
Senior Member
 
Kumaresh
Join Date: Oct 2016
Posts: 354
Rep Power: 12
Kummi is on a distinguished road
Send a message via Yahoo to Kummi
Dear Adhiraj,
Hereby in this post, gradient variables are defined explicitly inside fvMatrix.

How to add implicit terms to the momentum equation?
Quote:
-(U1 & fvc::grad(U1)) // U1 - volVectorField
And, gradient of vector field is taken, so it should result in tensor.
Could you please explain,as how the foamer defined the gradient variables inside fvMatrix ?

How to add implicit terms to the momentum equation?
The solve attached here by the same foamer, I tried compiling it, it has compiled well and good. I tried the same by defining gradient inside fvMatrix in my case, but it failed.

May I miss something ?
Kummi is offline   Reply With Quote

Old   January 23, 2020, 04:42
Question fvVectorMatrix structure !!
  #14
Senior Member
 
Kumaresh
Join Date: Oct 2016
Posts: 354
Rep Power: 12
Kummi is on a distinguished road
Send a message via Yahoo to Kummi
Dear Adhiraj,
I have came across a thread - implemented curl function in fvMatrix.
Does anyone work with curl in OpenFoam
With that in mind, I implemented the vector form of the equation in matrix form as:

\bigtriangledown \times \vee - \vee \times\bigtriangledown\left [  ln\left ( f_{1}+f_{2}\left | \rho U \right | \right ) \right ] = 0
Quote:
{
fvVectorMatrix UEqn
(
dummy*(fvm::ddt(U)) // (1) fvm::ddt(U) // ADDITIONAL implicit term - helps in compilation
+ (fvc::curl(U)) // (2)
- ((U^gradU)/(0.4343*(God))) // (3) volScalarField God = f1+(f2*rho*mag(U)); volVectorField gradU(fvc::grad(God));
);
UEqn.solve();
}
All (1) (2) (3) terms are with unit of (1/s).

- Without term (1) - dummy*(fvm::ddt(U)) implicit, the above matrix is not compiling in OpenFOAM. So is that mean, there should be atleast one implicit term in the matrix ?

- I feel, introducing term (1) in the above matrix doesn't affect the flow physics. Correct me if I'm wrong here.
- However, the solver is compiled good, there found no change in velocity during post-processing. I guess, its because the curl is defined explicitly.

Quote:
Curl only comes in the explicit version (fvc) because the implicit one couples the components of the vector. The current matrix support cannot handle that but the new version (block matrix) will come in due course). So, there's no fvm::curl at the moment.
I'm hereby attaching the case and code files. Kindly check it and share your thoughts.
Thank you
Attached Files
File Type: gz ErgunFoamm.tar.gz (6.2 KB, 2 views)
Kummi is offline   Reply With Quote

Old   January 23, 2020, 08:31
Default
  #15
Senior Member
 
Kumaresh
Join Date: Oct 2016
Posts: 354
Rep Power: 12
Kummi is on a distinguished road
Send a message via Yahoo to Kummi
Block matrices vs segregated solvers
Block matrix implementation for implicit curl operators. Its in Foam-Extend versions based on fully implicit method (FIM).
Guess it should work. Looking ahead !!!
Kummi is offline   Reply With Quote

Old   January 26, 2020, 05:38
Question Unable to define the operators - Implicitly
  #16
Senior Member
 
Kumaresh
Join Date: Oct 2016
Posts: 354
Rep Power: 12
Kummi is on a distinguished road
Send a message via Yahoo to Kummi
As like OpenFOAM, "curl" operator has been expressed only explicitly in foam-extend too.

However, implicit "grad" operator is handled in foam-extend. But, I'm not sure how far it is accessible. Because, fvm::grad is intended for particular purpose.
Quote:
Intended use: block coupled solvers. i.e. implicit grad(p) in momentum equation
https://github.com/Unofficial-Extend...niteVolume/fvm

With implicit "grad" operator in hand, I should split my curl into gradient operators. Then, instead of calculating vector variable like "U" as a whole, I should calculate my scalar [Ux, Uy] variables "fvm::grad(Ux)".
Quote:
\bigtriangledown \times \vee - \vee \times\bigtriangledown\left [  ln\left ( f_{1}+f_{2}\left | \rho U \right | \right ) \right ] = 0
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (Eq.1)


\left [ \frac{\delta v_{y}}{\delta {x}}-\frac{\delta v_{x}}{\delta {y}} \right ] -
\left \{ v_{x} \left [ \frac{\delta}{\delta {y}}(ln(f_{1}+f_{2}\left |  \rho v_{x} \right |) \right ] -v_{y} \left [ \frac{\delta}{\delta  {x}}(ln(f_{1}+f_{2}\left | \rho v_{x} \right |) \right ]\right \}=0 \ \ \  \ (Eq.1a)

\left [ \frac{\delta v_{y}}{\delta {x}}-\frac{\delta v_{x}}{\delta {y}} \right ] -
\left \{ v_{x} \left [ \frac{\delta}{\delta {y}}(ln(f_{1}+f_{2}\left |   \rho v_{y} \right |) \right ] -v_{y} \left [ \frac{\delta}{\delta   {x}}(ln(f_{1}+f_{2}\left | \rho v_{y} \right |) \right ]\right \}=0 \ \ \  \ (Eq.1b)
With this above equation in mind, if I set explicitly, then there is no compilation error - but there is no change in velocity during post-processing as expected.
Quote:
volVectorField gradCurlUx(fvc::grad(Ux)); // Explicit
volVectorField gradCurlUy(fvc::grad(Uy)); // Explicit
// If I try to set as implicit - fvm::grad(Ux) - it fails in compilation.

Yes, the gradient operator here can't be defined implicitly. Because physically, it calculates variables from the known value and so, explicit calculations of fvc returns geomertricField<Type>.
Quote:
In my case,
(1) velocity need to be calculated first (based on above equations)

(2) followed by the calculation of pressure.
So, if I want to get the solution for velocity, which is unknown for the problem, I need to handle the equation in implicit way. As stated in Programming Guide, fvm calculate implicit derivatives and return an fvMatrix <Type> - discretisation of a geometric <Type> Field.

I guess, the only way to define my above equation is to set the operators (grad or curl) implicitly. Stuck here !!

Difficulties:
  • No room to define the gradient operator implicitly (even in foam-extend).
  • And curl operator, by default, is expressed as explicitly only.
If someone have any thoughts or ideas in this work, kindly share it.
Thank you

Last edited by Kummi; January 26, 2020 at 06:48.
Kummi is offline   Reply With Quote

Old   March 3, 2020, 02:06
Question Defined an ADDITIONAL implicit term - helps in compilation
  #17
Senior Member
 
Kumaresh
Join Date: Oct 2016
Posts: 354
Rep Power: 12
Kummi is on a distinguished road
Send a message via Yahoo to Kummi
As explained above, in order to define the equation in matrix form, the implicit term (fvm) is highly necessary. In my equation, I have only curl operator, which is only explicitly (fvc) defined in standard openfoam versions. So, I intentionally come up with the transient term defined with fvm operator (fvm::ddt(dummy)), where the dummy constant vector variable is defined with 0 value.
Quote:
{
fvVectorMatrix UEqn
(
//dummy*(fvm::ddt(U))
fvm::ddt(dummy) // ADDITIONAL implicit term - helps in compilation
+ (fvc::curl(U))
- ((U^gradU)/(0.4343*(God)))
);
UEqn.solve();
}
- Without the ADDITIONAL implicit term - the above matrix structure wont be compiled in OpenFOAM.
- Now however, the solver is compiled good, there found no change in velocity during post-processing [ATTACHMENTS].
In above equation, the explicit calculations of fvc should return a field value. Still no change in velocity.
I'm hereby attaching the case and code files. Kindly someone check it and share the thoughts.
Thank you
Attached Images
File Type: png Pressure.png (21.0 KB, 7 views)
File Type: png velociy.png (10.4 KB, 7 views)
Attached Files
File Type: gz ERGUN.tar.gz (151.9 KB, 2 views)
Kummi is offline   Reply With Quote

Old   March 4, 2020, 15:33
Default
  #18
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 16
adhiraj is on a distinguished road
Quote:
Originally Posted by Kummi View Post
So, I intentionally come up with the transient term defined with fvm operator (fvm::ddt(dummy)), where the dummy constant vector variable is defined with 0 value.
You are not thinking clearly here.

You are creating the fvVectorMatrix in a way that makes dummy as the unknown, and then expecting to obtain U from the system. It does not work that way.

When you create the fvVectorMatrix, you are trying to create the matrix of the linear system

Ax = b.

Any term created using the fvm operators will go into the matrix A, and everything else will go into b. Your term
Code:
fvm::ddt(dummy)
ends up in the matrix A, and all velocity terms go into b.

The velocity will not be updated because the code as written in the post will not solve for velocity.
adhiraj is offline   Reply With Quote

Old   March 5, 2020, 15:39
Default
  #19
Senior Member
 
Kumaresh
Join Date: Oct 2016
Posts: 354
Rep Power: 12
Kummi is on a distinguished road
Send a message via Yahoo to Kummi
Thank you for your reply.

Got your points.

As I explained above,
Quote:
in order to define the equation in matrix form, atleast one implicit term (fvm) is highly necessary. But in my equation, I have only curl operator, which is only explicitly (fvc) defined in standard openfoam versions. So, I intentionally come up with the transient term defined with fvm operator (fvm::ddt(dummy)), in order to just compile the below Ueqn.
Quote:
{
fvVectorMatrix UEqn
(
fvm::ddt(dummy) // UNIT -1/s
+ (fvc::curl(U)) // UNIT -1/s
- ((U^gradU)/(0.4343*(God))) // UNIT -1/s
);
UEqn.solve();
}
If I define, fvm::ddt(U) - unit will be m/s2, where other terms are with unit of 1/s. Units mismatch will happen.

In my equation, I have only curl operator, which is only explicitly (fvc) defined. So all the velocity terms will go into b [Ax=b]. Velocity is not updated in matrix A.

My question is: In order to get the velocity updated, the matrix term is necessary to be updated ?
If so, in my work, there is no fvm operator to update the matrix for velocity variable. Any ideas as how to proceed from here..
Thank you
Kummi is offline   Reply With Quote

Old   March 6, 2020, 12:05
Default
  #20
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 16
adhiraj is on a distinguished road
There seem to be no implicit operators that can produce the velocity-equation matrix for your case, which is making the job hard.

Here is a thought: instead of solving an equation for \mathbf{u}, simply calculate the other quantities such as p^{2}, \nabla \times \mathbf{u}, and then directly update the velocity instead of solving an equation for \mathbf{u}.

Keep in mind that this approach probably needs a carefully drafted formulation.
I am not familiar with this problem, so I cannot help with the formulation, and I don't know what potential issues may crop up in doing so. Perhaps you can find some insight in the literature?
adhiraj is offline   Reply With Quote

Reply


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



All times are GMT -4. The time now is 03:58.