30 #ifndef MaterialVector_h 31 #define MaterialVector_h 34 #include "utility/kernel/CommandEntity.h" 35 #include "material/section/ResponseId.h" 36 #include "utility/actor/actor/MovableID.h" 37 #include "utility/matrix/Vector.h" 38 #include "utility/matrix/Matrix.h" 52 void alloc(
const std::vector<MAT *> &mats);
59 typedef typename std::vector<MAT *> mat_vector;
60 typedef typename mat_vector::iterator iterator;
61 typedef typename mat_vector::const_iterator const_iterator;
62 typedef typename mat_vector::reference reference;
63 typedef typename mat_vector::const_reference const_reference;
71 void clearMaterials(
void);
72 void setMaterial(
const MAT *);
73 void setMaterial(
size_t i,MAT *);
74 void setMaterial(
size_t i,
const MAT &);
75 void setMaterial(
const MAT *,
const std::string &);
78 bool empty(
void)
const;
104 std::set<std::string>
getNames(
void)
const;
106 std::set<int>
getTags(
void)
const;
107 boost::python::list
getTagsPy(
void)
const;
120 for(iterator i= mat_vector::begin();i!=mat_vector::end();i++)
122 (*i)=
dynamic_cast<MAT *
>(matModel->getCopy());
124 std::cerr << getClassName() <<
"::" << __FUNCTION__
125 <<
"; failed allocate material model pointer\n";
135 const size_t nMat= mats.size();
137 for(
size_t i= 0;i<nMat;i++)
141 (*this)[i]=
dynamic_cast<MAT *
>(mats[i]->getCopy());
143 std::cerr << getClassName() <<
"::" << __FUNCTION__
144 <<
"; failed allocate material model pointer\n";
169 for(iterator i= mat_vector::begin();i!=mat_vector::end();i++)
171 (*i)= new_mat->getCopy();
173 std::cerr << getClassName() <<
"::" << __FUNCTION__
174 <<
"; failed allocate material model pointer\n";
185 for(iterator i= mat_vector::begin();i!=mat_vector::end();i++)
187 (*i)= new_mat->getCopy(type.c_str());
189 std::cerr << getClassName() <<
"::" << __FUNCTION__
190 <<
"; failed allocate material model pointer\n";
205 { setMaterial(i, new_mat.getCopy()); }
215 for(iterator i= mat_vector::begin();i!=mat_vector::end();i++)
225 for(iterator i= mat_vector::begin();i!=mat_vector::end();i++)
239 if(mat_vector::empty())
242 return ((*
this)[0]==
nullptr);
249 std::vector<MAT *>::clear();
259 for(iterator i=mat_vector::begin();i!=mat_vector::end();i++)
270 for(iterator i=mat_vector::begin();i!=mat_vector::end();i++)
282 for(iterator i=mat_vector::begin();i!=mat_vector::end();i++)
295 const int nMat= this->size();
296 std::vector<Matrix> tmp(nMat);
300 for(const_iterator i=mat_vector::begin();i!=mat_vector::end();i++, count++)
302 const Matrix v= (*i)->getValues(code, silent);
304 nCols= std::max(nCols, v.
noCols());
307 retval.resize(nRows,nCols);
310 for(
int i= 0;i<nMat;i++)
313 for(
int j= 0;j<v.
noRows();j++)
315 for(
int k= 0;k<v.
noCols();k++)
318 retval(iRow,iCol)= v(j,k);
340 const size_t ncol= getGeneralizedStressSize();
341 const size_t nMat= this->size();
343 for(
size_t i= 0;i<nMat;i++)
345 const Vector &s= (*this)[i]->getGeneralizedStress();
355 const size_t ncol= getGeneralizedStrainSize();
356 const size_t nMat= this->size();
358 for(
size_t i= 0;i<nMat;i++)
360 const Vector &s= (*this)[i]->getGeneralizedStrain();
361 for(
size_t j= 0;j<ncol;j++)
372 retval= (*this)[0]->getGeneralizedStress();
373 const size_t nMat= this->size();
374 for(
size_t i= 1;i<nMat;i++)
375 retval+= (*
this)[i]->getGeneralizedStress();
385 retval= (*this)[0]->getGeneralizedStrain();
386 const size_t nMat= this->size();
387 for(
size_t i= 0;i<nMat;i++)
388 retval+= (*
this)[i]->getGeneralizedStrain();
399 const Vector &e= getMeanGeneralizedStrain();
400 const ResponseId &code= (*this)[0]->getResponseType();
401 const int order= code.
Size();
402 for(
int i= 0;i<order;i++)
413 const size_t nMat= this->size();
414 const ResponseId &code= (*this)[0]->getResponseType();
415 const int order= code.
Size();
417 for(
size_t i= 0;i<nMat;i++)
419 const Vector &e= (*this)[i]->getGeneralizedStrain();
420 for(
int j= 0;j<order;j++)
434 const Vector &f= getMeanGeneralizedStress();
435 const ResponseId &code= (*this)[0]->getResponseType();
436 const int order= code.
Size();
437 for(
int i= 0;i<order;i++)
448 const size_t nMat= this->size();
449 const ResponseId &code= (*this)[0]->getResponseType();
450 const int order= code.
Size();
452 for(
size_t i= 0;i<nMat;i++)
454 const Vector &e= (*this)[i]->getGeneralizedStress();
455 for(
int j= 0;j<order;j++)
467 const size_t nMat= this->size();
469 const ResponseId &code= (*this)[0]->getResponseType();
470 const int order= code.
Size();
471 for(
size_t i= 0;i<nMat;i++)
473 const Vector &s= (*this)[i]->getGeneralizedStress();
474 for(
int j= 0;j<order;j++)
486 const size_t nMat= this->size();
488 const ResponseId &code= (*this)[0]->getResponseType();
489 const int order= code.
Size();
490 for(
size_t i= 0;i<nMat;i++)
492 const Vector &s= (*this)[i]->getGeneralizedStrain();
493 for(
int j= 0;j<order;j++)
504 const size_t nMat= this->size();
505 const size_t sz= std::min(nMat,iS.size());
507 std::cerr << getClassName() <<
"::" << __FUNCTION__
509 << iS.size() <<
" generalized strain vectors, expected: " 511 for(
size_t i= 0;i<sz;i++)
512 (*
this)[i]->setInitialGeneralizedStrain(iS[i]);
519 const size_t nMat= this->size();
520 const size_t sz= std::min(nMat,iS.size());
522 std::cerr << getClassName() <<
"::" << __FUNCTION__
524 << iS.size() <<
" generalized strain vectors, expected: " 526 for(
size_t i= 0;i<sz;i++)
527 (*
this)[i]->incrementInitialGeneralizedStrain(iS[i]);
534 const size_t nMat= this->size();
535 for(
size_t i= 0;i<nMat;i++)
536 (*
this)[i]->zeroInitialGeneralizedStrain();
554 setDbTagDataPos(0,0);
557 setDbTagDataPos(0,1);
558 const size_t nMat= this->size();
561 for(
size_t i= 0;i<nMat;i++)
572 const int flag= getDbTagDataPos(0);
576 const size_t nMat= this->size();
580 for(
size_t i= 0;i<nMat;i++)
584 (*this)[i]= comm.getBrokedMaterial((*
this)[i],cpMat,meta);
594 std::set<std::string> retval;
595 for(const_iterator i= mat_vector::begin();i!=mat_vector::end();i++)
596 retval.insert((*i)->getName());
604 boost::python::list retval;
605 std::set<std::string> tmp= getNames();
606 for(std::set<std::string>::const_iterator i= tmp.begin();i!=tmp.end();i++)
615 std::set<int> retval;
616 for(const_iterator i= mat_vector::begin();i!=mat_vector::end();i++)
617 retval.insert((*i)->getTag());
625 boost::python::list retval;
626 std::set<int> tmp= getTags();
627 for(std::set<int>::const_iterator i= tmp.begin();i!=tmp.end();i++)
637 int res= sendData(comm);
638 const int dataTag=getDbTag();
639 res+= comm.
sendIdData(getDbTagData(),dataTag);
641 std::cerr << getClassName() <<
"::" << __FUNCTION__
642 << dataTag <<
" failed to send ID";
650 const int dataTag= this->getDbTag();
654 std::cerr << getClassName() <<
"::" << __FUNCTION__
655 << dataTag <<
" failed to receive ID\n";
657 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:465
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:634
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:132
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:266
std::set< std::string > getNames(void) const
Return the names of the materials.
Definition: MaterialVector.h:592
void setInitialGeneralizedStrains(const std::vector< Vector > &)
Assigns initial values to materials initial strains.
Definition: MaterialVector.h:502
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:369
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:237
Vector getGeneralizedStrainAtGaussPoints(const int &) const
Returns the defID component of the strain vector at Gauss points.
Definition: MaterialVector.h:411
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:338
boost::python::list getNamesPy(void) const
Return the names of the materials in a python list.
Definition: MaterialVector.h:602
size_t getGeneralizedStrainSize(void) const
Returns the size of generalized strains vector.
Definition: MaterialVector.h:333
void copyPropsFrom(const EntityWithProperties *)
copy the user defined properties of the given object on each of the materials.
Definition: MaterialVector.h:210
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:446
void incrementInitialGeneralizedStrains(const std::vector< Vector > &)
Adds to the materials initial strains the values being passed as parameters.
Definition: MaterialVector.h:517
boost::python::list getTagsPy(void) const
Return the identifiers of the materials in a python list.
Definition: MaterialVector.h:623
MaterialVector< MAT > & operator=(const MaterialVector< MAT > &)
Assignment operator.
Definition: MaterialVector.h:157
Material pointer container.
Definition: MaterialVector.h:48
Matrix getGeneralizedStrain(const int &defID) const
Returns the defID component of generalized strain vector on each integration point.
Definition: MaterialVector.h:484
size_t getGeneralizedStressSize(void) const
Returns the size of stress vector.
Definition: MaterialVector.h:328
int recvSelf(const Communicator &)
Receives object through the communicator argument.
Definition: MaterialVector.h:648
std::set< int > getTags(void) const
Return the identifiers of the materials.
Definition: MaterialVector.h:613
Objet that can execute python scripts.
Definition: CommandEntity.h:40
Stiffness material contribution response identifiers.
Definition: ResponseId.h:61
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:382
int sendData(Communicator &)
Send object members through the communicator argument.
Definition: MaterialVector.h:550
Matrix getGeneralizedStrains(void) const
Returns generalized strain values on each integration point.
Definition: MaterialVector.h:353
int commitState(void)
Commits materials state (normally after convergence).
Definition: MaterialVector.h:255
void zeroInitialGeneralizedStrains(void)
Initialize initial strains.
Definition: MaterialVector.h:532
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:570
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:542
Matrix getValues(const std::string &, bool silent=false) const
Ask the materials about the values that correspond to the code.
Definition: MaterialVector.h:292
int revertToStart(void)
Return materials to its initial state.
Definition: MaterialVector.h:278
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:115
int Size(void) const
Returns the vector size.
Definition: ID.h:115