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

scalarCodedSource - source term - field/s

Register Blogs Community New Posts Updated Threads Search

Like Tree13Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 7, 2021, 14:35
Default
  #21
Member
 
Andrea Di Ronco
Join Date: Nov 2016
Location: Milano, Italy
Posts: 57
Rep Power: 9
Diro7 is on a distinguished road
The momentum equation in UEqn.H calls the function
Code:
turbulence->divDevReff(U)
which should return something like the divergence of the deviatoric part of the effective stress tensor (if I'm not wrong).

I never did it myself, but I'm pretty sure that if you look at the corresponding source code, you'll find it calls nu at some point.

Andrea
mmohaqeqf likes this.
Diro7 is offline   Reply With Quote

Old   March 7, 2021, 20:39
Default
  #22
Member
 
Mohammad M F
Join Date: Jan 2016
Location: Washington DC, USA
Posts: 43
Rep Power: 10
mmohaqeqf is on a distinguished road
Ok, below is my scalar transport equation with my desired source term added to my modified version of the simpleFoam:
Code:
while (simple.correctNonOrthogonal())
        {
            fvScalarMatrix DEqn
            (
                fvm::ddt(D)
              + fvm::div(phi, D)
              - fvm::laplacian(DT, D)
             ==
                sqrt((turbulence -> nu())/6)
                *sqrt(
                        pow((2*fvc::grad(U).ref().component(tensor::XX))-(2*fvc::grad(U).ref().component(tensor::YY)),2)
                      + pow((2*fvc::grad(U).ref().component(tensor::YY))-(2*fvc::grad(U).ref().component(tensor::ZZ)),2)
                      + pow((2*fvc::grad(U).ref().component(tensor::ZZ))-(2*fvc::grad(U).ref().component(tensor::XX)),2)
                      + 6*pow((fvc::grad(U).ref().component(tensor::XY) + fvc::grad(U).ref().component(tensor::YX)),2)
                      + 6*pow((fvc::grad(U).ref().component(tensor::XZ) + fvc::grad(U).ref().component(tensor::ZX)),2)
                      + 6*pow((fvc::grad(U).ref().component(tensor::YZ) + fvc::grad(U).ref().component(tensor::ZY)),2)
                     )
                + fvOptions(D)
            );
It compiles without error.
But when I apply it to a simple pipe flow (straight converging pipe), it spits out following error:
Code:
--> FOAM FATAL ERROR:

    [D[0 0 -1 1 0 0 0] ] + [(sqrt((nu|6))*sqrt((((((pow(((2*grad(U).component(0))-(2*grad(U).component(4))),2)+pow(((2*grad(U).component(4))-(2*grad(U).component(8))),2))+pow(((2*grad(U).component(8))-(2*grad(U).component(0))),2))+(6*pow((grad(U).component(1)+grad(U).component(3)),2)))+(6*pow((grad(U).component(2)+grad(U).component(6)),2)))+(6*pow((grad(U).component(5)+grad(U).component(7)),2)))))[0 1 -1.5 0 0 0 0] ]

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

FOAM aborting

#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::error::exitOrAbort(int, bool) at ??:?
#2  void Foam::checkMethod<double>(Foam::fvMatrix<double> const&, Foam::DimensionedField<double, Foam::volMesh> const&, char const*) at ??:?
#3  ? at ??:?
#4  ? at ??:?
#5  __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6
#6  ? at ??:?
Aborted (core dumped)
Do you have any idea what might have gone wrong?
mmohaqeqf is offline   Reply With Quote

Old   March 7, 2021, 20:45
Default
  #23
Senior Member
 
Alejandro
Join Date: Jan 2014
Location: Argentina
Posts: 128
Rep Power: 12
ancolli is on a distinguished road
Quote:
Originally Posted by mmohaqeqf View Post
Ok, below is my scalar transport equation with my desired source term added to my modified version of the simpleFoam:
Code:
while (simple.correctNonOrthogonal())
        {
            fvScalarMatrix DEqn
            (
                fvm::ddt(D)
              + fvm::div(phi, D)
              - fvm::laplacian(DT, D)
             ==
                sqrt((turbulence -> nu())/6)
                *sqrt(
                        pow((2*fvc::grad(U).ref().component(tensor::XX))-(2*fvc::grad(U).ref().component(tensor::YY)),2)
                      + pow((2*fvc::grad(U).ref().component(tensor::YY))-(2*fvc::grad(U).ref().component(tensor::ZZ)),2)
                      + pow((2*fvc::grad(U).ref().component(tensor::ZZ))-(2*fvc::grad(U).ref().component(tensor::XX)),2)
                      + 6*pow((fvc::grad(U).ref().component(tensor::XY) + fvc::grad(U).ref().component(tensor::YX)),2)
                      + 6*pow((fvc::grad(U).ref().component(tensor::XZ) + fvc::grad(U).ref().component(tensor::ZX)),2)
                      + 6*pow((fvc::grad(U).ref().component(tensor::YZ) + fvc::grad(U).ref().component(tensor::ZY)),2)
                     )
                + fvOptions(D)
            );
It compiles without error.
But when I apply it to a simple pipe flow (straight converging pipe), it spits out following error:
Code:
--> FOAM FATAL ERROR:

    [D[0 0 -1 1 0 0 0] ] + [(sqrt((nu|6))*sqrt((((((pow(((2*grad(U).component(0))-(2*grad(U).component(4))),2)+pow(((2*grad(U).component(4))-(2*grad(U).component(8))),2))+pow(((2*grad(U).component(8))-(2*grad(U).component(0))),2))+(6*pow((grad(U).component(1)+grad(U).component(3)),2)))+(6*pow((grad(U).component(2)+grad(U).component(6)),2)))+(6*pow((grad(U).component(5)+grad(U).component(7)),2)))))[0 1 -1.5 0 0 0 0] ]

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

FOAM aborting

#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::error::exitOrAbort(int, bool) at ??:?
#2  void Foam::checkMethod<double>(Foam::fvMatrix<double> const&, Foam::DimensionedField<double, Foam::volMesh> const&, char const*) at ??:?
#3  ? at ??:?
#4  ? at ??:?
#5  __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6
#6  ? at ??:?
Aborted (core dumped)
Do you have any idea what might have gone wrong?
It is complaining about dimensional units, you must ensure the same dimensional units for each term you add. your left hand side has dimensional units of Kelvin per second and ur new term meters per second^1.5. Section 4.2.6 https://cfd.direct/openfoam/user-gui...c-file-format/
mmohaqeqf likes this.
ancolli is offline   Reply With Quote

Old   March 7, 2021, 21:27
Default
  #24
Member
 
Mohammad M F
Join Date: Jan 2016
Location: Washington DC, USA
Posts: 43
Rep Power: 10
mmohaqeqf is on a distinguished road
Ok, thanks;


It seems like I am not gonna give up asking questions :-)


Based on what you said, assuming that D in my case is unitless, I cannot use a scalar as a source term in my right hand side, because a scalar is unitless, while the left hand side would have a unit of 1/time, right?
Meaning that I should first define a dimensioned scalar with the unit of 1/time and then use it in the right hand side as a source term, right?
mmohaqeqf is offline   Reply With Quote

Old   March 8, 2021, 18:10
Default
  #25
Member
 
Mohammad M F
Join Date: Jan 2016
Location: Washington DC, USA
Posts: 43
Rep Power: 10
mmohaqeqf is on a distinguished road
I wanted to thank you both, Alejandro and Andrea for your help guys;


My new solver with a scalar transport equation is compiling fine and my sample pipe flow simulation runs successfully.
Diro7 likes this.
mmohaqeqf is offline   Reply With Quote

Old   March 9, 2021, 11:00
Default
  #26
Member
 
Mohammad M F
Join Date: Jan 2016
Location: Washington DC, USA
Posts: 43
Rep Power: 10
mmohaqeqf is on a distinguished road
Hi Alejandro (ancolli);


I have a question about the dimensions in OpenFOAM, related to my new solver discussed here;


Say I have a scalar transport equation (transported scalar is D) with zero diffusion (so pure convection), that has a source term which has the form:


Source = C * (mag(U))^0.185


Note that this source term has been obtained experimentally and thus the C and 0.185 are empirical constants.


What I would do is to set the dimension of D as (assuming C is unitless):


[0 0.185 1.185 0 0 0 0]


to make sure both RHS and LHS of the transport eqn are of the same dimension. (Note that the LHS would have the dimension of D divided by time)
The solver compiles fine and I can successfully run it on a sample pipe flow.
The problem starts when I want to load it up in paraview. Paraview doesn't like this dimension in D file (i.e. [0 0.185 1.185 0 0 0 0]).


How can I work around it?
mmohaqeqf is offline   Reply With Quote

Old   March 21, 2021, 18:40
Default
  #27
Senior Member
 
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 21
jherb is on a distinguished road
If you write your own code for the source term, you could e.g. use the value() method to get dimensionless cell values. Or you access the fields e. g. as volScalarField which neither does have dimension.


Or you change your equation to Source = C * (mag(U)/C2)^0.185 with C2 being a uniformDimensionedScalarField. See https://github.com/OpenFOAM/OpenFOAM...sionedFields.H
mmohaqeqf likes this.
jherb is offline   Reply With Quote

Old   March 21, 2021, 18:59
Default
  #28
Senior Member
 
Alejandro
Join Date: Jan 2014
Location: Argentina
Posts: 128
Rep Power: 12
ancolli is on a distinguished road
Quote:
Originally Posted by mmohaqeqf View Post
Hi Alejandro (ancolli);


I have a question about the dimensions in OpenFOAM, related to my new solver discussed here;


Say I have a scalar transport equation (transported scalar is D) with zero diffusion (so pure convection), that has a source term which has the form:


Source = C * (mag(U))^0.185


Note that this source term has been obtained experimentally and thus the C and 0.185 are empirical constants.


What I would do is to set the dimension of D as (assuming C is unitless):


[0 0.185 1.185 0 0 0 0]


to make sure both RHS and LHS of the transport eqn are of the same dimension. (Note that the LHS would have the dimension of D divided by time)
The solver compiles fine and I can successfully run it on a sample pipe flow.
The problem starts when I want to load it up in paraview. Paraview doesn't like this dimension in D file (i.e. [0 0.185 1.185 0 0 0 0]).


How can I work around it?
Sorry, i just saw ur post ( i did not receive a notification....)
U can not assume that C is unitless... u should give dimensions to C. Then paraview will not complain, and like this ur problem is well posed

const dimensionedScalar C("C",dimensionSet(kg,m,s,K,mol,A,cd), 1000);//[kg m s K mol A cd] C = 1000
mmohaqeqf likes this.
ancolli is offline   Reply With Quote

Old   February 4, 2022, 15:08
Default
  #29
New Member
 
Join Date: Dec 2016
Posts: 5
Rep Power: 9
Iain_symthe is on a distinguished road
I have case where I want to specify a volumetric heat source (W/m3) as a function of space say heSource[i] = 1.0*x[i]*V[i]; I am trying to see if there is a way to integrate the volumetric heat source over volume so that I know what the total power is in Watts.
Iain_symthe is offline   Reply With Quote

Old   October 14, 2022, 10:48
Default
  #30
New Member
 
Ujjwal
Join Date: Sep 2022
Posts: 1
Rep Power: 0
EpicMega is on a distinguished road
Hey can,anybody help me to have source term as a function of space in laplacian foam
EpicMega 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
[Other] Tabulated thermophysicalProperties library chriss85 OpenFOAM Community Contributions 62 October 2, 2022 03:50
Source Term due to evaporation in energy transport equation styleworker OpenFOAM Programming & Development 3 September 7, 2022 03:09
polynomial BC srv537 OpenFOAM Pre-Processing 4 December 3, 2016 09:07
"parabolicVelocity" in OpenFoam 2.1.0 ? sawyer86 OpenFOAM Running, Solving & CFD 21 February 7, 2012 11:44
DxFoam reader update hjasak OpenFOAM Post-Processing 69 April 24, 2008 01:24


All times are GMT -4. The time now is 21:13.