38 static LoggerPtr logger(Logger::getLogger(
"pz.strmatrix.TPZStructMatrixCS"));
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"));
45 #ifdef CHECKCONSISTENCY 63 cout <<
"TPZStructMatrixCS::Create should never be called\n";
68 cout <<
"TPZStructMatrixCS::Clone should never be called\n";
82 if (stiffness.
Rows() != neqcondense) {
114 if(rhs.
Rows() != neqexpand ||
Norm(rhs) != 0.)
146 LOGPZ_ERROR(logger,
"Serial_Assemble called without mesh")
150 if(dynamic_cast<TPZSubCompMesh * >(
fMesh))
152 std::stringstream sout;
153 sout <<
"AllEig = {};";
168 bool globalresult =
true;
169 bool writereadresult =
true;
171 TPZTimer calcstiff(
"Computing the stiffness matrices");
172 TPZTimer assemble(
"Assembling the stiffness matrices");
176 for(iel=0; iel < nelem; iel++) {
192 int matid = mat->
Id();
211 if(guiInterface)
if(guiInterface->
AmIKilled()){
216 if(dynamic_cast<TPZSubCompMesh * >(
fMesh))
218 std::stringstream objname;
219 objname <<
"Element" << iel;
220 std::string name = objname.str();
222 std::stringstream sout;
224 sout <<
"AppendTo[AllEig,Eigenvalues[" << name <<
"]];";
239 #ifdef CHECKCONSISTENCY
241 stiffconsist.SetOverWrite(
true);
243 result = stiffconsist.CheckObject(ek.fMat);
246 globalresult =
false;
247 std::stringstream sout;
248 sout <<
"element " << iel <<
" computed differently";
258 ek.ComputeDestinationIndices();
263 stiffness.
AddKel(ek.fMat,ek.fSourceIndex,ek.fDestinationIndex);
264 rhs.
AddFel(ef.
fMat,ek.fSourceIndex,ek.fDestinationIndex);
273 if(loggerel->isDebugEnabled())
275 std::stringstream sout;
281 gel->
X(center, xcenter);
282 sout <<
"Stiffness for computational element index " << el->
Index() << std::endl;
283 sout <<
"Stiffness for geometric element " << gel->
Index() <<
" center " << xcenter << std::endl;
286 sout <<
"Stiffness for computational element without associated geometric element\n";
295 ek.ApplyConstraints();
297 ek.ComputeDestinationIndices();
299 stiffness.
AddKel(ek.fConstrMat,ek.fSourceIndex,ek.fDestinationIndex);
304 std::stringstream sout;
308 gel->
X(center, xcenter);
309 sout <<
"Stiffness for geometric element " << gel->
Index() <<
" center " << xcenter << std::endl;
319 if(count > 20) std::cout << std::endl;
322 if(loggerCheck->isDebugEnabled())
324 std::stringstream sout;
325 sout <<
"The comparaison results are : consistency check " << globalresult <<
" write read check " << writereadresult;
341 TPZTimer calcresidual(
"Computing the residual vector");
342 TPZTimer assemble(
"Assembling the residual vector");
346 for(iel=0; iel < nelem; iel++) {
352 int matid = mat->
Id();
357 calcresidual.
start();
382 if(logger->isDebugEnabled())
384 std::stringstream sout;
385 sout << calcresidual.
processName() <<
" " << calcresidual << std::endl;
399 int64_t cols =
MAX(1, rhs.
Cols());
404 if(loggerel->isDebugEnabled())
406 std::stringstream sout;
407 stiff->
Print(
"Stiffness matrix",sout);
408 rhs.
Print(
"Right hand side", sout);
421 AssembleTask tasks(&threaddata);
436 &threaddata, __FUNCTION__);
446 if(loggerCheck->isDebugEnabled())
448 std::stringstream sout;
463 AssembleTask tasks(&threaddata);
478 &threaddata, __FUNCTION__);
494 : fStruct(strmat), fGuiInterface(guiInterface), fGlobMatrix(&mat), fGlobRhs(&rhs), fNextElement(0)
587 if (logger->isDebugEnabled()) {
588 std::stringstream sout;
589 sout <<
"Computing element " << iel;
594 std::stringstream sout;
595 sout <<
"Element " << iel <<
" elapsed time ";
624 if(guiInterface)
if(guiInterface->
AmIKilled()){
636 if(loggerel->isDebugEnabled())
638 std::stringstream sout;
639 sout <<
"Element index " << iel << std::endl;
640 ek->
fMat.
Print(
"Element stiffness matrix",sout);
641 ef->
fMat.
Print(
"Element right hand side", sout);
659 std::stringstream sout;
668 if(loggerel->isDebugEnabled())
670 std::stringstream sout;
671 sout <<
"Element index " << iel << std::endl;
706 if (logger->isDebugEnabled())
708 std::stringstream sout;
709 sout << timeforel.processName() << timeforel;
753 int matid = mat->
Id();
763 void TPZStructMatrixCS::AssembleTask::operator()(
const tbb::blocked_range<size_t>& range)
const 768 for(
size_t iel=range.begin(); iel!=range.end(); ++iel )
771 if (logger->isDebugEnabled()) {
772 std::stringstream sout;
773 sout <<
"Computing element " << iel;
778 std::stringstream sout;
779 sout <<
"Element " << iel <<
" elapsed time ";
786 if (data->fGlobMatrix) {
803 if (data->fGlobMatrix) {
811 if(guiInterface)
if(guiInterface->
AmIKilled()){
818 if(data->fStruct->HasRange())
823 if(loggerel->isDebugEnabled())
825 std::stringstream sout;
826 sout <<
"Element index " << iel << std::endl;
827 ek->
fMat.
Print(
"Element stiffness matrix",sout);
828 ef->
fMat.
Print(
"Element right hand side", sout);
834 if (data->fGlobMatrix) {
839 if(data->fStruct->HasRange())
846 std::stringstream sout;
855 if(loggerel->isDebugEnabled())
857 std::stringstream sout;
858 sout <<
"Element index " << iel << std::endl;
868 if (logger->isDebugEnabled())
870 std::stringstream sout;
871 sout << timeforel.processName() << timeforel;
879 if (data->fGlobMatrix) {
891 if (data->fGlobMatrix) {
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.
#define PZ_PTHREAD_MUTEX_UNLOCK(mutex, fn)
virtual TPZMatrix< STATE > * Create() override
Sets number of threads in Assemble process.
The timer class. Utility.
static RunStatsTable ass_rhs("-ass_rhs", "Assemble Stiffness")
Contains TPZAnalysis class which implements the sequence of actions to perform a finite element analy...
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.
pthread_mutex_t fAccessElementF
Mutexes (to choose which element is next)
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.
Refines geometrical mesh (all the elements) num times.
virtual void CalcStiff(TPZElementMatrix &ek, TPZElementMatrix &ef)
Computes the element stifness matrix and right hand side.
int64_t fNextElement
Current element.
Contains the TPZStructMatrixCS class which responsible for a interface among Matrix and Finite Elemen...
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.
#define MAX(a, b)
Gets maxime value between a and b.
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.
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.
TPZManVector< int64_t > fDestinationIndex
void ComputeDestinationIndices()
static RunStatsTable ass_stiff("-ass_stiff", "Assemble Stiffness")
pthread_mutex_t fAccessElement
Mutexes (to choose which element is next)
virtual int IsInterface()
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)
void Read(TPZStream &buf, void *context) override
read objects from the stream
pthread_mutex_t fAccessElementK
Mutexes (to choose which element is next)
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.
#define PZ_PTHREAD_MUTEX_LOCK(mutex, fn)
std::string & processName()
Gets the process name (for reporting purposes).
void start()
Turns the timer on.
TPZMatrix< STATE > * fGlobMatrix
Global matrix.
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
virtual void MultiThread_Assemble(TPZFMatrix< STATE > &rhs, TPZAutoPointer< TPZGuiInterface > guiInterface)
Assemble the global right hand side.
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.
void parallel_for(int n, body_t &obj)
int64_t Rows() const
Returns number of rows.
virtual TPZMatrix< STATE > * CreateAssemble(TPZFMatrix< STATE > &rhs, TPZAutoPointer< TPZGuiInterface > guiInterface, unsigned numthreads_assemble, unsigned numthreads_decompose)
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)
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
int64_t NEqExpand() const
Retorna o numero de equacoes do sistema original.
TPZFMatrix< STATE > * fGlobRhs
Global rhs 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. ...
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)
ThreadData(TPZStructMatrixCS *strmat, TPZMatrix< STATE > &mat, TPZFMatrix< STATE > &rhs, std::set< int > &MaterialIds, TPZAutoPointer< TPZGuiInterface > guiInterface)
Initialize the mutex semaphores and others.
Contains declaration of TPZCompMesh class which is a repository for computational elements...
TPZAutoPointer< TPZGuiInterface > fGuiInterface
Gui interface object.
int Redim(const int64_t newRows, const int64_t newCols) override
Redimension a matrix and ZERO your elements.
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)
~ThreadData()
Destructor: Destroy the mutex semaphores and others.
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.
TPZStructMatrixCS * fStruct
Current structmatrix 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 ...
int ClassId() const override
Define the class id associated with the class.
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 TPZStructMatrixCS * Clone() override
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...
int64_t NextElement()
Look for an element index which needs to be computed and put it on the stack.
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.
#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.
bool ShouldCompute(int matid)
Establish whether the element should be computed.
Defines the interface of a computational element. Computational Element.
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.
Structure to manipulate thread to solve system equations.
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.
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.
static void * ThreadWork(void *threaddata)
The function which will compute the matrices.