38 static LoggerPtr logger(Logger::getLogger(
"pz.strmatrix.TPZStructMatrixOR"));
39 static LoggerPtr loggerel(Logger::getLogger(
"pz.strmatrix.element"));
40 static LoggerPtr loggerel2(Logger::getLogger(
"pz.strmatrix.elementinterface"));
41 static LoggerPtr loggerelmat(Logger::getLogger(
"pz.strmatrix.elementmat"));
42 static LoggerPtr loggerCheck(Logger::getLogger(
"pz.strmatrix.checkconsistency"));
43 static LoggerPtr loggerGlobStiff(Logger::getLogger(
"pz.strmatrix.globalstiffness"));
46 #ifdef CHECKCONSISTENCY 66 cout <<
"TPZStructMatrixOR::Create should never be called\n";
71 cout <<
"TPZStructMatrixOR::Clone should never be called\n";
85 if (stiffness.
Rows() != neqcondense) {
112 if (rhs.
Rows() != neqexpand ||
Norm(rhs) != 0.) {
137 LOGPZ_ERROR(logger,
"Serial_Assemble called without mesh")
141 if (loggerelmat->isDebugEnabled()) {
142 if (dynamic_cast<TPZSubCompMesh *> (
fMesh)) {
143 std::stringstream sout;
144 sout <<
"AllEig = {};";
160 bool globalresult =
true;
161 bool writereadresult =
true;
163 TPZTimer calcstiff(
"Computing the stiffness matrices");
164 TPZTimer assemble(
"Assembling the stiffness matrices");
168 for (iel = 0; iel < nelem; iel++) {
182 if (!(count % 1000)) {
186 if (!(count % 20000)) {
193 if (guiInterface)
if (guiInterface->
AmIKilled()) {
198 if (loggerelmat->isDebugEnabled()) {
199 if (dynamic_cast<TPZSubCompMesh *> (
fMesh)) {
200 std::stringstream objname;
201 objname <<
"Element" << iel;
202 std::string name = objname.str();
204 std::stringstream sout;
206 sout <<
"AppendTo[AllEig,Eigenvalues[" << name <<
"]];";
221 #ifdef CHECKCONSISTENCY
223 stiffconsist.SetOverWrite(
true);
225 result = stiffconsist.CheckObject(ek.fMat);
227 globalresult =
false;
228 std::stringstream sout;
229 sout <<
"element " << iel <<
" computed differently";
238 if (!ek.HasDependency()) {
239 ek.ComputeDestinationIndices();
244 stiffness.
AddKel(ek.fMat, ek.fSourceIndex, ek.fDestinationIndex);
247 REAL eknorm =
Norm(ek.fMat);
248 if (std::isnan(rhsnorm) || std::isnan(eknorm)) {
249 std::cout <<
"element " << iel <<
" has norm " << rhsnorm << std::endl;
251 ek.fMat.Print(
"ek",std::cout);
255 rhs.
AddFel(ef.
fMat, ek.fSourceIndex, ek.fDestinationIndex);
263 if (loggerel->isDebugEnabled()) {
264 std::stringstream sout;
269 gel->
X(center, xcenter);
270 sout <<
"Stiffness for computational element index " << el->
Index() <<
" material id " << gel->
MaterialId() << std::endl;
271 sout <<
"Stiffness for geometric element " << gel->
Index() <<
" center " << xcenter << std::endl;
273 sout <<
"Stiffness for computational element without associated geometric element index " << el->
Index() <<
"\n";
282 ek.ApplyConstraints();
284 ek.ComputeDestinationIndices();
286 stiffness.
AddKel(ek.fConstrMat, ek.fSourceIndex, ek.fDestinationIndex);
290 if (loggerel->isDebugEnabled()) {
291 std::stringstream sout;
303 gel->
X(center, xcenter);
304 sout <<
"Stiffness for geometric element " << gel->
Index() <<
" center " << xcenter << std::endl;
306 sout <<
"Stiffness for computational element index " << iel << std::endl;
354 if (count > 1000) std::cout << std::endl;
357 if (loggerCheck->isDebugEnabled()) {
358 std::stringstream sout;
359 sout <<
"The comparaison results are : consistency check " << globalresult <<
" write read check " << writereadresult;
362 if (loggerGlobStiff->isDebugEnabled())
364 std::stringstream sout;
379 TPZTimer calcresidual(
"Computing the residual vector");
380 TPZTimer assemble(
"Assembling the residual vector");
384 for (iel = 0; iel < nelem; iel++) {
412 calcresidual.
start();
418 if(loggerel->isDebugEnabled())
420 std::stringstream sout;
425 gel->
X(center, xcenter);
426 sout <<
"Residual for computational element index " << el->
Index() <<
" material id " << gel->
MaterialId() << std::endl;
427 sout <<
"Residual for geometric element " << gel->
Index() <<
" center " << xcenter << std::endl;
429 sout <<
"Residual for computational element without associated geometric element index " << el->
Index() <<
"\n";
448 if(loggerel->isDebugEnabled())
450 std::stringstream sout;
461 if (logger->isDebugEnabled()) {
462 std::stringstream sout;
463 sout << calcresidual.
processName() <<
" " << calcresidual << std::endl;
484 &threaddata, __FUNCTION__);
494 if (loggerCheck->isDebugEnabled()) {
495 std::stringstream sout;
517 &threaddata, __FUNCTION__);
531 : fStruct(strmat), fGuiInterface(guiInterface), fGlobMatrix(&mat), fGlobRhs(&rhs), fNextElement(0) {
663 if (guiInterface)
if (guiInterface->
AmIKilled()) {
674 if (loggerel->isDebugEnabled()) {
675 std::stringstream sout;
676 sout <<
"Element index " << iel << std::endl;
677 ek->
fMat.
Print(
"Element stiffness matrix", sout);
678 ef->
fMat.
Print(
"Element right hand side", sout);
694 std::stringstream sout;
703 if (loggerel->isDebugEnabled()) {
704 std::stringstream sout;
705 sout <<
"Element index " << iel << std::endl;
743 while (nextel < nel || numprocessed) {
744 if (guiInterface)
if (guiInterface->
AmIKilled()) {
748 std::set<int>::iterator itprocess;
749 bool keeplooking =
false;
753 if (itavail->first == *itprocess) {
758 int iel = *itprocess;
765 if (logger->isDebugEnabled()) {
766 std::stringstream sout;
767 sout <<
"Assembling element " << iel;
771 #ifdef CHECKCONSISTENCY
773 stiffconsist.SetOverWrite(
true);
775 result = stiffconsist.CheckObject(ek->
fMat);
777 globalresult =
false;
778 std::stringstream sout;
779 sout <<
"element " << iel <<
" computed differently";
808 if (logger->isDebugEnabled()) {
809 LOGPZ_DEBUG(logger,
"Going to sleep within assembly")
822 if (logger->isDebugEnabled()) {
834 if (loggerCheck->isDebugEnabled()) {
835 std::stringstream sout;
836 sout <<
"nextel = " << nextel <<
" numprocessed = " << numprocessed <<
" submitted " << data->
fSubmitted.size() << std::endl;
841 if (loggerCheck->isDebugEnabled()) {
842 std::stringstream sout;
873 if (logger->isDebugEnabled()) {
874 std::stringstream sout;
875 sout << __PRETTY_FUNCTION__ <<
" returning " << nextel <<
" fNextElement " <<
fNextElement;
int ClassId() const override
Define the class id associated with the class.
int64_t NElements() const
Number of computational elements allocated.
static RunStatsTable ass_stiff("-ass_stiff", "Assemble Stiffness")
Contains a class to record running statistics on CSV tables.
int fNumThreads
Number of threads in Assemble process.
#define PZ_PTHREAD_MUTEX_UNLOCK(mutex, fn)
TPZAutoPointer< TPZGuiInterface > fGuiInterface
Gui interface object.
The timer class. Utility.
Contains TPZAnalysis class which implements the sequence of actions to perform a finite element analy...
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
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.
Structure to manipulate thread to solve system equations.
int MaterialId() const
Returns the material index of the element.
Timing class. Absolutely copied from GNU time. Take a look at
Contains declaration of TPZGeoNode class which defines a geometrical node.
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.
pthread_mutex_t fAccessElement
Mutexes (to choose which element is next)
Contains the declaration of the TPZElementGroup class, which implements an computational element whic...
TPZFMatrix< STATE > * fGlobRhs
Global rhs vector.
virtual bool NeedsComputing(const std::set< int > &materialids)
return true if the element has a variational statement associated with the material ids ...
virtual void CalcStiff(TPZElementMatrix &ek, TPZElementMatrix &ef)
Computes the element stifness matrix and right hand side.
~ThreadData()
Destructor: Destroy the mutex semaphores and others.
TPZEquationFilter fEquationFilter
Object which will determine which equations will be assembled.
Declarates the TPZBlock<REAL>class which implements block matrices.
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.
Implements a chunk vector with free store administration. Utility.
std::map< int, std::pair< TPZAutoPointer< TPZElementMatrix >, TPZAutoPointer< TPZElementMatrix > > > fSubmitted
List of computed element matrices (autopointers?)
virtual int NSides() const =0
Returns the number of connectivities of the element.
Contains the TPZStructMatrixOR class which responsible for a interface among Matrix and Finite Elemen...
int ClassId() const override
Define the class id associated with the class.
static void * ThreadWork(void *threaddata)
The function which will compute the matrices.
TPZManVector< int64_t > fDestinationIndex
void ComputeDestinationIndices()
virtual int IsInterface()
Refines geometrical mesh (all the elements) num times.
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.
virtual TPZStructMatrixOR * Clone() override
void Print(std::ostream &out)
int64_t fNextElement
Current element.
ThreadData(TPZStructMatrixOR *strmat, TPZMatrix< STATE > &mat, TPZFMatrix< STATE > &rhs, std::set< int > &MaterialIds, TPZAutoPointer< TPZGuiInterface > guiInterface)
Initialize the mutex semaphores and others.
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.
TPZStructMatrixOR * fStruct
Current structmatrix object.
#define PZ_PTHREAD_MUTEX_LOCK(mutex, fn)
std::string & processName()
Gets the process name (for reporting purposes).
void start()
Turns the timer on.
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
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.
#define LOGPZ_DEBUG(A, B)
Define log for debug info.
Free store vector implementation.
TPZMatrix< STATE > * fGlobMatrix
Global matrix.
int64_t Rows() const
Returns number of rows.
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.
int64_t NextElement()
Look for an element index which needs to be computed and put it on the stack.
virtual void MultiThread_Assemble(TPZFMatrix< STATE > &rhs, TPZAutoPointer< TPZGuiInterface > guiInterface)
Assemble the global right hand side.
virtual void AddKel(TPZFMatrix< TVar > &elmat, TPZVec< int64_t > &destinationindex)
Add a contribution of a stiffness matrix.
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_DESTROY(mutex, fn)
int64_t NEqExpand() const
Retorna o numero de equacoes do sistema original.
Contains declaration of TPZCheckMesh class which verifies the consistency of the datastructure of a T...
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. ...
TPZManVector< int64_t > fSourceIndex
virtual void InitializeElementMatrix(TPZElementMatrix &ek, TPZElementMatrix &ef)
Initialize element matrix in which is computed CalcStiff.
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)
Contains declaration of TPZCompMesh class which is a repository for computational elements...
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.
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.
static RunStatsTable ass_rhs("-ass_rhs", "Assemble Stiffness")
void ApplyConstraints()
Apply the constraints applied to the nodes by transforming the tangent matrix and right hand side...
static void * ThreadAssembly(void *threaddata)
The function which will compute the assembly.
Contains declaration of TPZSubCompMesh class which implements a group of computational elements as a ...
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.
std::set< int > fProcessed
Elements which are being processed.
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...
TPZSemaphore fAssembly
Semaphore (to wake up assembly thread)
void Reset(TPZCompMesh *mesh=NULL, MType type=Unknown)
Reset the data structure.
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...
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.
void Read(TPZStream &buf, void *context) override
read objects from the stream
#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.
void ComputedElementMatrix(int64_t iel, TPZAutoPointer< TPZElementMatrix > &ek, TPZAutoPointer< TPZElementMatrix > &ef)
Put the computed element matrices in the map.
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.
virtual bool HasRange() const
Verify if a range has been specified.
bool HasDependency()
Returns true if the element has at least one dependent node. Returns false otherwise.
virtual TPZMatrix< STATE > * Create() override
void Read(TPZStream &buf, void *context) override
read objects from the stream
Implements computational element based on an interpolation space. Computational Element.
Implements an interface to register a class id and a restore function. Persistence.
Contains TPZSFMatrix class which implements a symmetric full matrix.