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

Unable to compile a source from an old repo?

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 3 Post By Daniel_Khazaei

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 15, 2019, 20:58
Default Unable to compile a source from an old repo?
  #1
Senior Member
 
Andrew Somorjai
Join Date: May 2013
Posts: 175
Rep Power: 13
massive_turbulence is on a distinguished road
Hello All,

I'm trying to get this code to compile so that I can see what it does but for some reason it's hung up over this

Code:
solver.C:34:65: error: passing ‘const Internal {aka const Foam::DimensionedField<Foam::Vector<double>, Foam::volMesh>}’ as ‘this’ argument discards qualifiers [-fpermissive]
     U.internalField() = axis ^ (centres.internalField() - origin);
Here's the full code

Code:
#include "fvCFD.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{

	#include "setRootCase.H"
	#include "createTime.H"
	#include "createMesh.H"

    Info<< "Time = " << runTime.value() << endl;

    Info<< "    Reading U" << endl;
    volVectorField U
    (
        IOobject
        (
            "U",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        ),
        mesh
    );

    // Do cells
    const volVectorField& centres = mesh.C();

    point origin(1, 1, 0.05);
    vector axis(0, 0, -1);

    U.internalField() = axis ^ (centres.internalField() - origin);

    U.boundaryField()[0] == (axis ^ (centres.boundaryField()[0] - origin));
    U.boundaryField()[1] == (axis ^ (centres.boundaryField()[1] - origin));
    U.boundaryField()[2] == (axis ^ (centres.boundaryField()[2] - origin));

    U.write();

    Info<< "End\n" << endl;

    return(0);
}
and the link to the original Github

Please let me know if there are other ways to do the same thing or something similar.
massive_turbulence is offline   Reply With Quote

Old   January 15, 2019, 22:51
Default
  #2
Senior Member
 
Daniel
Join Date: Mar 2013
Location: Noshahr, Iran
Posts: 348
Rep Power: 21
Daniel_Khazaei will become famous soon enough
you haven't said what OpenFOAM version you are trying to compile this piece of code on, but if the latest version is involved, you may try this:

Code:
U.primitiveFieldRef() = axis ^ (centres.primitiveField() - origin);

U.boundaryFieldRef()[0] == (axis ^ (centres.boundaryField()[0] - origin));
U.boundaryFieldRef()[1] == (axis ^ (centres.boundaryField()[1] - origin));
U.boundaryFieldRef()[2] == (axis ^ (centres.boundaryField()[2] - origin));
In recent versions, internalField() and boundaryField() functions both return a "const" reference to the internal field and boundary field of an object, respectively! So you can't modify them and need to use the above method.

Last edited by Daniel_Khazaei; January 16, 2019 at 10:58.
Daniel_Khazaei is offline   Reply With Quote

Old   January 16, 2019, 11:13
Default
  #3
Senior Member
 
Andrew Somorjai
Join Date: May 2013
Posts: 175
Rep Power: 13
massive_turbulence is on a distinguished road
Quote:
Originally Posted by Daniel_Khazaei View Post
you haven't said what OpenFOAM version you are trying to compile this piece of code on, but if the latest version is involved, you may try this:

Code:
U.primitiveFieldRef() = axis ^ (centres.primitiveField() - origin);

U.boundaryFieldRef()[0] == (axis ^ (centres.boundaryField()[0] - origin));
U.boundaryFieldRef()[1] == (axis ^ (centres.boundaryField()[1] - origin));
U.boundaryFieldRef()[2] == (axis ^ (centres.boundaryField()[2] - origin));
In recent versions, internalField() and boundaryField() functions both return a "const" reference to the internal field and boundary field of an object, respectively! So you can't modify them and need to use the above method.
OpenFOAM 6 v1806. Thank you sir!
massive_turbulence is offline   Reply With Quote

Reply

Tags
compilation error, internalfield


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
[swak4Foam] Installation Problem with OF 6 version Aurel OpenFOAM Community Contributions 14 November 18, 2020 17:18
[swak4Foam] groovyBC in openFOAM-2.0 for parabolic velocity bc ofslcm OpenFOAM Community Contributions 25 March 6, 2017 11:03
[swak4Foam] swak4foam building problem GGerber OpenFOAM Community Contributions 54 April 24, 2015 17:02
SparceImage v1.7.x Issue on MAC OS X rcarmi OpenFOAM Installation 4 August 14, 2014 07:42
Problem compiling a custom Lagrangian library brbbhatti OpenFOAM Programming & Development 2 July 7, 2014 12:32


All times are GMT -4. The time now is 10:06.