Expected primary-expression before '(' token

Hey, I have been trying to compile my c++ code in OpenFoam and for some reason I keep getting expected primary expression before '(' token.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
y_(wallDist::New(this->mesh_).y()),

        delta
        (
                IOobject
                (
                        "delta",
                        this->runTime_.timeName(),
                        this->mesh_,
                        IOobject::NO_READ,
                        IOobject::AUTO_WRITE,
                ),
                this->mesh_,
                dimensionedScalar("zero", pow(dimVolume,1.0/3.0), 0.0)
        ),
Which particular
'(' token
? It's not as if your code doesn't have quite a few of them.
It is the one at line 4
You should show more code. Unless you are making some very odd use of the comma function, the whole thing appears to be part of an argument list or something. Impossible to see from that snippet.

Presumably delta is an existing class or function?

What's it for? Large-eddy simulation or the like?
Hello Thugfreak,

What are all the (,)s at the end of the lines for? Did you mean (;)?

Andy
No, all of them are within the parentheses and not the semicolon.
Let's get one thing pinned down here.....


....is delta a function?
From the context it is probably intended to be the "typical length scale" of a cell (i.e. volume1/3). It's used in some turbulence models (viz the OpenFOAM CFD solver).

But the OP doesn't show sufficient code to decide what he/she is trying to do here.
Okay, This is the code,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
template<class BasicTurbulenceModel>
kOmegaSSTPANS<BasicTurbulenceModel>::kOmegaSSTPANS
(
    const alphaField& alpha,
    const rhoField& rho,
    const volVectorField& U,
    const surfaceScalarField& alphaRhoPhi,
    const surfaceScalarField& phi,
    const transportModel& transport,
    const word& propertiesName,
    const word& type
)
:
    eddyViscosity<RASModel<BasicTurbulenceModel>>
    (
        type,
        alpha,
        rho,
        U,
        alphaRhoPhi,
        phi,
        transport,
        propertiesName
    ),
	alphaK1_
	(
		dimensioned<scalar>::lookupOrAddToDict
		(
			"aplhaK1",
			this->coeffDict_,
			0.85
		)
	),
	alphaK2_
	(
		dimensioned<scalar>::lookupOrAddToDict
		(
			"aplhaK2",
			this->coeffDict_,
			1.0
		)
	),
	alphaOmega1_
	(
		dimensioned<scalar>::lookupOrAddToDict
		(
			"alphaOmega1",
			this->coeffDict_,
			0.5
		)
	),
	alphaOmega2_
	(
		dimensioned<scalar>::lookupOrAddToDict
		(
			"alphaOmega2",
			this->coeffDict_,
			0.856
		)
	),
	gamma1_
	(
		dimensioned<scalar>::lookupOrAddToDict
		(
			"gamma1",
			this->coeffDict_,
			5.0/9.0
		)
	),
	gamma2_
	(
		dimensioned<scalar>::lookupOrAddToDict
		(
			"gamma2",
			this->coeffDict_,
			0.44
		)
	),
	beta1_
	(
		dimensioned<scalar>::lookupOrAddToDict
		(
			"beta1",
			this->coeffDict_,
			0.075
		)
	),
	beta2_
	(
		dimensioned<scalar>::lookupOrAddToDict
		(
			"beta2",
			this->coeffDict_,
			0.0828
		)
	),
	betaStar_
	(
		dimensioned<scalar>::lookupOrAddToDict
		(
			"betaStar",
			this->coeffDict_,
			0.09
		)
	),
	a1_
	(
		dimensioned<scalar>::lookupOrAddToDict
		(
			"a1",
			this->coeffDict_,
			0.31
		)
	),
	b1_
	(
		dimensioned<scalar>::lookupOrAddToDict
		(
			"b1",
			this->coeffDict_,
			1.0
		)
	),
	c1_
	(
		dimensioned<scalar>::lookupOrAddToDict
		(
			"c1",
			this->coeffDict_,
			10.0
		)
	),
	F3_
	(
		Switch::lookupOrAddToDict
		(
			"F3",
			this->coeffDict_,
			false
		)
	),
	fEpsilon_ // new fEpsilon value
	(
		dimensioned<scalar>::lookupOrAddToDict
		(
			"fEpsilon",
			this->coeffDict_,
			1.0
		)
	),
	fkstatic_ //static value for fk
	(
		dimensioned<scalar>::lookupOrAddToDict
		(
			"fkstatic",
			this->coeffDict_,
			0.3
		)
	),
	y_(wallDist::New(this->mesh_).y()),

	delta
	(
		IOobject
		(
		"delta",
		this->runTime_.timeName(),
		this->mesh_,
		IOobject::NO_READ,
		IOobject::AUTO_WRITE
		),
		this->mesh_,
		dimensionedScalar("zero", pow(dimVolume,1.0/3.0), 0.0)
	),
	fk_
	(
		IOobject
		(
			"fk",
			this->runTime_.timeName(),
			this->mesh_,
			IOobject::NO_READ,
			IOobject::AUTO_WRITE
		),
		this->mesh_,
		dimensionedScalar("zero", fkstatic_)
	),
	fOmega_
	(
		IOobject
		(
			"fOmega",
			this->runTime_.timeName(),
			this->mesh_,
			IOobject::NO_READ,
			IOobject::AUTO_WRITE
		),
		fEpsilon_/fk_
	),
	k_
	(
		IOobject
		(
			IOobject::groupName("k", U.group()),
			this->runTime_.timeName(),
			this->mesh_,
			IOobject::NO_READ,
			IOobject::AUTO_WRITE
		),
		this->mesh_
	),
	omega_
	(
		IOobject
		(
			IOobject::groupName("omega", U.group()),
			this->runTime_.timeName(),
			this->mesh_,
			IOobject::NO_READ,
			IOobject::AUTO_WRITE
		),
		this->mesh_
	),
	kU_
	(
		IOobject
		(
			IOobject::groupName("kU", U.group()),
			this->runTime_.timeName(),
			this->mesh_,
			IOobject::NO_READ,
			IOobject::AUTO_WRITE
		),
		k_*fk_,
		k_.boundaryField().types()
	),
	omegaU_
	(
		IOobject
		(
			IOobject::groupName("omegaU", U.group()),
			this->runTime_.timeName(),
			this->mesh_,
			IOobject::NO_READ,
			IOobject::AUTO_WRITE
		),
		omega_*fOmega_,
		omega_.boundaryField().types()
	)

{
Are you sure it shouldn't be
delta_
rather than
delta

i.e. with an underscore at the end?

Your k-omega SST model seems to be a lot more complex than the Florian Menter original.
Last edited on
I tried using the underscore after delta but I still get the same error.
What data members are defined in the kOmegaSSTPANS class? Is delta_ or delta one of them? I've coded a k-omega turbulence model in a different code and don't recall any need for such a variable in any purely RANS turbulence model. LES maybe, but not RANS. What happens if you simply comment out the section with the delta variable?

Your code is just setting data members in the constructor. Try commenting them all out and then bringing them back in one-by-one.
Last edited on
You are right with respect to RANS but I am making a hybrid model here where is switches from RANS to LES. I think I will try doing what you suggested and see what happens.
The snippet of code you use is essentially the same as that here (about 377 lines down):
https://github.com/HelioVillanueva/helio-3.0.x/blob/master/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTPANS/kOmegaSSTPANS.C


Are you sure that delta is a field variable in the particular version of the class that you are using? (You should be able to find it in the corresponding .h header file.) Note that if you are working from a modified k-omega SST model then somebody may already have put it there, but if you are working from the original SST model then it wouldn't be there, as such a quantity isn't needed in RANS alone.


The error message that you get:
expected primary expression before '(' token.

is notorious for not necessarily occurring on that line, but being a knock-on effect of things like imbalanced brackets long before (or occasionally after) the line that gets flagged.

I can only suggest that you break your source file down into smaller fragments (even one function per file) and try to compile them separately. I would start with this basic kOmegaSSTPANS constructor - just put the included headers and this function in a separate file and try to compile (but not link) it separately.

I'm not convinced that the error is in any of the snippets of code that you have shown - they basically look OK. It may be a knock-on error from elsewhere.

Are you working with Prof Lars Davidson? He does this sort of mixed RANS/LES modelling, I believe.
Last edited on
Yes, I am trying to work on a modified k-omega SST model and not the original model.

In that case, I will try to break it down into smaller fragments and compile them. The problem is I started using OpenFOAM only for my thesis so had to learn the c++ basics used for OpenFOAM , until now I had worked mainly on Python and MATLAB for my fluid courses.

I am working under Prof Rickard Bensow but took the Turbulence modeling and Fluid Mechanics course under Prof Lars Davidson. I had asked him before I came to this forum but unfortunately, he has not worked that much under the PANS model.
I'd check first in the header file. There is A version at
https://github.com/HelioVillanueva/helio-3.0.x/blob/master/src/TurbulenceModels/turbulenceModels/RAS/kOmegaSSTPANS/kOmegaSSTPANS.H

The field delta is declared at line 182 in that - but this file may or may not be the header file that you are using.

If that is not the root of the problem then it may be necessary to compile one function at a time.

Good luck!
Thank you, I will have a look it at.
I know everyone has their own style but your use of parenthesis are quite hard to read.
Actually I am using a modified version so the constructors were all written in this way so thought I will follow the same method.
Topic archived. No new replies allowed.