13 #if !defined(KRATOS_MONOTONICITY_PRESERVING_SOLVER_H_INCLUDED )
14 #define KRATOS_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,
201 double *values_vector = rA.value_data().begin();
202 std::size_t *index1_vector = rA.index1_data().begin();
203 std::size_t *index2_vector = rA.index2_data().begin();
208 for (std::size_t
k = index1_vector[
i];
k < index1_vector[
i + 1];
k++) {
209 const double value = values_vector[
k];
211 const auto j = index2_vector[
k];
216 auto& r_aii = rA(
i,
i).ref();
218 auto& r_ajj = rA(
j,
j).ref();
221 AtomicAdd(r_bi, value*dofs_values[
j] - value*dofs_values[
i]);
223 AtomicAdd(r_bj, value*dofs_values[
i] - value*dofs_values[
j]);
230 if (mpLinearSolver->AdditionalPhysicalDataIsNeeded()) {
231 mpLinearSolver->ProvideAdditionalData(rA,rX,rB,rdof_set,r_model_part);
237 mpLinearSolver->InitializeSolutionStep(rA,rX,rB);
248 mpLinearSolver->FinalizeSolutionStep(rA,rX,rB);
257 mpLinearSolver->Clear();
268 return mpLinearSolver->Solve(rA,rX,rB);
288 std::string
Info()
const override
290 std::stringstream buffer;
291 buffer <<
"Composite Linear Solver. Uses internally the following linear solver " << mpLinearSolver->Info();
362 template<
class TSparseSpaceType,
class TDenseSpaceType,
363 class TPreconditionerType,
364 class TReordererType>
367 TReordererType>& rThis)
373 template<
class TSparseSpaceType,
class TDenseSpaceType,
374 class TPreconditionerType,
375 class TReordererType>
378 TReordererType>& rThis)
380 rThis.PrintInfo(OStream);
381 OStream << std::endl;
382 rThis.PrintData(OStream);
Dof represents a degree of freedom (DoF).
Definition: dof.h:86
EquationIdType EquationId() const
Definition: dof.h:324
TDataType & GetSolutionStepValue(IndexType SolutionStepIndex=0)
Definition: dof.h:256
This class is useful for index iteration over containers.
Definition: parallel_utilities.h:451
void for_each(TUnaryFunction &&f)
Definition: parallel_utilities.h:514
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
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
Definition: monotonicity_preserving_solver.h:62
LinearSolverFactory< TSparseSpaceType, TDenseSpaceType > LinearSolverFactoryType
The definition of the linear solver factory type.
Definition: monotonicity_preserving_solver.h:83
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: monotonicity_preserving_solver.h:296
MonotonicityPreservingSolver(Parameters ThisParameters)
Constructor with parameters.
Definition: monotonicity_preserving_solver.h:109
LinearSolver< TSparseSpaceType, TDenseSpaceType, TReordererType > BaseType
Definition of the base type.
Definition: monotonicity_preserving_solver.h:71
MonotonicityPreservingSolver & operator=(const MonotonicityPreservingSolver &Other)
Assignment operator.
Definition: monotonicity_preserving_solver.h:161
MonotonicityPreservingSolver(typename BaseType::Pointer pLinearSolver)
Constructor without parameters.
Definition: monotonicity_preserving_solver.h:98
bool Solve(SparseMatrixType &rA, VectorType &rX, VectorType &rB) override
Definition: monotonicity_preserving_solver.h:266
KRATOS_CLASS_POINTER_DEFINITION(MonotonicityPreservingSolver)
Pointer definition of MonotonicityPreservingSolver.
void FinalizeSolutionStep(SparseMatrixType &rA, VectorType &rX, VectorType &rB) override
Definition: monotonicity_preserving_solver.h:246
void ProvideAdditionalData(SparseMatrixType &rA, VectorType &rX, VectorType &rB, typename ModelPart::DofsArrayType &rdof_set, ModelPart &r_model_part) override
Definition: monotonicity_preserving_solver.h:187
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: monotonicity_preserving_solver.h:302
std::string Info() const override
Turn back information as a string.
Definition: monotonicity_preserving_solver.h:288
MonotonicityPreservingSolver()
Default constructor.
Definition: monotonicity_preserving_solver.h:90
void InitializeSolutionStep(SparseMatrixType &rA, VectorType &rX, VectorType &rB) override
Definition: monotonicity_preserving_solver.h:235
~MonotonicityPreservingSolver() override
Destructor.
Definition: monotonicity_preserving_solver.h:153
TDenseSpaceType::MatrixType DenseMatrixType
The definition of the spaces (dense matrix)
Definition: monotonicity_preserving_solver.h:80
MonotonicityPreservingSolver(const MonotonicityPreservingSolver &Other)
Copy constructor.
Definition: monotonicity_preserving_solver.h:149
bool AdditionalPhysicalDataIsNeeded() override
Definition: monotonicity_preserving_solver.h:176
void Clear() override
Definition: monotonicity_preserving_solver.h:255
TSparseSpaceType::MatrixType SparseMatrixType
The definition of the spaces (sparse matrix)
Definition: monotonicity_preserving_solver.h:74
TSparseSpaceType::VectorType VectorType
The definition of the spaces (vector)
Definition: monotonicity_preserving_solver.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
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
void AtomicAdd(TDataType &target, const TDataType &value)
Definition: atomic_utilities.h:55
void block_for_each(TIterator itBegin, TIterator itEnd, TFunction &&rFunction)
Execute a functor on all items of a range in parallel.
Definition: parallel_utilities.h:299
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
int k
Definition: quadrature.py:595
int j
Definition: quadrature.py:648
integer i
Definition: TensorModule.f:17