30 #ifndef MaterialVector_h 31 #define MaterialVector_h 34 #include "utility/kernel/CommandEntity.h" 35 #include "material/ResponseId.h" 36 #include "utility/actor/actor/MovableID.h" 37 #include "utility/matrix/Vector.h" 38 #include "utility/matrix/Matrix.h" 39 #include "utility/utils/misc_utils/colormod.h" 53 static MAT *get_material_copy(
const MAT *,
const std::string &type);
54 static MAT *get_material_copy(
const MAT *);
55 void alloc(
const std::vector<MAT *> &mats);
62 typedef typename std::vector<MAT *> mat_vector;
63 typedef typename mat_vector::iterator iterator;
64 typedef typename mat_vector::const_iterator const_iterator;
65 typedef typename mat_vector::reference reference;
66 typedef typename mat_vector::const_reference const_reference;
74 void clearMaterials(
void);
75 void setMaterial(
const MAT *);
76 void setMaterial(
size_t i,
const MAT *);
77 void setMaterial(
size_t i,
const MAT &);
78 void setMaterial(
const MAT *,
const std::string &);
81 bool empty(
void)
const;
111 std::set<std::string>
getNames(
void)
const;
113 std::set<int>
getTags(
void)
const;
114 boost::python::list
getTagsPy(
void)
const;
127 for(iterator i= mat_vector::begin();i!=mat_vector::end();i++)
141 const size_t nMat= mats.size();
143 for(
size_t i= 0;i<nMat;i++)
171 MAT *retval=
nullptr;
177 retval=
dynamic_cast<MAT *
>(copy_ptr);
180 std::cerr << Color::red <<
"MaterialVector::" << __FUNCTION__
181 <<
"; the type of the given material: " 182 << new_mat->getClassName()
183 <<
" cannot be converted to a " 184 <<
typeid(MAT).name()
186 << Color::def << std::endl;
192 std::cerr << Color::red <<
"MaterialVector::" << __FUNCTION__
193 <<
"; failed allocate material model pointer." 194 << Color::def << std::endl;
202 MAT *retval=
nullptr;
208 retval=
dynamic_cast<MAT *
>(copy_ptr);
211 std::cerr << Color::red <<
"MaterialVector::" << __FUNCTION__
212 <<
"; the type of the given material: " 213 << new_mat->getClassName()
214 <<
" cannot be converted to a " 215 <<
typeid(MAT).name()
217 << Color::def << std::endl;
223 std::cerr << Color::red <<
"MaterialVector::" << __FUNCTION__
224 <<
"; failed allocate material model pointer." 225 << Color::def << std::endl;
236 for(iterator i= mat_vector::begin();i!=mat_vector::end();i++)
251 for(iterator i= mat_vector::begin();i!=mat_vector::end();i++)
271 { setMaterial(i, &new_mat); }
281 for(iterator i= mat_vector::begin();i!=mat_vector::end();i++)
291 for(iterator i= mat_vector::begin();i!=mat_vector::end();i++)
305 if(mat_vector::empty())
308 return ((*
this)[0]==
nullptr);
315 std::vector<MAT *>::clear();
325 for(iterator i=mat_vector::begin();i!=mat_vector::end();i++)
336 for(iterator i=mat_vector::begin();i!=mat_vector::end();i++)
348 for(iterator i=mat_vector::begin();i!=mat_vector::end();i++)
361 const int nMat= this->size();
362 std::vector<Matrix> tmp(nMat);
366 for(const_iterator i=mat_vector::begin();i!=mat_vector::end();i++, count++)
368 const Matrix v= (*i)->getValues(code, silent);
370 nCols= std::max(nCols, v.
noCols());
373 retval.resize(nRows,nCols);
376 for(
int i= 0;i<nMat;i++)
379 for(
int j= 0;j<v.
noRows();j++)
381 for(
int k= 0;k<v.
noCols();k++)
384 retval(iRow,iCol)= v(j,k);
406 const size_t ncol= getGeneralizedStressSize();
407 const size_t nMat= this->size();
409 for(
size_t i= 0;i<nMat;i++)
411 const Vector &s= (*this)[i]->getGeneralizedStress();
421 const size_t ncol= getGeneralizedStrainSize();
422 const size_t nMat= this->size();
424 for(
size_t i= 0;i<nMat;i++)
426 const Vector &s= (*this)[i]->getGeneralizedStrain();
427 for(
size_t j= 0;j<ncol;j++)
438 retval= (*this)[0]->getGeneralizedStress();
439 const size_t nMat= this->size();
440 for(
size_t i= 1;i<nMat;i++)
441 retval+= (*
this)[i]->getGeneralizedStress();
451 retval= (*this)[0]->getGeneralizedStrain();
452 const size_t nMat= this->size();
453 for(
size_t i= 0;i<nMat;i++)
454 retval+= (*
this)[i]->getGeneralizedStrain();
464 const ResponseId &rId= (*this)[0]->getResponseType();
474 const Vector &e= getMeanGeneralizedStrain();
475 const ResponseId &code= (*this)[0]->getResponseType();
476 const int order= code.
Size();
477 for(
int i= 0;i<order;i++)
488 const ResponseId &rId= (*this)[0]->getResponseType();
490 return this->getMeanGeneralizedStrain(defId);
498 const size_t nMat= this->size();
499 const ResponseId &code= (*this)[0]->getResponseType();
500 const int order= code.
Size();
502 for(
size_t i= 0;i<nMat;i++)
504 const Vector &e= (*this)[i]->getGeneralizedStrain();
505 for(
int j= 0;j<order;j++)
519 const Vector &f= getMeanGeneralizedStress();
520 const ResponseId &code= (*this)[0]->getResponseType();
521 const int order= code.
Size();
522 for(
int i= 0;i<order;i++)
533 const ResponseId &rId= (*this)[0]->getResponseType();
535 return this->getMeanGeneralizedStress(defId);
543 const size_t nMat= this->size();
544 const ResponseId &code= (*this)[0]->getResponseType();
545 const int order= code.
Size();
547 for(
size_t i= 0;i<nMat;i++)
549 const Vector &e= (*this)[i]->getGeneralizedStress();
550 for(
int j= 0;j<order;j++)
562 const size_t nMat= this->size();
564 const ResponseId &code= (*this)[0]->getResponseType();
565 const int order= code.
Size();
566 for(
size_t i= 0;i<nMat;i++)
568 const Vector &s= (*this)[i]->getGeneralizedStress();
569 for(
int j= 0;j<order;j++)
581 const size_t nMat= this->size();
583 const ResponseId &code= (*this)[0]->getResponseType();
584 const int order= code.
Size();
585 for(
size_t i= 0;i<nMat;i++)
587 const Vector &s= (*this)[i]->getGeneralizedStrain();
588 for(
int j= 0;j<order;j++)
599 const size_t nMat= this->size();
600 const size_t sz= std::min(nMat,iS.size());
602 std::cerr << Color::red << getClassName() <<
"::" << __FUNCTION__
604 << iS.size() <<
" generalized strain vectors, expected: " 606 << Color::def << std::endl;
607 for(
size_t i= 0;i<sz;i++)
608 (*
this)[i]->setInitialGeneralizedStrain(iS[i]);
615 const size_t nMat= this->size();
616 const size_t sz= std::min(nMat,iS.size());
618 std::cerr << Color::red << getClassName() <<
"::" << __FUNCTION__
620 << iS.size() <<
" generalized strain vectors, expected: " 622 << Color::def << std::endl;
623 for(
size_t i= 0;i<sz;i++)
624 (*
this)[i]->incrementInitialGeneralizedStrain(iS[i]);
631 const size_t nMat= this->size();
632 for(
size_t i= 0;i<nMat;i++)
633 (*
this)[i]->zeroInitialGeneralizedStrain();
651 setDbTagDataPos(0,0);
654 setDbTagDataPos(0,1);
655 const size_t nMat= this->size();
658 for(
size_t i= 0;i<nMat;i++)
669 const int flag= getDbTagDataPos(0);
673 const size_t nMat= this->size();
677 for(
size_t i= 0;i<nMat;i++)
681 (*this)[i]= comm.getBrokedMaterial((*
this)[i],cpMat,meta);
691 std::set<std::string> retval;
692 for(const_iterator i= mat_vector::begin();i!=mat_vector::end();i++)
693 retval.insert((*i)->getName());
701 boost::python::list retval;
702 std::set<std::string> tmp= getNames();
703 for(std::set<std::string>::const_iterator i= tmp.begin();i!=tmp.end();i++)
712 std::set<int> retval;
713 for(const_iterator i= mat_vector::begin();i!=mat_vector::end();i++)
714 retval.insert((*i)->getTag());
722 boost::python::list retval;
723 std::set<int> tmp= getTags();
724 for(std::set<int>::const_iterator i= tmp.begin();i!=tmp.end();i++)
734 int res= sendData(comm);
735 const int dataTag=getDbTag();
736 res+= comm.
sendIdData(getDbTagData(),dataTag);
738 std::cerr << Color::red << getClassName() <<
"::" << __FUNCTION__
739 << dataTag <<
" failed to send ID" 740 << Color::def << std::endl;
748 const int dataTag= this->getDbTag();
752 std::cerr << Color::red << getClassName() <<
"::" << __FUNCTION__
753 << dataTag <<
" failed to receive ID" 754 << Color::def << std::endl;
756 res+= recvData(comm);
int sendIdData(const DbTagData &, const int &)
Sends miembro data through the communicator argument.
Definition: Communicator.cc:411
Matrix getGeneralizedStress(const int &defID) const
Returns the defID component of generalized stress vector on each integration point.
Definition: MaterialVector.h:560
virtual int getComponentIdFromString(const std::string &str) const
Return the identifier of the response component from the given label (something like 'Mz' or 'N'...
Definition: ResponseId.cc:167
int sendBrokedPtr(MovableObject *ptr, DbTagData &, const BrokedPtrCommMetaData &)
Sends a pointer to movable object through the communicator argument.
Definition: Communicator.cc:1204
int sendSelf(Communicator &)
Sends object through the communicator argument.
Definition: MaterialVector.h:731
Float vector abstraction.
Definition: Vector.h:94
Communication parameters between processes.
Definition: Communicator.h:66
void alloc(const std::vector< MAT *> &mats)
Copy materials from another vector.
Definition: MaterialVector.h:138
Object that can return properties as Python objects.
Definition: EntityWithProperties.h:32
int revertToLastCommit(void)
Returns materials to its last committed state.
Definition: MaterialVector.h:332
std::set< std::string > getNames(void) const
Return the names of the materials.
Definition: MaterialVector.h:689
void setInitialGeneralizedStrains(const std::vector< Vector > &)
Assigns initial values to materials initial strains.
Definition: MaterialVector.h:597
Object that can move between processes.
Definition: MovableObject.h:100
const Vector & getMeanGeneralizedStress(void) const
Returns average generalized stress values on element. In a future we can enhance this by providing an...
Definition: MaterialVector.h:435
int send(DbTagData &, Communicator &, const CommMetaData &) const
Sends the object.
Definition: DbTagData.cc:102
bool empty(void) const
Returns true ifno se ha asignado material.
Definition: MaterialVector.h:303
Vector getGeneralizedStrainAtGaussPoints(const int &) const
Returns the defID component of the strain vector at Gauss points.
Definition: MaterialVector.h:496
Base class for materials.
Definition: Material.h:93
int noCols() const
Returns the number of columns, numCols, of the Matrix.
Definition: Matrix.h:273
Vector that stores the dbTags of the class members.
Definition: DbTagData.h:44
Matrix getGeneralizedStresses(void) const
Returns generalized stress values on each integration point.
Definition: MaterialVector.h:404
boost::python::list getNamesPy(void) const
Return the names of the materials in a python list.
Definition: MaterialVector.h:699
size_t getGeneralizedStrainSize(void) const
Returns the size of generalized strains vector.
Definition: MaterialVector.h:399
void copyPropsFrom(const EntityWithProperties *)
copy the user defined properties of the given object on each of the materials.
Definition: MaterialVector.h:276
int receive(DbTagData &, const Communicator &, const CommMetaData &)
Receive the object.
Definition: DbTagData.cc:106
Vector getGeneralizedStressAtGaussPoints(const int &) const
Returns the defID component of the stress vector at Gauss points.
Definition: MaterialVector.h:541
void incrementInitialGeneralizedStrains(const std::vector< Vector > &)
Adds to the materials initial strains the values being passed as parameters.
Definition: MaterialVector.h:613
boost::python::list getTagsPy(void) const
Return the identifiers of the materials in a python list.
Definition: MaterialVector.h:720
MaterialVector< MAT > & operator=(const MaterialVector< MAT > &)
Assignment operator.
Definition: MaterialVector.h:162
Material pointer container.
Definition: MaterialVector.h:49
Matrix getGeneralizedStrain(const int &defID) const
Returns the defID component of generalized strain vector on each integration point.
Definition: MaterialVector.h:579
size_t getGeneralizedStressSize(void) const
Returns the size of stress vector.
Definition: MaterialVector.h:394
int recvSelf(const Communicator &)
Receives object through the communicator argument.
Definition: MaterialVector.h:746
std::set< int > getTags(void) const
Return the identifiers of the materials.
Definition: MaterialVector.h:710
std::deque< int > getComponentIndexesFromCode(const std::string &code) const
Return the strain or stress vector index corresponding to the given code.
Definition: MaterialVector.h:462
Objet that can execute python scripts.
Definition: CommandEntity.h:40
Stiffness material contribution response identifiers.
Definition: ResponseId.h:68
void copyPropsFrom(const EntityWithProperties &)
Copy the properties from the argument.
Definition: EntityWithProperties.cc:82
int noRows() const
Returns the number of rows, numRows, of the Matrix.
Definition: Matrix.h:269
const Vector & getMeanGeneralizedStrain(void) const
Returns average generalized strain values on element.In a future we can enhance this by providing an ...
Definition: MaterialVector.h:448
int sendData(Communicator &)
Send object members through the communicator argument.
Definition: MaterialVector.h:647
virtual TaggedObject * getCopy(void) const
Virtual constructor.
Definition: TaggedObject.cpp:83
Matrix getGeneralizedStrains(void) const
Returns generalized strain values on each integration point.
Definition: MaterialVector.h:419
int commitState(void)
Commits materials state (normally after convergence).
Definition: MaterialVector.h:321
void zeroInitialGeneralizedStrains(void)
Initialize initial strains.
Definition: MaterialVector.h:629
std::deque< int > getComponentIndexesFromCode(const int &) const
Return the strain or stress vector indexes corresponding to the given code.
Definition: ResponseId.cc:124
int receiveIdData(DbTagData &, const int &) const
Receives el miembro data through the communicator argument.
Definition: Communicator.cc:415
int recvData(const Communicator &)
Receives object through the communicator argument.
Definition: MaterialVector.h:667
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:35
Matrix of floats.
Definition: Matrix.h:111
DbTagData & getDbTagData(void) const
Returns a vector to store the dbTags of the class members.
Definition: MaterialVector.h:639
Matrix getValues(const std::string &, bool silent=false) const
Ask the materials about the values that correspond to the code.
Definition: MaterialVector.h:358
int revertToStart(void)
Return materials to its initial state.
Definition: MaterialVector.h:344
void putRow(int, const Vector &)
Put the vector at the i-th row.
Definition: Matrix.cpp:1118
MaterialVector(const size_t &nMat, const MAT *matModel=nullptr)
Default constructor.
Definition: MaterialVector.h:122
int Size(void) const
Returns the vector size.
Definition: ID.h:116