CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   convert dimensioned<double>’ to ‘double’ (https://www.cfd-online.com/Forums/openfoam-programming-development/78918-convert-dimensioned-double-double.html)

wyldckat December 29, 2013 16:24

Greetings to all!

@Thamali: Unfortunately, I can't make figure out where the problem is in the file you had attached, just by looking at the source code :(

As for the latest error, seems to either it's a very strange problem. It suggests that it's missing an indication of a library that has got the object-class "Foam::fv::laplacianScheme", which should already be present in "libOpenFOAM" or "libfiniteVolume".

If possible, can you share the whole source code package of your modified solver?
And knowing which OpenFOAM version or variant you are using, as well as knowing how you installed it and in which Linux Distribution and version, would all come in handing as well, so that I can reproduce the same error.

Because from what I can deduce, the latest error can be related to any of the details I asked above, namely: OpenFOAM version, how it was installed, which Linux Distribution and version, and access to the source code.

Best regards,
Bruno

Thamali December 30, 2013 01:40

Thank you very much for the wishes and Wish you all a very happy new year.....!!
wyldckat,
I will send my code through a private message to you cannot attach all file at once.

If anyone interested pls send me a message.
I am eager for your reply wyldckat.
Thanks again.

wyldckat January 5, 2014 11:47

Hi Thamali,

I've finally managed to have a look into this. Here are the steps I've taken to diagnose and sort-of solve the problem:
  1. Prepared a copy of fireFoam from OpenFOAM 2.2.x for comparison with your modified solver. Conclusion: Too many changes were made, in order to figure out the problem.
  2. Tried building with other versions of OpenFOAM. Did not seem to be a version problem (although I didn't check with 1.6-ext nor foam-extend 3.0).
  3. Applied the technique of isolate-and-conquer. I commented out the entries for "laplacian", to see which one is triggering the problem. Had to comment out the inclusion of "YghgEqn.H" as well, since it's loaded with "laplacian" calls.
  4. After gradually removing the comments from the "laplacian" entries, the first one to pick up the problem was the one in the file "YshsEqn.H". Note: the file "YghgEqn.H" was not yet included.
  5. The problem line is this one:
    Code:

    fvm::laplacian(kappa,ts)
    Looking for its variable definitions within it:
    • "volVectorField kappa"
    • "volScalarField ts"
  6. Looking at the error message:
    Code:

    Foam::fv::laplacianScheme<double, Foam::Vector<double> >
    this indicates that it's trying to create a class instance based off the template characteristics "<double, Foam::Vector<double>". This is likely so that it is compatible with the structure of the preceding code:
    Code:

    fvm::div(phi2,ts)
    Where: "surfaceScalarField phi2"
  7. So, what is exactly the problem? If you have a look into the OpenFOAM Programmer's Guide (here's an indirect link for it: http://openfoamwiki.net/index.php/Op...s_Guide_Errata ), you'll see what the Divergence and Laplacian operators do:
    • Divergence will essentially reduce the rank by one, turning rank-1 tensors into vectors and vectors into scalars.
    • Laplacian does not change the rank, therefore a vector remains a vector and a scalar remains a scalar.
  8. The problem is that you are trying to add a scalar "div(phi2,ts)" with a vector "laplacian(kappa,ts)".
  9. The quick fix was to switch the "kappa" field into a scalar, by using "mag":
    Code:

    fvm::laplacian(mag(kappa),ts)
    This no longer gave any building problems.
  10. The big question is: what is the equation you are trying to solve here? Because the equation on paper should have given you the perfect notion that the ranks of each item were incompatible.
I did not continue with the diagnosis, since all of the other Laplacian problems are in the file "YghgEqn.H", which I assume of the same nature of problems.

Best regards,
Bruno

Thamali January 7, 2014 00:35

Thanking
 
Dear Bruno,

I am very much grateful to you.
  • I always tried to find an answer to this error on searching about "ld returned 1 exit status".What I understood is some error on incompatibility of compiler versions vs OpenFoam versions(although it is not possible in Ubuntu 12.04LTS).
Therefore I never tried to looking to my code again.(my bad-sorry if I took your time on a foolish error.)
  • What I am trying to do here is making an anisotropic thermal conductivity field.The equation is for "enthalpy of solid phase" in a packed bed combusting wood chips.
  • In here I am trying to use a homogeneous model for the thermal conductivity of bed and therefore using same values for the gas phase too.
  • After changing same in the YghgEqn now my code is compiling.
  • If I went through the code at very early stage what exaclty happens when applying anisotropic thermal conductivity,I would not wasting time on developing a volVectorField and I will directly use a volScalarField with magnitude of volVectorField.(this will be a lesson for me and all new users as well)
Thank you very much again.
With Regards,
Thamali

gaza August 16, 2016 05:50

Hi
Yes this method works.
But I have a question:
If I have volScalarField T and then I want to assign

T[celli] = a*b; // a and b are dimensionedScalars

so then do I always use .value() method? I lose in this way dimensions checking or I am wrong?

nimasam September 1, 2016 03:03

yep. value() returns only value of variable not its dimension

krishna_kant_IITH August 29, 2017 03:44

similar problem in conversion
 
Hello Everyone
I am trying to solve laplace equation without using laplacian function. So I am stuck in multiplying the area vector to the grad of scalar T.

I am including the line of the code below which is showing problem

T[cellid]=T[cellid]-runTime.deltaT()*1.00*(gradT.value()*mesh.Sf()[faceid].value());
here T is the volScalarField, gradT is the volVectorField
This shows the error that they don't have any member named "value"
I have tried other ways too

T[cellid]=T[cellid]-runTime.deltaT()*1.00*(gradT*mesh.Sf()[faceid]);
This shows the following error
note: mismatched types ‘const Foam::dimensioned<Type>’ and ‘double’

T[cellid]=T[cellid]-runTime.deltaTValue()*1.00*(gradT*mesh.Sf()[faceid]);
This shows the same error as above.

T[cellid]=T[cellid]-runTime.deltaTValue()*1.00*(gradT.component(0)*mes h.Sf()[faceid].x()+gradT.component(1)*mesh.Sf()[faceid].y()+gradT.component(2)*mesh.Sf()[faceid].z());
This shows the following error
error: cannot convert ‘Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >’ to ‘double’ in assignment

Any help is deeply appreciated.

gaza August 29, 2017 11:27

Hi,
gradT is a vector so you can only access its component no value. Try this:
https://www.cfd-online.com/Forums/op...ell-label.html

azad_786 August 6, 2020 07:28

Hi All,
I am trying to generate a random number r between zero to one at the interface where phi lies between 0.01 to 0.99 as follows

volScalarField r;
forAll( r, cellID)
{
//r[cellID] = DO SOMETHING
if (phi[cellID] > 0.01)
{
r[cellI] =random number;
}

if (phi[cellI] <0.99)
{
r[cellId] =random number;
}
else
{
r[cellId] =0;
}

}


for this I am getting error

error: cannot convert 'long int() throw ()' to 'double' in assignment
r[cellID]=random number;

could you please suggest me how to resolve?
Thanks

sujata September 20, 2020 06:00

no suitable user-defined conversion
 
Hi foamers,
I am trying to put a condition that if after a certain height in a twophaseflow the properties of the fluid will be interchanged and the drag will be calculated using that changed property. My code is mentioned below and I am getting the following error:
error: no suitable user-defined conversion from "Foam::tmp<Foam::GeometricField<Foam::scalar={Foam ::doubleScalar={double}}, Foam::fvPatchField, Foam::volMesh>>" to "const Foam::volVectorField" exists
const volVectorField y_dist2=U.mesh().C().component(1);
^

dragModels/Tsuchiya2/Tsuchiya2.C(98): error: no suitable user-defined conversion from "Foam::tmp<Foam::volVectorField>" to "const Foam::volScalarField" exists
const volScalarField y_dist = y_dist2/l_unit;
:confused:



*................................................. ......................* //Code starts here
#include "Tsuchiya2.H"
#include "phasePair.H"
#include "addToRunTimeSelectionTable.H"

// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

namespace Foam
{
namespace dragModels
{
defineTypeNameAndDebug(Tsuchiya2, 0);
addToRunTimeSelectionTable(dragModel, Tsuchiya2, dictionary);
}
}


// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

Foam::dragModels::Tsuchiya2::Tsuchiya2
(
const dictionary& dict,
const phasePair& pair,
const bool registerObject
)
:
dragModel(dict, pair, registerObject),
residualRe_("residualRe", dimless, dict),
residualEo_("residualEo", dimless, dict)
{}


// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

Foam::dragModels::Tsuchiya2::~Tsuchiya2()
{}


// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

Foam::tmp<Foam::volScalarField>
Foam::dragModels::Tsuchiya2::CdRe() const
{
volScalarField Re(max(pair_.Re(), residualRe_));
//volScalarField Re(pair_.Re());
volScalarField Eo(max(pair_.Eo(), residualEo_));

Info<< "Re =" <<Re[0] << endl;
Info<< "Eo =" <<Eo[0] << endl;
volScalarField temp
{
max
(
24.0*(1.0 + 0.15*pow(Re, 0.687))/Re,
8.0*Eo/(3.0*(Eo + 4.0))
)
};

Info<< "Cd=" <<temp[0] <<endl;


return
temp*Re;

dimensionedScalar l_unit
(
"l_unit",
dimensionSet (0, 1, 0, 0, 0, 0, 0),
scalar(1.0)
);

const volVectorField U= this->db().objectRegistry::lookupObject<volVectorField> ("U.water");
const volVectorField y_dist2=U.mesh().C().component(1);
const volScalarField y_dist = y_dist2/l_unit;

dimensionedScalar h_i
(
"h_i",
dimensionSet (0, 0, 0, 0, 0, 0, 0),
scalar (1.1)
);

const volScalarField f_highUG
(
pos(y_dist-h_i)*
(
1e-06
)
+ neg(y_dist-h_i)*1.0
);

ybapat September 21, 2020 06:36

U.mesh().C().component(1) is returning tmp<volScalarField > not volScalarField

sujata September 21, 2020 06:43

Quote:

Originally Posted by ybapat (Post 783323)
U.mesh().C().component(1) is returning tmp<volScalarField > not volScalarField

Hey, Thank you for your response. Could you please tell me the correct form.


All times are GMT -4. The time now is 12:50.