|
[Sponsors] |
April 11, 2022, 05:45 |
Problem: Foam::fvMesh& in new class.
|
#1 |
New Member
Zhang Yan
Join Date: Nov 2021
Posts: 15
Rep Power: 5 |
Hi, Foamers!
I'm using openFoam v2106 to program a new C++ class. In order to get access to cell centers. I set the variable [const Foam::fvMesh& B_mesh;] and use the function [const Foam::vectorField& meshCenters = B_mesh.cellCentres();]. in .H Code:
const Foam::fvMesh& B_mesh; Code:
const Foam::vectorField& meshCenters = mesh.cellCentres(); Code:
IBSystem.H:22:5: error: uninitialized reference member in ‘const class Foam::fvMesh&’ [-fpermissive] 22 | IBSystem() | ^~~~~~~~ IBSystem.H:19:25: note: ‘const Foam::fvMesh& IBSystem::B_mesh’ should be initialized 19 | const Foam::fvMesh& B_mesh; | ^~~~~~ |
|
April 24, 2022, 13:21 |
|
#2 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
Quote:
If you have it as a reference, this is something that you will need to initialize when constructing your class, which means that you need to pass in a reference to the constructor. Have you looked at any of the OpenFOAM source code? There are plenty of places using this type of thing. |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
area does not match neighbour by ... % -- possible face ordering problem | St.Pacholak | OpenFOAM | 11 | September 4, 2024 05:28 |
[OpenFOAM.com] Installing superThermo with Allwmake command | Dekkers | OpenFOAM Installation | 0 | January 28, 2022 06:32 |
Large problem partitioner | tzy | CFX | 3 | February 7, 2018 18:11 |
class element problem | nellosamr | OpenFOAM Programming & Development | 3 | September 11, 2017 07:42 |
natural convection problem for a CHT problem | Se-Hee | CFX | 2 | June 10, 2007 07:29 |