Loading...
Searching...
No Matches
mpc.hh
Go to the documentation of this file.
//==============================================================================
//==============================================================================
#ifndef MPC_HH_
#define MPC_HH_
#include <map>
#include <vector>
#include <iosfwd>
#include <set>
namespace Opm {
namespace Elasticity {
enum Direction { NONE = 0, X = 1, Y = 2, Z = 4,
XY = 1+2, XZ = 1+4, YZ = 2+4,
XYZ = 1+2+4 };
class MPC
{
public:
struct DOF
{
DOF() : node(0), dof(0), coeff(double(0)) {}
DOF(int n, int d, double c = double(0)) : node(n), dof(d), coeff(c) {}
friend std::ostream& operator<<(std::ostream& s, const DOF& d);
int node;
int dof;
double coeff;
};
class Less {
public:
bool operator()(const MPC* lhs, const MPC* rhs) const;
static bool compareSlaveDofOnly;
};
MPC(int n, int d, double c = double(0)) : slave(n,d,c) { iceq = -1; }
void addMaster(int n, int d, double c = double(1), double tol = double(1.0e-8))
{
if (c < -tol || c > tol) master.push_back(DOF(n,d,c));
}
void updateMaster(size_t pos, double c)
{
if (pos < master.size())
master[pos].coeff = c;
}
void removeMaster(size_t pos)
{
if (pos < master.size())
master.erase(master.begin()+pos);
}
void addOffset(double offset) { slave.coeff += offset; }
void setSlaveCoeff(double c0) { slave.coeff = c0; }
const DOF& getSlave() const { return slave; }
const DOF& getMaster(size_t i) const { return master[i]; }
size_t getNoMaster() const { return master.size(); }
friend std::ostream& operator<<(std::ostream& s, const MPC& mpc);
int iceq;
private:
DOF slave;
std::vector<DOF> master;
};
typedef std::set<MPC*,MPC::Less> MPCSet;
typedef std::map<int,MPC*> MPCMap;
}
}
#endif
Opm::Elasticity::MPC::Less
Comparison predicate for MPCs.
Definition mpc.hh:86
Opm::Elasticity::MPC::Less::operator()
bool operator()(const MPC *lhs, const MPC *rhs) const
Comparison operator used when inserting an MPC-pointer into a set<MPC*,MPC::Less> object.
Definition mpc.cpp:39
Opm::Elasticity::MPC::Less::compareSlaveDofOnly
static bool compareSlaveDofOnly
Indicates whether only the slave dof number should affect sorting.
Definition mpc.hh:93
Opm::Elasticity::MPC
A class for representing a general multi-point constraint equation.
Definition mpc.hh:59
Opm::Elasticity::MPC::operator<<
friend std::ostream & operator<<(std::ostream &s, const MPC &mpc)
Global stream operator printing a constraint equation.
Definition mpc.cpp:63
Opm::Elasticity::MPC::getNoMaster
size_t getNoMaster() const
Returns the number of master DOFs.
Definition mpc.hh:141
Opm::Elasticity::MPC::setSlaveCoeff
void setSlaveCoeff(double c0)
Assigns a new c0 coefficient to the constraint equation.
Definition mpc.hh:133
Opm::Elasticity::MPC::MPC
MPC(int n, int d, double c=double(0))
Constructor creating a constraint for a specified slave DOF with no master DOFs.
Definition mpc.hh:102
Opm::Elasticity::MPC::addMaster
void addMaster(int n, int d, double c=double(1), double tol=double(1.0e-8))
Adds a master DOF to the constraint equation.
Definition mpc.hh:110
Opm::Elasticity::MPC::getSlave
const DOF & getSlave() const
Returns a reference to the slave DOF.
Definition mpc.hh:136
Opm::Elasticity::MPC::addOffset
void addOffset(double offset)
Increments the c0 coefficient by a given offset.
Definition mpc.hh:130
Opm::Elasticity::MPC::iceq
int iceq
Global constraint equation identifier.
Definition mpc.hh:146
Opm::Elasticity::MPC::removeMaster
void removeMaster(size_t pos)
Removes the pos'th master DOF from the constraint equation.
Definition mpc.hh:123
Opm::Elasticity::MPC::updateMaster
void updateMaster(size_t pos, double c)
Updates the coefficient of the pos'th master DOF.
Definition mpc.hh:116
Opm::Elasticity::MPC::getMaster
const DOF & getMaster(size_t i) const
Returns a reference to the i'th master DOF.
Definition mpc.hh:138
Opm::Elasticity::Direction
Direction
An enum for specification of global coordinate directions.
Definition mpc.hh:24
Opm::Elasticity::MPCSet
std::set< MPC *, MPC::Less > MPCSet
A set of MPCs.
Definition mpc.hh:153
Opm::Elasticity::MPCMap
std::map< int, MPC * > MPCMap
A mapping from dof to MPCs.
Definition mpc.hh:156
Opm
Inverting small matrices.
Definition ImplicitAssembly.hpp:43
Opm::Elasticity::MPC::DOF
A struct for representing one term (DOF number and associated coefficient) in a MPC equation.
Definition mpc.hh:67
Opm::Elasticity::MPC::DOF::DOF
DOF()
Default constructor.
Definition mpc.hh:69
Opm::Elasticity::MPC::DOF::DOF
DOF(int n, int d, double c=double(0))
Convenience constructor creating a valid DOF object.
Definition mpc.hh:75
Opm::Elasticity::MPC::DOF::dof
int dof
Local DOF number within node.
Definition mpc.hh:81
Opm::Elasticity::MPC::DOF::node
int node
Node number identifying this DOF.
Definition mpc.hh:80
Opm::Elasticity::MPC::DOF::operator<<
friend std::ostream & operator<<(std::ostream &s, const DOF &d)
Global stream operator printing a DOF instance.
Definition mpc.cpp:86
Opm::Elasticity::MPC::DOF::coeff
double coeff
The constrained value, or master DOF scaling coefficient.
Definition mpc.hh:82