98 const Matrix& rTContribution,
99 const std::vector<std::size_t>& rSlaveEquationId,
100 const std::vector<std::size_t>& rMasterEquationId
106 int slave_active_indices = 0;
107 for (
unsigned int i = 0;
i < rSlaveEquationId.size();
i++) {
108 if (rSlaveEquationId[
i] < system_size) {
109 ++slave_active_indices;
112 int master_active_indices = 0;
113 for (
unsigned int i = 0;
i < rMasterEquationId.size();
i++) {
114 if (rMasterEquationId[
i] < system_size) {
115 ++master_active_indices;
119 if (slave_active_indices > 0 && master_active_indices > 0) {
120 std::vector<int> indices(master_active_indices);
121 std::vector<double>
values(master_active_indices);
124 for (
unsigned int i = 0;
i < rSlaveEquationId.size();
i++) {
125 if (rSlaveEquationId[
i] < system_size) {
126 const int current_global_row = rSlaveEquationId[
i];
128 unsigned int loc_j = 0;
129 for (
unsigned int j = 0;
j < rMasterEquationId.size();
j++) {
130 if (rMasterEquationId[
j] < system_size) {
131 indices[loc_j] = rMasterEquationId[
j];
132 values[loc_j] = rTContribution(
i,
j);
137 const int ierr = rT.SumIntoGlobalValues(current_global_row, master_active_indices,
values.data(), indices.data());
152 const Vector& rConstantContribution,
153 const std::vector<std::size_t>& rSlaveEquationId
159 unsigned int slave_active_indices = 0;
160 for (
unsigned int i = 0;
i < rSlaveEquationId.size();
i++)
161 if (rSlaveEquationId[
i] < system_size)
162 ++slave_active_indices;
164 if (slave_active_indices > 0) {
166 Epetra_IntSerialDenseVector indices(slave_active_indices);
167 Epetra_SerialDenseVector
values(slave_active_indices);
170 unsigned int loc_i = 0;
171 for (
unsigned int i = 0;
i < rSlaveEquationId.size();
i++) {
172 if (rSlaveEquationId[
i] < system_size) {
173 indices[loc_i] = rSlaveEquationId[
i];
174 values[loc_i] = rConstantContribution[
i];
179 const int ierr = rC.SumIntoGlobalValues(indices,
values);
196 Epetra_IntSerialDenseVector indices(1);
197 Epetra_SerialDenseVector
values(1);
200 int ierr = rX.ReplaceGlobalValues(indices,
values);
203 ierr = rX.GlobalAssemble(Insert,
true);
204 KRATOS_ERROR_IF(ierr < 0) <<
"Epetra failure when attempting to insert value in function SetValue" << std::endl;
219 Epetra_IntSerialDenseVector indices(1);
220 Epetra_SerialDenseVector
values(1);
223 const int ierr = rX.ReplaceGlobalValues(indices,
values);
239 int ierr = rX.ReplaceMyValue(
static_cast<int>(
i), 0, Value);
241 ierr = rX.GlobalAssemble(Insert,
true);
242 KRATOS_ERROR_IF(ierr < 0) <<
"Epetra failure when attempting to insert value in function SetValue" << std::endl;
257 const int ierr = rX.ReplaceMyValue(
static_cast<int>(
i), 0, Value);
275 std::vector<double>
values(1, Value);
276 std::vector<int> indices(1,
j);
278 int ierr = rA.ReplaceGlobalValues(
static_cast<int>(
i), 1,
values.data(), indices.data());
281 ierr = rA.GlobalAssemble();
282 KRATOS_ERROR_IF(ierr < 0) <<
"Epetra failure when attempting to insert value in function SetValue" << std::endl;
299 std::vector<double>
values(1, Value);
300 std::vector<int> indices(1,
j);
302 const int ierr = rA.ReplaceGlobalValues(
static_cast<int>(
i), 1,
values.data(), indices.data());
320 std::vector<double>
values(1, Value);
321 std::vector<int> indices(1,
j);
323 int ierr = rA.ReplaceMyValues(
static_cast<int>(
i), 1,
values.data(), indices.data());
326 ierr = rA.GlobalAssemble();
327 KRATOS_ERROR_IF(ierr < 0) <<
"Epetra failure when attempting to insert value in function SetValue" << std::endl;
344 std::vector<double>
values(1, Value);
345 std::vector<int> indices(1,
j);
347 const int ierr = rA.ReplaceMyValues(
static_cast<int>(
i), 1,
values.data(), indices.data());
367 virtual std::string
Info()
const
369 return "TrilinosAssemblingUtilities";
378 rOStream <<
"TrilinosAssemblingUtilities";
The Trilinos assembling utilities.
Definition: trilinos_assembling_utilities.h:51
static void AssembleRelationMatrixT(MatrixType &rT, const Matrix &rTContribution, const std::vector< std::size_t > &rSlaveEquationId, const std::vector< std::size_t > &rMasterEquationId)
Assembles the relation matrix T of the system with MPC.
Definition: trilinos_assembling_utilities.h:96
static void SetLocalValueWithoutGlobalAssembly(VectorType &rX, IndexType i, const double Value)
Sets a value in a vector (local without global assembly)
Definition: trilinos_assembling_utilities.h:251
TrilinosSparseSpaceType::VectorType VectorType
Definition of the vector type.
Definition: trilinos_assembling_utilities.h:66
static void SetLocalValueWithoutGlobalAssembly(MatrixType &rA, IndexType i, IndexType j, const double Value)
Sets a value in a matrix.
Definition: trilinos_assembling_utilities.h:337
std::size_t SizeType
Definition of the size type.
Definition: trilinos_assembling_utilities.h:72
virtual std::string Info() const
Turn back information as a string.
Definition: trilinos_assembling_utilities.h:367
static void SetLocalValue(VectorType &rX, IndexType i, const double Value)
Sets a value in a vector (local)
Definition: trilinos_assembling_utilities.h:233
TrilinosAssemblingUtilities()=delete
Default constructor.
KRATOS_CLASS_POINTER_DEFINITION(TrilinosAssemblingUtilities)
Pointer definition of TrilinosAssemblingUtilities.
std::size_t IndexType
Definition of the index type.
Definition: trilinos_assembling_utilities.h:69
TrilinosSparseSpaceType::MatrixType MatrixType
Definition of the matrix type.
Definition: trilinos_assembling_utilities.h:63
virtual void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: trilinos_assembling_utilities.h:376
static void SetLocalValue(MatrixType &rA, IndexType i, IndexType j, const double Value)
Sets a value in a matrix.
Definition: trilinos_assembling_utilities.h:313
static void SetGlobalValue(VectorType &rX, IndexType i, const double Value)
Sets a value in a vector.
Definition: trilinos_assembling_utilities.h:190
static void AssembleConstantVector(VectorType &rC, const Vector &rConstantContribution, const std::vector< std::size_t > &rSlaveEquationId)
Assembles the Constant vector of the system with MPC.
Definition: trilinos_assembling_utilities.h:150
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: trilinos_assembling_utilities.h:385
static void SetGlobalValueWithoutGlobalAssembly(VectorType &rX, IndexType i, const double Value)
Sets a value in a vector.
Definition: trilinos_assembling_utilities.h:213
static void SetGlobalValueWithoutGlobalAssembly(MatrixType &rA, IndexType i, IndexType j, const double Value)
Sets a value in a matrix.
Definition: trilinos_assembling_utilities.h:292
static void SetGlobalValue(MatrixType &rA, IndexType i, IndexType j, const double Value)
Sets a value in a matrix.
Definition: trilinos_assembling_utilities.h:268
The space adapted for Trilinos vectors and matrices.
Definition: trilinos_space.h:75
TVectorType VectorType
Definition of the vector type.
Definition: trilinos_space.h:90
static IndexType Size1(MatrixType const &rM)
Returns number of rows of rM.
Definition: trilinos_space.h:186
TMatrixType MatrixType
Definition of the matrix type.
Definition: trilinos_space.h:87
static IndexType Size(const VectorType &rV)
Returns size of vector rV.
Definition: trilinos_space.h:175
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
list values
Definition: bombardelli_test.py:42
int j
Definition: quadrature.py:648
integer i
Definition: TensorModule.f:17