Product2I.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2024 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "Product2.H"
27 
28 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
29 
30 template<class Type, Foam::direction rank>
32 (
33  const scalar x,
34  const scalar y
35 ) const
36 {
37  const ProductFilter<Type> filter;
38  static const direction otherRank = pTraits<Type>::rank - rank;
39  const ProductFunction1s<Type, otherRank>& other = *this;
40 
41  if (fs.first().valid())
42  {
43  return filter(fs.first()->value(x)*other.fs.second()->value(y));
44  }
45  else if (fs.second().valid())
46  {
47  return filter(other.fs.first()->value(x)*fs.second()->value(y));
48  }
49  else
50  {
52  }
53 }
54 
55 
56 template<class Type>
58 (
59  const scalar x,
60  const scalar y
61 ) const
62 {
63  const ProductFilter<Type> filter;
64  return filter(fs.first()->value(x)*fs.second()->value(y));
65 }
66 
67 
68 template<class Type>
70 (
71  const scalar x,
72  const scalar y
73 ) const
74 {
75  return fs_.value(x, y);
76 }
77 
78 
79 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
80 
82 {
83  return "value" + Foam::name(argument + 1);
84 }
85 
86 
88 (
89  const direction argument,
90  const word& typeName
91 )
92 {
93  return
94  typeName.empty()
95  ? valueName(argument)
96  : valueName(argument) + "<" + typeName + ">";
97 }
98 
99 
100 template<class Type>
101 inline Foam::word Foam::Function2s::valueName(const direction argument)
102 {
103  return valueName(argument, pTraits<Type>::typeName);
104 }
105 
106 
108 (
109  const direction argument,
110  const Tuple2<word, label>& typeAndRank
111 )
112 {
113  return valueName(argument, typeAndRank.first());
114 }
115 
116 
117 // ************************************************************************* //
scalar y
Pair< autoPtr< function1Type > > fs
Functions.
Definition: Product2.H:170
Type value(const scalar x, const scalar y) const
Evaluate.
Definition: Product2I.H:32
virtual Type value(const scalar x, const scalar y) const
Return value.
Definition: Product2I.H:70
A 2-tuple for storing two objects of different types.
Definition: Tuple2.H:66
const Type1 & first() const
Return first.
Definition: Tuple2.H:119
Traits class for primitives.
Definition: pTraits.H:53
A class for handling words, derived from string.
Definition: word.H:62
word valueName(const direction argument)
Return the name of the value entry for the given argument.
Definition: Product2I.H:81
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
uint8_t direction
Definition: direction.H:45