solvers::functions: New solver module to execute functionObjects in a time-loop

Description
    Solver module to execute the \c functionObjects for a specified solver

    The solver specified by either the \c subSolver or if not present the \c
    solver entry in the \c controlDict is instantiated to provide the physical
    fields needed by the \c functionObjects.  The \c functionObjects are then
    instantiated from the specifications are read from the \c functions entry in
    the \c controlDict and executed in a time-loop also controlled by entries in
    \c controlDict and the \c maxDeltaT() returned by the sub-solver.

    The fields and other objects registered by the sub-solver are set to
    NO_WRITE as they are not changed by the execution of the functionObjects and
    should not be written out each write-time.  Fields and other objects created
    and changed by the execution of the functionObjects are written out.

solvers::functions in conjunction with the scalarTransport functionObject
replaces scalarTransportFoam and provide more general handling of the scalar
diffusivity.
This commit is contained in:
Henry Weller
2023-01-27 14:31:58 +00:00
parent 260a8502f0
commit 8de6cd744e
25 changed files with 87357 additions and 12447 deletions

View File

@ -1,3 +0,0 @@
scalarTransportFoam.C
EXE = $(FOAM_APPBIN)/scalarTransportFoam

View File

@ -1,11 +0,0 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lfvModels \
-lfvConstraints \
-lmeshTools \
-lsampling

View File

@ -1,58 +0,0 @@
Info<< "Reading field T\n" << endl;
volScalarField T
(
IOobject
(
"T",
runTime.name(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.name(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info<< "Reading physicalProperties\n" << endl;
IOdictionary physicalProperties
(
IOobject
(
"physicalProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
);
Info<< "Reading diffusivity DT\n" << endl;
dimensionedScalar DT
(
physicalProperties.lookup("DT")
);
#include "createPhi.H"
#include "createFvModels.H"
#include "createFvConstraints.H"

View File

@ -1,87 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-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/>.
Application
scalarTransportFoam
Description
Solves the steady or transient transport equation for a passive scalar.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "fvModels.H"
#include "fvConstraints.H"
#include "simpleControl.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
#include "setRootCaseLists.H"
#include "createTime.H"
#include "createMesh.H"
simpleControl simple(mesh);
#include "createFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nCalculating scalar transport\n" << endl;
#include "CourantNo.H"
while (simple.loop(runTime))
{
Info<< "Time = " << runTime.userTimeName() << nl << endl;
fvModels.correct();
while (simple.correctNonOrthogonal())
{
fvScalarMatrix TEqn
(
fvm::ddt(T)
+ fvm::div(phi, T)
- fvm::laplacian(DT, T)
==
fvModels.source(T)
);
TEqn.relax();
fvConstraints.constrain(TEqn);
TEqn.solve();
fvConstraints.constrain(T);
}
runTime.write();
}
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -99,9 +99,6 @@ int main(int argc, char *argv[])
<< exit(FatalError);
}
// Load the solver library
libs.open("lib" + solverName + ".so");
// Create the default single region mesh
#include "createMesh.H"

View File

@ -0,0 +1,3 @@
functions.C
LIB = $(FOAM_LIBBIN)/libfunctions

View File

@ -0,0 +1,7 @@
EXE_INC = \
-I$(FOAM_SOLVERS)/modules/movingMesh/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude
LIB_LIBS = \
-lmovingMesh \
-lfiniteVolume

View File

@ -0,0 +1,110 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023 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 "functions.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace solvers
{
defineTypeNameAndDebug(functions, 0);
addToRunTimeSelectionTable(solver, functions, fvMesh);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::solvers::functions::functions(fvMesh& mesh)
:
movingMesh(mesh)
{
// Read the solverName from the subSolver or solver entry in controlDict
const word solverName
(
runTime.controlDict().found("subSolver")
? runTime.controlDict().lookup("subSolver")
: runTime.controlDict().lookup("solver")
);
// Instantiate the selected solver
solverPtr = (solver::New(solverName, mesh));
// Set all registered objects to NO_WRITE
// so only those created by the functionObjects are written
for
(
objectRegistry::iterator iter = mesh.objectRegistry::begin();
iter != mesh.objectRegistry::end();
++iter
)
{
iter()->writeOpt() = IOobject::NO_WRITE;
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::solvers::functions::~functions()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::scalar Foam::solvers::functions::maxDeltaT() const
{
return solverPtr->maxDeltaT();
}
void Foam::solvers::functions::prePredictor()
{}
void Foam::solvers::functions::momentumPredictor()
{}
void Foam::solvers::functions::thermophysicalPredictor()
{}
void Foam::solvers::functions::pressureCorrector()
{}
void Foam::solvers::functions::postCorrector()
{}
void Foam::solvers::functions::postSolve()
{}
// ************************************************************************* //

View File

@ -0,0 +1,135 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2023 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::solvers::functions
Description
Solver module to execute the \c functionObjects for a specified solver
The solver specified by either the \c subSolver or if not present the \c
solver entry in the \c controlDict is instantiated to provide the physical
fields needed by the \c functionObjects. The \c functionObjects are then
instantiated from the specifications are read from the \c functions entry in
the \c controlDict and executed in a time-loop also controlled by entries in
\c controlDict and the \c maxDeltaT() returned by the sub-solver.
The fields and other objects registered by the sub-solver are set to
NO_WRITE as they are not changed by the execution of the functionObjects and
should not be written out each write-time. Fields and other objects created
and changed by the execution of the functionObjects are written out.
SourceFiles
functions.C
\*---------------------------------------------------------------------------*/
#ifndef solvers_functions_H
#define solvers_functions_H
#include "movingMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace solvers
{
/*---------------------------------------------------------------------------*\
Class functions Declaration
\*---------------------------------------------------------------------------*/
class functions
:
public movingMesh
{
protected:
//- Pointer to the solid or fluid solver
autoPtr<solver> solverPtr;
public:
//- Runtime type information
TypeName("functions");
// Constructors
//- Construct from region mesh
functions(fvMesh& mesh);
//- Disallow default bitwise copy construction
functions(const functions&) = delete;
//- Destructor
virtual ~functions();
// Member Functions
//- Return the current maximum time-step for stable solution
virtual scalar maxDeltaT() const;
//- Called at the beginning of the PIMPLE loop
virtual void prePredictor();
//- Construct and optionally solve the momentum equation
virtual void momentumPredictor();
//- Construct and solve the energy equation,
// convert to temperature
// and update thermophysical and transport properties
virtual void thermophysicalPredictor();
//- Construct and solve the pressure equation in the PISO loop
virtual void pressureCorrector();
//- Correct the thermophysical transport modelling
virtual void postCorrector();
//- Called after the PIMPLE loop at the end of the time-step
virtual void postSolve();
// Member Operators
//- Disallow default bitwise assignment
void operator=(const functions&) = delete;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace solvers
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

62
bin/scalarTransportFoam Executable file
View File

@ -0,0 +1,62 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration | Website: https://openfoam.org
# \\ / A nd | Copyright (C) 2023 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/>.
#
# Script
# scalarTransportFoam
#
# Description
# Script to inform the user that scalarTransportFoam has been superseded
# and replaced by the more general functions solver module
# executed by the foamRun application.
#
# The solver specified by either the subSolver or if not present the solver
# entry in the controlDict is instantiated to provide the physical fields
# needed by the functionObjects. The functionObjects are then instantiated
# from the specifications are read from the functions entry in the
# controlDict and executed in a time-loop also controlled by entries in
# controlDict and the maxDeltaT() returned by the sub-solver.
#
# See tutorials/modules/incompressibleFluid/pitzDailyScalarTransport
#
#------------------------------------------------------------------------------
cat <<EOF
scalarTransportFoam has been superseded and replaced by the more general
functions solver module executed by the foamRun application:
foamRun -solver functions
The solver specified by either the subSolver or if not present the solver entry
in the controlDict is instantiated to provide the physical fields needed by the
functionObjects. The functionObjects are then instantiated from the
specifications are read from the functions entry in the controlDict and executed
in a time-loop also controlled by entries in controlDict and the maxDeltaT()
returned by the sub-solver. See:
tutorials/modules/incompressibleFluid/pitzDailyScalarTransport
EOF
#------------------------------------------------------------------------------

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2023 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -30,10 +30,10 @@ Description
- To specify the field name set the \c field entry
- To employ the same numerical schemes as another field set
the \c schemesField entry,
- The \c diffusivity entry can be set to \c none, \c constant, \c viscosity
- The \c diffusion entry can be set to \c none, \c constant, \c viscosity
- A constant diffusivity is specified with the \c D entry,
- If a momentum transport model is available and the \c viscosity
diffusivity option specified an effective diffusivity may be constructed
diffusion option specified an effective diffusivity may be constructed
from the laminar and turbulent viscosities using the diffusivity
coefficients \c alphal and \c alphat:
\verbatim

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,33 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: dev
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "constant";
object momentumTransport;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
simulationType RAS;
RAS
{
// Tested with kEpsilon, realizableKE, kOmega, kOmega2006, kOmegaSST, v2f,
// ShihQuadraticKE, LienCubicKE.
model kEpsilon;
turbulence on;
printCoeffs on;
viscosityModel Newtonian;
}
// ************************************************************************* //

View File

@ -14,7 +14,8 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
DT DT [0 2 -1 0 0 0 0] 0.01;
viscosityModel constant;
nu 1e-05;
// ************************************************************************* //

View File

@ -14,7 +14,11 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application scalarTransportFoam;
application foamRun;
solver functions;
subSolver incompressibleFluid;
startFrom startTime;
@ -44,5 +48,9 @@ timePrecision 6;
runTimeModifiable true;
functions
{
#includeFunc scalarTransport(T, diffusion=constant, D = 0.01)
}
// ************************************************************************* //

View File

@ -32,8 +32,7 @@ divSchemes
laplacianSchemes
{
default none;
laplacian(DT,T) Gauss linear corrected;
default Gauss linear corrected;
}
interpolationSchemes