Files
opm-simulators/flowexperimental/comp/flow_comp.hpp
T
hnilandClaude Fable 5 aac6802a09 Fix formatting of new files
Remove trailing whitespace, add missing end-of-file newlines and add
the standard license header to the new ComponentName files.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 10:00:52 +02:00

302 lines
9.6 KiB
C++

/*
Copyright 2024, SINTEF Digital
This file is part of the Open Porous Media project (OPM).
OPM 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.
OPM 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 OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef FLOW_COMP_HPP
#define FLOW_COMP_HPP
#include <memory>
#include <opm/material/constraintsolvers/PTFlash.hpp>
#include <opm/material/fluidsystems/GenericOilGasWaterFluidSystem.hpp>
#include <opm/models/discretization/common/baseauxiliarymodule.hh>
#include <opm/models/nonlinear/newtonmethod.hh>
#include <opm/models/ptflash/flashmodel.hh>
#include <opm/simulators/flow/Main.hpp>
#include <opm/simulators/flow/FlowProblemComp.hpp>
#include <opm/simulators/flow/FlowProblemCompProperties.hpp>
#include <opm/simulators/linalg/parallelbicgstabbackend.hh>
#include <flowexperimental/comp/EmptyModel.hpp>
#include <flowexperimental/comp/wells/CompWellModel.hpp>
// // the current code use eclnewtonmethod adding other conditions to proceed_ should do the trick for KA
// // adding linearshe sould be chaning the update_ function in the same class with condition that the error is reduced.
// the trick is to be able to recalculate the residual from here.
// unsure where the timestepping is done from suggestedtime??
// suggestTimeStep is taken from newton solver in problem.limitTimestep
namespace Opm {
template<int numComp, bool EnableWater>
int dispatchFlowComp(int argc, char** argv);
} // namespace Opm
namespace Opm::Properties {
template <class TypeTag, class MyTypeTag>
struct DiscNewtonMethod;
template <class TypeTag, class MyTypeTag>
struct WellModel;
template <class TypeTag, class MyTypeTag>
struct TracerModel;
namespace TTag {
template<int NumComp, bool EnableWater>
struct FlowCompProblem {
using InheritsFrom = std::tuple<FlowBaseProblemComp, FlashModel>;
};
}
template<class TypeTag, int NumComp, bool EnableWater>
struct SparseMatrixAdapter<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
enum { numEq = getPropValue<TypeTag, Properties::NumEq>() };
using Block = MatrixBlock<Scalar, numEq, numEq>;
public:
using type = typename Linear::IstlSparseMatrixAdapter<Block>;
};
// NOTE: Do NOT override NewtonMethod here.
// The inherited model configuration decides the solver implementation.
#if 0
template<class TypeTag>
struct SolidEnergyLaw<TypeTag, TTag::FlowCompProblem>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
public:
using EclThermalLawManager = ::Opm::EclThermalLawManager<Scalar, FluidSystem>;
using type = typename EclThermalLawManager::SolidEnergyLaw;
};
// Set the material law for thermal conduction
template<class TypeTag>
struct ThermalConductionLaw<TypeTag, TTag::FlowCompProblem>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
public:
using EclThermalLawManager = ::Opm::EclThermalLawManager<Scalar, FluidSystem>;
using type = typename EclThermalLawManager::ThermalConductionLaw;
};
template <class TypeTag>
struct SpatialDiscretizationSplice<TypeTag, TTag::FlowCompProblem>
{
using type = TTag::EcfvDiscretization;
};
template <class TypeTag>
struct LocalLinearizerSplice<TypeTag, TTag::FlowCompProblem>
{
using type = TTag::AutoDiffLocalLinearizer;
};
#endif
// Set the problem property
template <class TypeTag, int NumComp, bool EnableWater>
struct Problem<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>>
{
using type = FlowProblemComp<TypeTag>;
};
template<class TypeTag, int NumComp, bool EnableWater>
struct AquiferModel<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
using type = EmptyModel<TypeTag>;
};
template<class TypeTag, int NumComp, bool EnableWater>
struct WellModel<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
using type = CompWellModel<TypeTag>;
};
template<class TypeTag, int NumComp, bool EnableWater>
struct TracerModel<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
using type = EmptyModel<TypeTag>;
};
template <class TypeTag, int NumComp, bool EnableWater>
struct FlashSolver<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
using Evaluation = GetPropType<TypeTag, Properties::Evaluation>;
public:
using type = Opm::PTFlash<Scalar, FluidSystem>;
};
template <class TypeTag, class MyTypeTag>
struct NumComp { using type = UndefinedProperty; };
// TODO: this is unfortunate, have to check why we need to hard-code it
template <class TypeTag, int NumComp_, bool EnableWater_>
struct NumComp<TypeTag, TTag::FlowCompProblem<NumComp_, EnableWater_>> {
static constexpr int value = NumComp_;
};
template <class TypeTag, class MyTypeTag>
struct EnableDummyWater { using type = UndefinedProperty; };
template <class TypeTag, int NumComp_, bool EnableWater_>
struct EnableDummyWater<TypeTag, TTag::FlowCompProblem<NumComp_, EnableWater_>> {
static constexpr bool value = EnableWater_;
};
#if 0
struct Temperature { using type = UndefinedProperty; };
template <class TypeTag>
struct Temperature<TypeTag, TTag::FlowCompProblem> {
using type = GetPropType<TypeTag, Scalar>;
static constexpr type value = 423.25;
};
#endif
template <class TypeTag, int NumComp_, bool EnableWater_>
struct FluidSystem<TypeTag, TTag::FlowCompProblem<NumComp_, EnableWater_>>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
static constexpr int num_comp = getPropValue<TypeTag, Properties::NumComp>();
static constexpr bool enable_water = getPropValue<TypeTag, Properties::EnableDummyWater>();
public:
using type = Opm::GenericOilGasWaterFluidSystem<Scalar, num_comp, enable_water>;
};
template<class TypeTag, int NumComp, bool EnableWater>
struct EnableMech<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
static constexpr bool value = false;
};
template<class TypeTag, int NumComp, bool EnableWater>
struct EnableDisgasInWater<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
static constexpr bool value = false;
};
template<class TypeTag, int NumComp, bool EnableWater>
struct Stencil<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using GridView = GetPropType<TypeTag, Properties::GridView>;
public:
using type = EcfvStencil<Scalar, GridView>;
};
template<class TypeTag, int NumComp, bool EnableWater>
struct EnableApiTracking<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
static constexpr bool value = false;
};
template<class TypeTag, int NumComp, bool EnableWater>
struct EnableSaltPrecipitation<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
static constexpr bool value = false;
};
template<class TypeTag, int NumComp, bool EnableWater>
struct EnablePolymerMW<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
static constexpr bool value = false;
};
template<class TypeTag, int NumComp, bool EnableWater>
struct EnablePolymer<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
static constexpr bool value = false;
};
template<class TypeTag, int NumComp, bool EnableWater>
struct EnableDispersion<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
static constexpr bool value = false;
};
template<class TypeTag, int NumComp, bool EnableWater>
struct EnableBrine<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
static constexpr bool value = false;
};
template<class TypeTag, int NumComp, bool EnableWater>
struct EnableVapwat<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
static constexpr bool value = false;
};
template<class TypeTag, int NumComp, bool EnableWater>
struct EnableSolvent<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
static constexpr bool value = false;
};
template<class TypeTag, int NumComp, bool EnableWater>
struct EnableFoam<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
static constexpr bool value = false;
};
template<class TypeTag, int NumComp, bool EnableWater>
struct EnableExtbo<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
static constexpr bool value = false;
};
template<class TypeTag, int NumComp, bool EnableWater>
struct EnableBioeffects<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>> {
static constexpr bool value = false;
};
template<class TypeTag, int NumComp, bool EnableWater>
struct EnableDebuggingChecks<TypeTag, TTag::FlowCompProblem<NumComp, EnableWater>>{
static constexpr bool value = false;
};
// disable thermal flux boundaries by default
#if 0
template<class TypeTag>
struct EnableThermalFluxBoundaries<TypeTag, TTag::FlowCompProblem> {
static constexpr bool value = false;
};
#endif
} // namespace Opm::Properties
namespace Opm {
template<int numComp, bool EnableWater>
int dispatchFlowComp(int argc, char** argv)
{
using TypeTag = Properties::TTag::FlowCompProblem<numComp, EnableWater>;
auto mainObject = std::make_unique<Opm::Main>(argc, argv);
const auto ret = mainObject->runStatic<TypeTag>();
mainObject.reset();
return ret;
}
} // namespace Opm
#endif