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/)
-   -   Foam Serious Error while running solver (https://www.cfd-online.com/Forums/openfoam-programming-development/255365-foam-serious-error-while-running-solver.html)

Hamedhoorijani April 4, 2024 06:32

Foam Serious Error while running solver
 
Hi everyone,
I am receiving errors regarding two volScalarFields while running my own solver. It's strange to me that only these two variables are causing errors, considering I have defined and worked with other variables in the code without any issues during solver execution. Additionally, I should mention that the solver compiles without any errors or warnings. It's a coupling solver with LIGGGHTS (CFD-DEM), but I'm encountering this error prior to the coupling initiation at each CFD time-step.

I am confused why I am getting error just for these two variables, I would appreciate it if anyone can help me.

Error:

Quote:

[0] --> FOAM Serious Error :
[0] From function virtual bool Foam::regIOobject::writeObject(Foam::IOstream::str eamFormat, Foam::IOstream::versionNumber, Foam::IOstream::compressionType, bool) const
[0] in file db/regIOobject/regIOobjectWrite.C at line 55
[0] instance undefined for object Qaj
[3] --> FOAM Serious Error :
[3] From function virtual bool Foam::regIOobject::writeObject(Foam::IOstream::str eamFormat, Foam::IOstream::versionNumber, Foam::IOstream::compressionType, bool) const
[3] in file db/regIOobject/regIOobjectWrite.C at line 55
[3] instance undefined for object cellQj
Defining Qaj and cellQj:
Code:

volScalarField cellQj
(
  IOobject
  (
    "cellQj",
      mesh,
      IOobject::NO_READ,
      IOobject::AUTO_WRITE
  ),
    mesh,
    dimensionedScalar(dimPower, Zero)
);

volScalarField Qaj
(
  IOobject
  (
    "Qaj",
      mesh,
      IOobject::NO_READ,
      IOobject::AUTO_WRITE
  ),
    mesh,
    dimensionedScalar(dimPower, Zero)
);

Code: (all the variables are dimensionedScalar in this code snippet and emfVec is a vector field.
Code:



imensionedScalar tempValue = sqrt(coilElectricalResis/(relParticleMagPer* particleElectricalResis));
dimensionedScalar elecEfficiency = 1/(1 + (Di/Do) * tempValue);
forAll(emfVec,celli)
{
    Qaj[celli] = (pow(mag(emfVec[celli]),2)/particleElectricalResis.value())+ SMALL;
}
cellQj= Qaj/(elecEfficiency * thermalEfficiency);
runTime.write();


VRN April 16, 2024 09:56

Hello Hamedhoorijani,

Not sure this will help, but in your definition of the fields one line seems to be missing; the mesh.time().timeName() parameter inside the IOobject.

As per the coding guidelines (https://develop.openfoam.com/Develop...terns/registry) new field definition format is as follows:

fieldPtr = new volScalarField
(
IOobject
(
objectName,
mesh.time().timeName(),
mesh.thisDb(),
IOobject::NO_READ,
IOobject::NO_WRITE
// implicit: IOobject::REGISTER
),
mesh,
dimensionedScalar(dimless, Zero)
// implicit: calculatedType()
);

olesen April 16, 2024 11:04

Quote:

Originally Posted by VRN (Post 867800)
Hello Hamedhoorijani,

Not sure this will help, but in your definition of the fields one line seems to be missing; the mesh.time().timeName() parameter inside the IOobject.

Most definitely this is the cause. If you have called it with a single parameter (eg, "fieldName") the only constructor it knows about takes a fileName, which it tries to split into components (it splits on the '/' slashes).


Good answer, BTW.

Hamedhoorijani April 17, 2024 04:23

Dear Vinayak and Mark,

Thank you for your reply. Overlooking those lines was indeed the cause of errors that I was getting. It is solved now.


All times are GMT -4. The time now is 14:36.