37 static LoggerPtr logger(Logger::getLogger(
"pz.strmatrix.TPZStructMatrixGC"));
38 static LoggerPtr loggerel(Logger::getLogger(
"pz.strmatrix.element"));
39 static LoggerPtr loggerel2(Logger::getLogger(
"pz.strmatrix.elementinterface"));
40 static LoggerPtr loggerelmat(Logger::getLogger(
"pz.strmatrix.elementmat"));
41 static LoggerPtr loggerCheck(Logger::getLogger(
"pz.strmatrix.checkconsistency"));
44 #ifdef CHECKCONSISTENCY 73 cout <<
"TPZStructMatrixGC::Create should never be called\n";
78 cout <<
"TPZStructMatrixGC::Clone should never be called\n";
91 if (stiffness.
Rows() != neqcondense) {
123 if(rhs.
Rows() != neqexpand ||
Norm(rhs) != 0.)
155 LOGPZ_ERROR(logger,
"Serial_Assemble called without mesh")
159 if(dynamic_cast<TPZSubCompMesh * >(
fMesh))
161 std::stringstream sout;
162 sout <<
"AllEig = {};";
177 bool globalresult =
true;
178 bool writereadresult =
true;
180 TPZTimer calcstiff(
"Computing the stiffness matrices");
181 TPZTimer assemble(
"Assembling the stiffness matrices");
185 for(iel=0; iel < nelem; iel++) {
201 int matid = mat->
Id();
220 if(guiInterface)
if(guiInterface->
AmIKilled()){
225 if(dynamic_cast<TPZSubCompMesh * >(
fMesh))
227 std::stringstream objname;
228 objname <<
"Element" << iel;
229 std::string name = objname.str();
231 std::stringstream sout;
233 sout <<
"AppendTo[AllEig,Eigenvalues[" << name <<
"]];";
248 #ifdef CHECKCONSISTENCY
250 stiffconsist.SetOverWrite(
true);
252 result = stiffconsist.CheckObject(ek.fMat);
255 globalresult =
false;
256 std::stringstream sout;
257 sout <<
"element " << iel <<
" computed differently";
267 ek.ComputeDestinationIndices();
272 stiffness.
AddKel(ek.fMat,ek.fSourceIndex,ek.fDestinationIndex);
273 rhs.
AddFel(ef.
fMat,ek.fSourceIndex,ek.fDestinationIndex);
282 if(loggerel->isDebugEnabled())
284 std::stringstream sout;
290 gel->
X(center, xcenter);
291 sout <<
"Stiffness for computational element index " << el->
Index() << std::endl;
292 sout <<
"Stiffness for geometric element " << gel->
Index() <<
" center " << xcenter << std::endl;
295 sout <<
"Stiffness for computational element without associated geometric element\n";
304 ek.ApplyConstraints();
306 ek.ComputeDestinationIndices();
308 stiffness.
AddKel(ek.fConstrMat,ek.fSourceIndex,ek.fDestinationIndex);
313 std::stringstream sout;
317 gel->
X(center, xcenter);
318 sout <<
"Stiffness for geometric element " << gel->
Index() <<
" center " << xcenter << std::endl;
328 if(count > 20) std::cout << std::endl;
331 if(loggerCheck->isDebugEnabled())
333 std::stringstream sout;
334 sout <<
"The comparaison results are : consistency check " << globalresult <<
" write read check " << writereadresult;
350 TPZTimer calcresidual(
"Computing the residual vector");
351 TPZTimer assemble(
"Assembling the residual vector");
355 for(iel=0; iel < nelem; iel++) {
361 int matid = mat->
Id();
366 calcresidual.
start();
391 if(logger->isDebugEnabled())
393 std::stringstream sout;
394 sout << calcresidual.
processName() <<
" " << calcresidual << std::endl;
408 int64_t cols =
MAX(1, rhs.
Cols());
413 if(loggerel->isDebugEnabled())
415 std::stringstream sout;
416 stiff->
Print(
"Stiffness matrix",sout);
417 rhs.
Print(
"Right hand side", sout);
443 &threaddata, __FUNCTION__);
452 if(loggerCheck->isDebugEnabled())
454 std::stringstream sout;
483 &threaddata, __FUNCTION__);
498 : fStruct(strmat), fGuiInterface(guiInterface), fGlobMatrix(&mat), fGlobRhs(&rhs), fNextElement(0)
590 int64_t blockedel = -1;
593 if(logger->isDebugEnabled())
595 std::stringstream sout;
596 sout <<
"Checking out " << localiel <<
" next blocked element " << blockedel;
613 if (logger->isDebugEnabled())
615 std::stringstream sout;
616 sout <<
"Element can be computed iel = " << localiel <<
" element blocked " << elBl;
631 if (logger->isDebugEnabled()) {
632 std::stringstream sout;
633 sout <<
"Going to sleep cannot do " << localiel <<
" because of " << data->
felBlocked.begin()->first <<
" has to be computed first";
657 std::stringstream sout;
658 sout <<
"Element " << localiel <<
" elapsed time ";
666 if(guiInterface)
if(guiInterface->
AmIKilled()){
675 if(loggerel->isDebugEnabled())
677 std::stringstream sout;
678 ek.
fMat.
Print(
"Element stiffness matrix",sout);
679 ef.
fMat.
Print(
"Element right hand side", sout);
693 std::stringstream sout;
721 if (logger->isDebugEnabled())
723 std::stringstream sout;
724 sout << timeforel.processName() << timeforel;
732 if (logger->isDebugEnabled()) {
733 std::stringstream sout;
734 sout <<
"Computed and Assembled " << localiel;
746 if(logger->isDebugEnabled())
748 std::stringstream sout;
749 sout <<
"Element " << elBl <<
" released";
758 if(logger->isDebugEnabled()){
766 else if (dataelbl < 0)
773 if (logger->isDebugEnabled()) {
774 std::stringstream sout;
775 sout <<
"Not freeing the blocked element " << elBl;
841 if(guiInterface)
if(guiInterface->
AmIKilled()){
849 if(loggerel->isDebugEnabled())
851 std::stringstream sout;
852 ef.
fMat.
Print(
"Element right hand side", sout);
864 std::stringstream sout;
906 for (int64_t i = 0; i < connectlist.
NElements(); i++) {
907 if (elContribute[connectlist[i]] >= 0) {
915 for (int64_t i = 0; i < connectlist.
NElements(); i++) {
916 elContribute[connectlist[i]] = el;
922 for (int64_t i = 0; i < connectlist.
NElements(); i++) {
923 int64_t elBlocked = elContribute[connectlist[i]];
924 if (elBlocked == -1)
continue;
925 int64_t elBlockedIndex = elSeqinv[elBlocked];
926 if (el == -1) el = elBlockedIndex;
927 if (elBlockedIndex < el) el = elBlockedIndex;
937 for (int64_t i = 0; i < connectlist.
NElements(); i++) {
938 int64_t conindex = connectlist[i];
939 if (elContribute[conindex] != elSequence) {
942 elContribute[conindex] = -1;
947 int minPassIndex = -1;
948 for (int64_t i = 0; i < connectlist.
NElements(); i++) {
949 int64_t elcont = elContribute[connectlist[i]];
950 int64_t passindex = -1;
952 passindex = passIndex[elcont];
953 if (minPassIndex == -1) minPassIndex = passindex;
955 if (minPassIndex < passindex) minPassIndex = passindex;
963 const int64_t n_connects = cmesh->
NConnects();
969 elSequenceColor.
Resize(nel);
970 elSequenceColor.
Fill(-1);
973 int64_t nelProcessed = 0;
974 int64_t currentPassIndex = 0;
975 while (nelProcessed < elSequence.
NElements()) {
976 for (
auto elindex : elSequence) {
977 if (elSequenceColorInv[elindex] == -1) {
985 int minPass =
MinPassIndex(connectlist, elContribute, passIndex);
988 passIndex[elindex] = currentPassIndex;
990 elSequenceColor[nelProcessed] = elindex;
991 elSequenceColorInv[elindex] = nelProcessed;
993 }
else if (minPass == currentPassIndex) {
994 }
else if (minPass < currentPassIndex) {
996 const int64_t el =
WhoBlockedMe(connectlist, elContribute, elSequenceColorInv);
997 if (elBlocked[el] == -1) elBlocked[el] = nelProcessed;
998 int64_t locindex = elSequenceColor[el];
999 RemoveEl(locindex, cmesh, elContribute, locindex);
1002 passIndex[elindex] = currentPassIndex;
1004 elSequenceColor[nelProcessed] = elindex;
1005 elSequenceColorInv[elindex] = nelProcessed;
1033 int64_t numelconnected = 0;
1037 firstelconnect[0] = 0;
1038 for (int64_t ic = 0; ic < nconnect; ic++) {
1039 numelconnected += cmesh->
ConnectVec()[ic].NElConnected();
1040 firstelconnect[ic + 1] = firstelconnect[ic] + cmesh->
ConnectVec()[ic].NElConnected();
1047 for (int64_t el = 0; el < cmesh->
NElements(); el++) {
1053 for (int64_t ic = 0; ic < nc; ic++) {
1054 int64_t cindex = connectlist[ic];
1055 elconnect[firstelconnect[cindex]] = el;
1056 firstelconnect[cindex]++;
1060 firstelconnect[0] = 0;
1061 for (int64_t ic = 0; ic < nconnect; ic++) {
1062 firstelconnect[ic + 1] = firstelconnect[ic] + cmesh->
ConnectVec()[ic].NElConnected();
1073 ElementOrder.
Fill(-1);
1075 firstelconnect[0] = 0;
1076 for (int64_t ic = 0; ic < nconnect; ic++) {
1077 int64_t seqnum = cmesh->
ConnectVec()[ic].SequenceNumber();
1078 if (seqnum >= 0) nodeorder[seqnum] = ic;
1084 int64_t elsequence = 0;
1086 for (int64_t seq = 0; seq < nconnect; seq++) {
1087 int64_t ic = nodeorder[seq];
1088 if (ic == -1)
continue;
1089 int64_t firstind = firstelconnect[ic];
1090 int64_t lastind = firstelconnect[ic + 1];
1091 for (int64_t ind = firstind; ind < lastind; ind++) {
1092 int64_t el = elconnect[ind];
1096 if (elorderinv[el] == -1) elorderinv[el] = elsequence++;
1104 if (elorderinv[seq] == -1)
continue;
1105 ElementOrder[elorderinv[seq]] = seq;
1110 if (ElementOrder[seq] == -1)
break;
1112 ElementOrder.
Resize(seq);
int64_t NElements() const
Number of computational elements allocated.
Contains a class to record running statistics on CSV tables.
int fNumThreads
Number of threads in Assemble process.
virtual void Serial_Assemble(TPZMatrix< STATE > &mat, TPZFMatrix< STATE > &rhs, TPZAutoPointer< TPZGuiInterface > guiInterface)
Assemble the global system of equations into the matrix which has already been created.
virtual void Assemble(TPZMatrix< STATE > &mat, TPZFMatrix< STATE > &rhs, TPZAutoPointer< TPZGuiInterface > guiInterface) override
Assemble the global system of equations into the matrix which has already been created.
virtual TPZStructMatrixGC * Clone() override
The timer class. Utility.
TPZStructMatrixGC * fStruct
Current structmatrix object.
virtual TPZMatrix< STATE > * Create() override
Contains TPZAnalysis class which implements the sequence of actions to perform a finite element analy...
std::map< int, int > felBlocked
int ClassId() const override
Define the class id associated with the class.
void Scatter(const TPZFMatrix< TVar > &vsmall, TPZFMatrix< TVar > &vexpand) const
Contains definitions to LOGPZ_DEBUG, LOGPZ_INFO, LOGPZ_WARN, LOGPZ_ERROR and LOGPZ_FATAL, and the implementation of the inline InitializePZLOG(string) function using log4cxx library or not. It must to be called out of "#ifdef LOG4CXX" scope.
static void * ThreadWorkResidual(void *datavoid)
int MaterialId() const
Returns the material index of the element.
Timing class. Absolutely copied from GNU time. Take a look at
virtual void BuildConnectList(std::set< int64_t > &indepconnectlist, std::set< int64_t > &depconnectlist)
Builds the list of all connectivities related to the element including the connects pointed to by dep...
static void ElementColoring(TPZCompMesh *cmesh, TPZVec< int64_t > &elSequence, TPZVec< int64_t > &elSequenceColor, TPZVec< int64_t > &elBlocked)
Create blocks of elements to parallel processing.
Contains declaration of TPZGeoNode class which defines a geometrical node.
virtual TPZCompMesh * Mesh() const
Access method for the mesh pointer.
void Read(TPZStream &buf, void *context) override
read objects from the stream
void Filter(TPZVec< int64_t > &orig, TPZVec< int64_t > &dest) const
void AddFel(TPZFMatrix< TVar > &rhs, TPZVec< int64_t > &destination)
Performs a right hand side assemblage.
TPZFNMatrix< 1000, STATE > fMat
Pointer to a blocked matrix object.
Contains declaration of TPZCompEl class which defines the interface of a computational element...
Templated vector implementation.
static void * ThreadWork(void *threaddata)
The function which will compute the matrices.
static int64_t WhoBlockedMe(TPZStack< int64_t > &connectlist, TPZVec< int64_t > &elContribute, TPZVec< int64_t > &elSeqinv)
virtual void CalcStiff(TPZElementMatrix &ek, TPZElementMatrix &ef)
Computes the element stifness matrix and right hand side.
void LeaveCriticalSection(pz_critical_section_t &cs)
int64_t fNextElement
Current element.
TPZEquationFilter fEquationFilter
Object which will determine which equations will be assembled.
Declarates the TPZBlock<REAL>class which implements block matrices.
RunStatsTable stat_ass_graph("-ass_graph", "Run statistics table for the graph creation and coloring TPZStructMatrixGC.")
This class implements a simple vector storage scheme for a templated class T. Utility.
int64_t NElements() const
Access method to query the number of elements of the vector.
static void RemoveEl(int64_t el, TPZCompMesh *cmesh, TPZVec< int64_t > &elContribute, int64_t elSequence)
Implements a chunk vector with free store administration. Utility.
#define MAX(a, b)
Gets maxime value between a and b.
Contains the TPZStructMatrixGC class which responsible for a interface among Matrix and Finite Elemen...
virtual int NSides() const =0
Returns the number of connectivities of the element.
int ClassId() const override
Define the class id associated with the class.
void EnterCriticalSection(pz_critical_section_t &cs)
TPZManVector< int64_t > fDestinationIndex
void ComputeDestinationIndices()
virtual int IsInterface()
virtual void MultiThread_Assemble(TPZFMatrix< STATE > &rhs, TPZAutoPointer< TPZGuiInterface > guiInterface)
Assemble the global right hand side.
This abstract class defines the behaviour which each derived class needs to implement.
Contains declaration of TPZElementMatrix struct which associates an element matrix with the coeficien...
virtual void CenterPoint(int side, TPZVec< REAL > &masscent) const =0
It returns the coordinates from the center of the side of the element in the element coordinate space...
TPZCompMesh * fMesh
Pointer to the computational mesh from which the matrix will be generated.
#define PZ_PTHREAD_JOIN(thread, val, fn)
virtual const std::set< int > & MaterialIds()
Returns the material ids.
virtual TPZMaterial * Material() const
Identify the material object associated with the element.
void Print(std::ostream &out)
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object reallocating the necessary storage, copying the existing objects to the new...
TPZCompEl * Element(int64_t iel)
Contains declaration of TPZMesh class which defines a geometrical mesh and contains a corresponding l...
int64_t NActiveEquations() const
Retorna o numero de equacoes ativas do sistema.
TPZVec< int64_t > felSequenceColor
std::string & processName()
Gets the process name (for reporting purposes).
void start()
Turns the timer on.
virtual void Write(const bool val)
static int MinPassIndex(TPZStack< int64_t > &connectlist, TPZVec< int64_t > &elContribute, TPZVec< int64_t > &passIndex)
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
TPZVec< int64_t > * felSequenceColor
int64_t Index() const
Returns the index of the element within the element vector of the mesh.
TVar Norm(const TPZFMatrix< TVar > &A)
Returns the norm of the matrix A.
Contains TPZMatrixclass which implements full matrix (using column major representation).
Implements a group of computational elements as a mesh and an element. Computational Mesh...
#define DebugStop()
Returns a message to user put a breakpoint in.
Structure to manipulate thread to solve system equations.
#define LOGPZ_DEBUG(A, B)
Define log for debug info.
Free store vector implementation.
static void OrderElement(TPZCompMesh *cmesh, TPZVec< int64_t > &ElementOrder)
Find the order to assemble the elements.
pthread_cond_t fCondition
TPZMatrix< STATE > * fGlobMatrix
Global matrix.
int64_t Rows() const
Returns number of rows.
static void AssembleColor(int64_t el, TPZStack< int64_t > &connectlist, TPZVec< int64_t > &elContribute)
ThreadData(TPZStructMatrixGC *strmat, TPZMatrix< STATE > &mat, TPZFMatrix< STATE > &rhs, std::set< int > &MaterialIds, TPZAutoPointer< TPZGuiInterface > guiInterface)
Initialize the mutex semaphores and others.
virtual void AddKel(TPZFMatrix< TVar > &elmat, TPZVec< int64_t > &destinationindex)
Add a contribution of a stiffness matrix.
virtual TPZMatrix< STATE > * CreateAssemble(TPZFMatrix< STATE > &rhs, TPZAutoPointer< TPZGuiInterface > guiInterface, unsigned numthreads_assemble, unsigned numthreads_decompose)
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
TPZAutoPointer< TPZGuiInterface > fGuiInterface
Gui interface object.
#define PZ_PTHREAD_MUTEX_DESTROY(mutex, fn)
int64_t NEqExpand() const
Retorna o numero de equacoes do sistema original.
int64_t NConnects() const
Number of connects allocated including free nodes.
TPZAdmChunkVector< TPZConnect > & ConnectVec()
Return a reference to the connect pointers vector.
int64_t Index() const
Returns element index of the mesh fELementVec list.
virtual bool ShouldCompute(int matid) const
Establish whether the element should be computed.
Implements an interface to check the consistency of two implementations. Utility. ...
TPZVec< int64_t > * fnextBlocked
Vector for mesh coloring.
TPZManVector< int64_t > fSourceIndex
std::set< int > fMaterialIds
Set of material ids to be considered. It is a private attribute.
#define LOGPZ_ERROR(A, B)
Define log for errors (cout)
static RunStatsTable ass_rhs("-ass_rhs", "Assemble Stiffness")
TPZVec< int64_t > fnextBlocked
Vectors for mesh coloring.
Contains declaration of TPZCompMesh class which is a repository for computational elements...
int Redim(const int64_t newRows, const int64_t newCols) override
Redimension a matrix and ZERO your elements.
Refines geometrical mesh (all the elements) num times.
bool NeedsComputing(const std::set< int > &matids) override
Verifies if any element needs to be computed corresponding to the material ids.
int32_t Hash(std::string str)
This class associates an element matrix with the coeficients of its contribution in the global stiffn...
TPZFNMatrix< 1000, STATE > fConstrMat
Pointer to the constrained matrix object.
void ApplyConstraints()
Apply the constraints applied to the nodes by transforming the tangent matrix and right hand side...
Contains declaration of TPZSubCompMesh class which implements a group of computational elements as a ...
~ThreadData()
Destructor: Destroy the mutex semaphores and others.
virtual int Dimension() const =0
Returns the dimension of the element.
virtual void CalcResidual(TPZElementMatrix &ef)
Computes the element right hand side.
TPZGeoEl * Reference() const
Return a pointer to the corresponding geometric element if such exists, return 0 otherwise.
virtual void X(TPZVec< REAL > &qsi, TPZVec< REAL > &result) const =0
Return the coordinate in real space of the point coordinate in the master element space...
static bool CanAssemble(TPZStack< int64_t > &connectlist, TPZVec< int64_t > &elContribute)
Implements computational mesh. Computational Mesh.
TPZAdmChunkVector< TPZCompEl * > & ElementVec()
Returns a reference to the element pointers vector.
virtual void Print(std::ostream &out=std::cout) const
Prints element data.
#define PZ_PTHREAD_CREATE(thread, attr, routine, args, fn)
Contains declaration of TPZInterpolatedElement class which implements computational element of the in...
void Fill(const T ©, const int64_t from=0, const int64_t numelem=-1)
Will fill the elements of the vector with a copy object.
pthread_mutex_t fAccessElement
Mutexes (to choose which element is next)
int64_t Cols() const
Returns number of cols.
virtual void FilterEquations(TPZVec< int64_t > &origindex, TPZVec< int64_t > &destindex) const
Filter out the equations which are out of the range.
virtual void Print(std::ostream &out) const
Defines the interface for saving and reading data. Persistency.
void stop()
Turns the timer off, and computes the elapsed time.
int64_t NElements() const
Returns the number of elements of the vector.
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
#define PZ_PTHREAD_MUTEX_INIT(mutex, attr, fn)
virtual void Print(std::ostream &out=std::cout)
Print all relevant data of the element to cout.
Defines the interface of a computational element. Computational Element.
virtual int HasDependency()
Returns 1 if the element has at least one dependent node. Returns 0 otherwise.
bool HasDependency()
Returns true if the element has at least one dependent node. Returns false otherwise.
static RunStatsTable ass_stiff("-ass_stiff", "Assemble Stiffness")
void Read(TPZStream &buf, void *context) override
read objects from the stream
Implements an interface to register a class id and a restore function. Persistence.
Contains TPZSFMatrix class which implements a symmetric full matrix.
virtual void Read(bool &val)
TPZFMatrix< STATE > * fGlobRhs
Global rhs vector.