Loading...
Searching...
No Matches
invBP.C
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-------------------------------------------------------------------------------
11License
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\*---------------------------------------------------------------------------*/
28
29#include "invBP.H"
31
32// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33
34namespace Foam
35{
38 (
40 invBP,
42 );
43}
44
45
46// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47
48Foam::invBP::invBP
49(
50 const fvMesh& mesh,
51 const dictionary& dict
52)
53:
54 topOInterpolationFunction(mesh, dict),
55 b_(Function1<scalar>::New("b", dict))
56{}
57
58
59// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
60
62(
63 const scalarField& arg,
64 scalarField& res
65) const
66{
67 const scalar time(mesh_.time().timeOutputValue());
68 const scalar t(time == 0 ? 1. : time);
69 const scalar b(b_->value(t));
71 << type() << "::interpolate:: t, b value " << t << " " << b << endl;
72
73 res = arg*(b + 1)/( b*arg +1);
74}
75
76
79{
81 scalarField& deriv = tderiv.ref();
82
83 const scalar t(mesh_.time().timeOutputValue());
84 const scalar b(b_->value(t));
86 << type() << "::derivative:: t, b " << t << " " << b << endl;
87
88 deriv = (b + scalar(1))/sqr(scalar(1) + b*arg);
89
90 return tderiv;
91}
92
93
94// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition Function1.H:92
scalar timeOutputValue() const
Return the current user-time value. (ie, after applying any timeToUserTime() conversion).
Definition TimeStateI.H:24
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
const Time & time() const
Return the top-level database.
Definition fvMesh.H:360
Computes the Brickmann penalization function for topology optimisation, based in the inverse of the f...
Definition invBP.H:59
virtual void interpolate(const scalarField &arg, scalarField &res) const
Interpolate argument and write to result.
Definition invBP.C:55
virtual tmp< scalarField > derivative(const scalarField &arg) const
Return of function with respect to the argument field.
Definition invBP.C:71
A class for managing temporary objects.
Definition tmp.H:75
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
Definition tmp.H:215
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
Definition tmpI.H:235
static autoPtr< topOInterpolationFunction > New(const fvMesh &mesh, const dictionary &dict)
Return an autoPtr to the selected interpolation type.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
dynamicFvMesh & mesh
#define DebugInfo
Report an information message using Foam::Info.
Namespace for OpenFOAM.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition POSIX.C:801
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
dictionary dict
volScalarField & b