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

Accessing Pair<volScalarField>

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 30, 2020, 11:00
Default Accessing Pair<volScalarField>
  #1
Senior Member
 
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 15
gaza is on a distinguished road
Hi All,
I have a function:
Code:
Pair<volScalarField> f() const
{
   Pair<volScalarField> myObj;
   // some modification of myObj

   return myObj;
}
Than in the code I have volScalarField object and I want to assign the

result of f() with it in this way:
Code:
volScalarField vsfObj;
vsfObj = f()[0];
however I got error:
Code:
error: no match for ‘operator=’ (operand types are ‘Foam::volScalarField {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ and ‘Foam::tmp<Foam::DimensionedField<double, Foam::volMesh> >’)
Can anyone know how to solve it?
__________________
best regards
pblasiak
gaza is offline   Reply With Quote

Old   December 5, 2020, 04:33
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,686
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Two things. Normally you'd want to construct the volScalarField with the argument instead of constructing empty and assigning after. But from you error message, it looks like your routine is not returning what it should. You need to check that.
For figuring these things if can be help to try assigning some thing really stupid, for example
Code:
// with your "f()" generator 
std::string junk = f().first();
The compiler errors will show the mismatch, from which you will see the types and also realise the problem is your return values (the righthand side)
olesen is offline   Reply With Quote

Old   December 22, 2020, 09:23
Default
  #3
Senior Member
 
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 15
gaza is on a distinguished road
Hi Mark,
Thank you for your reply. You are right my two sides are different.
To explain it better I give the line where error is and next the compiler error:
Code:
mCond_ = mDotAlphal()[0]*mesh.V();
where mCond is volScalarField and mDotAlphal() returns Pair<volScalarField>


And here is the error:
Code:
error: no match for ‘operator=’ (operand types are ‘Foam::volScalarField {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ and ‘Foam::tmp<Foam::DimensionedField<double, Foam::volMesh> >’)
   mCond_ = mDotAlphal()[0]*mesh.V();
                                   ^
__________________
best regards
pblasiak
gaza 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
[OpenFOAM.com] Accessing the root account via Docker garumple OpenFOAM Installation 7 October 9, 2021 05:22
accessing solver data with UDF macros Dushan FLUENT 1 April 22, 2017 21:05
How to define a Macro accessing rad intensity Grey FLUENT 0 May 21, 2007 00:12
accessing gradient in boundary for define_proile Asghari FLUENT 0 September 19, 2006 02:23
UDF & Accessing Turbulence Properties Dimal FLUENT 0 March 5, 2002 13:14


All times are GMT -4. The time now is 03:52.