IFEM  90A354
AlgEqSystem.h
Go to the documentation of this file.
1 // $Id$
2 //==============================================================================
12 //==============================================================================
13 
14 #ifndef _ALG_EQ_SYSTEM_H
15 #define _ALG_EQ_SYSTEM_H
16 
17 #include "GlobalIntegral.h"
18 #include "LinAlgenums.h"
19 #include "MatVec.h"
20 
21 class SAM;
22 class ProcessAdm;
23 class LinSolParams;
24 class SystemMatrix;
25 class SystemVector;
26 
27 
33 {
34 public:
36  explicit AlgEqSystem(const SAM& s, const ProcessAdm* a = nullptr);
38  AlgEqSystem(const AlgEqSystem& a) : sam(a.sam), adm(a.adm) { this->copy(a); }
40  virtual ~AlgEqSystem() { this->clear(); }
41 
43  AlgEqSystem& operator=(const AlgEqSystem& s) { return this->copy(s); }
44 
46  AlgEqSystem& copy(const AlgEqSystem& that);
48  AlgEqSystem& add(const AlgEqSystem& that);
49 
59  bool init(LinAlg::MatrixType mtype, const LinSolParams* spar = nullptr,
60  size_t nmat = 1, size_t nvec = 1, size_t nscl = 0,
61  bool reactions = false, int num_threads_SLU = 1,
62  bool forcePreAss = false);
63 
65  void clear();
66 
75  bool setAssociatedVector(size_t imat, size_t ivec);
76 
79  virtual void initialize(char initLHS);
82  virtual bool finalize(bool newLHS);
83 
87  virtual bool assemble(const LocalIntegral* elmObj, int elmId);
88 
90  size_t getNoRHS() const { return b.size(); }
92  const SAM& getSAM() const { return sam; }
93 
95  SystemMatrix* getMatrix(size_t i = 0) { return i < A.size() ? A[i]._A : 0; }
97  SystemVector* getVector(size_t i = 0) { return i < b.size() ? b[i] : 0; }
99  double getScalar(size_t i = 0) { return i < c.size() ? c[i] : 0.0; }
101  void addScalar(double s, size_t i = 0) { if (i < c.size()) c[i] += s; }
103  const std::vector<double>& getScalars() const { return c; }
104 
106  const std::vector<double>* getReactions() const { return R.empty() ? 0 : &R; }
107 
114  bool staticCondensation(Matrix& Ared, Vector& bred,
115  const std::vector<int>& extNodes,
116  size_t imat = 0,
117  const char* recmatFile = nullptr) const;
118 
122  static bool readRecoveryMatrix(Matrix& Rmat, const char* recmatFile);
128  bool recoverInternals(const Matrix& Rmat,
129  const std::vector<int>& extNodes,
130  const Vector& xe, Vector& xFull) const;
131 
132 private:
135  {
138 
140  SysMatrixPair() : _A(nullptr), _b(nullptr) {}
141  };
142 
143  std::vector<SysMatrixPair> A;
144  std::vector<SystemVector*> b;
145  std::vector<double> c;
146  std::vector<double>* d;
147  std::vector<double> R;
148 
149  const SAM& sam;
150  const ProcessAdm* adm;
151 };
152 
153 #endif
Abstract interface for classes representing integrated quantities.
Various enums for linear algebra scope.
Global algebraic operations on index 1-based matrices and vectors.
Class for storage of general algebraic system of equations.
Definition: AlgEqSystem.h:33
AlgEqSystem & operator=(const AlgEqSystem &s)
Assignment operator.
Definition: AlgEqSystem.h:43
size_t getNoRHS() const
Returns the number of right-hand-side vectors allocated.
Definition: AlgEqSystem.h:90
AlgEqSystem(const SAM &s, const ProcessAdm *a=nullptr)
The constructor sets its reference to SAM and ProcessAdm objects.
Definition: AlgEqSystem.C:27
AlgEqSystem(const AlgEqSystem &a)
Copy constructor.
Definition: AlgEqSystem.h:38
const std::vector< double > * getReactions() const
Returns a pointer to the nodal reaction forces, if any.
Definition: AlgEqSystem.h:106
void addScalar(double s, size_t i=0)
Adds the value s to the i'th scalar quantity.
Definition: AlgEqSystem.h:101
AlgEqSystem & add(const AlgEqSystem &that)
Adds that to *this (assuming similar structure).
Definition: AlgEqSystem.C:136
const ProcessAdm * adm
Parallel process administrator.
Definition: AlgEqSystem.h:150
void clear()
Erases the system matrices and frees dynamically allocated storage.
Definition: AlgEqSystem.C:156
static bool readRecoveryMatrix(Matrix &Rmat, const char *recmatFile)
Reads the recovery matrix from file.
Definition: AlgEqSystem.C:476
virtual ~AlgEqSystem()
The destructor frees the dynamically allocated objects.
Definition: AlgEqSystem.h:40
virtual bool finalize(bool newLHS)
Finalizes the system matrices after element assembly.
Definition: AlgEqSystem.C:307
SystemMatrix * getMatrix(size_t i=0)
Returns the i'th matrix of the equation system.
Definition: AlgEqSystem.h:95
std::vector< double > * d
Multithreading buffer for the scalar values.
Definition: AlgEqSystem.h:146
bool init(LinAlg::MatrixType mtype, const LinSolParams *spar=nullptr, size_t nmat=1, size_t nvec=1, size_t nscl=0, bool reactions=false, int num_threads_SLU=1, bool forcePreAss=false)
Allocates the system matrices of the specified format.
Definition: AlgEqSystem.C:33
std::vector< SysMatrixPair > A
The actual coefficient matrices.
Definition: AlgEqSystem.h:143
virtual void initialize(char initLHS)
Initializes the system matrices to zero.
Definition: AlgEqSystem.C:188
const std::vector< double > & getScalars() const
Returns a const reference to the assembled scalars.
Definition: AlgEqSystem.h:103
std::vector< double > c
Global scalar quantities.
Definition: AlgEqSystem.h:145
const SAM & getSAM() const
Returns a const reference to the SAM object.
Definition: AlgEqSystem.h:92
bool recoverInternals(const Matrix &Rmat, const std::vector< int > &extNodes, const Vector &xe, Vector &xFull) const
Performs recovery of internal DOF values from the external DOFs.
Definition: AlgEqSystem.C:523
bool staticCondensation(Matrix &Ared, Vector &bred, const std::vector< int > &extNodes, size_t imat=0, const char *recmatFile=nullptr) const
Performs static condensation of the indicated equation system.
Definition: AlgEqSystem.C:355
SystemVector * getVector(size_t i=0)
Returns the i'th right-hand-side vector of the equation system.
Definition: AlgEqSystem.h:97
double getScalar(size_t i=0)
Returns the i'th scalar quantity.
Definition: AlgEqSystem.h:99
std::vector< SystemVector * > b
The actual right-hand-side vectors.
Definition: AlgEqSystem.h:144
bool setAssociatedVector(size_t imat, size_t ivec)
Associates a system vector to a system matrix.
Definition: AlgEqSystem.C:177
virtual bool assemble(const LocalIntegral *elmObj, int elmId)
Adds a set of element matrices into the algebraic equation system.
Definition: AlgEqSystem.C:216
AlgEqSystem & copy(const AlgEqSystem &that)
Makes *this a copy of that.
Definition: AlgEqSystem.C:101
const SAM & sam
Data for FE assembly management.
Definition: AlgEqSystem.h:149
std::vector< double > R
Nodal reaction forces.
Definition: AlgEqSystem.h:147
Abstract base class representing a system level integrated quantity.
Definition: GlobalIntegral.h:29
Class for linear solver parameters.
Definition: LinSolParams.h:67
Abstract base class representing an element level integrated quantity.
Definition: LocalIntegral.h:25
Class for administration of MPI processes in IFEM library.
Definition: ProcessAdm.h:33
This class contains data and functions for the assembly of FE matrices.
Definition: SAM.h:39
Base class for representing a system matrix on different formats.
Definition: SystemMatrix.h:220
Base class for representing a system vector on different formats.
Definition: SystemMatrix.h:32
A vector class with some added algebraic operations.
Definition: matrix.h:64
MatrixType
The available system matrix formats and associated solvers.
Definition: LinAlgenums.h:22
Struct defining a coefficient matrix and an associated RHS-vector.
Definition: AlgEqSystem.h:135
SystemVector * _b
Pointer to the associated right-hand-side vector.
Definition: AlgEqSystem.h:137
SysMatrixPair()
Constructor initializing the pointers to zero.
Definition: AlgEqSystem.h:140
SystemMatrix * _A
The coefficient matrix.
Definition: AlgEqSystem.h:136