CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   new cannot satisfy memory request. (https://www.cfd-online.com/Forums/openfoam-solving/242868-new-cannot-satisfy-memory-request.html)

Roozbeh_Sa May 16, 2022 12:27

new cannot satisfy memory request.
 
2 Attachment(s)
Dear fomers,

I faced a strange run-time error after doing some small modifications to the interFoam solver, (with a new name interNewFoam after modification) and some of the libraries relevant to the mixture viscosity calculation. All the libraries and the solver were compiled without any warning and error, but when I tried to run the interNewFoam solver on the damBreak tutorial case I faced the following error.
Code:

new cannot satisfy memory request.
This does not necessarily mean you have run out of virtual memory.
It could be due to a stack violation caused by e.g. bad use of pointers or an out-of-date shared library
Aborted (core dumped)

My primary aim was to change the way viscosity was calculated in the interface of two phases. I describe what I did in what follows:
1- I modified the "incompressibleTwoPhaseMixture" library.
2- I modified the "immiscibleIncompressibleNewTwoPhaseMixture" library, and linked the modified library of step 1, to this library
3- I linked both of the above libraries to interNewFoam solver, and modified it as well.
All the new files, with their new names, are attached.
Having tried to solve this issue, I found out that the problem is coming from a very simple thing which is the initialization of two scalar variables. I defined two variables in my incompressibleNewTwoPhaseMixture.H as follows:
Code:

const scalar k_;
const scalar L_;

And initialized them in the constructor of the class (only the relevant part of the constructor is shown below):
Code:

Foam::incompressibleTwoPhaseMixture::incompressibleTwoPhaseMixture
(
    const volVectorField& U,
    const surfaceScalarField& phi
)
:
...,
k_(20),
L_(2),
...
{
calcNu();
}

With this method, I faced the run-time error message that was shown at the beginning of this post. However, if I define the scalar variables for each member function, the simulation runs very smoothly. One example of defining these variables in the calcNu() member function is shown below:

Code:

void Foam::incompressibleTwoPhaseMixture::calcNu()
{
    const scalar k_=20.0;
    const scalar L_=2.0;
    ...
    ...
}

I implemented this solver on the damBreak case, and I used both precompiled and compiled versions of OFv2112.

I want to know why this error message appears for the first method (defining the variable in the header file and initializing them in the constructor), while it is a valid C++ variable definition.

My src and applications directories, located in the $FOAM_RUN, containing only the two described libraries and the modified interNewFoam solver are attached below.

Any comment is appreciated.


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