/* A vertex is connected to beams. The question is how many bars are rotuled We define 2 dofs per node */ void frameSolver2d::createDofs() { // printf("coucou %d fixations\n",_fixations.size()); for(std::size_t i = 0; i < _fixations.size(); ++i) { const gmshFixation &f = _fixations[i]; // printf("f._vertex(%d) = %p %d // %g\n",i,f._vertex,f._direction,f._value); MVertex *v = f._vertex->mesh_vertices[0]; Dof DOF(v->getNum(), f._direction); pAssembler->fixDof(DOF, f._value); } // printf("coucou2\n"); computeRotationTags(); // printf("coucou3\n"); for(std::size_t i = 0; i < _beams.size(); i++) { // printf("beam[%d] rot %d // %d\n",i,_beams[i]._rotationTags[0],_beams[i]._rotationTags[1]); for(std::size_t j = 0; j < 2; j++) { MVertex *v = _beams[i]._element->getVertex(j); Dof theta(v->getNum(), Dof::createTypeWithTwoInts(2, _beams[i]._rotationTags[j])); pAssembler->numberDof(theta); Dof U(v->getNum(), 0); pAssembler->numberDof(U); Dof V(v->getNum(), 1); pAssembler->numberDof(V); } } // printf("%d dofs\n",pAssembler->sizeOfR()); }
PView *GMSH_NewViewPlugin::execute(PView * v) { if(GModel::current()->getMeshStatus() < 1){ Msg::Error("No mesh available to create the view: please mesh your model!"); return v ; } std::map<int, std::vector<double> > d; std::vector<GEntity*> entities; GModel::current()->getEntities(entities); for(unsigned int i = 0; i < entities.size(); i++){ for(unsigned int j = 0; j < entities[i]->mesh_vertices.size(); j++){ MVertex *ve = entities[i]->mesh_vertices[j]; d[ve->getNum()].push_back(0.); } } PView *vn = new PView("New view", "NodeData", GModel::current(), d); return vn ; }
void frameSolver2d::solve() { #if defined(HAVE_PETSC) linearSystemPETSc<double> *lsys = new linearSystemPETSc<double>; #elif defined(HAVE_GMM) linearSystemCSRGmm<double> *lsys = new linearSystemCSRGmm<double>; lsys->setGmres(1); lsys->setNoisy(1); #else linearSystemFull<double> *lsys = new linearSystemFull<double>; #endif if(pAssembler) delete pAssembler; pAssembler = new dofManager<double>(lsys); // fix dofs and create free ones createDofs(); // force vector std::vector<std::pair<GVertex *, std::vector<double> > >::iterator it = _nodalForces.begin(); for(; it != _nodalForces.end(); ++it) { MVertex *v = it->first->mesh_vertices[0]; const std::vector<double> &F = it->second; Dof DOFX(v->getNum(), 0); Dof DOFY(v->getNum(), 1); pAssembler->assemble(DOFX, F[0]); pAssembler->assemble(DOFY, F[1]); } // stifness matrix for(std::size_t i = 0; i < _beams.size(); i++) { fullMatrix<double> K(6, 6); computeStiffnessMatrix(i, K); _beams[i]._stiffness = K; MVertex *v0 = _beams[i]._element->getVertex(0); MVertex *v1 = _beams[i]._element->getVertex(1); Dof theta0(v0->getNum(), Dof::createTypeWithTwoInts(2, _beams[i]._rotationTags[0])); Dof theta1(v1->getNum(), Dof::createTypeWithTwoInts(2, _beams[i]._rotationTags[1])); Dof U0(v0->getNum(), 0); Dof U1(v1->getNum(), 0); Dof V0(v0->getNum(), 1); Dof V1(v1->getNum(), 1); Dof DOFS[6] = {U0, V0, theta0, U1, V1, theta1}; for(int j = 0; j < 6; j++) { for(int k = 0; k < 6; k++) { pAssembler->assemble(DOFS[j], DOFS[k], K(j, k)); } } } lsys->systemSolve(); // save the solution for(std::size_t i = 0; i < _beams.size(); i++) { MVertex *v0 = _beams[i]._element->getVertex(0); MVertex *v1 = _beams[i]._element->getVertex(1); Dof theta0(v0->getNum(), Dof::createTypeWithTwoInts(2, _beams[i]._rotationTags[0])); Dof theta1(v1->getNum(), Dof::createTypeWithTwoInts(2, _beams[i]._rotationTags[1])); Dof U0(v0->getNum(), 0); Dof U1(v1->getNum(), 0); Dof V0(v0->getNum(), 1); Dof V1(v1->getNum(), 1); Dof DOFS[6] = {U0, V0, theta0, U1, V1, theta1}; for(int j = 0; j < 6; j++) { pAssembler->getDofValue(DOFS[j], _beams[i]._displacement[j]); } } delete lsys; delete pAssembler; }
int GModel::writeCELUM(const std::string &name, bool saveAll, double scalingFactor) { std::string namef = name + "_f"; FILE *fpf = Fopen(namef.c_str(), "w"); if(!fpf) { Msg::Error("Unable to open file '%s'", namef.c_str()); return 0; } std::string names = name + "_s"; FILE *fps = Fopen(names.c_str(), "w"); if(!fps) { Msg::Error("Unable to open file '%s'", names.c_str()); fclose(fpf); return 0; } if(noPhysicalGroups()) saveAll = true; // count faces and vertices; the CELUM format duplicates vertices on the // boundary of CAD patches int numf = 0, nums = 0; for(fiter it = firstFace(); it != lastFace(); it++) { GFace *f = *it; if(!saveAll && f->physicals.empty()) continue; numf += f->triangles.size(); std::set<MVertex *> vset; for(std::size_t i = 0; i < f->triangles.size(); i++) { for(int j = 0; j < 3; j++) vset.insert(f->triangles[i]->getVertex(j)); } nums += vset.size(); } Msg::Info("Writing %d triangles and %d vertices", numf, nums); int idf = 1, ids = 1; /* * a file with faces - number of faces - empty line ... for each face - number of the face (starts at 1 : used for read errors) - char string (name of geom part, material,... ) - list of 3 vertex nums - empty line ... * a file with vertices - number of vertices - conversion factor - empty line ... for each vertex - number of the vertex (starts at 1 : used for read errors) - cartesian coordinates of the vertex - componants of the exterior oriented normal - value of 1st principal curvature - value of second princpal curvature - components of 1st principal direction - components of 2nd principal direction - empty line ... */ fprintf(fpf, "%d\n\n", numf); fprintf(fps, "%d %g\n\n", nums, 1.0); for(fiter it = firstFace(); it != lastFace(); it++) { GFace *f = *it; if(!saveAll && f->physicals.empty()) continue; std::vector<MVertex *> vvec; std::map<MVertex *, CelumInfo> vmap; for(std::size_t i = 0; i < f->triangles.size(); i++) { fprintf(fpf, "%d \"face %d\"", idf++, f->tag()); for(int j = 0; j < 3; j++) { MVertex *v = f->triangles[i]->getVertex(j); if(!vmap.count(v)) { v->setIndex(ids++); SPoint2 param; bool ok = reparamMeshVertexOnFace(v, f, param); if(!ok) Msg::Warning("Could not reparamtrize vertex %d on face %d", v->getNum(), f->tag()); CelumInfo info; info.normal = f->normal(param); f->curvatures(param, info.dirMax, info.dirMin, info.curvMax, info.curvMin); vmap[v] = info; vvec.push_back(v); } fprintf(fpf, " %ld", v->getIndex()); } fprintf(fpf, "\n\n"); } for(std::size_t i = 0; i < vvec.size(); i++) { MVertex *v = vvec[i]; std::map<MVertex *, CelumInfo>::iterator it = vmap.find(v); fprintf(fps, "%ld %g %g %g %g %g %g %g %g %g %g %g %g %g %g\n\n", it->first->getIndex(), it->first->x(), it->first->y(), it->first->z(), it->second.normal.x(), it->second.normal.y(), it->second.normal.z(), it->second.curvMin, it->second.curvMax, it->second.dirMin.x(), it->second.dirMin.y(), it->second.dirMin.z(), it->second.dirMax.x(), it->second.dirMax.y(), it->second.dirMax.z()); } } fclose(fpf); fclose(fps); return 1; }