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

autoPtr in Openfoam code

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By hchen

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 13, 2014, 08:38
Default autoPtr in Openfoam code
  #1
Member
 
Hao Chen
Join Date: Aug 2014
Posts: 66
Rep Power: 0
hchen is on a distinguished road
Hi,

I am pretty new to Openfoam and now trying to dig into the code.

If anybody can explain what is autoPtr, I met it several times but can not find any information about it. eg.

Code:
autoPtr<motionSolver> motionPtr_
Thanks!

Best regards
Hao
ordinary likes this.
hchen is offline   Reply With Quote

Old   August 14, 2014, 08:48
Default
  #2
Senior Member
 
Jens Höpken
Join Date: Apr 2009
Location: Duisburg, Germany
Posts: 159
Rep Power: 17
jhoepken is on a distinguished road
Send a message via Skype™ to jhoepken
Hi Hao,

an autoPtr<T> is a smart pointer, which is basically "nothing more" than a wrapper around C++ pointers and handles e.g. garbage collection in an automatic fashion. Resources are released automatically, when they are out of scope.

Good luck with the dynamic meshes

Jens
__________________
Blog: sourceflux.de/blog
"The OpenFOAM Technology Primer": sourceflux.de/book
Twitter: @sourceflux_de
Interested in courses on OpenFOAM?
jhoepken is offline   Reply With Quote

Old   August 14, 2014, 09:25
Default
  #3
Member
 
Eric M. Tridas
Join Date: May 2011
Location: Tampa, Florida
Posts: 48
Rep Power: 14
eric.m.tridas is on a distinguished road
So if I understand correctly, using "autoPtr<T>" is preferable to using "new T()"?
eric.m.tridas is offline   Reply With Quote

Old   August 14, 2014, 09:40
Default
  #4
Senior Member
 
Jens Höpken
Join Date: Apr 2009
Location: Duisburg, Germany
Posts: 159
Rep Power: 17
jhoepken is on a distinguished road
Send a message via Skype™ to jhoepken
autoPtr<T> myVar is preferable to T* myVar.
__________________
Blog: sourceflux.de/blog
"The OpenFOAM Technology Primer": sourceflux.de/book
Twitter: @sourceflux_de
Interested in courses on OpenFOAM?
jhoepken is offline   Reply With Quote

Old   August 14, 2014, 09:46
Default
  #5
Member
 
Eric M. Tridas
Join Date: May 2011
Location: Tampa, Florida
Posts: 48
Rep Power: 14
eric.m.tridas is on a distinguished road
That makes sense. Thanks!
eric.m.tridas is offline   Reply With Quote

Old   August 14, 2014, 09:47
Default
  #6
Senior Member
 
Jens Höpken
Join Date: Apr 2009
Location: Duisburg, Germany
Posts: 159
Rep Power: 17
jhoepken is on a distinguished road
Send a message via Skype™ to jhoepken
No problemo
__________________
Blog: sourceflux.de/blog
"The OpenFOAM Technology Primer": sourceflux.de/book
Twitter: @sourceflux_de
Interested in courses on OpenFOAM?
jhoepken is offline   Reply With Quote

Old   August 15, 2014, 04:46
Default
  #7
Member
 
Hao Chen
Join Date: Aug 2014
Posts: 66
Rep Power: 0
hchen is on a distinguished road
Hi Jens,

Thanks very much!

And one more question is that I can see in dynamic motion solver fv mesh, there are displacement laplacian and velocity laplacian, but I found one more mesh class called laplace...which equation does it solve? I can not find the source code of it...

Also waiting for your Openfoam book!

Hao



Quote:
Originally Posted by jhoepken View Post
Hi Hao,

an autoPtr<T> is a smart pointer, which is basically "nothing more" than a wrapper around C++ pointers and handles e.g. garbage collection in an automatic fashion. Resources are released automatically, when they are out of scope.

Good luck with the dynamic meshes

Jens
hchen is offline   Reply With Quote

Old   August 15, 2014, 08:13
Default
  #8
Senior Member
 
Jens Höpken
Join Date: Apr 2009
Location: Duisburg, Germany
Posts: 159
Rep Power: 17
jhoepken is on a distinguished road
Send a message via Skype™ to jhoepken
There are several types of motionSolvers:
  1. componentDisplacement
  2. componentVelocity
  3. displacement
  4. velocity
These are all virtual base classes for actual implementations motionSolvers. Look in $FOAM_SRC/fvMotionSolver/fvMotionSolvers (assuming you have the vanilla version of OpenFOAM).

For displacementLaplacianFvMotionSolver it solves Laplace equation:
Code:
void Foam::displacementLaplacianFvMotionSolver::solve()
{
    // The points have moved so before interpolation update
    // the motionSolver accordingly
    movePoints(fvMesh_.points());

    diffusivity().correct();
    pointDisplacement_.boundaryField().updateCoeffs();

    Foam::solve
    (
        fvm::laplacian
        (
            diffusivity().operator()(),
            cellDisplacement_,
            "laplacian(diffusivity,cellDisplacement)"
        )
    );
}
__________________
Blog: sourceflux.de/blog
"The OpenFOAM Technology Primer": sourceflux.de/book
Twitter: @sourceflux_de
Interested in courses on OpenFOAM?
jhoepken is offline   Reply With Quote

Old   August 15, 2014, 09:02
Default
  #9
Member
 
Hao Chen
Join Date: Aug 2014
Posts: 66
Rep Power: 0
hchen is on a distinguished road
Hi Jens,

I see, thank you!

Another thing is when I select some diffusivity models, say exponential or quadratic, the error shows that: attempt to read beyond EOF, but normally uniform diffusivity is OK...Do you have any idea about the reason?

Best regards
Hao



Quote:
Originally Posted by jhoepken View Post
There are several types of motionSolvers:
  1. componentDisplacement
  2. componentVelocity
  3. displacement
  4. velocity
These are all virtual base classes for actual implementations motionSolvers. Look in $FOAM_SRC/fvMotionSolver/fvMotionSolvers (assuming you have the vanilla version of OpenFOAM).

For displacementLaplacianFvMotionSolver it solves Laplace equation:
Code:
void Foam::displacementLaplacianFvMotionSolver::solve()
{
    // The points have moved so before interpolation update
    // the motionSolver accordingly
    movePoints(fvMesh_.points());

    diffusivity().correct();
    pointDisplacement_.boundaryField().updateCoeffs();

    Foam::solve
    (
        fvm::laplacian
        (
            diffusivity().operator()(),
            cellDisplacement_,
            "laplacian(diffusivity,cellDisplacement)"
        )
    );
}
hchen is offline   Reply With Quote

Old   August 15, 2014, 09:41
Default
  #10
Senior Member
 
Jens Höpken
Join Date: Apr 2009
Location: Duisburg, Germany
Posts: 159
Rep Power: 17
jhoepken is on a distinguished road
Send a message via Skype™ to jhoepken
Maybe you are missing a parameter? Or a semicolon? Look in the source code of the particular model you use, and check which parameters it requires.
__________________
Blog: sourceflux.de/blog
"The OpenFOAM Technology Primer": sourceflux.de/book
Twitter: @sourceflux_de
Interested in courses on OpenFOAM?
jhoepken is offline   Reply With Quote

Reply


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
Memory protection in OpenFOAM / combinig with FORTRAN botp OpenFOAM Programming & Development 2 February 15, 2016 12:25
How to calculate Reynolds stress tensor in OpenFOAM code. yzf1215 OpenFOAM Programming & Development 1 October 26, 2013 07:25
OpenFOAM Foundation releases OpenFOAM 2.2.2 opencfd OpenFOAM Announcements from ESI-OpenCFD 0 October 14, 2013 07:18
How to code integral of (DU/Dt - 2000 ) in openFoam erncyc OpenFOAM 5 September 13, 2012 06:33
OpenFOAM for subsurface flow, or coupling with a subsurface flow code? chljl OpenFOAM Running, Solving & CFD 0 February 14, 2012 19:38


All times are GMT -4. The time now is 08:57.