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

free() invalid pointer error for modified new solver

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By Daniel_Khazaei
  • 1 Post By Daniel_Khazaei

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 29, 2020, 05:29
Default free() invalid pointer error for modified new solver
  #1
Senior Member
 
Hojatollah Gholami
Join Date: Jan 2019
Posts: 171
Rep Power: 7
Hgholami is on a distinguished road
Dear foamers
I modify a fsiFoam and add an object to fluidSolidInterface as:
Quote:
void Foam::fluidSolidInterface::updateFluidTemperature( )
{
if (conjugate())
{
Info <<"set temperature to fluid" << endl;

const scalarField solidZoneTemperature_ =
stress().faceZoneTemperature
(
solidZoneIndex(),
solidPatchIndex()
);
const scalarField solidZoneKappaDelta_ =
stress().faceZoneKappaDelta
(
solidZoneIndex(),
solidPatchIndex()
);

scalarField nbrFluidZoneTemperature_
(
fluidMesh().faceZones()[fluidZoneIndex()].size(),
0.0
);
scalarField nbrFluidZoneKappaDelta_ =
scalarField
(
fluidMesh().faceZones()[fluidZoneIndex()].size(),
0.0
);


nbrFluidZoneTemperature_ =
ggiInterpolator().slaveToMaster
(
solidZoneTemperature_
);
nbrFluidZoneKappaDelta_ =
ggiInterpolator().slaveToMaster
(
solidZoneKappaDelta_
);
Info << "test ggiInterpolator" << endl;
flow().setTemperature
(
fluidPatchIndex(),
fluidZoneIndex(),
nbrFluidZoneTemperature_,
nbrFluidZoneKappaDelta_
);
Info << "test interface" << endl;
}
Info << "test if out of conjugate()" << endl;
}
the solver compiled with gcc5 in ubuntu18.04 (foam-extend4.0) successfully. But in running a case I see the bellow error.
Quote:
Time = 0.0001, iteration: 1
Modes before clean-up : 0, modes after clean-up : 0
Current fsi under-relaxation factor: 0.05
Creating accumulated fluid interface displacement
Maximal accumulated displacement of interface points: 0
GAMG: Solving for cellMotionUx, Initial residual = 0, Final residual = 0, No Iterations 1
GAMG: Solving for cellMotionUy, Initial residual = 0, Final residual = 0, No Iterations 1
GAMG: Solving for cellMotionUx, Initial residual = 0, Final residual = 0, No Iterations 1
GAMG: Solving for cellMotionUy, Initial residual = 0, Final residual = 0, No Iterations 1
set temperature to fluid
test ggiInterpolator
test interface
free():invalid pointer
Aborted (core dumped)
I confused why this problem occur only in out of if loop. can you help me?
Thanks
Hojatollah
Hgholami is offline   Reply With Quote

Old   March 29, 2020, 11:27
Default
  #2
Senior Member
 
Daniel
Join Date: Mar 2013
Location: Noshahr, Iran
Posts: 348
Rep Power: 21
Daniel_Khazaei will become famous soon enough
take a look at these two threads:

corrupted size vs prev_size error in foam-extend4.0
*** glibc detected *** free(): invalid pointer

As stated, these kind of errors occur when the compiler has to free the same object twice or you are linking libraries that probably have classes with the exact same naming convention. Either way, this is a user coding error.

Compile and run the solver in debug mode, that will show you when and where the error occur.

Regards,

D. Khazaei
Hgholami likes this.
Daniel_Khazaei is offline   Reply With Quote

Old   March 30, 2020, 14:42
Default
  #3
Senior Member
 
Hojatollah Gholami
Join Date: Jan 2019
Posts: 171
Rep Power: 7
Hgholami is on a distinguished road
Yes. It seen, the problem can come from each code line, so I comment each line in object and found the problem comes from stress().faceZoneKappaDelta and fix it.
unfortunately, the showing error can't show correct position.
Quote:
Originally Posted by Daniel_Khazaei View Post
take a look at these two threads:

corrupted size vs prev_size error in foam-extend4.0
*** glibc detected *** free(): invalid pointer

As stated, these kind of errors occur when the compiler has to free the same object twice or you are linking libraries that probably have classes with the exact same naming convention. Either way, this is a user coding error.

Compile and run the solver in debug mode, that will show you when and where the error occur.

Regards,

D. Khazaei
Hgholami is offline   Reply With Quote

Old   March 30, 2020, 16:12
Default
  #4
Senior Member
 
Daniel
Join Date: Mar 2013
Location: Noshahr, Iran
Posts: 348
Rep Power: 21
Daniel_Khazaei will become famous soon enough
Quote:
Originally Posted by Hgholami View Post
Yes. It seen, the problem can come from each code line, so I comment each line in object and found the problem comes from stress().faceZoneKappaDelta and fix it.
unfortunately, the showing error can't show correct position.
I'm glad that you solved the problem with your code.

For detailed information you need to compile and run in debug mode and use gdb backtrace command to see which line in the code is causing any type of error. This provides step by step sequence of events that lead to the error.
Daniel_Khazaei is offline   Reply With Quote

Old   March 31, 2020, 04:13
Default
  #5
Senior Member
 
Hojatollah Gholami
Join Date: Jan 2019
Posts: 171
Rep Power: 7
Hgholami is on a distinguished road
Dear Khazaei
Thanks for your reply.
I have a question that not relative to this topic.
In setTemperature object. I see the reference article "Vynnycky, M., Kimura, S., Kanev, K., & Pop, I. (1998). Forced convection heat transfer from a flat plate: the conjugate problem. International Journal of Heat and Mass Transfer, 41(1), 45–59. doi:10.1016/s0017-9310(97)00113-0*".
It is for steady simulation. And also, in chtMultiRegionFoam solver, it use similar conjugate condition (mixed). Although uses temporal term in "fvm::ddt(rho, h)", but I am not sure the mixed condition for temperature is suitable for fsi problem with transient behavior. Do you sure about this condition?
Do you know, the commercial software such as ANSYS, COMSOL, use which conjugate boundary condition?
The result of mixed condition for pr >>1 for steady problem give appropriate agreement but for Pr =<1 is not good. Do you found any other reference for Pr =<1?
Thanks
Hojatollah

Last edited by Hgholami; March 31, 2020 at 06:35.
Hgholami is offline   Reply With Quote

Old   March 31, 2020, 13:14
Default
  #6
Senior Member
 
Daniel
Join Date: Mar 2013
Location: Noshahr, Iran
Posts: 348
Rep Power: 21
Daniel_Khazaei will become famous soon enough
Quote:
Originally Posted by Hgholami View Post
I have a question that not relative to this topic.
In setTemperature object. I see the reference article "Vynnycky, M., Kimura, S., Kanev, K., & Pop, I. (1998). Forced convection heat transfer from a flat plate: the conjugate problem. International Journal of Heat and Mass Transfer, 41(1), 45–59. doi:10.1016/s0017-9310(97)00113-0*".
It is for steady simulation. And also, in chtMultiRegionFoam solver, it use similar conjugate condition (mixed). Although uses temporal term in "fvm::ddt(rho, h)", but I am not sure the mixed condition for temperature is suitable for fsi problem with transient behavior. Do you sure about this condition?
As far as I know, there is no limitation with mixed boundary condition procedure to be used in steady or transient simulations. In chtMultiRegionFoam solver's description it is clearly stated:

Solver for steady or transient fluid flow and solid heat conduction, with
conjugate heat transfer between regions, buoyancy effects, turbulence,
reactions and radiation modelling.

Also a simple search using google brought up a few papers that use chtMultiRegionFoam solver for transient simulation. The conjugate procedure implemented in fsi toolkit is doing the exact same thing and I don't see why it can not be used in transient simulations as long as it maintains heat flux and temperature consistency on the interface for each time step.

As I didn't have enough time to check CHT + FSI cases yet, I created a new branch called feature-thermoCoupling and removed fsi related part from solids4Foam toolkit until I can make sure it is working as expected. I'm concerned about solid region formulation when dealing with CHT+FSI cases. Nevertheless, the new branch should practically work with both steady and transient CHT only simulations. Let me know if you face any problem running transient cases.

Quote:
Originally Posted by Hgholami View Post
Do you know, the commercial software such as ANSYS, COMSOL, use which conjugate boundary condition?
I don't know how these software implement conjugate boundary condition as they are closed-source, but they should all agree on two constrains:
  1. heat flux consistency
  2. temperature field continuity
Above conditions hold when no heat generation or temperature jump is specified on the interface.

Quote:
Originally Posted by Hgholami View Post
The result of mixed condition for pr >>1 for steady problem give appropriate agreement but for Pr =<1 is not good. Do you found any other reference for Pr =<1?
Which fluid model are you using for the simulation?
The validation test case provided with solids4Foam is using Pr = 0.01 and it is in good agreement with experimental data. Also you can see that solids4Foam and chtMultiRegionFoam produce almost identical results.

Regards,
D. Khazaei
Attached Images
File Type: jpg conjugateBoundaryT.jpg (59.3 KB, 8 views)
File Type: jpg conjugateBoundaryTheta.jpg (61.2 KB, 7 views)
Hgholami likes this.
Daniel_Khazaei is offline   Reply With Quote

Reply

Tags
free(): invalid pointer, fsifoam


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
PEMFC model with FLUENT brahimchoice FLUENT 22 April 19, 2020 16:44
long error when using make-install SU2_AD. tomp1993 SU2 Installation 3 March 17, 2018 07:25
OpenFOAM install on Ubuntu Natty 11.04 bkubicek OpenFOAM 13 May 26, 2011 06:48
free " ordinary differential equations solver" ztdep Main CFD Forum 2 March 21, 2006 02:58
Free 2D Axisymmetric Potential Flow Solver for Matlab? Jonas Larsson Main CFD Forum 0 August 13, 2003 10:13


All times are GMT -4. The time now is 05:46.