ENH: add cell/face set/zone support for patch expressions

- for cell quantities, these evaluate on the faceCells associated with
  that patch to produce a field of true/false values

- for face quantities, these simply correspond to the mesh faces
  associated with that patch to produce a field of true/false values
This commit is contained in:
Mark Olesen
2021-10-26 21:08:19 +02:00
parent fc6239d96e
commit 643763d258
9 changed files with 314 additions and 131 deletions

View File

@ -471,8 +471,8 @@ public:
//- Return cell/face/point zone/set type or unknown //- Return cell/face/point zone/set type or unknown
topoSetSource::sourceType topoSourceType(const word& name) const; topoSetSource::sourceType topoSourceType(const word& name) const;
//- Read and return labels associated with the topo set //- Get the labels associated with the topo set
labelList getTopoSetLabels refPtr<labelList> getTopoSetLabels
( (
const word& name, const word& name,
enum topoSetSource::sourceType setType enum topoSetSource::sourceType setType

View File

@ -34,13 +34,17 @@ License
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
Foam::labelList Foam::expressions::fvExprDriver::getTopoSetLabels Foam::refPtr<Foam::labelList>
Foam::expressions::fvExprDriver::getTopoSetLabels
( (
const word& name, const word& name,
enum topoSetSource::sourceType setType enum topoSetSource::sourceType setType
) const ) const
{ {
// Zones first - they are cheap to handle (no IO) refPtr<labelList> selected;
// Zones first
// - cheap to handle (no IO) and can simply reference their labels
switch (setType) switch (setType)
{ {
@ -58,7 +62,7 @@ Foam::labelList Foam::expressions::fvExprDriver::getTopoSetLabels
<< exit(FatalError); << exit(FatalError);
} }
return zones[zoneID]; selected.cref(zones[zoneID]);
break; break;
} }
@ -76,7 +80,7 @@ Foam::labelList Foam::expressions::fvExprDriver::getTopoSetLabels
<< exit(FatalError); << exit(FatalError);
} }
return zones[zoneID]; selected.cref(zones[zoneID]);
break; break;
} }
@ -94,7 +98,7 @@ Foam::labelList Foam::expressions::fvExprDriver::getTopoSetLabels
<< exit(FatalError); << exit(FatalError);
} }
return zones[zoneID]; selected.cref(zones[zoneID]);
break; break;
} }
@ -103,6 +107,12 @@ Foam::labelList Foam::expressions::fvExprDriver::getTopoSetLabels
} }
if (selected.valid())
{
return selected;
}
IOobject io(topoSet::findIOobject(mesh(), name)); IOobject io(topoSet::findIOobject(mesh(), name));
switch (setType) switch (setType)
@ -121,7 +131,7 @@ Foam::labelList Foam::expressions::fvExprDriver::getTopoSetLabels
} }
classType set(io); classType set(io);
return set.sortedToc(); selected.reset(refPtr<labelList>::New(set.sortedToc()));
break; break;
} }
@ -139,7 +149,7 @@ Foam::labelList Foam::expressions::fvExprDriver::getTopoSetLabels
} }
classType set(io); classType set(io);
return set.sortedToc(); selected.reset(refPtr<labelList>::New(set.sortedToc()));
break; break;
} }
@ -157,7 +167,7 @@ Foam::labelList Foam::expressions::fvExprDriver::getTopoSetLabels
} }
classType set(io); classType set(io);
return set.sortedToc(); selected.reset(refPtr<labelList>::New(set.sortedToc()));
break; break;
} }
@ -171,7 +181,7 @@ Foam::labelList Foam::expressions::fvExprDriver::getTopoSetLabels
} }
} }
return labelList::null(); return selected;
} }

View File

@ -111,6 +111,21 @@ protected:
// Protected Member Functions // Protected Member Functions
//- Cell selections (as logical)
tmp<boolField> field_cellSelection
(
const word& name,
enum topoSetSource::sourceType setType
) const;
//- Face selections (as logical)
tmp<boolField> field_faceSelection
(
const word& name,
enum topoSetSource::sourceType setType
) const;
// No copy copy construct // No copy copy construct
parseDriver(const parseDriver&) = delete; parseDriver(const parseDriver&) = delete;
@ -281,6 +296,20 @@ public:
//- The patch point locations - (swak = pts) //- The patch point locations - (swak = pts)
tmp<vectorField> field_pointField() const; tmp<vectorField> field_pointField() const;
//- Cell selection (set)
inline tmp<boolField> field_cellSet(const word& name) const;
//- Cell selection (zone)
inline tmp<boolField> field_cellZone(const word& name) const;
//- Face selection (set)
inline tmp<boolField> field_faceSet(const word& name) const;
//- Face selection (zone)
inline tmp<boolField> field_faceZone(const word& name) const;
//- A uniform random field //- A uniform random field
tmp<scalarField> field_rand(label seed=0, bool gaussian=false) const; tmp<scalarField> field_rand(label seed=0, bool gaussian=false) const;

View File

@ -55,6 +55,97 @@ Foam::expressions::patchExpr::parseDriver::getPointField<bool>
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::boolField>
Foam::expressions::patchExpr::parseDriver::field_cellSelection
(
const word& name,
enum topoSetSource::sourceType setType
) const
{
refPtr<labelList> tselected;
switch (setType)
{
case topoSetSource::sourceType::CELLZONE_SOURCE:
case topoSetSource::sourceType::CELLSET_SOURCE:
{
tselected = getTopoSetLabels(name, setType);
break;
}
default:
{
FatalErrorInFunction
<< "Unexpected sourceType: " << int(setType) << nl
<< exit(FatalError);
break;
}
}
// Not particularly efficient...
labelHashSet inSelection(tselected());
const labelList& faceCells = patch_.faceCells();
auto tresult = tmp<boolField>::New(this->size(), false);
auto& result = tresult.ref();
forAll(result, facei)
{
if (inSelection.found(faceCells[facei]))
{
result[facei] = true;
}
}
return tresult;
}
Foam::tmp<Foam::boolField>
Foam::expressions::patchExpr::parseDriver::field_faceSelection
(
const word& name,
enum topoSetSource::sourceType setType
) const
{
refPtr<labelList> tselected;
switch (setType)
{
case topoSetSource::sourceType::FACESET_SOURCE:
case topoSetSource::sourceType::FACEZONE_SOURCE:
{
tselected = getTopoSetLabels(name, setType);
break;
}
default:
{
FatalErrorInFunction
<< "Unexpected sourceType: " << int(setType) << nl
<< exit(FatalError);
break;
}
}
// Not particularly efficient...
labelHashSet inSelection(tselected());
const label patchStart = patch_.start();
auto tresult = tmp<boolField>::New(this->size(), false);
auto& result = tresult.ref();
forAll(result, facei)
{
if (inSelection.found(facei + patchStart))
{
result[facei] = true;
}
}
return tresult;
}
Foam::tmp<Foam::scalarField> Foam::tmp<Foam::scalarField>
Foam::expressions::patchExpr::parseDriver::field_faceArea() const Foam::expressions::patchExpr::parseDriver::field_faceArea() const
{ {

View File

@ -47,4 +47,60 @@ inline Foam::label Foam::expressions::patchExpr::parseDriver::size
} }
inline Foam::tmp<Foam::boolField>
Foam::expressions::patchExpr::parseDriver::parseDriver::field_cellSet
(
const word& name
) const
{
return field_cellSelection
(
name,
topoSetSource::sourceType::CELLSET_SOURCE
);
}
inline Foam::tmp<Foam::boolField>
Foam::expressions::patchExpr::parseDriver::field_cellZone
(
const word& name
) const
{
return field_cellSelection
(
name,
topoSetSource::sourceType::CELLZONE_SOURCE
);
}
inline Foam::tmp<Foam::boolField>
Foam::expressions::patchExpr::parseDriver::field_faceSet
(
const word& name
) const
{
return field_faceSelection
(
name,
topoSetSource::sourceType::FACESET_SOURCE
);
}
inline Foam::tmp<Foam::boolField>
Foam::expressions::patchExpr::parseDriver::field_faceZone
(
const word& name
) const
{
return field_faceSelection
(
name,
topoSetSource::sourceType::FACEZONE_SOURCE
);
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -61,23 +61,19 @@ define([rules_driver_surface_functions],
[dnl [dnl
_logic_ (lhs) ::= CELL_SET LPAREN identifier (name) RPAREN .dnl _logic_ (lhs) ::= CELL_SET LPAREN identifier (name) RPAREN .dnl
{dnl {dnl
driver->reportFatal("Not implemented: " + make_obj(name)); lhs = driver->field_cellSet(make_obj(name)).ptr();
lhs = nullptr;dnl
}dnl }dnl
_logic_ (lhs) ::= CELL_ZONE LPAREN identifier (name) RPAREN .dnl _logic_ (lhs) ::= CELL_ZONE LPAREN identifier (name) RPAREN .dnl
{dnl {dnl
driver->reportFatal("Not implemented: " + make_obj(name)); lhs = driver->field_cellZone(make_obj(name)).ptr();
lhs = nullptr;dnl
}dnl }dnl
_logic_ (lhs) ::= FACE_SET LPAREN identifier (name) RPAREN .dnl _logic_ (lhs) ::= FACE_SET LPAREN identifier (name) RPAREN .dnl
{dnl {dnl
driver->reportFatal("Not implemented: " + make_obj(name)); lhs = driver->field_faceSet(make_obj(name)).ptr();
lhs = nullptr;dnl
}dnl }dnl
_logic_ (lhs) ::= FACE_ZONE LPAREN identifier (name) RPAREN .dnl _logic_ (lhs) ::= FACE_ZONE LPAREN identifier (name) RPAREN .dnl
{dnl {dnl
driver->reportFatal("Not implemented: " + make_obj(name)); lhs = driver->field_faceZone(make_obj(name)).ptr();
lhs = nullptr;dnl
}dnl }dnl
dnl dnl
rule_driver_nullary(_scalar_, FACE_AREA, field_faceArea)dnl rule_driver_nullary(_scalar_, FACE_AREA, field_faceArea)dnl

View File

@ -59,8 +59,7 @@ namespace Foam
//- An {int, c_str} enum pairing for field types //- An {int, c_str} enum pairing for field types
#define FIELD_PAIR(Fld,T) { TOKEN_OF(T), Fld::typeName.c_str() } #define FIELD_PAIR(Fld,T) { TOKEN_OF(T), Fld::typeName.c_str() }
#undef HAS_LOOKBEHIND_TOKENS #define HAS_LOOKBEHIND_TOKENS
#ifdef HAS_LOOKBEHIND_TOKENS
// Special handling for these known (stashed) look-back types // Special handling for these known (stashed) look-back types
static const Enum<int> lookBehindTokenEnums static const Enum<int> lookBehindTokenEnums
({ ({
@ -70,7 +69,7 @@ static const Enum<int> lookBehindTokenEnums
TOKEN_PAIR("pointZone", POINT_ZONE), TOKEN_PAIR("pointSet", POINT_SET), TOKEN_PAIR("pointZone", POINT_ZONE), TOKEN_PAIR("pointSet", POINT_SET),
#endif #endif
}); });
#endif
// Special handling of predefined method types. Eg, .x(), .y(), ... // Special handling of predefined method types. Eg, .x(), .y(), ...
@ -190,7 +189,7 @@ static int driverTokenType
const word& ident const word& ident
) )
{ {
#if 0 #ifdef HAS_LOOKBEHIND_TOKENS
// Get stashed "look-behind" to decide what type of identifier we expect // Get stashed "look-behind" to decide what type of identifier we expect
const int lookBehind = driver_.resetStashedTokenId(); const int lookBehind = driver_.resetStashedTokenId();
@ -310,7 +309,7 @@ static int driverTokenType
#line 314 "patchExprScanner.cc" #line 313 "patchExprScanner.cc"
static const int patchExpr_start = 14; static const int patchExpr_start = 14;
static const int patchExpr_first_final = 14; static const int patchExpr_first_final = 14;
static const int patchExpr_error = 0; static const int patchExpr_error = 0;
@ -318,7 +317,7 @@ static const int patchExpr_error = 0;
static const int patchExpr_en_main = 14; static const int patchExpr_en_main = 14;
#line 470 "patchExprScanner.rl" #line 469 "patchExprScanner.rl"
@ -576,7 +575,7 @@ bool Foam::expressions::patchExpr::scanner::process
// Initialize FSM variables // Initialize FSM variables
#line 580 "patchExprScanner.cc" #line 579 "patchExprScanner.cc"
{ {
cs = patchExpr_start; cs = patchExpr_start;
ts = 0; ts = 0;
@ -584,18 +583,18 @@ bool Foam::expressions::patchExpr::scanner::process
act = 0; act = 0;
} }
#line 726 "patchExprScanner.rl" #line 725 "patchExprScanner.rl"
/* ^^^ FSM initialization here ^^^ */; /* ^^^ FSM initialization here ^^^ */;
#line 592 "patchExprScanner.cc" #line 591 "patchExprScanner.cc"
{ {
if ( p == pe ) if ( p == pe )
goto _test_eof; goto _test_eof;
switch ( cs ) switch ( cs )
{ {
tr2: tr2:
#line 339 "patchExprScanner.rl" #line 338 "patchExprScanner.rl"
{te = p+1;{ {te = p+1;{
// Emit identifier // Emit identifier
driver_.parsePosition() = (ts-buf); driver_.parsePosition() = (ts-buf);
@ -604,7 +603,7 @@ tr2:
}} }}
goto st14; goto st14;
tr4: tr4:
#line 339 "patchExprScanner.rl" #line 338 "patchExprScanner.rl"
{te = p+1;{ {te = p+1;{
// Emit identifier // Emit identifier
driver_.parsePosition() = (ts-buf); driver_.parsePosition() = (ts-buf);
@ -613,7 +612,7 @@ tr4:
}} }}
goto st14; goto st14;
tr5: tr5:
#line 314 "patchExprScanner.rl" #line 313 "patchExprScanner.rl"
{{p = ((te))-1;}{ {{p = ((te))-1;}{
// Emit number // Emit number
driver_.parsePosition() = (ts-buf); driver_.parsePosition() = (ts-buf);
@ -640,11 +639,11 @@ tr5:
}} }}
goto st14; goto st14;
tr8: tr8:
#line 387 "patchExprScanner.rl" #line 386 "patchExprScanner.rl"
{te = p+1;{ EMIT_TOKEN(EQUAL); }} {te = p+1;{ EMIT_TOKEN(EQUAL); }}
goto st14; goto st14;
tr9: tr9:
#line 339 "patchExprScanner.rl" #line 338 "patchExprScanner.rl"
{{p = ((te))-1;}{ {{p = ((te))-1;}{
// Emit identifier // Emit identifier
driver_.parsePosition() = (ts-buf); driver_.parsePosition() = (ts-buf);
@ -653,103 +652,103 @@ tr9:
}} }}
goto st14; goto st14;
tr11: tr11:
#line 446 "patchExprScanner.rl" #line 445 "patchExprScanner.rl"
{{p = ((te))-1;}{ EMIT_TOKEN(TENSOR); }} {{p = ((te))-1;}{ EMIT_TOKEN(TENSOR); }}
goto st14; goto st14;
tr13: tr13:
#line 457 "patchExprScanner.rl" #line 456 "patchExprScanner.rl"
{te = p+1;{ EMIT_TOKEN(IDENTITY_TENSOR); }} {te = p+1;{ EMIT_TOKEN(IDENTITY_TENSOR); }}
goto st14; goto st14;
tr14: tr14:
#line 445 "patchExprScanner.rl" #line 444 "patchExprScanner.rl"
{{p = ((te))-1;}{ EMIT_TOKEN(VECTOR); }} {{p = ((te))-1;}{ EMIT_TOKEN(VECTOR); }}
goto st14; goto st14;
tr16: tr16:
#line 454 "patchExprScanner.rl" #line 453 "patchExprScanner.rl"
{te = p+1;{ EMIT_VECTOR_TOKEN(1,0,0); }} {te = p+1;{ EMIT_VECTOR_TOKEN(1,0,0); }}
goto st14; goto st14;
tr17: tr17:
#line 455 "patchExprScanner.rl" #line 454 "patchExprScanner.rl"
{te = p+1;{ EMIT_VECTOR_TOKEN(0,1,0); }} {te = p+1;{ EMIT_VECTOR_TOKEN(0,1,0); }}
goto st14; goto st14;
tr18: tr18:
#line 456 "patchExprScanner.rl" #line 455 "patchExprScanner.rl"
{te = p+1;{ EMIT_VECTOR_TOKEN(0,0,1); }} {te = p+1;{ EMIT_VECTOR_TOKEN(0,0,1); }}
goto st14; goto st14;
tr19: tr19:
#line 390 "patchExprScanner.rl" #line 389 "patchExprScanner.rl"
{te = p+1;{ EMIT_TOKEN(LOR); }} {te = p+1;{ EMIT_TOKEN(LOR); }}
goto st14; goto st14;
tr23: tr23:
#line 372 "patchExprScanner.rl" #line 371 "patchExprScanner.rl"
{te = p+1;{ EMIT_TOKEN(PERCENT); }} {te = p+1;{ EMIT_TOKEN(PERCENT); }}
goto st14; goto st14;
tr26: tr26:
#line 373 "patchExprScanner.rl" #line 372 "patchExprScanner.rl"
{te = p+1;{ EMIT_TOKEN(LPAREN); }} {te = p+1;{ EMIT_TOKEN(LPAREN); }}
goto st14; goto st14;
tr27: tr27:
#line 374 "patchExprScanner.rl" #line 373 "patchExprScanner.rl"
{te = p+1;{ EMIT_TOKEN(RPAREN); }} {te = p+1;{ EMIT_TOKEN(RPAREN); }}
goto st14; goto st14;
tr28: tr28:
#line 375 "patchExprScanner.rl" #line 374 "patchExprScanner.rl"
{te = p+1;{ EMIT_TOKEN(TIMES); }} {te = p+1;{ EMIT_TOKEN(TIMES); }}
goto st14; goto st14;
tr29: tr29:
#line 376 "patchExprScanner.rl" #line 375 "patchExprScanner.rl"
{te = p+1;{ EMIT_TOKEN(PLUS); }} {te = p+1;{ EMIT_TOKEN(PLUS); }}
goto st14; goto st14;
tr30: tr30:
#line 378 "patchExprScanner.rl" #line 377 "patchExprScanner.rl"
{te = p+1;{ EMIT_TOKEN(COMMA); }} {te = p+1;{ EMIT_TOKEN(COMMA); }}
goto st14; goto st14;
tr31: tr31:
#line 377 "patchExprScanner.rl" #line 376 "patchExprScanner.rl"
{te = p+1;{ EMIT_TOKEN(MINUS); }} {te = p+1;{ EMIT_TOKEN(MINUS); }}
goto st14; goto st14;
tr33: tr33:
#line 380 "patchExprScanner.rl" #line 379 "patchExprScanner.rl"
{te = p+1;{ EMIT_TOKEN(DIVIDE); }} {te = p+1;{ EMIT_TOKEN(DIVIDE); }}
goto st14; goto st14;
tr35: tr35:
#line 382 "patchExprScanner.rl" #line 381 "patchExprScanner.rl"
{te = p+1;{ EMIT_TOKEN(COLON); }} {te = p+1;{ EMIT_TOKEN(COLON); }}
goto st14; goto st14;
tr39: tr39:
#line 381 "patchExprScanner.rl" #line 380 "patchExprScanner.rl"
{te = p+1;{ EMIT_TOKEN(QUESTION); }} {te = p+1;{ EMIT_TOKEN(QUESTION); }}
goto st14; goto st14;
tr41: tr41:
#line 393 "patchExprScanner.rl" #line 392 "patchExprScanner.rl"
{te = p+1;{ EMIT_TOKEN(BIT_XOR); }} {te = p+1;{ EMIT_TOKEN(BIT_XOR); }}
goto st14; goto st14;
tr59: tr59:
#line 366 "patchExprScanner.rl" #line 365 "patchExprScanner.rl"
{te = p;p--;} {te = p;p--;}
goto st14; goto st14;
tr60: tr60:
#line 371 "patchExprScanner.rl" #line 370 "patchExprScanner.rl"
{te = p;p--;{ EMIT_TOKEN(LNOT); }} {te = p;p--;{ EMIT_TOKEN(LNOT); }}
goto st14; goto st14;
tr61: tr61:
#line 388 "patchExprScanner.rl" #line 387 "patchExprScanner.rl"
{te = p+1;{ EMIT_TOKEN(NOT_EQUAL); }} {te = p+1;{ EMIT_TOKEN(NOT_EQUAL); }}
goto st14; goto st14;
tr62: tr62:
#line 391 "patchExprScanner.rl" #line 390 "patchExprScanner.rl"
{te = p;p--;{ EMIT_TOKEN(BIT_AND); }} {te = p;p--;{ EMIT_TOKEN(BIT_AND); }}
goto st14; goto st14;
tr63: tr63:
#line 389 "patchExprScanner.rl" #line 388 "patchExprScanner.rl"
{te = p+1;{ EMIT_TOKEN(LAND); }} {te = p+1;{ EMIT_TOKEN(LAND); }}
goto st14; goto st14;
tr64: tr64:
#line 379 "patchExprScanner.rl" #line 378 "patchExprScanner.rl"
{te = p;p--;{ EMIT_TOKEN(DOT); }} {te = p;p--;{ EMIT_TOKEN(DOT); }}
goto st14; goto st14;
tr67: tr67:
#line 314 "patchExprScanner.rl" #line 313 "patchExprScanner.rl"
{te = p;p--;{ {te = p;p--;{
// Emit number // Emit number
driver_.parsePosition() = (ts-buf); driver_.parsePosition() = (ts-buf);
@ -776,7 +775,7 @@ tr67:
}} }}
goto st14; goto st14;
tr69: tr69:
#line 346 "patchExprScanner.rl" #line 345 "patchExprScanner.rl"
{te = p;p--;{ {te = p;p--;{
// Tokenized ".method" - dispatch '.' and "method" separately // Tokenized ".method" - dispatch '.' and "method" separately
driver_.parsePosition() = (ts-buf); driver_.parsePosition() = (ts-buf);
@ -785,23 +784,23 @@ tr69:
}} }}
goto st14; goto st14;
tr70: tr70:
#line 383 "patchExprScanner.rl" #line 382 "patchExprScanner.rl"
{te = p;p--;{ EMIT_TOKEN(LESS); }} {te = p;p--;{ EMIT_TOKEN(LESS); }}
goto st14; goto st14;
tr71: tr71:
#line 384 "patchExprScanner.rl" #line 383 "patchExprScanner.rl"
{te = p+1;{ EMIT_TOKEN(LESS_EQ); }} {te = p+1;{ EMIT_TOKEN(LESS_EQ); }}
goto st14; goto st14;
tr72: tr72:
#line 385 "patchExprScanner.rl" #line 384 "patchExprScanner.rl"
{te = p;p--;{ EMIT_TOKEN(GREATER); }} {te = p;p--;{ EMIT_TOKEN(GREATER); }}
goto st14; goto st14;
tr73: tr73:
#line 386 "patchExprScanner.rl" #line 385 "patchExprScanner.rl"
{te = p+1;{ EMIT_TOKEN(GREATER_EQ); }} {te = p+1;{ EMIT_TOKEN(GREATER_EQ); }}
goto st14; goto st14;
tr74: tr74:
#line 339 "patchExprScanner.rl" #line 338 "patchExprScanner.rl"
{te = p;p--;{ {te = p;p--;{
// Emit identifier // Emit identifier
driver_.parsePosition() = (ts-buf); driver_.parsePosition() = (ts-buf);
@ -935,47 +934,47 @@ tr76:
} }
goto st14; goto st14;
tr92: tr92:
#line 415 "patchExprScanner.rl" #line 414 "patchExprScanner.rl"
{te = p;p--;{ EMIT_TOKEN(ATAN); }} {te = p;p--;{ EMIT_TOKEN(ATAN); }}
goto st14; goto st14;
tr107: tr107:
#line 411 "patchExprScanner.rl" #line 410 "patchExprScanner.rl"
{te = p;p--;{ EMIT_TOKEN(COS); }} {te = p;p--;{ EMIT_TOKEN(COS); }}
goto st14; goto st14;
tr142: tr142:
#line 404 "patchExprScanner.rl" #line 403 "patchExprScanner.rl"
{te = p;p--;{ EMIT_TOKEN(LOG); }} {te = p;p--;{ EMIT_TOKEN(LOG); }}
goto st14; goto st14;
tr149: tr149:
#line 420 "patchExprScanner.rl" #line 419 "patchExprScanner.rl"
{te = p;p--;{ EMIT_TOKEN(MAG); }} {te = p;p--;{ EMIT_TOKEN(MAG); }}
goto st14; goto st14;
tr157: tr157:
#line 424 "patchExprScanner.rl" #line 423 "patchExprScanner.rl"
{te = p;p--;{ EMIT_TOKEN(NEG); }} {te = p;p--;{ EMIT_TOKEN(NEG); }}
goto st14; goto st14;
tr174: tr174:
#line 423 "patchExprScanner.rl" #line 422 "patchExprScanner.rl"
{te = p;p--;{ EMIT_TOKEN(POS); }} {te = p;p--;{ EMIT_TOKEN(POS); }}
goto st14; goto st14;
tr194: tr194:
#line 410 "patchExprScanner.rl" #line 409 "patchExprScanner.rl"
{te = p;p--;{ EMIT_TOKEN(SIN); }} {te = p;p--;{ EMIT_TOKEN(SIN); }}
goto st14; goto st14;
tr214: tr214:
#line 407 "patchExprScanner.rl" #line 406 "patchExprScanner.rl"
{te = p;p--;{ EMIT_TOKEN(SQR); }} {te = p;p--;{ EMIT_TOKEN(SQR); }}
goto st14; goto st14;
tr230: tr230:
#line 412 "patchExprScanner.rl" #line 411 "patchExprScanner.rl"
{te = p;p--;{ EMIT_TOKEN(TAN); }} {te = p;p--;{ EMIT_TOKEN(TAN); }}
goto st14; goto st14;
tr236: tr236:
#line 446 "patchExprScanner.rl" #line 445 "patchExprScanner.rl"
{te = p;p--;{ EMIT_TOKEN(TENSOR); }} {te = p;p--;{ EMIT_TOKEN(TENSOR); }}
goto st14; goto st14;
tr247: tr247:
#line 445 "patchExprScanner.rl" #line 444 "patchExprScanner.rl"
{te = p;p--;{ EMIT_TOKEN(VECTOR); }} {te = p;p--;{ EMIT_TOKEN(VECTOR); }}
goto st14; goto st14;
st14: st14:
@ -986,7 +985,7 @@ st14:
case 14: case 14:
#line 1 "NONE" #line 1 "NONE"
{ts = p;} {ts = p;}
#line 990 "patchExprScanner.cc" #line 989 "patchExprScanner.cc"
switch( (*p) ) { switch( (*p) ) {
case 32: goto st15; case 32: goto st15;
case 33: goto st16; case 33: goto st16;
@ -1115,7 +1114,7 @@ st19:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof19; goto _test_eof19;
case 19: case 19:
#line 1119 "patchExprScanner.cc" #line 1118 "patchExprScanner.cc"
switch( (*p) ) { switch( (*p) ) {
case 69: goto st5; case 69: goto st5;
case 101: goto st5; case 101: goto st5;
@ -1166,7 +1165,7 @@ st22:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof22; goto _test_eof22;
case 22: case 22:
#line 1170 "patchExprScanner.cc" #line 1169 "patchExprScanner.cc"
switch( (*p) ) { switch( (*p) ) {
case 46: goto tr65; case 46: goto tr65;
case 69: goto st5; case 69: goto st5;
@ -1216,236 +1215,236 @@ case 25:
tr75: tr75:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 339 "patchExprScanner.rl" #line 338 "patchExprScanner.rl"
{act = 78;} {act = 78;}
goto st26; goto st26;
tr79: tr79:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 453 "patchExprScanner.rl" #line 452 "patchExprScanner.rl"
{act = 70;} {act = 70;}
goto st26; goto st26;
tr86: tr86:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 414 "patchExprScanner.rl" #line 413 "patchExprScanner.rl"
{act = 40;} {act = 40;}
goto st26; goto st26;
tr87: tr87:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 458 "patchExprScanner.rl" #line 457 "patchExprScanner.rl"
{act = 75;} {act = 75;}
goto st26; goto st26;
tr89: tr89:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 413 "patchExprScanner.rl" #line 412 "patchExprScanner.rl"
{act = 39;} {act = 39;}
goto st26; goto st26;
tr93: tr93:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 416 "patchExprScanner.rl" #line 415 "patchExprScanner.rl"
{act = 42;} {act = 42;}
goto st26; goto st26;
tr98: tr98:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 432 "patchExprScanner.rl" #line 431 "patchExprScanner.rl"
{act = 55;} {act = 55;}
goto st26; goto st26;
tr101: tr101:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 444 "patchExprScanner.rl" #line 443 "patchExprScanner.rl"
{act = 63;} {act = 63;}
goto st26; goto st26;
tr105: tr105:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 409 "patchExprScanner.rl" #line 408 "patchExprScanner.rl"
{act = 35;} {act = 35;}
goto st26; goto st26;
tr108: tr108:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 418 "patchExprScanner.rl" #line 417 "patchExprScanner.rl"
{act = 44;} {act = 44;}
goto st26; goto st26;
tr116: tr116:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 401 "patchExprScanner.rl" #line 400 "patchExprScanner.rl"
{act = 27;} {act = 27;}
goto st26; goto st26;
tr119: tr119:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 460 "patchExprScanner.rl" #line 459 "patchExprScanner.rl"
{act = 77;} {act = 77;}
goto st26; goto st26;
tr121: tr121:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 403 "patchExprScanner.rl" #line 402 "patchExprScanner.rl"
{act = 29;} {act = 29;}
goto st26; goto st26;
tr126: tr126:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 452 "patchExprScanner.rl" #line 451 "patchExprScanner.rl"
{act = 69;} {act = 69;}
goto st26; goto st26;
tr139: tr139:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 440 "patchExprScanner.rl" #line 439 "patchExprScanner.rl"
{act = 61;} {act = 61;}
goto st26; goto st26;
tr144: tr144:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 405 "patchExprScanner.rl" #line 404 "patchExprScanner.rl"
{act = 31;} {act = 31;}
goto st26; goto st26;
tr148: tr148:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 431 "patchExprScanner.rl" #line 430 "patchExprScanner.rl"
{act = 54;} {act = 54;}
goto st26; goto st26;
tr152: tr152:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 421 "patchExprScanner.rl" #line 420 "patchExprScanner.rl"
{act = 47;} {act = 47;}
goto st26; goto st26;
tr153: tr153:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 430 "patchExprScanner.rl" #line 429 "patchExprScanner.rl"
{act = 53;} {act = 53;}
goto st26; goto st26;
tr158: tr158:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 426 "patchExprScanner.rl" #line 425 "patchExprScanner.rl"
{act = 51;} {act = 51;}
goto st26; goto st26;
tr169: tr169:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 441 "patchExprScanner.rl" #line 440 "patchExprScanner.rl"
{act = 62;} {act = 62;}
goto st26; goto st26;
tr170: tr170:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 400 "patchExprScanner.rl" #line 399 "patchExprScanner.rl"
{act = 26;} {act = 26;}
goto st26; goto st26;
tr173: tr173:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 406 "patchExprScanner.rl" #line 405 "patchExprScanner.rl"
{act = 32;} {act = 32;}
goto st26; goto st26;
tr175: tr175:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 425 "patchExprScanner.rl" #line 424 "patchExprScanner.rl"
{act = 50;} {act = 50;}
goto st26; goto st26;
tr183: tr183:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 402 "patchExprScanner.rl" #line 401 "patchExprScanner.rl"
{act = 28;} {act = 28;}
goto st26; goto st26;
tr184: tr184:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 436 "patchExprScanner.rl" #line 435 "patchExprScanner.rl"
{act = 59;} {act = 59;}
goto st26; goto st26;
tr193: tr193:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 427 "patchExprScanner.rl" #line 426 "patchExprScanner.rl"
{act = 52;} {act = 52;}
goto st26; goto st26;
tr195: tr195:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 417 "patchExprScanner.rl" #line 416 "patchExprScanner.rl"
{act = 43;} {act = 43;}
goto st26; goto st26;
tr199: tr199:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 439 "patchExprScanner.rl" #line 438 "patchExprScanner.rl"
{act = 60;} {act = 60;}
goto st26; goto st26;
tr212: tr212:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 448 "patchExprScanner.rl" #line 447 "patchExprScanner.rl"
{act = 67;} {act = 67;}
goto st26; goto st26;
tr215: tr215:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 408 "patchExprScanner.rl" #line 407 "patchExprScanner.rl"
{act = 34;} {act = 34;}
goto st26; goto st26;
tr216: tr216:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 433 "patchExprScanner.rl" #line 432 "patchExprScanner.rl"
{act = 56;} {act = 56;}
goto st26; goto st26;
tr224: tr224:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 447 "patchExprScanner.rl" #line 446 "patchExprScanner.rl"
{act = 66;} {act = 66;}
goto st26; goto st26;
tr231: tr231:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 419 "patchExprScanner.rl" #line 418 "patchExprScanner.rl"
{act = 45;} {act = 45;}
goto st26; goto st26;
tr239: tr239:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 459 "patchExprScanner.rl" #line 458 "patchExprScanner.rl"
{act = 76;} {act = 76;}
goto st26; goto st26;
tr241: tr241:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 451 "patchExprScanner.rl" #line 450 "patchExprScanner.rl"
{act = 68;} {act = 68;}
goto st26; goto st26;
tr261: tr261:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 434 "patchExprScanner.rl" #line 433 "patchExprScanner.rl"
{act = 57;} {act = 57;}
goto st26; goto st26;
tr263: tr263:
#line 1 "NONE" #line 1 "NONE"
{te = p+1;} {te = p+1;}
#line 435 "patchExprScanner.rl" #line 434 "patchExprScanner.rl"
{act = 58;} {act = 58;}
goto st26; goto st26;
st26: st26:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof26; goto _test_eof26;
case 26: case 26:
#line 1449 "patchExprScanner.cc" #line 1448 "patchExprScanner.cc"
switch( (*p) ) { switch( (*p) ) {
case 46: goto tr75; case 46: goto tr75;
case 95: goto tr75; case 95: goto tr75;
@ -2212,7 +2211,7 @@ st68:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof68; goto _test_eof68;
case 68: case 68:
#line 2216 "patchExprScanner.cc" #line 2215 "patchExprScanner.cc"
switch( (*p) ) { switch( (*p) ) {
case 46: goto tr75; case 46: goto tr75;
case 58: goto st8; case 58: goto st8;
@ -3810,7 +3809,7 @@ st155:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof155; goto _test_eof155;
case 155: case 155:
#line 3814 "patchExprScanner.cc" #line 3813 "patchExprScanner.cc"
switch( (*p) ) { switch( (*p) ) {
case 46: goto tr75; case 46: goto tr75;
case 58: goto st9; case 58: goto st9;
@ -4009,7 +4008,7 @@ st165:
if ( ++p == pe ) if ( ++p == pe )
goto _test_eof165; goto _test_eof165;
case 165: case 165:
#line 4013 "patchExprScanner.cc" #line 4012 "patchExprScanner.cc"
switch( (*p) ) { switch( (*p) ) {
case 46: goto tr75; case 46: goto tr75;
case 58: goto st11; case 58: goto st11;
@ -4664,7 +4663,7 @@ case 13:
_out: {} _out: {}
} }
#line 728 "patchExprScanner.rl" #line 727 "patchExprScanner.rl"
/* ^^^ FSM execution here ^^^ */; /* ^^^ FSM execution here ^^^ */;
if (0 == cs) if (0 == cs)

View File

@ -57,8 +57,7 @@ namespace Foam
//- An {int, c_str} enum pairing for field types //- An {int, c_str} enum pairing for field types
#define FIELD_PAIR(Fld,T) { TOKEN_OF(T), Fld::typeName.c_str() } #define FIELD_PAIR(Fld,T) { TOKEN_OF(T), Fld::typeName.c_str() }
#undef HAS_LOOKBEHIND_TOKENS #define HAS_LOOKBEHIND_TOKENS
#ifdef HAS_LOOKBEHIND_TOKENS
// Special handling for these known (stashed) look-back types // Special handling for these known (stashed) look-back types
static const Enum<int> lookBehindTokenEnums static const Enum<int> lookBehindTokenEnums
({ ({
@ -68,7 +67,7 @@ static const Enum<int> lookBehindTokenEnums
TOKEN_PAIR("pointZone", POINT_ZONE), TOKEN_PAIR("pointSet", POINT_SET), TOKEN_PAIR("pointZone", POINT_ZONE), TOKEN_PAIR("pointSet", POINT_SET),
#endif #endif
}); });
#endif
// Special handling of predefined method types. Eg, .x(), .y(), ... // Special handling of predefined method types. Eg, .x(), .y(), ...
@ -188,7 +187,7 @@ static int driverTokenType
const word& ident const word& ident
) )
{ {
#if 0 #ifdef HAS_LOOKBEHIND_TOKENS
// Get stashed "look-behind" to decide what type of identifier we expect // Get stashed "look-behind" to decide what type of identifier we expect
const int lookBehind = driver_.resetStashedTokenId(); const int lookBehind = driver_.resetStashedTokenId();

View File

@ -45,13 +45,13 @@ Foam::expressions::volumeExpr::parseDriver::field_cellSelection
dimensionedScalar(Zero) dimensionedScalar(Zero)
); );
labelList selected; refPtr<labelList> tselected;
switch (setType) switch (setType)
{ {
case topoSetSource::sourceType::CELLZONE_SOURCE: case topoSetSource::sourceType::CELLZONE_SOURCE:
case topoSetSource::sourceType::CELLSET_SOURCE: case topoSetSource::sourceType::CELLSET_SOURCE:
{ {
selected = getTopoSetLabels(name, setType); tselected = getTopoSetLabels(name, setType);
break; break;
} }
@ -63,6 +63,7 @@ Foam::expressions::volumeExpr::parseDriver::field_cellSelection
break; break;
} }
} }
const auto& selected = tselected();
auto& fld = tresult.ref().primitiveFieldRef(); auto& fld = tresult.ref().primitiveFieldRef();
UIndirectList<scalar>(fld, selected) = scalar(1); UIndirectList<scalar>(fld, selected) = scalar(1);
@ -85,13 +86,13 @@ Foam::expressions::volumeExpr::parseDriver::field_faceSelection
dimensionedScalar(Zero) dimensionedScalar(Zero)
); );
labelList selected; refPtr<labelList> tselected;
switch (setType) switch (setType)
{ {
case topoSetSource::sourceType::FACESET_SOURCE: case topoSetSource::sourceType::FACESET_SOURCE:
case topoSetSource::sourceType::FACEZONE_SOURCE: case topoSetSource::sourceType::FACEZONE_SOURCE:
{ {
selected = getTopoSetLabels(name, setType); tselected = getTopoSetLabels(name, setType);
break; break;
} }
@ -103,6 +104,7 @@ Foam::expressions::volumeExpr::parseDriver::field_faceSelection
break; break;
} }
} }
const auto& selected = tselected();
const auto& bmesh = mesh().boundaryMesh(); const auto& bmesh = mesh().boundaryMesh();
@ -160,13 +162,13 @@ Foam::expressions::volumeExpr::parseDriver::field_pointSelection
dimensionedScalar(Zero) dimensionedScalar(Zero)
); );
labelList selected; refPtr<labelList> tselected;
switch (setType) switch (setType)
{ {
case topoSetSource::sourceType::POINTSET_SOURCE: case topoSetSource::sourceType::POINTSET_SOURCE:
case topoSetSource::sourceType::POINTZONE_SOURCE: case topoSetSource::sourceType::POINTZONE_SOURCE:
{ {
selected = getTopoSetLabels(name, setType); tselected = getTopoSetLabels(name, setType);
break; break;
} }
@ -178,6 +180,7 @@ Foam::expressions::volumeExpr::parseDriver::field_pointSelection
break; break;
} }
} }
const auto& selected = tselected();
auto& fld = tresult.ref().primitiveFieldRef(); auto& fld = tresult.ref().primitiveFieldRef();
UIndirectList<scalar>(fld, selected) = scalar(1); UIndirectList<scalar>(fld, selected) = scalar(1);