20 #include "pzviscoelastic.h" 30 #include <tbb/blocked_range.h> 31 #include <tbb/partitioner.h> 32 #include <tbb/task_scheduler_init.h> 33 #include <tbb/parallel_for.h> 42 clarg::argInt nloop(
"-l",
"Number of loop iterations of the Subst_Backward/Subst_Forward", 1);
57 vector<TPZSkylMatrix<REAL>* > *fTasks;
59 void operator()(
const tbb::blocked_range<size_t>& range)
const {
60 for(
size_t i=range.begin(); i!=range.end(); ++i ) {
61 (*fTasks)[i]->Decompose_Cholesky();
66 class tbb_substitution {
69 vector<TPZSkylMatrix<REAL>* > *fTasks;
71 void operator()(
const tbb::blocked_range<size_t>& range)
const {
72 for(
size_t i=range.begin(); i!=range.end(); ++i ) {
74 (*fTasks)[i]->Subst_Forward(&
f);
75 (*fTasks)[i]->Subst_Backward(&
f);
83 printf(
"\nUsage: %s\n", prog);
84 printf(
"Arguments: \n");
91 int main(
int argc,
char **argv)
95 cerr <<
"Error when parsing the arguments!" << endl;
107 std::sort(fTasks->begin(), fTasks->end(),
wayToSort);
117 for(
int i=0; i<fTasks->size(); i++)
122 cout <<
"The copied matrix has Memory Foot Print of : " << (orig->MemoryFootprint()/(1024*1024)) <<
" MBs" << endl;
125 tbb::task_scheduler_init init;
132 cout <<
"TPZSkylMatrix::Decompose_Cholesky()" << endl;
133 for (
int i=0; i<nmatrices; i++) {
134 (*fTasks)[i]->Decompose_Cholesky();
138 cout <<
"TPZSkylMatrix::Subst_Backward/Subst_Forward()" << endl;
141 for (
int i=0; i<nmatrices; i++) {
143 (*fTasks)[i]->Subst_Forward(&f);
144 (*fTasks)[i]->Subst_Backward(&f);
152 disp.fTasks = fTasks;
154 tbb::affinity_partitioner ap;
155 cout <<
"TPZSkylMatrix::Decompose_Cholesky()" << endl;
158 parallel_for(tbb::blocked_range<size_t>(0, nmatrices), disp, ap);
160 parallel_for(tbb::blocked_range<size_t>(0, nmatrices), disp);
162 tbb_substitution dispb;
163 dispb.fTasks = fTasks;
164 cout <<
"TPZSkylMatrix::Subst_Backward/Subst_Forward()" << endl;
168 parallel_for(tbb::blocked_range<size_t>(0, nmatrices), dispb, ap);
170 parallel_for(tbb::blocked_range<size_t>(0, nmatrices), dispb);
174 cout <<
"Compiled without TBB support." << endl;
189 bool countnodes =
false;
190 bool countelements =
false;
192 ifstream
read (filename.c_str());
193 if (!
read.is_open()) {
194 cerr <<
"Could not open file: " << filename << endl;
201 read.getline(buf, 1024);
202 std::string str(buf);
203 if(str ==
"Coordinates") countnodes =
true;
204 if(str ==
"end coordinates") countnodes =
false;
205 if(countnodes) numnodes++;
207 if(str ==
"Elements") countelements =
true;
208 if(str ==
"end elements") countelements =
false;
209 if(countelements) numelements++;
215 gMesh -> NodeVec().Resize(numnodes);
219 const int Qnodes = numnodes;
223 int64_t nodeId = 0, elementId = 0, matElId = 1;
226 read.open(filename.c_str());
228 double nodecoordX , nodecoordY , nodecoordZ ;
231 read.getline(buf, 1024);
232 read.getline(buf, 1024);
233 std::string str(buf);
235 for(in=0; in<numnodes; in++)
241 Node[nodeId-1].SetNodeId(nodeId);
242 Node[nodeId-1].SetCoord(0,nodecoordX);
243 Node[nodeId-1].SetCoord(1,nodecoordY);
244 Node[nodeId-1].SetCoord(2,nodecoordZ);
245 gMesh->
NodeVec()[nodeId-1] = Node[nodeId-1];
250 read.open(filename.c_str());
252 int l ,
m = numnodes+5;
255 read.getline(buf, 1024);
261 for(el=0; el<numelements; el++)
264 read >> TopolTetra[0];
265 read >> TopolTetra[1];
266 read >> TopolTetra[2];
267 read >> TopolTetra[3];
283 for(el=0; el<numelements; el++)
290 for (
int i = 0; i < 4; i++)
293 Nodefinder[i] = gMesh->
NodeVec()[pos];
294 Nodefinder[i].GetCoordinates(nodecoord);
295 if (nodecoord[2] == 0.)
298 ncoordzVec.
Resize(sizeOfVec);
299 ncoordzVec[sizeOfVec-1] = pos;
342 template<
class TTVar>
346 fSubMeshIndex(submesh_idx), fSubstruct(substruct) {}
365 fAssembly(assembly), fMesh(mesh) {}
376 typename std::vector<work_item_t<TVar> >::iterator it = work_items.begin();
377 typename std::vector<work_item_t<TVar> >::iterator end = work_items.end();
379 for (;it != end; it++)
389 void operator()(
const blocked_range<size_t>& range)
const 391 for(
size_t i=range.begin(); i!=range.end(); ++i ) {
399 void run_parallel_for()
403 parallel_for(blocked_range<size_t>(0,work_items.size(), 1 ), *
this);
416 const std::list<TPZAutoPointer<TPZDohrSubstructCondense<STATE> > > &sublist = dohr->
SubStructures();
417 vector<TPZSkylMatrix<STATE>* > *fSkyTasks =
new vector<TPZSkylMatrix<STATE>* >();
418 std::list<TPZAutoPointer<TPZDohrSubstructCondense<STATE> > >::const_iterator it = sublist.begin();
425 std::cout <<
"TPZDohrStructMatrix::Assemble()" << std::endl;
426 for (
unsigned isub=0; isub<
nsub ; isub++) {
428 if(!submesh)
continue;
429 parallel_tasks.push_work_item(isub, *it);
434 parallel_tasks.run_parallel_for();
436 parallel_tasks.run_serial();
439 it = sublist.begin();
440 for (
unsigned isub=0; isub<
nsub ; isub++) {
442 if(!submesh)
continue;
450 fSkyTasks->push_back(sky);
458 fSkyTasks->push_back(sky);
470 cmeshauto->SetDimModel(3);
472 cmeshauto->AutoBuild();
477 cout <<
"TPZDohrStructMatrix::SubStructure()" << endl;
480 cout <<
"TPZDohrStructMatrix::Create()" << endl;
Assembling using Dohrmann algorithm. Sub structure.
static void SetgOrder(int order)
Sets the value of the default interpolation order.
int main(int argc, char **argv)
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.
Implements a vector class which allows to use external storage provided by the user. Utility.
clarg::argBool bc("-bc", "binary checkpoints", false)
Contains the TPZDohrSubstruct class which implements sub structure matrices using Dohrman algorithm...
TPZAutoPointer< TPZDohrAssembly< TVar > > fAssembly
Contains the TPZVTKGraphMesh class which implements the graphical mesh to VTK environment.
Contains declaration of TPZCompEl class which defines the interface of a computational element...
TPZAutoPointer< TPZDohrAssembly< STATE > > Assembly()
static TPZSubCompMesh * SubMesh(TPZAutoPointer< TPZCompMesh > compmesh, int isub)
return a pointer to the isub submesh
This class implements a 3D isotropic elasticity material.
Contains the TPZDohrMatrix class which implements a matrix divided into substructures. Also contains the TPZDohrThreadMultData and TPZDohrThreadMultList structs.
clarg::argBool aff_tbb("-aff", "Use of affinity partitioner", false)
virtual int64_t MemoryFootprint() const override
Returns the approximate size of the memory footprint (amount of memory required to store this object)...
clarg::argInt plevel("-p", "plevel", 1)
clarg::argInt nsub("-nsub", "number of substructs", 32)
Utility class which represents an element with its side. The Geometric approximation classes Geometry...
Contains declaration of TPZGeoElBC class, it is a structure to help the construction of geometric ele...
TPZGeoMesh * malha_predio(string filename)
TPZAutoPointer< TPZCompMesh > fMesh
Implements a matrix divided into substructures. Matrix Sub structure.
virtual int64_t NodeIndex(int i) const =0
Returns the index of the ith node the index is the location of the node in the nodevector of the mesh...
Contains the TPZDohrAssembly class which implements assembling using Dohrmann algorithm.
int WhichSide(TPZVec< int64_t > &SideNodeIds)
Returns the side number which is connected to the SideNodes returns -1 if no side is found...
Implements a skyline storage format. A Skyline matrix is symmetric so square. Matrix.
Contains the TPZDohrStructMatrix class which implements structural matrix divided in sub structures...
Contains the TPZElasticity3D class which implements a 3D isotropic elasticity material.
This abstract class defines the behaviour which each derived class needs to implement.
Contains the TPZBndCond class which implements a boundary condition for TPZMaterial objects...
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...
Contains the TPZGenSubStruct class which is an interface to "feed" the datastructure of the Dohrmann ...
Implements a generic geometric element which is refined according to a generic refinement pattern...
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
Contains the implementation of the TPZDohrStructMatrix methods.
Contains the TPZGeoTetrahedra class which implements the geometry of a tetrahedral element...
Implements a group of computational elements as a mesh and an element. Computational Mesh...
int parse_arguments(int argc, char *argv[])
static int64_t NSubMesh(TPZAutoPointer< TPZCompMesh > compmesh)
Return the number of submeshes.
This class defines the boundary condition for TPZMaterial objects.
Contains the TPZSkylineStructMatrix class which implements SkyLine Structural Matrices.
void parallel_for(int n, body_t &obj)
TPZAdmChunkVector< TPZGeoNode > & NodeVec()
Contains the TPZDohrPrecond class which implements a matrix which computes the preconditioner develop...
virtual TPZMatrix< STATE > * Create() override
This will create a DohrMatrix.
clarg::argInt nloop("-l", "Number of loop iterations of the Subst_Backward/Subst_Forward", 1)
Contains the TPZPairStructMatrix class.
clarg::argBool help("-h", "Show usage message.", false)
void IdentifyExternalConnectIndexes()
Identify the external connects.
Contains TPZSkyline class which implements a skyline storage format.
work_item_t(unsigned submesh_idx, const TPZAutoPointer< TPZDohrSubstructCondense< TTVar > > &substruct)
RunStatsTable dec_rst("-dec", "Decompose statistics raw data table")
void arguments_descriptions(ostream &os, string prefix, string suffix)
RunStatsTable sub_rst("-sub", "Substitution Forward/Backward statistics raw data table")
TPZAutoPointer< TPZDohrSubstructCondense< TTVar > > fSubstruct
void SetDimModel(int dim)
Set de dimension of the domain of the problem.
bool wayToSort(TPZSkylMatrix< REAL > *i, TPZSkylMatrix< REAL > *j)
Structure to help the construction of geometric elements along side of a given geometric element...
void BuildConnectivity()
Build the connectivity of the grid.
static void AssembleMatrices(TPZSubCompMesh *submesh, TPZAutoPointer< TPZDohrSubstructCondense< STATE > > substruct, TPZAutoPointer< TPZDohrAssembly< STATE > > dohrassembly, pthread_mutex_t *TestThread)
virtual TPZBndCond * CreateBC(TPZMaterial *reference, int id, int typ, TPZFMatrix< STATE > &val1, TPZFMatrix< STATE > &val2)
Creates an object TPZBndCond derived of TPZMaterial.
int InsertMaterialObject(TPZMaterial *mat)
Insert a material object in the datastructure.
Contains the TPZArc3D class which implements three dimensional arc.
const SubsList & SubStructures() const
std::vector< work_item_t< TVar > > work_items
This class implements a geometric mesh for the pz environment. Geometry.
clarg::argBool usetbb("-tbb", "Use of parallel tbb version", false)
vector< TPZSkylMatrix< STATE > *> * only_assemble(TPZDohrStructMatrix *dohrstruct, TPZMatrix< STATE > &mat, TPZFMatrix< STATE > &rhs, TPZAutoPointer< TPZCompMesh > &fMesh)
Implements computational mesh. Computational Mesh.
const T & get_value() const
Contains TPZStepSolver class which defines step solvers class.
void push_work_item(unsigned submesh_idx, const TPZAutoPointer< TPZDohrSubstructCondense< TVar > > &substruct)
clarg::argString predio_file("-f", "Mesh file.", "8andares02.txt")
int64_t NElements() const
Returns the number of elements of the vector.
vector< TPZSkylMatrix< STATE > *> * get_sky_matrices()
par_assemble_task_t(TPZAutoPointer< TPZDohrAssembly< TVar > > assembly, TPZAutoPointer< TPZCompMesh > mesh)
clarg::argString m("-m", "input matrix file name (text format)", "matrix.txt")
void insert_elasticity(TPZAutoPointer< TPZCompMesh > mesh)
Contains the TPZVTKGeoMesh class which implements the graphical mesh to VTK environment to geometric ...
void SubStructure(int nsub)
Partition the mesh in submeshes.
Implements structural matrix divided in sub structures. Structural Matrix Sub structure.
TPZAdmChunkVector< TPZGeoEl * > & ElementVec()
Methods for handling pzlists.