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

Add vector field in momentum conservation equation

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By jherb
  • 1 Post By jherb

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 3, 2022, 09:33
Default Add vector field in momentum conservation equation
  #1
Member
 
Nikos
Join Date: Aug 2012
Location: Greece
Posts: 30
Rep Power: 14
nikoscham is on a distinguished road
Hi community!

I would like to add a vector field (with constant value) in the momentum conservation equation.

I have the following equation form in the solver:

Code:
   fvVectorMatrix UEqn
    (
        fvm::ddt(U) + fvm::div(phi, U)
      + fvm::Sp(C*pow(1-lf, 2)/(rhoRef*(pow(lf, 3)+q)), U)
      + MRF.DDt(U)
      + turbulence->divDevReff(U)
     ==
        fvOptions(U)
     );
which is part of the meltingFoam solver (see here melting problem: looking for appropriate solvers). This solver is described in the paper https://www.researchgate.net/publica...th_experiments

I would like to subtract a constant vector field (Up) from the velocity vector U.

I changed the code as follows:

Code:
   fvVectorMatrix UEqn
    (
        fvm::ddt(U) + fvm::div(phi, U)
      + fvm::Sp(C*pow(1-lf, 2)/(rhoRef*(pow(lf, 3)+q)), U - Up) //modified
      + MRF.DDt(U)
      + turbulence->divDevReff(U)
     ==
        fvOptions(U)
     );
Moreover I added the following in the createFields.H


Code:
Info<< "Reading field Up\n" << endl;
volVectorField Up
(
    IOobject
    (
        "Up",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ,
        IOobject::NO_WRITE
    ),
    mesh
 );
By compiling the solver, however I get errors. Part of the error log is the following:

Code:
/opt/OpenFOAM/OpenFOAM-v2012/src/finiteVolume/lnInclude/fvmSup.C:142:1: note:   template argument deduction/substitution failed:
In file included from meltingPullFoam.C:97:0:
UEqn.H:12:63: note:   ‘Foam::tmp<Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> >’ is not derived from ‘const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>’
       + fvm::Sp(C*pow(1-lf, 2)/(rhoRef*(pow(lf, 3)+q)), U - Up) //added
                                                               ^
In file included from /opt/OpenFOAM/OpenFOAM-v2012/src/finiteVolume/lnInclude/fvmSup.H:165:0,
                 from /opt/OpenFOAM/OpenFOAM-v2012/src/finiteVolume/lnInclude/fvm.H:49,
                 from /opt/OpenFOAM/OpenFOAM-v2012/src/finiteVolume/lnInclude/fvCFD.H:10,
                 from meltingPullFoam.C:48:
/opt/OpenFOAM/OpenFOAM-v2012/src/finiteVolume/lnInclude/fvmSup.C:156:1: note: candidate: template<class Type> Foam::tmp<Foam::fvMatrix<Type> > Foam::fvm::Sp(const dimensionedScalar&, const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>&)
  Foam::fvm::Sp
It seems that the operation (U-Up) is not accepted. . .

Do you have any proposals or tips?

Thank you in advance!


Nikos
nikoscham is offline   Reply With Quote

Old   August 28, 2022, 12:40
Default
  #2
Senior Member
 
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 22
jherb is on a distinguished road
The method fvm::Sp() is used to add a source term implicitly to an equation to be solved, meaning as matrix components on the "left" side of the equation. So its argument must be the field to be solved (U in your case). But now, you also try to add the Up field to the matrix, which is not solved for. So you have to put on the "right" side of the equation explicitly. So I guess, you have to split this fmv::Sp() term into two, one for with fvm::Sp(..., U) and one without fvm:Sp() and just Up.
nikoscham likes this.
jherb is offline   Reply With Quote

Old   November 24, 2022, 05:07
Default
  #3
Member
 
Nikos
Join Date: Aug 2012
Location: Greece
Posts: 30
Rep Power: 14
nikoscham is on a distinguished road
Thank you Joachim for your reply. I have split the two terms as you proposed. For the second term (with the constant Up vector) I have tried to use fvm::Sp(..., Up) but I get:

Code:
--> FOAM FATAL ERROR: (openfoam-2012)
incompatible fields for operation
    [U] - [Up]

   From void Foam::checkMethod(const Foam::fvMatrix<Type>&, const Foam::fvMatrix<Type>&, const char*) [with Type = Foam::Vector<double>]
    in file /opt/OpenFOAM/OpenFOAM-v2012/src/finiteVolume/lnInclude/fvMatrix.C at line 1319.

 FOAM aborting
What I have finally done is to use
Code:
fvc::Sp(..., Up)
in order to add this term on the "right" side of the equation explicitly. It works now, however, don't know if the results are correct. I have to compare them with another software I suppose. What do you think?
nikoscham is offline   Reply With Quote

Old   December 4, 2022, 20:35
Default
  #4
Senior Member
 
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 22
jherb is on a distinguished road
You are right, you need to use the explicit operator fvc::Sp() for Up, because it is obviously not the solution variable, so you cannot use the implicit fvm::Sp().
nikoscham likes this.
jherb 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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to add a body force to a momentum equation anon_q OpenFOAM Programming & Development 25 May 11, 2021 16:39
add a pressure drop term in the momentum equation a.lone FLUENT 0 July 3, 2019 07:48
Domain Reference Pressure and mass flow inlet boundary AdidaKK CFX 75 August 20, 2018 06:37
Question on the discretization of momentum equation in icoFoam MPJ OpenFOAM 3 October 4, 2011 10:44
Constant velocity of the material Sas CFX 15 July 13, 2010 09:56


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