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

How would you code this simple term into OpenFOAM?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 7, 2014, 14:17
Default How would you code this simple term into OpenFOAM?
  #1
Member
 
CHARLES
Join Date: May 2013
Posts: 46
Rep Power: 13
CHARLES is on a distinguished road
Hello,

I would like to add the following term to the dissipation equation:
partial/partial(x_k) * [nu*delta_jk * partial(epsilon)/partial(x_j)]

(I couldn't figure out how to nicely display an equation on here so I've attached it as an image)

From my understanding, this term should only be added when the indices j and k are equal (i.e.: each individual term in the diagonal of partial^2(epsilon)/partial(x_j,x_k) NOT THE TRACE).

Although this is very simple mathematically, I'm having a hard time translating it into compile-able code.

My approach was to take the gradient of epsilon twice, which would give me a tensor of rank=2, and then to do element-by-element multiplication (still haven't figured out how to do this either) with nuEff*I.

I can't figure out how to multiply nuEff by I without getting errors, or how to do the element-by-element multiplication. Could someone please give me a hand? My programming skills aren't the best so I have been basing my modifications on the existing code >_<

Below are my definitions and where I want to add the line of code (I've tried changing the field type on nuI and it hasn't helped)

Perhaps there is a better, more efficient, approach so I am open to suggestions.

Thank you!


Code:
    
              volVectorField gradEps(fvc::grad(epsilon_));
              volTensorField gradsqEps(fvc::grad(gradEps)); 
              volTensorField nuI(nuEff()*I); 

...
         fvm::ddt(epsilon_) 
      + fvm::div(phi_, epsilon_) 
      - fvm::laplacian(DissDest(), epsilon_) //Don't worry about this line
     //ADD NEW LINE HERE
     ==
...
The error:
Code:
sebastian@navier1:~/OpenFOAM/sebastian-2.2.0/src/turbulenceModels/incompressible/RAS/SPLRRIP$ wmake libso
wmakeLnInclude: linking include files to ./lnInclude
Making dependency list for source file SPLRRIP.C
SOURCE=SPLRRIP.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/opt/openfoam220/src/turbulenceModels -I/opt/openfoam220/src/transportModels -I/opt/openfoam220/src/finiteVolume/lnInclude -I/opt/openfoam220/src/meshTools/lnInclude -I/opt/openfoam220/src/turbulenceModels/incompressible/RAS/lnInclude -IlnInclude -I. -I/opt/openfoam220/src/OpenFOAM/lnInclude -I/opt/openfoam220/src/OSspecific/POSIX/lnInclude   -fPIC -c $SOURCE -o Make/linux64GccDPOpt/SPLRRIP.o
SPLRRIP.C: In member function ‘virtual void Foam::incompressible::RASModels::SPLRRIP::correct()’:
SPLRRIP.C:403:30: error: no matching function for call to ‘Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh>::GeometricField(Foam::tmp<Foam::GeometricField<Foam::SphericalTensor<double>, Foam::fvPatchField, Foam::volMesh> >)’
SPLRRIP.C:403:30: note: candidates are:
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:605:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Foam::GeometricField<Type, PatchField, GeoMesh>&, const wordList&, const wordList&) [with Type = Foam::Tensor<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::wordList = Foam::List<Foam::word>]
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:605:1: note:   candidate expects 4 arguments, 1 provided
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:570:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Foam::GeometricField<Type, PatchField, GeoMesh>&, const Foam::word&) [with Type = Foam::Tensor<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:570:1: note:   candidate expects 3 arguments, 1 provided
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:540:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::word&, const Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >&) [with Type = Foam::Tensor<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:540:1: note:   candidate expects 2 arguments, 1 provided
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:507:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::word&, const Foam::GeometricField<Type, PatchField, GeoMesh>&) [with Type = Foam::Tensor<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:507:1: note:   candidate expects 2 arguments, 1 provided
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:475:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Foam::GeometricField<Type, PatchField, GeoMesh>&) [with Type = Foam::Tensor<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:475:1: note:   candidate expects 2 arguments, 1 provided
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:444:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >&) [with Type = Foam::Tensor<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:444:1: note:   no known conversion for argument 1 from ‘Foam::tmp<Foam::GeometricField<Foam::SphericalTensor<double>, Foam::fvPatchField, Foam::volMesh> >’ to ‘const Foam::tmp<Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh> >&’
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:412:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::GeometricField<Type, PatchField, GeoMesh>&) [with Type = Foam::Tensor<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:412:1: note:   no known conversion for argument 1 from ‘Foam::tmp<Foam::GeometricField<Foam::SphericalTensor<double>, Foam::fvPatchField, Foam::volMesh> >’ to ‘const Foam::GeometricField<Foam::Tensor<double>, Foam::fvPatchField, Foam::volMesh>&’
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:371:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dictionary&) [with Type = Foam::Tensor<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh]
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:371:1: note:   candidate expects 3 arguments, 1 provided
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:331:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&) [with Type = Foam::Tensor<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh]
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:331:1: note:   candidate expects 2 arguments, 1 provided
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:304:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dimensionSet&, const Foam::Field<TypeR>&, const Foam::PtrList<PatchField<Type> >&) [with Type = Foam::Tensor<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh]
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:304:1: note:   candidate expects 5 arguments, 1 provided
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:274:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dimensioned<Form>&, const wordList&, const wordList&) [with Type = Foam::Tensor<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh, Foam::wordList = Foam::List<Foam::word>]
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:274:1: note:   candidate expects 5 arguments, 1 provided
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:245:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dimensioned<Form>&, const Foam::word&) [with Type = Foam::Tensor<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh]
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:245:1: note:   candidate expects 4 arguments, 1 provided
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:217:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dimensionSet&, const wordList&, const wordList&) [with Type = Foam::Tensor<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh, Foam::wordList = Foam::List<Foam::word>]
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:217:1: note:   candidate expects 5 arguments, 1 provided
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:187:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dimensionSet&, const Foam::word&) [with Type = Foam::Tensor<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh]
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:187:1: note:   candidate expects 4 arguments, 1 provided
make: *** [Make/linux64GccDPOpt/SPLRRIP.o] Error 1
Attached Images
File Type: png Screen shot 2014-03-07 at 10.42.02 AM.png (8.0 KB, 9 views)
CHARLES is offline   Reply With Quote

Old   April 23, 2014, 22:32
Default
  #2
Member
 
CHARLES
Join Date: May 2013
Posts: 46
Rep Power: 13
CHARLES is on a distinguished road
This was very simple...

fvm::laplacian(nu(), epsilon_)
CHARLES is offline   Reply With Quote

Reply

Tags
kronecker delta


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
Include OpenFoam code Latex emirust OpenFOAM Post-Processing 5 November 28, 2012 03:56
adding a C code to OpenFOAM latvietis OpenFOAM Programming & Development 1 November 21, 2012 04:46
How to code integral of (DU/Dt - 2000 ) in openFoam erncyc OpenFOAM 5 September 13, 2012 07:33
Specific OpenFOAM Code pbhuter OpenFOAM 13 June 30, 2012 20:06
New OpenFOAM Forum Structure jola OpenFOAM 2 October 19, 2011 07:55


All times are GMT -4. The time now is 07:41.