Function1: Added squarePulse
This function gives a value of one during a user-specified duration, and
zero at all other times. It is useful for defining the time range in
which an injection or ignition heat source or similar operates.
Example usage, scaling a value:
<name>
{
type scale;
scale squarePulse;
start 0;
duration 1;
value 100;
}
This function has been utilised in a number of tutorial fvOption
configurations to provide a specific window in which the fvOption is
applied. This was previously achieved by "timeStart" and "duration"
controls hard coded into the fvOptions themselves.
This commit is contained in:
@ -96,6 +96,7 @@ primitives/functions/Function1/quadraticRamp/quadraticRamp.C
|
||||
primitives/functions/Function1/quarterSineRamp/quarterSineRamp.C
|
||||
primitives/functions/Function1/quarterCosineRamp/quarterCosineRamp.C
|
||||
primitives/functions/Function1/halfCosineRamp/halfCosineRamp.C
|
||||
primitives/functions/Function1/squarePulse/squarePulse.C
|
||||
primitives/functions/Function1/Table/tableBase.C
|
||||
primitives/functions/Function1/Table/TableReader/makeTableReaders.C
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2017-2020 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2017-2021 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2017-2020 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2017-2021 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
|
||||
@ -0,0 +1,75 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2021 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "squarePulse.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace Function1s
|
||||
{
|
||||
makeScalarFunction1(squarePulse);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::Function1s::squarePulse::read(const dictionary& dict)
|
||||
{
|
||||
start_ = dict.lookupOrDefault<scalar>("start", 0);
|
||||
duration_ = dict.lookup<scalar>("duration");
|
||||
}
|
||||
|
||||
|
||||
Foam::Function1s::squarePulse::squarePulse
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
FieldFunction1<scalar, squarePulse>(name)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Function1s::squarePulse::~squarePulse()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::Function1s::squarePulse::write(Ostream& os) const
|
||||
{
|
||||
writeEntry(os, "start", start_);
|
||||
writeEntry(os, "duration", duration_);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,161 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2021 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::Function1s::squarePulse
|
||||
|
||||
Description
|
||||
Square pulse function. Takes a value of 0 before \c start, then rises
|
||||
instantaneously to 1, remains at 1 for \c duration, then drops
|
||||
instantaneously back to 0.
|
||||
|
||||
Usage:
|
||||
\verbatim
|
||||
<name> squarePulse;
|
||||
<name>Coeffs
|
||||
{
|
||||
start 10;
|
||||
duration 20;
|
||||
}
|
||||
\endverbatim
|
||||
or
|
||||
\verbatim
|
||||
<name>
|
||||
{
|
||||
type squarePulse;
|
||||
start 10;
|
||||
duration 20;
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Where:
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
start | Start time | no | 0
|
||||
duration | Duration | yes |
|
||||
\endtable
|
||||
|
||||
See also
|
||||
Foam::Function1
|
||||
|
||||
SourceFiles
|
||||
squarePulse.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef squarePulse_H
|
||||
#define squarePulse_H
|
||||
|
||||
#include "Function1.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace Function1s
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class squarePulse Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class squarePulse
|
||||
:
|
||||
public FieldFunction1<scalar, squarePulse>
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Start-time of the ramp function
|
||||
scalar start_;
|
||||
|
||||
//- Duration of the ramp function
|
||||
scalar duration_;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Read the coefficients from the given dictionary
|
||||
void read(const dictionary& dict);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Runtime type information
|
||||
TypeName("squarePulse");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from name and dictionary
|
||||
squarePulse
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~squarePulse();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return value for time t
|
||||
virtual inline scalar value(const scalar t) const;
|
||||
|
||||
//- Return the integral between times t1 and t2
|
||||
virtual inline scalar integral
|
||||
(
|
||||
const scalar t1,
|
||||
const scalar t2
|
||||
) const;
|
||||
|
||||
//- Write data to dictionary stream
|
||||
virtual void write(Ostream& os) const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const squarePulse&) = delete;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Function1s
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "squarePulseI.H"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,47 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2021 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "squarePulse.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::scalar Foam::Function1s::squarePulse::value(const scalar t) const
|
||||
{
|
||||
return start_ < t && t < start_ + duration_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::Function1s::squarePulse::integral
|
||||
(
|
||||
const scalar t1,
|
||||
const scalar t2
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
return NaN;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -21,9 +21,8 @@ options
|
||||
{
|
||||
type semiImplicitSource;
|
||||
|
||||
timeStart 0;
|
||||
duration 1e6;
|
||||
selectionMode all;
|
||||
|
||||
volumeMode specific;
|
||||
|
||||
sources
|
||||
|
||||
@ -15,6 +15,32 @@ FoamFile
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
ignition
|
||||
{
|
||||
type semiImplicitSource;
|
||||
|
||||
selectionMode cellSet;
|
||||
cellSet ignition;
|
||||
|
||||
volumeMode specific;
|
||||
|
||||
sources
|
||||
{
|
||||
h
|
||||
{
|
||||
explicit
|
||||
{
|
||||
type scale;
|
||||
scale squarePulse;
|
||||
start 0;
|
||||
duration 1;
|
||||
value 5e7; // kg/m/s^3
|
||||
}
|
||||
implicit 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
radiation
|
||||
{
|
||||
type radiation;
|
||||
|
||||
@ -19,8 +19,6 @@ momentumSource
|
||||
{
|
||||
type semiImplicitSource;
|
||||
|
||||
timeStart 0.0;
|
||||
duration 1000;
|
||||
selectionMode all;
|
||||
|
||||
volumeMode specific;
|
||||
|
||||
@ -48,8 +48,6 @@ massSource
|
||||
{
|
||||
type semiImplicitSource;
|
||||
|
||||
timeStart 0.2;
|
||||
duration 2.0;
|
||||
selectionMode points;
|
||||
points
|
||||
(
|
||||
@ -58,29 +56,53 @@ massSource
|
||||
|
||||
volumeMode absolute;
|
||||
|
||||
squarePulse
|
||||
{
|
||||
type scale;
|
||||
scale squarePulse;
|
||||
start 0.2;
|
||||
duration 2;
|
||||
}
|
||||
|
||||
sources
|
||||
{
|
||||
rho
|
||||
{
|
||||
explicit 1e-4; // kg/s
|
||||
explicit
|
||||
{
|
||||
$squarePulse;
|
||||
value 1e-4; // kg/s
|
||||
}
|
||||
implicit 0;
|
||||
}
|
||||
|
||||
U
|
||||
{
|
||||
explicit (0 0.005 0);
|
||||
explicit
|
||||
{
|
||||
$squarePulse;
|
||||
value (0 0.005 0);
|
||||
}
|
||||
implicit 0;
|
||||
}
|
||||
|
||||
h
|
||||
{
|
||||
explicit 10;
|
||||
explicit
|
||||
{
|
||||
$squarePulse;
|
||||
value 10;
|
||||
}
|
||||
implicit 0;
|
||||
}
|
||||
|
||||
H2O
|
||||
{
|
||||
explicit 1e-4; // kg/s
|
||||
explicit
|
||||
{
|
||||
$squarePulse;
|
||||
value 1e-4; // kg/s
|
||||
}
|
||||
implicit 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,10 +21,12 @@ source1
|
||||
|
||||
timeStart 0.1;
|
||||
duration 0.4;
|
||||
|
||||
selectionMode cellSet;
|
||||
cellSet ignitionCells;
|
||||
|
||||
mode uniform;
|
||||
|
||||
temperature 2000;
|
||||
}
|
||||
|
||||
|
||||
@ -32,9 +32,6 @@ option1
|
||||
|
||||
value (2 0 0);
|
||||
lambda 0.5;
|
||||
|
||||
timeStart 0;
|
||||
duration 1e6;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -31,9 +31,6 @@ option1
|
||||
}
|
||||
|
||||
lambda 0.5;
|
||||
|
||||
timeStart 0;
|
||||
duration 1e6;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -21,9 +21,6 @@ options
|
||||
{
|
||||
type massSource;
|
||||
|
||||
timeStart 0.1;
|
||||
duration 5;
|
||||
|
||||
selectionMode points;
|
||||
points
|
||||
(
|
||||
|
||||
@ -21,9 +21,6 @@ options
|
||||
{
|
||||
type massSource;
|
||||
|
||||
timeStart 1;
|
||||
duration 500;
|
||||
|
||||
selectionMode points;
|
||||
points
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user