mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Added FlowBCManager class.
This commit is contained in:
87
opm/core/pressure/FlowBCManager.cpp
Normal file
87
opm/core/pressure/FlowBCManager.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
Copyright 2012 SINTEF ICT, Applied Mathematics.
|
||||
|
||||
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/core/pressure/FlowBCManager.hpp>
|
||||
#include <opm/core/utility/ErrorMacros.hpp>
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
|
||||
|
||||
|
||||
/// Default constructor sets up empty boundary conditions.
|
||||
/// By convention, this is equivalent to all-noflow conditions.
|
||||
FlowBCManager::FlowBCManager()
|
||||
: bc_(0)
|
||||
{
|
||||
bc_ = flow_conditions_construct(0);
|
||||
if (!bc_) {
|
||||
THROW("Failed to construct FlowBoundaryConditions struct.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Destructor.
|
||||
FlowBCManager::~FlowBCManager()
|
||||
{
|
||||
flow_conditions_destroy(bc_);
|
||||
}
|
||||
|
||||
|
||||
/// Remove all appended BCs.
|
||||
/// By convention, BCs are now equivalent to all-noflow conditions.
|
||||
void FlowBCManager::clear()
|
||||
{
|
||||
flow_conditions_clear(bc_);
|
||||
}
|
||||
|
||||
|
||||
/// Append a single boundary condition.
|
||||
/// If the type is BC_NOFLOW the value argument is not used.
|
||||
/// If the type is BC_PRESSURE the value argument is a pressure value.
|
||||
/// If the type is BC_FLUX_TOTVOL the value argument is a total flux value (m^3/s).
|
||||
/// Note: unset boundary conditions are noflow by convention,
|
||||
/// so it is normally not necessary to explicitly append
|
||||
/// BC_NOFLOW conditions. However, it may make sense to do so
|
||||
/// if the bc will change during a simulation run.
|
||||
/// Note: if normal velocity bcs are desired, convert to
|
||||
/// fluxes by multiplying with face area.
|
||||
void FlowBCManager::append(const FlowBCType type,
|
||||
const int face,
|
||||
const double value)
|
||||
{
|
||||
int ok = flow_conditions_append(type, face, value, bc_);
|
||||
if (!ok) {
|
||||
THROW("Failed to append boundary condition for face " << face);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Access the managed boundary conditions.
|
||||
/// The method is named similarly to c_str() in std::string,
|
||||
/// to make it clear that we are returning a C-compatible struct.
|
||||
const FlowBoundaryConditions* FlowBCManager::c_bcs() const
|
||||
{
|
||||
return bc_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Opm
|
||||
75
opm/core/pressure/FlowBCManager.hpp
Normal file
75
opm/core/pressure/FlowBCManager.hpp
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
Copyright 2012 SINTEF ICT, Applied Mathematics.
|
||||
|
||||
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_FLOWBCMANAGER_HEADER_INCLUDED
|
||||
#define OPM_FLOWBCMANAGER_HEADER_INCLUDED
|
||||
|
||||
#include <opm/core/pressure/flow_bc.h>
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
|
||||
/// This class manages a FlowBoundaryConditions struct in the
|
||||
/// sense that it encapsulates creation and destruction of the
|
||||
/// data structure.
|
||||
/// The resulting struct is available through the c_bcs() method.
|
||||
class FlowBCManager
|
||||
{
|
||||
public:
|
||||
/// Default constructor sets up empty boundary conditions.
|
||||
/// By convention, this is equivalent to all-noflow conditions.
|
||||
FlowBCManager();
|
||||
|
||||
/// Destructor.
|
||||
~FlowBCManager();
|
||||
|
||||
/// Remove all appended BCs.
|
||||
/// By convention, BCs are now equivalent to all-noflow conditions.
|
||||
void clear();
|
||||
|
||||
/// Append a single boundary condition.
|
||||
/// If the type is BC_NOFLOW the value argument is not used.
|
||||
/// If the type is BC_PRESSURE the value argument is a pressure value.
|
||||
/// If the type is BC_FLUX_TOTVOL the value argument is a total flux value (m^3/s).
|
||||
/// Note: unset boundary conditions are noflow by convention,
|
||||
/// so it is normally not necessary to explicitly append
|
||||
/// BC_NOFLOW conditions. However, it may make sense to do so
|
||||
/// if the bc will change during a simulation run.
|
||||
/// Note: if normal velocity bcs are desired, convert to
|
||||
/// fluxes by multiplying with face area.
|
||||
void append(const FlowBCType type,
|
||||
const int face,
|
||||
const double value);
|
||||
|
||||
/// Access the managed boundary conditions.
|
||||
/// The method is named similarly to c_str() in std::string,
|
||||
/// to make it clear that we are returning a C-compatible struct.
|
||||
const FlowBoundaryConditions* c_bcs() const;
|
||||
|
||||
private:
|
||||
// Disable copying and assignment.
|
||||
FlowBCManager(const FlowBCManager& other);
|
||||
FlowBCManager& operator=(const FlowBCManager& other);
|
||||
// The managed struct.
|
||||
FlowBoundaryConditions* bc_;
|
||||
};
|
||||
|
||||
} // namespace Opm
|
||||
|
||||
#endif // OPM_FLOWBCMANAGER_HEADER_INCLUDED
|
||||
Reference in New Issue
Block a user