12 #if !defined(KRATOS_SYSTEM_VECTOR_H_INCLUDED )
13 #define KRATOS_SYSTEM_VECTOR_H_INCLUDED
59 template<
class TDataType=
double,
class TIndexType=std::
size_t>
76 mData.resize(rGraph.
Size(),
false);
81 mData.resize(rGraph.
Size(),
false);
85 if(rComm.IsDistributed())
86 KRATOS_ERROR <<
"Attempting to construct a serial system_vector with a distributed communicator" << std::endl;
88 mData.resize(
size,
false);
94 if(rComm.IsDistributed())
95 KRATOS_ERROR <<
"Attempting to construct a serial system_vector with a distributed communicator" << std::endl;
97 mData.resize(
data.size(),
false);
102 mpComm = rOtherVector.mpComm;
103 mData.resize(rOtherVector.
size(),
false);
106 (*this)[
i] = rOtherVector[
i];
176 (*this)[
i] +=
factor*rOtherVector[
i];
183 (*this)[
i] = rOtherVector[
i];
192 (*this)[
i] += rOtherVector[
i];
200 (*this)[
i] -= rOtherVector[
i];
208 (*this)[
i] *= multiplier_factor;
216 (*this)[
i] /= divide_factor;
223 KRATOS_WARNING_IF(
"SystemVector", gather_on_rank != 0) <<
"the parameter gather_on_rank essentially does nothing for a non-distribued vector. It is added to have the same interface as for the distributed_system_vector" << std::endl;
226 TDataType dot_value = partition.template for_each< SumReduction<TDataType> >([&](
IndexType i){
227 return (*
this)[
i]*rOtherVector[
i];
241 template<
class TVectorType,
class TIndexVectorType >
243 const TVectorType& rVectorInput,
244 const TIndexVectorType& EquationId
249 for(
unsigned int i=0;
i<EquationId.size(); ++
i){
274 std::stringstream buffer;
275 buffer <<
"SystemVector" ;
281 rOStream <<
"SystemVector" << std::endl;
287 std::cout << mData << std::endl;
385 template<
class TDataType,
class TIndexType>
393 template<
class TDataType,
class TIndexType>
398 rOStream << std::endl;
Serial (do-nothing) version of a wrapper class for MPI communication.
Definition: data_communicator.h:318
This class is useful for index iteration over containers.
Definition: parallel_utilities.h:451
void for_each(TUnaryFunction &&f)
Definition: parallel_utilities.h:514
static DataCommunicator & GetDataCommunicator(const std::string &rName)
Retrieve a registered DataCommunicator instance.
Definition: parallel_environment.cpp:26
const DataCommunicator * pGetComm() const
Definition: sparse_contiguous_row_graph.h:127
IndexType Size() const
Definition: sparse_contiguous_row_graph.h:141
Short class definition.
Definition: sparse_graph.h:66
IndexType Size() const
Definition: sparse_graph.h:129
const DataCommunicator * pGetComm() const
Definition: sparse_graph.h:124
Provides a SystemVector which implements FEM assemble capabilities, as well as some vector operations...
Definition: system_vector.h:61
void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: system_vector.h:286
void Clear()
Definition: system_vector.h:126
const TDataType & operator()(IndexType I) const
Definition: system_vector.h:147
SystemVector(IndexType size, DataCommunicator &rComm=ParallelEnvironment::GetDataCommunicator("Serial"))
Definition: system_vector.h:84
KRATOS_CLASS_POINTER_DEFINITION(SystemVector)
Pointer definition of SystemVector.
SystemVector & operator-=(const SystemVector &rOtherVector)
Definition: system_vector.h:197
TDataType & operator[](IndexType I)
Definition: system_vector.h:151
const DenseVector< TDataType > & data() const
provides low level access to internal data
Definition: system_vector.h:166
void Add(const TDataType factor, const SystemVector &rOtherVector)
Definition: system_vector.h:171
SystemVector(const SparseContiguousRowGraph< IndexType > &rGraph)
Definition: system_vector.h:79
TDataType & operator()(IndexType I)
Definition: system_vector.h:143
SystemVector & operator*=(const TDataType multiplier_factor)
Definition: system_vector.h:205
SystemVector(const Vector &data, DataCommunicator &rComm=ParallelEnvironment::GetDataCommunicator("Serial"))
Definition: system_vector.h:91
void Assemble(const TVectorType &rVectorInput, const TIndexVectorType &EquationId)
Definition: system_vector.h:242
SystemVector & operator/=(const TDataType divide_factor)
Definition: system_vector.h:213
IndexType size() const
Definition: system_vector.h:138
void SetValue(const TDataType value)
Definition: system_vector.h:131
void BeginAssemble()
Definition: system_vector.h:237
const DataCommunicator * pGetComm() const
Definition: system_vector.h:118
const TDataType & operator[](IndexType I) const
Definition: system_vector.h:155
TIndexType IndexType
Definition: system_vector.h:65
TDataType Dot(const SystemVector &rOtherVector, IndexType gather_on_rank=0)
Definition: system_vector.h:221
~SystemVector()
Destructor.
Definition: system_vector.h:111
void FinalizeAssemble()
Definition: system_vector.h:239
std::string Info() const
Turn back information as a string.
Definition: system_vector.h:272
SystemVector & operator+=(const SystemVector &rOtherVector)
Definition: system_vector.h:189
SystemVector & operator=(SystemVector const &rOtherVector)
Assignment operator.
Definition: system_vector.h:181
const DataCommunicator & GetComm() const
Definition: system_vector.h:113
void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: system_vector.h:280
SystemVector(const SystemVector< TDataType, TIndexType > &rOtherVector)
Copy constructor.
Definition: system_vector.h:101
SystemVector(const SparseGraph< IndexType > &rGraph)
Definition: system_vector.h:74
DenseVector< TDataType > & data()
provides low level access to internal data
Definition: system_vector.h:160
#define KRATOS_ERROR
Definition: exception.h:161
#define KRATOS_DEBUG_ERROR_IF(conditional)
Definition: exception.h:171
#define KRATOS_WARNING_IF(label, conditional)
Definition: logger.h:266
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
void AtomicAdd(TDataType &target, const TDataType &value)
Definition: atomic_utilities.h:55
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
integer i
Definition: TensorModule.f:17
float factor
for node in (self.combined_model_part).Nodes: pold = node.GetSolutionStepValue(PRESSURE,...
Definition: ulf_PGLASS.py:254