topOSource.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2020-2023 PCOpt/NTUA
9  Copyright (C) 2020-2023 FOSS GP
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::fv::topOSource
29 
30 Group
31  grpFvOptionsSources
32 
33 Description
34  Implements Brinkman penalisation terms for topology optimisation.
35  Looks up the indicator field (beta) from the registry, through
36  topOVariablesBase
37 
38 SourceFiles
39  topOSource.C
40 
41 \*---------------------------------------------------------------------------*/
42 
43 #ifndef topOSource_H
44 #define topOSource_H
45 
46 #include "cellSetOption.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 namespace fv
55 {
56 
57 
58 /*---------------------------------------------------------------------------*\
59  Class topOSource Declaration
60 \*---------------------------------------------------------------------------*/
61 
62 class topOSource
63 :
64  public option
65 {
66 
67 protected:
68 
69  // Protected data
70 
71  //- Interpolation function
73 
74  //- Interpolation field name
76 
77  //- Optional betaMax
78  // If not found, the one known by topOVariablesBase will be used.
79  scalar betaMax_;
80 
81  //- Does this option apply to a Darcy flow model
82  bool darcyFlow_;
83 
84  //- Dimensionless Darcy number
86 
87 
88  // Protected Member Functions
89 
90  //- Compute the source term based on the indicator field
92 
93 
94 private:
95 
96  // Private Member Functions
97 
98  //- No copy construct
99  topOSource(const topOSource&) = delete;
100 
101  //- No copy assignment
102  void operator=(const topOSource&) = delete;
103 
104 
105 public:
106 
107  //- Runtime type information
108  TypeName("topOSource");
109 
110 
111  // Constructors
112 
113  //- Construct from components
114  topOSource
115  (
116  const word& name,
117  const word& modelType,
118  const dictionary& dict,
119  const fvMesh& mesh
120  );
121 
122 
123  //- Destructor
124  virtual ~topOSource() = default;
125 
126 
127  // Member Functions
128 
129  //- Add implicit contribution to momentum equation
130  virtual void addSup
131  (
132  fvMatrix<vector>& eqn,
133  const label fieldi
134  );
135 
136  //- Add implicit contribution to scalar equations
137  //- (e.g. turbulence model)
138  virtual void addSup
139  (
140  fvMatrix<scalar>& eqn,
141  const label fieldi
142  );
143 
144  //- Add implicit contribution to compressible momentum equation
145  virtual void addSup
146  (
147  const volScalarField& rho,
148  fvMatrix<vector>& eqn,
149  const label fieldi
150  );
151 
152  //- Add implicit contribution to compressible scalar equation
153  virtual void addSup
154  (
155  const volScalarField& rho,
156  fvMatrix<scalar>& eqn,
157  const label fieldi
158  );
159 
160  //- Multiply sensitivities with the derivative of the interpolation
161  //- function
162  virtual void postProcessSens
163  (
164  scalarField& sensField,
165  const word& fieldName = word::null,
166  const word& designValue = word::null
167  );
168 
169  //- Read source dictionary
170  virtual bool read(const dictionary& dict);
171 };
172 
173 
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 
176 } // End namespace fv
177 } // End namespace Foam
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 #endif
182 
183 // ************************************************************************* //
dictionary dict
bool darcyFlow_
Does this option apply to a Darcy flow model.
Definition: topOSource.H:86
const fvMesh & mesh() const noexcept
Return const access to the mesh database.
Definition: fvOptionI.H:30
autoPtr< topOInterpolationFunction > interpolation_
Interpolation function.
Definition: topOSource.H:69
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
TypeName("topOSource")
Runtime type information.
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: topOSource.C:194
virtual void addSup(fvMatrix< vector > &eqn, const label fieldi)
Add implicit contribution to momentum equation.
Definition: topOSource.C:110
virtual ~topOSource()=default
Destructor.
word interpolationFieldName_
Interpolation field name.
Definition: topOSource.H:74
A class for handling words, derived from Foam::string.
Definition: word.H:63
labelList fv(nPoints)
autoPtr< scalar > Da_
Dimensionless Darcy number.
Definition: topOSource.H:91
static const word null
An empty word.
Definition: word.H:84
A special matrix type and solver, designed for finite volume solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
Definition: fvPatchField.H:64
const word & name() const noexcept
Return const access to the source name.
Definition: fvOptionI.H:24
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Implements Brinkman penalisation terms for topology optimisation. Looks up the indicator field (beta)...
Definition: topOSource.H:57
scalar betaMax_
Optional betaMax.
Definition: topOSource.H:81
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
virtual void postProcessSens(scalarField &sensField, const word &fieldName=word::null, const word &designValue=word::null)
Multiply sensitivities with the derivative of the interpolation function.
Definition: topOSource.C:164
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Namespace for OpenFOAM.
virtual tmp< DimensionedField< scalar, volMesh > > getSource()
Compute the source term based on the indicator field.
Definition: topOSource.C:48
Base abstract class for handling finite volume options (i.e. fvOption).
Definition: fvOption.H:123