13 #if !defined(KRATOS_TRILINOS_MONOTONICITY_PRESERVING_SOLVER_H_INCLUDED )
14 #define KRATOS_TRILINOS_MONOTONICITY_PRESERVING_SOLVER_H_INCLUDED
58 template<
class TSparseSpaceType,
class TDenseSpaceType,
59 class TReordererType = Reorderer<TSparseSpaceType, TDenseSpaceType> >
61 :
public LinearSolver<TSparseSpaceType, TDenseSpaceType, TReordererType>
99 typename BaseType::Pointer pLinearSolver
101 mpLinearSolver(pLinearSolver)
116 "solver_type" : "monotonicity_preserving",
117 "inner_solver_settings" : {
118 "preconditioner_type" : "amg",
119 "solver_type" : "amgcl",
120 "smoother_type" : "ilu0",
121 "krylov_type" : "lgmres",
122 "coarsening_type" : "aggregation",
123 "max_iteration" : 100,
124 "provide_coordinates" : false,
125 "gmres_krylov_space_dimension" : 100,
130 "use_block_matrices_if_possible" : true,
131 "coarse_enough" : 1000,
195 std::vector<int> global_ids(rdof_set.
size());
196 std::vector<double> dofs_values(rdof_set.
size());
199 for (
const auto&
dof : rdof_set) {
200 const int global_id =
dof.EquationId();
201 global_ids[
i] = global_id;
202 dofs_values[
i] =
dof.GetSolutionStepValue();
206 Epetra_Map localmap(-1, global_ids.size(), global_ids.data(), 0, rA.Comm());
207 Epetra_Vector dofs_local(Copy, localmap, dofs_values.data());
209 Epetra_Import dirichlet_importer(rA.ColMap(), dofs_local.Map());
212 Epetra_Vector
dofs(rA.ColMap());
215 int ierr =
dofs.Import(dofs_local, dirichlet_importer, Insert);
219 for (
int i = 0;
i < rA.NumMyRows();
i++) {
223 rA.ExtractMyRowView(
i, numEntries, vals, cols);
225 for (
int j = 0;
j < numEntries;
j++) {
226 const double value = vals[
j];
228 const int row_gid = rA.RowMap().GID(
i);
229 const int col_gid = rA.ColMap().GID(cols[
j]);
230 if (row_gid > col_gid) {
237 int row_lid = localmap.LID(row_gid);
238 dofs_sol[0] = dofs_local[row_lid];
239 dofs_sol[1] =
dofs[cols[
j]];
242 TSparseSpaceType::AssembleLHS(rA, LHS, equations_ids);
243 TSparseSpaceType::AssembleRHS(rB, RHS, equations_ids);
253 if (mpLinearSolver->AdditionalPhysicalDataIsNeeded()) {
254 mpLinearSolver->ProvideAdditionalData(rA,rX,rB,rdof_set,r_model_part);
260 mpLinearSolver->InitializeSolutionStep(rA,rX,rB);
271 mpLinearSolver->FinalizeSolutionStep(rA,rX,rB);
280 mpLinearSolver->Clear();
291 return mpLinearSolver->Solve(rA,rX,rB);
311 std::string
Info()
const override
313 std::stringstream buffer;
314 buffer <<
"Composite Linear Solver. Uses internally the following linear solver " << mpLinearSolver->Info();
385 template<
class TSparseSpaceType,
class TDenseSpaceType,
386 class TPreconditionerType,
387 class TReordererType>
390 TReordererType>& rThis)
396 template<
class TSparseSpaceType,
class TDenseSpaceType,
397 class TPreconditionerType,
398 class TReordererType>
401 TReordererType>& rThis)
403 rThis.PrintInfo(OStream);
404 OStream << std::endl;
405 rThis.PrintData(OStream);
std::vector< std::size_t > EquationIdVectorType
Definition: element.h:98
Here we add the functions needed for the registration of linear solvers.
Definition: linear_solver_factory.h:62
Base class for all the linear solvers in Kratos.
Definition: linear_solver.h:65
TSparseSpaceType::IndexType IndexType
The index type definition to be consistent.
Definition: linear_solver.h:88
virtual void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: linear_solver.h:388
LinearSolver & operator=(const LinearSolver &Other)
Assignment operator.
Definition: linear_solver.h:112
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
void ValidateAndAssignDefaults(const Parameters &rDefaultParameters)
This function is designed to verify that the parameters under testing match the form prescribed by th...
Definition: kratos_parameters.cpp:1306
A sorted associative container similar to an STL set, but uses a vector to store pointers to its data...
Definition: pointer_vector_set.h:72
size_type size() const
Returns the number of elements in the container.
Definition: pointer_vector_set.h:502
Definition: trilinos_monotonicity_preserving_solver.h:62
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: trilinos_monotonicity_preserving_solver.h:325
TrilinosMonotonicityPreservingSolver()
Default constructor.
Definition: trilinos_monotonicity_preserving_solver.h:90
TSparseSpaceType::VectorType VectorType
The definition of the spaces (vector)
Definition: trilinos_monotonicity_preserving_solver.h:77
~TrilinosMonotonicityPreservingSolver() override
Destructor.
Definition: trilinos_monotonicity_preserving_solver.h:153
TSparseSpaceType::MatrixType SparseMatrixType
The definition of the spaces (sparse matrix)
Definition: trilinos_monotonicity_preserving_solver.h:74
bool Solve(SparseMatrixType &rA, VectorType &rX, VectorType &rB) override
Definition: trilinos_monotonicity_preserving_solver.h:289
TrilinosMonotonicityPreservingSolver & operator=(const TrilinosMonotonicityPreservingSolver &Other)
Assignment operator.
Definition: trilinos_monotonicity_preserving_solver.h:161
KRATOS_CLASS_POINTER_DEFINITION(TrilinosMonotonicityPreservingSolver)
Pointer definition of TrilinosMonotonicityPreservingSolver.
void Clear() override
Definition: trilinos_monotonicity_preserving_solver.h:278
bool AdditionalPhysicalDataIsNeeded() override
Definition: trilinos_monotonicity_preserving_solver.h:176
LinearSolverFactory< TSparseSpaceType, TDenseSpaceType > LinearSolverFactoryType
The definition of the linear solver factory type.
Definition: trilinos_monotonicity_preserving_solver.h:83
LinearSolver< TSparseSpaceType, TDenseSpaceType, TReordererType > BaseType
Definition of the base type.
Definition: trilinos_monotonicity_preserving_solver.h:71
void ProvideAdditionalData(SparseMatrixType &rA, VectorType &rX, VectorType &rB, typename ModelPart::DofsArrayType &rdof_set, ModelPart &r_model_part) override
Definition: trilinos_monotonicity_preserving_solver.h:187
TDenseSpaceType::MatrixType DenseMatrixType
The definition of the spaces (dense matrix)
Definition: trilinos_monotonicity_preserving_solver.h:80
void InitializeSolutionStep(SparseMatrixType &rA, VectorType &rX, VectorType &rB) override
Definition: trilinos_monotonicity_preserving_solver.h:258
void FinalizeSolutionStep(SparseMatrixType &rA, VectorType &rX, VectorType &rB) override
Definition: trilinos_monotonicity_preserving_solver.h:269
TrilinosMonotonicityPreservingSolver(typename BaseType::Pointer pLinearSolver)
Constructor without parameters.
Definition: trilinos_monotonicity_preserving_solver.h:98
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: trilinos_monotonicity_preserving_solver.h:319
std::string Info() const override
Turn back information as a string.
Definition: trilinos_monotonicity_preserving_solver.h:311
TrilinosMonotonicityPreservingSolver(Parameters ThisParameters)
Constructor with parameters.
Definition: trilinos_monotonicity_preserving_solver.h:109
TrilinosMonotonicityPreservingSolver(const TrilinosMonotonicityPreservingSolver &Other)
Copy constructor.
Definition: trilinos_monotonicity_preserving_solver.h:149
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR
Definition: exception.h:161
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
AMatrix::MatrixProductExpression< TExpression1Type, TExpression2Type > prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:568
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
dofs
Enforced auxTangentSlipNonObjective = delta_time * gap_time_derivative_non_objective....
Definition: generate_frictional_mortar_condition.py:210
int dof
Definition: ode_solve.py:393
int j
Definition: quadrature.py:648
integer i
Definition: TensorModule.f:17