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

PETSC4FOAM solve function argument psi.ref

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By olesen
  • 1 Post By olesen

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 8, 2023, 05:35
Default PETSC4FOAM solve function argument psi.ref
  #1
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 741
Blog Entries: 1
Rep Power: 17
dlahaye is on a distinguished road
Greetings,

The PETSC4FOAM solve() function calls the scalarSolve() with tpsi.ref() as argument. See L396 of https://develop.openfoam.com/modules.../petscSolver.C .

Why is tpsi.ref() used instead of tpsi? What is .ref() of tpsi ?

Thx!
dlahaye is offline   Reply With Quote

Old   March 9, 2023, 05:57
Default
  #2
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 741
Blog Entries: 1
Rep Power: 17
dlahaye is on a distinguished road
I imagine .ref() to return a non-constant reference to tpsi as explained at
Difference between boundaryField() and boundaryFieldRef()

Correct?
dlahaye is offline   Reply With Quote

Old   March 14, 2023, 12:54
Default
  #3
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,695
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by dlahaye View Post
Greetings,

The PETSC4FOAM solve() function calls the scalarSolve() with tpsi.ref() as argument. See L396 of https://develop.openfoam.com/modules.../petscSolver.C .

Why is tpsi.ref() used instead of tpsi? What is .ref() of tpsi ?

Thx!



Take a look at tmp.H, refPtr.H and PrecisionAdaptor.H for where ref() is being used. In short, you are correct - it is for a modifiable reference to the underlying object. Unlike boundaryFieldRef() however, there is no event counter to track changes.
dlahaye likes this.
olesen is offline   Reply With Quote

Old   March 14, 2023, 15:21
Default
  #4
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 741
Blog Entries: 1
Rep Power: 17
dlahaye is on a distinguished road
Thx!

What tmp.H, refPtr.H and PrecisionAdaptor.H do you mean? I do not find it immediately in PETSC4Foam.

Best. D.
dlahaye is offline   Reply With Quote

Old   March 15, 2023, 08:59
Default
  #5
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,695
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by dlahaye View Post
Thx!

What tmp.H, refPtr.H and PrecisionAdaptor.H do you mean? I do not find it immediately in PETSC4Foam.

Best. D.

They are all located here:

https://develop.openfoam.com/Develop...penFOAM/memory
dlahaye likes this.
olesen is offline   Reply With Quote

Old   March 15, 2023, 15:10
Default
  #6
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 741
Blog Entries: 1
Rep Power: 17
dlahaye is on a distinguished road
Thx! Much appreciated!
dlahaye is offline   Reply With Quote

Old   March 20, 2023, 02:28
Default
  #7
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 741
Blog Entries: 1
Rep Power: 17
dlahaye is on a distinguished road
I am trying to overwrite computed values of TEqn.psi() within laplacianFoam (or any other solver). I am struggling with the syntax. To modify the first component of TEqn.psi(), I tried the syntax

Code:
TEqn.psi().ref()[0] = 1.0;
and variants thereof. These variants result in various compiler error messages.

Help is appreciated.

Last edited by dlahaye; March 20, 2023 at 02:29. Reason: modified
dlahaye is offline   Reply With Quote

Old   March 20, 2023, 12:50
Default
  #8
Senior Member
 
Domenico Lahaye
Join Date: Dec 2013
Posts: 741
Blog Entries: 1
Rep Power: 17
dlahaye is on a distinguished road
Below for v1906 and v1912

Code:
GeometricField<scalar, fvPatchField, volMesh>& psi =
    const_cast<GeometricField<scalar, fvPatchField, volMesh>&>(TEqn.psi());
psi.primitiveFieldRef()[0] = 1.0;
dlahaye 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
[Other] refineWallLayer Error Yuby OpenFOAM Meshing & Mesh Conversion 2 November 11, 2021 11:04
eigenValues of volTensorField xuegy OpenFOAM Programming & Development 8 February 26, 2021 16:46
OpenFOAM static build on Cray XT5 asaijo OpenFOAM Installation 9 April 6, 2011 12:21
Can anybody help me to solve the list errors while compiling Openfoam 15 on Opensuse 103 32bit coompressor OpenFOAM Installation 0 November 12, 2008 19:53
[blockMesh] Axisymmetrical mesh Rasmus Gjesing (Gjesing) OpenFOAM Meshing & Mesh Conversion 10 April 2, 2007 14:00


All times are GMT -4. The time now is 02:18.