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

How to access protected variable?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 15, 2014, 02:21
Default How to access protected variable?
  #1
Member
 
Manjunath Reddy
Join Date: Jun 2013
Posts: 47
Rep Power: 13
manju819 is on a distinguished road
Hiiii,

While making Ldumatrix.C in which is in test folder. I'm getting error with this lines


UEqnp.addBoundaryDiag(U3Eqnp.diag(), 0);
UEqnp.addBoundarySource(U3Eqnp.source(), false);

That is
/opt/openfoam222/src/finiteVolume/lnInclude/fvMatrix.C:150:6: error: ‘void Foam::fvMatrix<Type>::addBoundarySource(Foam::Fiel d<Type>&, bool) const [with Type = Foam::Vector<double>]’ is protected

which is showing addBoundarySource is protected how to access that please help me...

Regards
Manjunath
manju819 is offline   Reply With Quote

Old   October 22, 2015, 08:05
Default
  #2
New Member
 
Join Date: Oct 2015
Posts: 15
Rep Power: 11
martel is on a distinguished road
Hi Manjunath,

I have the same problem when accessing protected variables with addBoundaryDiag and addBoundarySource.

Did you find any information on how to solve it?

Regards,

--CME



Quote:
Originally Posted by manju819 View Post
Hiiii,

While making Ldumatrix.C in which is in test folder. I'm getting error with this lines


UEqnp.addBoundaryDiag(U3Eqnp.diag(), 0);
UEqnp.addBoundarySource(U3Eqnp.source(), false);

That is
/opt/openfoam222/src/finiteVolume/lnInclude/fvMatrix.C:150:6: error: ‘void Foam::fvMatrix<Type>::addBoundarySource(Foam::Fiel d<Type>&, bool) const [with Type = Foam::Vector<double>]’ is protected

which is showing addBoundarySource is protected how to access that please help me...

Regards
Manjunath
martel is offline   Reply With Quote

Old   October 22, 2015, 10:06
Default
  #3
Senior Member
 
mkraposhin's Avatar
 
Matvey Kraposhin
Join Date: Mar 2009
Location: Moscow, Russian Federation
Posts: 355
Rep Power: 21
mkraposhin is on a distinguished road
Quote:
Originally Posted by manju819 View Post
Hiiii,

While making Ldumatrix.C in which is in test folder. I'm getting error with this lines


UEqnp.addBoundaryDiag(U3Eqnp.diag(), 0);
UEqnp.addBoundarySource(U3Eqnp.source(), false);

That is
/opt/openfoam222/src/finiteVolume/lnInclude/fvMatrix.C:150:6: error: ‘void Foam::fvMatrix<Type>::addBoundarySource(Foam::Fiel d<Type>&, bool) const [with Type = Foam::Vector<double>]’ is protected

which is showing addBoundarySource is protected how to access that please help me...

Regards
Manjunath
1) Add friend functions or classes to the source code
Or
2) Create a nested class which inherits base class (fvMatrix)
mkraposhin is offline   Reply With Quote

Old   October 22, 2015, 10:31
Default
  #4
New Member
 
Join Date: Oct 2015
Posts: 15
Rep Power: 11
martel is on a distinguished road
Quote:
Originally Posted by mkraposhin View Post
1) Add friend functions or classes to the source code
Or
2) Create a nested class which inherits base class (fvMatrix)
thanks for your answer mkraposhin

Undortunately, my minimal C++ skills are not enopugh to understand it.

For this very simple example that does not compile
Quote:
// Define a matrix that contains the coefficients of the Laplacian
tmp<fvScalarMatrix> TEqnLaplaciano
(
fvm::laplacian(DT,T)
);

// Add BC contribution to matrix diagonal
scalarField& diag = TEqnLaplaciano().diag();
TEqnLaplaciano().addBoundaryDiag(diag,0);
Could you please let me know which code lines to insert to add a friend function that works.

Thanks in advance for youe help.

Regards,

--Carlos
martel is offline   Reply With Quote

Old   October 22, 2015, 10:51
Default
  #5
Senior Member
 
mkraposhin's Avatar
 
Matvey Kraposhin
Join Date: Mar 2009
Location: Moscow, Russian Federation
Posts: 355
Rep Power: 21
mkraposhin is on a distinguished road
In both cases it is not a trivial task:

1) In the first case you must declare any some function like
Quote:
void function1 ();
then you must put its declaration as friend to the declaration of fvMatrix class:
Quote:
protected:
void function1 ();
then you must recompile all libraries and binaries, that are using fvMatrix class

2) In the second case you can use inheritace mechanism:
Quote:
template<class T>
myClass : public fvMatrix<T>
{
}

Any way, you will need a good knowledge of C++
mkraposhin is offline   Reply With Quote

Old   October 22, 2015, 11:17
Default
  #6
New Member
 
Join Date: Oct 2015
Posts: 15
Rep Power: 11
martel is on a distinguished road
thanks again mkraposhin
martel 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
How access member variable of a boundary condition Vesposo OpenFOAM Programming & Development 1 March 13, 2014 08:49
emag beta feature: charge density charlotte CFX 4 March 22, 2011 10:14
error in COMSOL:'ERROR:6164 Duplicate Variable' bhushas COMSOL 1 May 30, 2008 05:35
Error: access: unbound variable cfd-novice FLUENT 0 April 3, 2003 05:53
Replace periodic by inlet-outlet pair lego CFX 3 November 5, 2002 21:09


All times are GMT -4. The time now is 16:51.