ENH: support exprField specification for SemiImplicitSource

- this allows more flexibility when defining the location or intensity
  of sources.

  For example,

  {
      type            scalarSemiImplicitSource;
      volumeMode      specific;
      selectionMode   all;

      sources
      {
          tracer0
          {
              explicit
              {
                  type       exprField;

                  functions<scalar>
                  {
                      square
                      {
                          type square;
                          scale 0.0025;
                          level 0.0025;
                          frequency 10;
                      }
                  }

                  expression
                  #{
                      (hypot(pos().x() + 0.025, pos().y()) < 0.01)
                    ? fn:square(time())
                    : 0
                  #};
              }
          }
      }
  }

ENH: SemiImplicitSource: handle "sources" with explicit/implicit entries

- essentially the same as injectionRateSuSp with Su/Sp,
  but potentially clearer in purpose.

ENH: add Function1 good() method to define if function can be evaluated

- for example, provides a programmatic means of avoiding the 'none'
  function
This commit is contained in:
Mark Olesen
2022-05-30 13:27:22 +02:00
parent ef743147ea
commit d2e10bca40
14 changed files with 575 additions and 107 deletions

View File

@ -0,0 +1,47 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2206 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object tracer0;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 0 0 0 0];
internalField uniform 0;
boundaryField
{
#includeEtc "caseDicts/setConstraintTypes"
rotor
{
type zeroGradient;
}
stator
{
type zeroGradient;
}
front
{
type empty;
}
back
{
type empty;
}
}
// ************************************************************************* //

View File

@ -33,9 +33,50 @@ tracer0
}
}
injectionRateSuSp
sources
{
tracer0 (0.01 0);
tracer0
{
explicit constant 0.01;
}
}
}
source2
{
type scalarSemiImplicitSource;
volumeMode specific;
selectionMode all;
sources
{
tracer0
{
explicit
{
type exprField;
functions<scalar>
{
square
{
type square;
scale 0.0025;
level 0.0025;
frequency 10;
}
}
expression
#{
(hypot(pos().x() + 0.025, pos().y()) < 0.01)
? fn:square(time())
: 0
#};
}
}
}
}
}

View File

@ -49,10 +49,24 @@ IOdictionary fvOptions
IOobject::NO_WRITE
)
);
const dictionary& gradPDict =
fvOptions.subDict("momentumSource").subDict("injectionRateSuSp");
const scalar K =
gradPDict.get<Tuple2<vector, scalar>>("U").first().x();
scalar K(0);
// Get x() component from U source
{
const dictionary& momSource = fvOptions.subDict("momentumSource");
if (momSource.findDict("sources"))
{
K = momSource.subDict("sources")
.get<Tuple2<vector, scalar>>("U").first().x();
}
else
{
K = momSource.subDict("injectionRateSuSp")
.get<Tuple2<vector, scalar>>("U").first().x();
}
}
dictionary probes(IFstream(runTime.system()/"probes")());
const point location = pointField(probes.lookup("probeLocations"))[0];