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

How to code integral of (DU/Dt - 2000 ) in openFoam

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By nimasam

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 10, 2012, 08:05
Default How to code integral of (DU/Dt - 2000 ) in openFoam
  #1
New Member
 
ernest
Join Date: Jun 2010
Posts: 21
Rep Power: 14
erncyc is an unknown quantity at this point
Dear Foamers,

I am trying to code the expression DU/Dt - 2000, in openFoam. DU/Dt is a volVectorField. I have tried the code below but I get the error posted. Any help will be appreciated. Thanks.


DDtU =
(fvc::ddt(U)
+ fvc::div(phi, U)
- fvc::div(phi)*U) - 2000;


Compilation error:

error: no match for ‘operator-’ in ‘Foam:perator-(const Foam::tmp<Foam::GeometricField<TypeR, PatchField, GeoMesh> >&, const Foam::tmp<Foam::GeometricField<Type1, PatchField, GeoMesh> >&) [with Type1 = Foam::Vector<double>, Type2 = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh](((const Foam::tmp<Foam::GeometricField<Foam::Vector<double >, Foam::fvPatchField, Foam::volMesh> >&)((const Foam::tmp<Foam::GeometricField<Foam::Vector<double >, Foam::fvPatchField, Foam::volMesh> >*)(& Foam:perator*(const Foam::tmp<Foam::GeometricField<double, PatchField, GeoMesh> >&, const Foam::GeometricField<Type, PatchField, GeoMesh>&) [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh](((const Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>&)((const Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>*)(& U)))))))) - 2000’
/opt/openfoam201/src/OpenFOAM/lnInclude/septernionI.H:190: note: candidates are: Foam::septernion Foam:perator-(const Foam::septernion&, const Foam::vector&)
/opt/openfoam201/src/OpenFOAM/lnInclude/quaternionI.H:279: note: Foam::quaternion Foam:perator-(const Foam::quaternion&, const Foam::quaternion&)
/opt/openfoam201/src/OpenFOAM/lnInclude/quaternionI.H:273: note: Foam::quaternion Foam:perator-(const Foam::quaternion&)
erncyc is offline   Reply With Quote

Old   September 10, 2012, 09:21
Default
  #2
Senior Member
 
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,266
Blog Entries: 1
Rep Power: 24
nimasam is on a distinguished road
answer these simple questions:
1) do you know different type (scalar and vector)?
2)do you know OpenFOAM analysis dimensions?
3) do you read programmer guide which show how to implement a source to your solver?
Cyp likes this.
nimasam is offline   Reply With Quote

Old   September 10, 2012, 10:02
Default
  #3
New Member
 
ernest
Join Date: Jun 2010
Posts: 21
Rep Power: 14
erncyc is an unknown quantity at this point
The answer is yes to all 3 questions............I have initialised DDtU as a volVectorField (which as you know has field values and boundary values). I guess what I am asking is how to convert the scalar (2000) into a volVectorField (or vice versa) if at all possible...i know it is a simple question...but can't just get my head around it ...pardon me.
erncyc is offline   Reply With Quote

Old   September 10, 2012, 15:13
Default
  #4
Senior Member
 
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,266
Blog Entries: 1
Rep Power: 24
nimasam is on a distinguished road
dimensionedVector ("S",dimensionSet(0,1,-2,0,0,0,0),vector(2000,2000,2000));
nimasam is offline   Reply With Quote

Old   September 13, 2012, 06:26
Default Segmentation fault - multiphase- vof - interFoam
  #5
New Member
 
ernest
Join Date: Jun 2010
Posts: 21
Rep Power: 14
erncyc is an unknown quantity at this point
Hello Nima,

I hope you are fine. Thank you for the reply which was helpful. I have tried to advance my code and so far it is compiling (although I am a bit suspicious about it), but when I try to run it (OF 2.0.1) I get a segmentation fault as shown below: Basically I am trying to do the algorithm below (in a 2D rectangular domain with a virtual cylinder defined by a function eta) in order to obtain the variable dp2. I have included part of my code in each step. Thank you for finding time to read this. Ernest

Step 1: finding the initial acceleration (a==a2) of a rigid body, where




dimensionedVector g2 (g4.lookup("g1"));


volVectorField DDtU1 = (fvc::ddt(U)
+ fvc::div(phi, U)
- fvc::div(phi)*U);

vector K = fvc::domainIntegrate(DDtU1 - g2).value();


volVectorField a2 = 1000*0.000002826*eta*K/0.00254 + g2.value();



//volume of cylinder = 0.000002826



Step 2: rigid body velocity (vp2) is updated according to:

Vp2n+1 = Vp2n + a2nt


volVectorField vp2 = vp2 + (runTime.deltaT().value())*a2;

Step 3: rigid body position (dp) is updated according to:

dpn+1 = dpn + vpn+1t


volVectorField dp2 = dp2 + (runTime.deltaT().value())*vp2;

Step 4: I then set an intermediate velocity within the cylindrical region (to achieve no slip boundary), according to:

un+1 = Vp2n+1 + a2nt

U = U*(1 - eta) + eta*vp2;

Where eta is the function that defines the cylindrical region (eta = 1 in cylinder and zero elsewhere).




#0 Foam::error:rintStack(Foam::Ostream&) in "/opt/openfoam201/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#1 Foam::sigSegv::sigHandler(int) in "/opt/openfoam201/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#2 in "/lib/libc.so.6"
#3 std::basic_string<char, std::char_traits<char>, std::allocator<char> > std:perator+<char, std::char_traits<char>, std::allocator<char> >(char, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) in "/home/ernest/OpenFOAM/ernest-2.0.1/platforms/linux64GccDPOpt/bin/myInterFoam"
#4 Foam::tmp<Foam::GeometricField<Foam::typeOfSum<Foa m::Vector<double>, Foam::Vector<double> >::type, Foam::fvPatchField, Foam::volMesh> > Foam:perator+<Foam::Vector<double>, Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>(Foam::GeometricField<Foam::Vector<d ouble>, Foam::fvPatchField, Foam::volMesh> const&, Foam::tmp<Foam::GeometricField<Foam::Vector<double >, Foam::fvPatchField, Foam::volMesh> > const&) in "/home/ernest/OpenFOAM/ernest-2.0.1/platforms/linux64GccDPOpt/bin/myInterFoam"
#5
in "/home/ernest/OpenFOAM/ernest-2.0.1/platforms/linux64GccDPOpt/bin/myInterFoam"
#6 __libc_start_main in "/lib/libc.so.6"
#7
in "/home/ernest/OpenFOAM/ernest-2.0.1/platforms/linux64GccDPOpt/bin/myInterFoam"
Segmentation fault
erncyc is offline   Reply With Quote

Old   September 13, 2012, 06:33
Default Segmentation fault - multiphase- vof - interFoam
  #6
New Member
 
ernest
Join Date: Jun 2010
Posts: 21
Rep Power: 14
erncyc is an unknown quantity at this point
Hello Nima,

Sorry for the double post ...the equation image did not appear in earlier post.

I hope you are fine. Thank you for the reply which was helpful. I have tried to advance my code and so far it is compiling (although I am a bit suspicious about it), but when I try to run it (OF 2.0.1) I get a segmentation fault as shown below: Basically I am trying to do the algorithm below (in a 2D rectangular domain with a virtual cylinder defined by a function eta) in order to obtain the variable dp2. I have included part of my code in each step. Thank you for finding time to read this. Ernest

Step 1: finding the initial acceleration (a==a2) of a rigid body, where


ma = integration {rhoX[DU/Dt] - rho*g}dV + mg



dimensionedVector g2 (g4.lookup("g1"));


volVectorField DDtU1 = (fvc::ddt(U)
+ fvc::div(phi, U)
- fvc::div(phi)*U);

vector K = fvc::domainIntegrate(DDtU1 - g2).value();


volVectorField a2 = 1000*0.000002826*eta*K/0.00254 + g2.value();



//volume of cylinder = 0.000002826



Step 2: rigid body velocity (vp2) is updated according to:

Vp2n+1 = Vp2n + a2nt


volVectorField vp2 = vp2 + (runTime.deltaT().value())*a2;

Step 3: rigid body position (dp) is updated according to:

dpn+1 = dpn + vpn+1t


volVectorField dp2 = dp2 + (runTime.deltaT().value())*vp2;

Step 4: I then set an intermediate velocity within the cylindrical region (to achieve no slip boundary), according to:

un+1 = Vp2n+1 + a2nt

U = U*(1 - eta) + eta*vp2;

Where eta is the function that defines the cylindrical region (eta = 1 in cylinder and zero elsewhere).




#0 Foam::error:rintStack(Foam::Ostream&) in "/opt/openfoam201/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#1 Foam::sigSegv::sigHandler(int) in "/opt/openfoam201/platforms/linux64GccDPOpt/lib/libOpenFOAM.so"
#2 in "/lib/libc.so.6"
#3 std::basic_string<char, std::char_traits<char>, std::allocator<char> > std:perator+<char, std::char_traits<char>, std::allocator<char> >(char, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) in "/home/ernest/OpenFOAM/ernest-2.0.1/platforms/linux64GccDPOpt/bin/myInterFoam"
#4 Foam::tmp<Foam::GeometricField<Foam::typeOfSum<Foa m::Vector<double>, Foam::Vector<double> >::type, Foam::fvPatchField, Foam::volMesh> > Foam:perator+<Foam::Vector<double>, Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>(Foam::GeometricField<Foam::Vector<d ouble>, Foam::fvPatchField, Foam::volMesh> const&, Foam::tmp<Foam::GeometricField<Foam::Vector<double >, Foam::fvPatchField, Foam::volMesh> > const&) in "/home/ernest/OpenFOAM/ernest-2.0.1/platforms/linux64GccDPOpt/bin/myInterFoam"
#5
in "/home/ernest/OpenFOAM/ernest-2.0.1/platforms/linux64GccDPOpt/bin/myInterFoam"
#6 __libc_start_main in "/lib/libc.so.6"
#7
in "/home/ernest/OpenFOAM/ernest-2.0.1/platforms/linux64GccDPOpt/bin/myInterFoam"
Segmentation fault
erncyc 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
Gerris or Openfoam? houkensjtu Main CFD Forum 14 October 19, 2012 05:39
Specific OpenFOAM Code pbhuter OpenFOAM 13 June 30, 2012 19:06
OpenFoam code McCarra OpenFOAM Programming & Development 1 November 19, 2010 07:16
Modified OpenFOAM Forum Structure and New Mailing-List pete Site News & Announcements 0 June 29, 2009 05:56
What kind of Cmmercial CFD code you feel well? Lans Main CFD Forum 13 October 27, 1998 10:20


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