mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: createROMfields: new reduced-order model utility to reconstruct fields
This commit is contained in:
committed by
Andrew Heather
parent
b093e3a709
commit
c9d1f741ce
@ -0,0 +1,59 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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 "ROMmodel.H"
|
||||
#include "Time.H"
|
||||
#include "fvMesh.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(ROMmodel, 0);
|
||||
defineRunTimeSelectionTable(ROMmodel, dictionary);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::ROMmodel::ROMmodel
|
||||
(
|
||||
Time& runTime,
|
||||
fvMesh& mesh,
|
||||
const dictionary& dict,
|
||||
const instantList& times
|
||||
)
|
||||
:
|
||||
runTime_(runTime),
|
||||
mesh_(mesh),
|
||||
dict_(dict),
|
||||
times_(times)
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,163 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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/>.
|
||||
|
||||
Namespace
|
||||
Foam::ROMmodels
|
||||
|
||||
Description
|
||||
A namespace for various implementations of
|
||||
reduced-order (ROM) field creation models.
|
||||
|
||||
Class
|
||||
Foam::ROMmodel
|
||||
|
||||
Description
|
||||
Abstract base class for reduced-order models
|
||||
to handle specific model characteristics.
|
||||
|
||||
SourceFiles
|
||||
ROMmodel.C
|
||||
ROMmodelNew.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef Foam_ROMmodel_H
|
||||
#define Foam_ROMmodel_H
|
||||
|
||||
#include "runTimeSelectionTables.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward Declarations
|
||||
class Time;
|
||||
class fvMesh;
|
||||
class dictionary;
|
||||
class instant;
|
||||
typedef class List<instant> instantList;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class ROMmodel Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class ROMmodel
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected Data
|
||||
|
||||
//- Reference to the Time
|
||||
// Need non-const access to use setTime
|
||||
Time& runTime_;
|
||||
|
||||
//- Reference to the fvMesh
|
||||
// Need non-const access to use readFieldsHandler
|
||||
fvMesh& mesh_;
|
||||
|
||||
//- Const reference to the dictionary
|
||||
const dictionary& dict_;
|
||||
|
||||
//- Const reference to field times
|
||||
const instantList& times_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("ROMmodel");
|
||||
|
||||
|
||||
// Declare runtime constructor selection table
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
ROMmodel,
|
||||
dictionary,
|
||||
(
|
||||
Time& runTime,
|
||||
fvMesh& mesh,
|
||||
const dictionary& dict,
|
||||
const instantList& times
|
||||
),
|
||||
(runTime, mesh, dict, times)
|
||||
);
|
||||
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Return a reference to the selected ROMmodel
|
||||
static autoPtr<ROMmodel> New
|
||||
(
|
||||
Time& runTime,
|
||||
fvMesh& mesh,
|
||||
const dictionary& dict,
|
||||
const instantList& times
|
||||
);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
ROMmodel
|
||||
(
|
||||
Time& runTime,
|
||||
fvMesh& mesh,
|
||||
const dictionary& dict,
|
||||
const instantList& times
|
||||
);
|
||||
|
||||
//- No copy construct
|
||||
ROMmodel(const ROMmodel&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const ROMmodel&) = delete;
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~ROMmodel() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read model settings
|
||||
virtual bool read(const dictionary& dict) = 0;
|
||||
|
||||
//- Create and write fields
|
||||
virtual bool createAndWrite() = 0;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,60 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
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 "ROMmodel.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::ROMmodel> Foam::ROMmodel::New
|
||||
(
|
||||
Time& runTime,
|
||||
fvMesh& mesh,
|
||||
const dictionary& dict,
|
||||
const instantList& times
|
||||
)
|
||||
{
|
||||
const word modelType(dict.getWord("ROMmodel"));
|
||||
|
||||
auto* ctorPtr = dictionaryConstructorTable(modelType);
|
||||
|
||||
if (!ctorPtr)
|
||||
{
|
||||
FatalIOErrorInLookup
|
||||
(
|
||||
dict,
|
||||
"ROMmodel",
|
||||
modelType,
|
||||
*dictionaryConstructorTablePtr_
|
||||
) << exit(FatalIOError);
|
||||
}
|
||||
|
||||
return autoPtr<ROMmodel>(ctorPtr(runTime, mesh, dict, times));
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user