CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   How to code integral of (DU/Dt - 2000 ) in openFoam (http://www.cfd-online.com/Forums/openfoam/106829-how-code-integral-du-dt-2000-openfoam.html)

erncyc September 10, 2012 08:05

How to code integral of (DU/Dt - 2000 ) in openFoam
 
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::operator-(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::operator*(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::operator-(const Foam::septernion&, const Foam::vector&)
/opt/openfoam201/src/OpenFOAM/lnInclude/quaternionI.H:279: note: Foam::quaternion Foam::operator-(const Foam::quaternion&, const Foam::quaternion&)
/opt/openfoam201/src/OpenFOAM/lnInclude/quaternionI.H:273: note: Foam::quaternion Foam::operator-(const Foam::quaternion&)

nimasam September 10, 2012 09:21

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?

erncyc September 10, 2012 10:02

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.

nimasam September 10, 2012 15:13

dimensionedVector ("S",dimensionSet(0,1,-2,0,0,0,0),vector(2000,2000,2000));

erncyc September 13, 2012 06:26

Segmentation fault - multiphase- vof - interFoam
 
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

http://www.cfd-online.com/Forums/dat...BJRU5ErkJggg==


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::printStack(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::operator+<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::operator+<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 September 13, 2012 06:33

Segmentation fault - multiphase- vof - interFoam
 
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::printStack(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::operator+<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::operator+<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


All times are GMT -4. The time now is 23:27.