CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

Compilation error

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 12, 2022, 03:54
Default Compilation error
  #1
New Member
 
Join Date: Mar 2010
Posts: 11
Rep Power: 16
samaraseeri is on a distinguished road
I'm not familiar with openfoam and trying to compile a new solver which outputs the following error. Can anyone give me hint on what needs to be fixed. best


modeFFTuw.C:81:12: error: no viable conversion from 'dimensioned<Foam::Vector<double>>' to 'Foam::vector' (aka 'Vector<double>')
vector cornerCellCentre = ::Foam::max(mesh.C().internalField());
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/OpenFOAM/OpenFOAM-v2112/src/OpenFOAM/lnInclude/Vector.H:91:9: note: candidate constructor not viable: no known conversion from 'dimensioned<Foam::Vector<double>>' to 'const Foam::Vector<double> &' for 1st argument
Vector(const Vector&) = default;
^
/Users/OpenFOAM/OpenFOAM-v2112/src/OpenFOAM/lnInclude/Vector.H:100:16: note: candidate constructor not viable: no known conversion from 'dimensioned<Foam::Vector<double>>' to 'const Foam::zero' for 1st argument
inline Vector(const Foam::zero);
^
/Users/OpenFOAM/OpenFOAM-v2112/src/OpenFOAM/lnInclude/Vector.H:104:16: note: candidate template ignored: could not match 'VectorSpace' against 'dimensioned'
inline Vector(const VectorSpace<Vector<Cmpt2>, Cmpt2, 3>& vs);
^
/Users/OpenFOAM/OpenFOAM-v2112/src/OpenFOAM/lnInclude/Vector.H:110:25: note: explicit constructor is not a candidate
inline explicit Vector(Istream& is);
^
modeFFTuw.C:41:9: warning: 'sprintf' will always overflow; destination buffer has size 5, but format string expands to at least 13 [-Wfortify-source]
sprintf(filename,"%1s_sans_mode%1u",champ ,mode);
^
modeFFTuw.C:44:9: warning: 'sprintf' will always overflow; destination buffer has size 5, but format string expands to at least 8 [-Wfortify-source]
sprintf(filename,"%1s_mode%1u",champ ,mode);
^
2 warnings and 1 error generated.
make: *** [Make/darwin64ClangDPInt32Opt/modeFFTuw.o] Error 1
samaraseeri is offline   Reply With Quote

Old   September 12, 2022, 06:04
Default
  #2
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,737
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
Your units (dimensions) don't match and that's why it's refusing to build.
LuckyTran is offline   Reply With Quote

Old   September 12, 2022, 06:33
Default
  #3
New Member
 
Join Date: Mar 2010
Posts: 11
Rep Power: 16
samaraseeri is on a distinguished road
I found that solver on the forums site https://www.cfd-online.com/Forums/at...ft-modefftuw.c. Can you guide me on how to match the units. Thanks
samaraseeri is offline   Reply With Quote

Old   September 13, 2022, 06:52
Default
  #4
New Member
 
Join Date: Mar 2010
Posts: 11
Rep Power: 16
samaraseeri is on a distinguished road
Quote:
Originally Posted by LuckyTran View Post
Your units (dimensions) don't match and that's why it's refusing to build.

I found that solver on the forums site https://www.cfd-online.com/Forums/at...ft-modefftuw.c. Can you guide me on how to match the units. Thanks
samaraseeri is offline   Reply With Quote

Old   September 13, 2022, 07:24
Default
  #5
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,737
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
Check out the OpenFOAM guide on basic rules regarding dimensions.

In your case the problems start at
Code:
    vector cornerCellCentre = ::Foam::max(mesh.C().internalField());
You are taking the maximum cell centroid which is a dimensioned vector and trying to store it in a vector called cornerCellCentre. A (non-dimensioned) vector is not the same class as a dimensioned vector.

You cannot assign a dimensioned anything to a dimensionless anything because they are different classes. It is equivalent to trying to take an int and store it in a float. Your compiler can clearly see this upfront and that's why it refuses to build. There are simple workarounds such as gutting the dimensions or arbitrarily adding dimensions or recasting but if you managed to arrive here then it usually means you overlooked the basic I/O patterns in OpenFOAM in the first place.
LuckyTran is offline   Reply With Quote

Old   September 13, 2022, 07:47
Default
  #6
New Member
 
Join Date: Mar 2010
Posts: 11
Rep Power: 16
samaraseeri is on a distinguished road
Quote:
Originally Posted by LuckyTran View Post
Check out the OpenFOAM guide on basic rules regarding dimensions.

In your case the problems start at
Code:
    vector cornerCellCentre = ::Foam::max(mesh.C().internalField());
You are taking the maximum cell centroid which is a dimensioned vector and trying to store it in a vector called cornerCellCentre. A (non-dimensioned) vector is not the same class as a dimensioned vector.

You cannot assign a dimensioned anything to a dimensionless anything because they are different classes. It is equivalent to trying to take an int and store it in a float. Your compiler can clearly see this upfront and that's why it refuses to build. There are simple workarounds such as gutting the dimensions or arbitrarily adding dimensions or recasting but if you managed to arrive here then it usually means you overlooked the basic I/O patterns in OpenFOAM in the first place.

I think the code compiled and attached above was correct, maybe some headers were missing or there are libraries that needs to be linked. It is not my code I'm just examining it to learn from it.
samaraseeri is offline   Reply With Quote

Old   September 13, 2022, 09:20
Default
  #7
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,737
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
I mean you clearly show an error from wmake which shows the code not compiling
LuckyTran is offline   Reply With Quote

Old   September 13, 2022, 10:21
Default
  #8
New Member
 
Join Date: Mar 2010
Posts: 11
Rep Power: 16
samaraseeri is on a distinguished road
Quote:
Originally Posted by LuckyTran View Post
I mean you clearly show an error from wmake which shows the code not compiling

ok thanks for your reply. I'll check how to match the units then.
samaraseeri 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
[blockMesh] blockMesh with double grading. spwater OpenFOAM Meshing & Mesh Conversion 92 January 12, 2019 09:00
Pressure outlet boundary condition rolando OpenFOAM Running, Solving & CFD 62 September 18, 2017 06:45
DPM udf error haghshenasfard FLUENT 0 April 13, 2016 06:35
[OpenFOAM] Native ParaView Reader Bugs tj22 ParaView 270 January 4, 2016 11:39
Compiling problems with hello worldC fw407 OpenFOAM Installation 21 January 6, 2008 17:38


All times are GMT -4. The time now is 09:45.