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

Minor issue compiling solver

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By Taataa

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 30, 2018, 11:14
Default Minor issue compiling solver
  #1
Member
 
Join Date: Jun 2017
Posts: 58
Rep Power: 9
sturgeon is on a distinguished road
Hi all

I'm having a minor issue compiling UEqn for a solver I'm working on. I want to add a force and I'm putting it in the momentum predictor, but I've run into a strange problem.

When my code is like this:

Code:
volVectorField F("F",Fx*vector(1,0,0)+Fy*vector(0,1,0)+Fz*vector(0,0,1));

surfaceScalarField Ff = fvc::interpolate(F) & mesh.Sf();

    if (pimple.momentumPredictor())
    {
        solve(UEqn == fvc::reconstruct
   (
                (
                     fvc::interpolate(rhok-1)*(g & mesh.Sf())
					+ Ff
					 - fvc::snGrad(p)*mesh.magSf()
                )
				) 
				);

        fvOptions.correct(U);
    }
It compiles fine. However, when it's like this:

Code:
volVectorField F("F",Fx*vector(1,0,0)+Fy*vector(0,1,0)+Fz*vector(0,0,1));

    if (pimple.momentumPredictor())
    {
        solve(UEqn == fvc::reconstruct
   (
                (
                     fvc::interpolate(rhok-1)*(g & mesh.Sf())
					+ fvc::interpolate(F) & mesh.Sf()
					 - fvc::snGrad(p)*mesh.magSf()
                )
				) 
				);

        fvOptions.correct(U);
    }
I get a huge stream of errors in the console. But to me they should be functionally identical - however clearly they are not. The only difference is in the version that compiles, the force is interpolated to the faces and stored as a variable Ff, and in the second, this step is skipped in favour of just interpolating the faces within the code for UEqn==.

I know this is minor but I'm interested as to why this error happens to improve my knowledge of C++ and OF development.

Thanks
sturgeon is offline   Reply With Quote

Old   March 30, 2018, 11:37
Default
  #2
Senior Member
 
Taher Chegini
Join Date: Nov 2014
Location: Houston, Texas
Posts: 125
Rep Power: 13
Taataa is on a distinguished road
The "*" operator is outer product and "&" is inner product and you're adding output of these two operators. So I guess the difference could be because of mismatching of types. In the upper case you declared the type whereas in the lower one the compiler is taking care of that.
sturgeon likes this.
Taataa is offline   Reply With Quote

Old   March 30, 2018, 12:29
Default
  #3
Member
 
Join Date: Jun 2017
Posts: 58
Rep Power: 9
sturgeon is on a distinguished road
Quote:
Originally Posted by Taataa View Post
The "*" operator is outer product and "&" is inner product and you're adding output of these two operators. So I guess the difference could be because of mismatching of types. In the upper case you declared the type whereas in the lower one the compiler is taking care of that.
That makes sense so I guess that could be the issue. I better look into this and make sure the code is doing what I intend.

Thank you!
sturgeon 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
make: Clock skew detected. build may be incomplete. while compiling new solver. savee OpenFOAM Programming & Development 1 May 27, 2017 07:23
Hybrid discretisation - blend factor gcoopermax CFX 5 September 23, 2016 09:05
fluent divergence for no reason sufjanst FLUENT 2 March 23, 2016 17:08
Compiling meltFoam solver mick223 OpenFOAM Programming & Development 12 July 31, 2015 11:33
Working directory via command line Luiz CFX 4 March 6, 2011 21:02


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