ENH: add patch expression support for face unit normal (#2691)

- make available as normal()
This commit is contained in:
Mark Olesen
2023-01-31 13:13:14 +01:00
parent 8ee7595a77
commit a6b3a31b28
6 changed files with 54 additions and 41 deletions

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -41,7 +41,8 @@ Description
area | The face area magnitudes | 0 |
weightAverage| Area weighted average | 1 |
weightSum | Area weighted sum | 1 |
face | The face areaNormal vectors | 0 |
face | The face area normal vectors | 0 |
normal | The face unit normal vectors | 0 |
point | A point-field point value | 1 |
faceToPoint | Interpolate face values onto points | 1 |
pointToFace | Interpolate point values onto faces | 1 |
@ -293,6 +294,9 @@ public:
//- The face areas with their vector direction [Sf] - (swak = face)
tmp<vectorField> field_areaNormal() const;
//- The face unit normal direction [nf] - (expression: normal)
tmp<vectorField> field_unitNormal() const;
//- The patch point locations - (swak = pts)
tmp<vectorField> field_pointField() const;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -167,6 +167,13 @@ Foam::expressions::patchExpr::parseDriver::field_areaNormal() const
}
Foam::tmp<Foam::vectorField>
Foam::expressions::patchExpr::parseDriver::field_unitNormal() const
{
return patch_.nf();
}
Foam::tmp<Foam::vectorField>
Foam::expressions::patchExpr::parseDriver::field_pointField() const
{

View File

@ -90,36 +90,37 @@
#define TOK_FACE_ZONE 90
#define TOK_FACE_AREA 91
#define TOK_FACE_EXPR 92
#define TOK_WEIGHT_AVERAGE 93
#define TOK_WEIGHT_SUM 94
#define TOK_POINT_EXPR 95
#define TOK_PSCALAR_ID 96
#define TOK_PVECTOR_ID 97
#define TOK_PSPH_TENSOR_ID 98
#define TOK_PSYM_TENSOR_ID 99
#define TOK_PTENSOR_ID 100
#define TOK_PBOOL_ID 101
#define TOK_POINTS 102
#define TOK_MAG 103
#define TOK_MAGSQR 104
#define TOK_VECTOR 105
#define TOK_TENSOR 106
#define TOK_SYM_TENSOR 107
#define TOK_SPH_TENSOR 108
#define TOK_CMPT_X 109
#define TOK_CMPT_Y 110
#define TOK_CMPT_Z 111
#define TOK_CMPT_XX 112
#define TOK_CMPT_XY 113
#define TOK_CMPT_XZ 114
#define TOK_CMPT_YX 115
#define TOK_CMPT_YY 116
#define TOK_CMPT_YZ 117
#define TOK_CMPT_ZX 118
#define TOK_CMPT_ZY 119
#define TOK_CMPT_ZZ 120
#define TOK_CMPT_II 121
#define TOK_TRANSPOSE 122
#define TOK_DIAG 123
#define TOK_POINT_TO_FACE 124
#define TOK_FACE_TO_POINT 125
#define TOK_FACE_NORMAL 93
#define TOK_WEIGHT_AVERAGE 94
#define TOK_WEIGHT_SUM 95
#define TOK_POINT_EXPR 96
#define TOK_PSCALAR_ID 97
#define TOK_PVECTOR_ID 98
#define TOK_PSPH_TENSOR_ID 99
#define TOK_PSYM_TENSOR_ID 100
#define TOK_PTENSOR_ID 101
#define TOK_PBOOL_ID 102
#define TOK_POINTS 103
#define TOK_MAG 104
#define TOK_MAGSQR 105
#define TOK_VECTOR 106
#define TOK_TENSOR 107
#define TOK_SYM_TENSOR 108
#define TOK_SPH_TENSOR 109
#define TOK_CMPT_X 110
#define TOK_CMPT_Y 111
#define TOK_CMPT_Z 112
#define TOK_CMPT_XX 113
#define TOK_CMPT_XY 114
#define TOK_CMPT_XZ 115
#define TOK_CMPT_YX 116
#define TOK_CMPT_YY 117
#define TOK_CMPT_YZ 118
#define TOK_CMPT_ZX 119
#define TOK_CMPT_ZY 120
#define TOK_CMPT_ZZ 121
#define TOK_CMPT_II 122
#define TOK_TRANSPOSE 123
#define TOK_DIAG 124
#define TOK_POINT_TO_FACE 125
#define TOK_FACE_TO_POINT 126

View File

@ -6,7 +6,7 @@ divert(-1)dnl
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2019-2021 OpenCFD Ltd.
# Copyright (C) 2019-2023 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -79,6 +79,7 @@ dnl
rule_driver_nullary(_scalar_, FACE_AREA, field_faceArea)dnl
rule_driver_nullary(_vector_, POS, field_faceCentre)dnl FACE_CENTRE
rule_driver_nullary(_vector_, FACE_EXPR, field_areaNormal)dnl
rule_driver_nullary(_vector_, FACE_NORMAL, field_unitNormal)dnl
dnl
rule_driver_inplace_unary(_scalar_, WEIGHT_AVERAGE, areaAverage)dnl
rule_driver_inplace_unary(_vector_, WEIGHT_AVERAGE, areaAverage)dnl

View File

@ -7,7 +7,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2022 OpenCFD Ltd.
Copyright (C) 2019-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -36,7 +36,6 @@ Description
#include "patchExprLemonParser.h"
#include "patchExprParser.H"
#include "Enum.H"
//#include "macros.H"
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
#pragma GCC diagnostic ignored "-Wunused-const-variable"
@ -159,6 +158,7 @@ static const Enum<int> funcTokenEnums
TOKEN_PAIR("faceToPoint", FACE_TO_POINT),
TOKEN_PAIR("pointToFace", POINT_TO_FACE),
TOKEN_PAIR("normal", FACE_NORMAL), // Face unitNormal
TOKEN_PAIR("area", FACE_AREA),
TOKEN_PAIR("pts", POINTS),
});

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2022 OpenCFD Ltd.
Copyright (C) 2019-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -34,7 +34,6 @@ Description
#include "patchExprLemonParser.h"
#include "patchExprParser.H"
#include "Enum.H"
//#include "macros.H"
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
#pragma GCC diagnostic ignored "-Wunused-const-variable"
@ -157,6 +156,7 @@ static const Enum<int> funcTokenEnums
TOKEN_PAIR("faceToPoint", FACE_TO_POINT),
TOKEN_PAIR("pointToFace", POINT_TO_FACE),
TOKEN_PAIR("normal", FACE_NORMAL), // Face unitNormal
TOKEN_PAIR("area", FACE_AREA),
TOKEN_PAIR("pts", POINTS),
});