Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CMakeLists_files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ if(ENABLE_ECL_INPUT)
opm/input/eclipse/EclipseState/Aquifer/NumericalAquifer/SingleNumericalAquifer.cpp
opm/input/eclipse/EclipseState/Aquifer/NumericalAquifer/NumericalAquifers.cpp
opm/input/eclipse/EclipseState/Compositional/CompositionalConfig.cpp
opm/input/eclipse/EclipseState/Grid/AutoRefinement.cpp
opm/input/eclipse/EclipseState/Grid/AutoRefManager.cpp
opm/input/eclipse/EclipseState/Grid/Box.cpp
opm/input/eclipse/EclipseState/Grid/BoxManager.cpp
opm/input/eclipse/EclipseState/Grid/Carfin.cpp
Expand All @@ -159,6 +161,7 @@ if(ENABLE_ECL_INPUT)
opm/input/eclipse/EclipseState/Grid/NNC.cpp
opm/input/eclipse/EclipseState/Grid/Operate.cpp
opm/input/eclipse/EclipseState/Grid/PinchMode.cpp
opm/input/eclipse/EclipseState/Grid/readKeywordAutoRef.cpp
opm/input/eclipse/EclipseState/Grid/readKeywordCarfin.cpp
opm/input/eclipse/EclipseState/Grid/RegionSetMatcher.cpp
opm/input/eclipse/EclipseState/Grid/SatfuncPropertyInitializers.cpp
Expand Down Expand Up @@ -555,6 +558,7 @@ if(ENABLE_ECL_INPUT)
tests/parser/ACTIONX.cpp
tests/parser/ADDREGTests.cpp
tests/parser/AquiferTests.cpp
tests/parser/AutorefTests.cpp
tests/parser/BCConfigTests.cpp
tests/parser/BoxTests.cpp
tests/parser/CarfinTests.cpp
Expand Down Expand Up @@ -1239,6 +1243,8 @@ if(ENABLE_ECL_INPUT)
opm/input/eclipse/EclipseState/Grid/RegionSetMatcher.hpp
opm/input/eclipse/EclipseState/Grid/SatfuncPropertyInitializers.hpp
opm/input/eclipse/EclipseState/Grid/Fault.hpp
opm/input/eclipse/EclipseState/Grid/AutoRefinement.hpp
opm/input/eclipse/EclipseState/Grid/AutoRefManager.hpp
opm/input/eclipse/EclipseState/Grid/Box.hpp
opm/input/eclipse/EclipseState/Grid/Carfin.hpp
opm/input/eclipse/EclipseState/Grid/LgrCollection.hpp
Expand All @@ -1253,6 +1259,7 @@ if(ENABLE_ECL_INPUT)
opm/input/eclipse/EclipseState/Grid/FaceDir.hpp
opm/input/eclipse/EclipseState/Grid/MapAxes.hpp
opm/input/eclipse/EclipseState/Grid/MinpvMode.hpp
opm/input/eclipse/EclipseState/Grid/readKeywordAutoRef.hpp
opm/input/eclipse/EclipseState/EndpointScaling.hpp
opm/input/eclipse/EclipseState/TracerConfig.hpp
opm/input/eclipse/EclipseState/WagHysteresisConfig.hpp
Expand Down
37 changes: 37 additions & 0 deletions opm/input/eclipse/EclipseState/Grid/AutoRefManager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
Copyright 2025 Equinor
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/>.
*/
#include <opm/input/eclipse/EclipseState/Grid/AutoRefinement.hpp>
#include <opm/input/eclipse/EclipseState/Grid/AutoRefManager.hpp>

#include <memory>

namespace Opm {

AutoRefManager::AutoRefManager()
{}

const AutoRefinement& AutoRefManager::getAutoRef() const
{ // Add check nullptr
return *m_keywordAutoRef;
}

void AutoRefManager::readKeywordAutoRef(int nx,
int ny,
int nz,
double option_trans_mult)
{
this->m_keywordAutoRef = std::make_unique<AutoRefinement>(nx, ny, nz, option_trans_mult);
}
} // namespace Opm
42 changes: 42 additions & 0 deletions opm/input/eclipse/EclipseState/Grid/AutoRefManager.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Copyright 2025 Equinor
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 AUTOREFMANAGER_HPP_
#define AUTOREFMANAGER_HPP_

#include <opm/input/eclipse/EclipseState/Grid/AutoRefinement.hpp>

#include <memory>

namespace Opm {

class AutoRefManager
{
public:
explicit AutoRefManager();

void readKeywordAutoRef(int nx,
int ny,
int nz,
double option_trans_mult);

const AutoRefinement& getAutoRef() const;

private:
std::unique_ptr<AutoRefinement> m_keywordAutoRef;
};
}

#endif
67 changes: 67 additions & 0 deletions opm/input/eclipse/EclipseState/Grid/AutoRefinement.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
Copyright (C) 2025 Equinor
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/>.
*/

#include <opm/input/eclipse/EclipseState/Grid/AutoRefinement.hpp>


#include <stdexcept>

namespace Opm {


AutoRefinement::AutoRefinement()
{}

AutoRefinement::AutoRefinement(int nx,
int ny,
int nz,
double option_trans_mult)
{
bool invalid = invalidRefinementFactor(nx) || invalidRefinementFactor(ny) || invalidRefinementFactor(nz);
bool notYet = (option_trans_mult>0);
if (invalid) {
throw std::invalid_argument("Refinement factors must be odd and positive.");
}
else if (notYet) {
throw std::invalid_argument("Only OPTION_TRANS_MULT 0 is supported for now.");
}
nx_ = nx;
ny_ = ny;
nz_ = nz;
}

int AutoRefinement::NX() const
{
return nx_;
}

int AutoRefinement::NY() const
{
return ny_;
}

int AutoRefinement::NZ() const
{
return nz_;
}

double AutoRefinement::OPTION_TRANS_MULT() const
{
// Throw if not equal to zero?
return option_trans_mult_;
}

} // namespace Opm

65 changes: 65 additions & 0 deletions opm/input/eclipse/EclipseState/Grid/AutoRefinement.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
Copyright (C) 2025 Equinor
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 OPM_INPUT_GRID_AUTOREFINEMENT_HPP
#define OPM_INPUT_GRID_AUTOREFINEMENT_HPP

namespace Opm {

class AutoRefinement {
public:
AutoRefinement();

/// @brief Constructs an AutoRefinement configuration.
///
/// Initializes the refinement factors in each grid direction (NX, NY, NZ)
/// and an optional transmissibility multiplier for refinement.
///
/// @param nx Refinement factor in the X direction (must be odd and positive).
/// @param ny Refinement factor in the Y direction (must be odd and positive).
/// @param nz Refinement factor in the Z direction (must be odd and positive).
/// @param option_trans_mult Optional transmissibility multiplier.
/// Currently only 0.0 is supported.
///
/// @throws std::invalid_argument
/// If any refinement factor is not odd and positive.
/// @throws std::invalid_argument
/// If option_trans_mult is not zero (feature not yet supported).
AutoRefinement(int nx,
int ny,
int nz,
double option_trans_mult);

int NX() const;
int NY() const;
int NZ() const;
double OPTION_TRANS_MULT() const;

private:
int nx_;
int ny_;
int nz_;
double option_trans_mult_{0.};

bool invalidRefinementFactor(int n)
{
return (n<=0) || (n%2 == 0);
}


};
}

#endif // OPM_INPUT_GRID_AUTOREFINEMENT_HPP
42 changes: 42 additions & 0 deletions opm/input/eclipse/EclipseState/Grid/readKeywordAutoRef.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Copyright (C) 2025 Equinor
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/>.
*/

#include <opm/input/eclipse/Deck/DeckItem.hpp>
#include <opm/input/eclipse/Deck/DeckRecord.hpp>

#include <opm/input/eclipse/EclipseState/Grid/AutoRefManager.hpp>
#include <opm/input/eclipse/EclipseState/Grid/readKeywordAutoRef.hpp>

#include <opm/input/eclipse/Parser/ParserKeywords/A.hpp> // AUTOREF

namespace Opm {

void readKeywordAutoRef(const DeckRecord& deckRecord, AutoRefManager& autoRefManager) {
const auto& NXItem = deckRecord.getItem<ParserKeywords::AUTOREF::NX>();
const auto& NYItem = deckRecord.getItem<ParserKeywords::AUTOREF::NY>();
const auto& NZItem = deckRecord.getItem<ParserKeywords::AUTOREF::NZ>();
const auto& OPTItem = deckRecord.getItem<ParserKeywords::AUTOREF::OPTION_TRANS_MULT>();

const auto& active_autoRef = autoRefManager.getAutoRef();

const int nx = NXItem.defaultApplied(0) ? active_autoRef.NX() : NXItem.get<int>(0);
const int ny = NYItem.defaultApplied(0) ? active_autoRef.NY() : NYItem.get<int>(0);
const int nz = NZItem.defaultApplied(0) ? active_autoRef.NZ() : NZItem.get<int>(0);
const double opt = OPTItem.defaultApplied(0) ? active_autoRef.OPTION_TRANS_MULT() : OPTItem.get<double>(0);

autoRefManager.readKeywordAutoRef(nx, ny, nz, opt);
}

}
27 changes: 27 additions & 0 deletions opm/input/eclipse/EclipseState/Grid/readKeywordAutoRef.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
Copyright (C) 2025 Equinor
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 READ_KEYWORD_AUTOREF_HPP
#define READ_KEYWORD_AUTOREF_HPP

namespace Opm {

class DeckRecord;
class AutoRefManager;

void readKeywordAutoRef(const DeckRecord& deckRecord, AutoRefManager& autoRefManager);

}
#endif
1 change: 1 addition & 0 deletions opm/input/eclipse/share/keywords/000_Eclipse100/A/AUTOREF
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"sections": [
"RUNSPEC"
],
"size": 1,
"items": [
{
"name": "NX",
Expand Down
Loading