コード例 #1
0
ファイル: substruct.cpp プロジェクト: labmec/neopz
void InsertViscoElasticity(TPZAutoPointer<TPZCompMesh> mesh)
{
	mesh->SetDimModel(3);
	int nummat = 1;
	STATE Ela = 1.e6;
	STATE poisson = 0.2;
	TPZManVector<STATE> force(3,0.);
	force[2] = -20.;
	STATE ElaE = 1000000., poissonE = 0.2, ElaV = 950000., poissonV = 0.14; 
	
	STATE lambdaV = 0, muV = 0, alpha = 0, deltaT = 0;
	lambdaV = 11.3636;
	muV = 45.4545;
	alpha = 1.;	
	deltaT = 0.1;
	
	TPZViscoelastic *viscoelast = new TPZViscoelastic(nummat);
	viscoelast->SetMaterialDataHooke(ElaE, poissonE, ElaV, poissonV, alpha, deltaT, force);
	
	TPZMaterial * viscoelastauto(viscoelast);
	TPZFMatrix<STATE> val1(3,3,0.),val2(3,1,0.);
	TPZBndCond *bc = viscoelast->CreateBC(viscoelastauto, -1, 0, val1, val2);
	TPZFNMatrix<6> qsi(6,1,0.);
	viscoelast->SetDefaultMem(qsi); //elast
	int index = viscoelast->PushMemItem(); //elast
	TPZMaterial * bcauto(bc);
	mesh->InsertMaterialObject(viscoelastauto);
	mesh->InsertMaterialObject(bcauto);	
}
コード例 #2
0
ファイル: main.cpp プロジェクト: labmec/neopz
void RefinamentoUniforme(TPZAutoPointer<TPZGeoMesh> gmesh, int nref,TPZVec<int> dims)
{
    
    int ir, iel, k;
    int nel=0, dim=0;
    int ndims = dims.size();
	for(ir = 0; ir < nref; ir++ )
    {
		TPZVec<TPZGeoEl *> filhos;
        nel = gmesh->NElements();
        
		for (iel = 0; iel < nel; iel++ )
        {
			TPZGeoEl * gel = gmesh->ElementVec()[iel];
            if(!gel) DebugStop();
            
            dim = gel->Dimension();
            
            for(k = 0; k<ndims; k++)
            {
                if(dim == dims[k])
                {
                    gel->Divide (filhos);
                    break;
                }
            }
		}
	}
    
}
コード例 #3
0
ファイル: pzdxmesh.cpp プロジェクト: JoaoFelipe/oceano
void TPZDXGraphMesh::DrawSolution(char * var)
{
	
    //int nmat = fCompMesh->MaterialVec().NElements();
    TPZAutoPointer<TPZMaterial> matp = Material();
    int i,varind;
    varind = matp->VariableIndex(var);
    TPZVec<int> vec(1);
    (fOutFile) << "object " << fNextDataField << " class array type float rank 1 shape " <<
	matp->NSolutionVariables(varind) << " items " << NPoints() << " data follows " << endl;
    vec[0] = varind;
    int nel = fCompMesh->ConnectVec().NElements();
    for(i=0;i<nel;i++) {
		TPZGraphNode n = fNodeMap[i];
		n.DrawSolution(vec,fStyle);
    }
    (fOutFile) << "attribute \"dep\" string \"positions\"" << endl;
    (fOutFile) << "#" << endl;
    (fOutFile) << "object " << (fNextDataField+1) << " class field" << endl;
    (fOutFile) << "component \"data\" value " << fNextDataField << endl;
	//    (fOutFile) << "component \"positions\" value " << fNodeCoField << endl;
	//    (fOutFile) << "component \"connections\" value " << fConnectField << endl;
    (fOutFile) << "attribute \"name\" string \"" << var << fNextDataField <<
	"\"" << endl;
    (fOutFile) << "#" << endl;
    fNextDataField += 2;
	
}
コード例 #4
0
ファイル: tpzdohrmatrix.cpp プロジェクト: labmec/neopz
void TPZDohrMatrix<TVar, TSubStruct >::Read(TPZStream &buf, void *context )
{
    SAVEABLE_SKIP_NOTE(buf);
    TPZMatrix<TVar>::Read(buf, context);
    SAVEABLE_SKIP_NOTE(buf);
    fAssembly = TPZAutoPointerDynamicCast<TPZDohrAssembly<TVar>>(TPZPersistenceManager::GetAutoPointer(&buf));
    SAVEABLE_SKIP_NOTE(buf);
    buf.Read(&fNumCoarse);
    SAVEABLE_SKIP_NOTE(buf);
    buf.Read(&fNumThreads);
    int sz;
    SAVEABLE_SKIP_NOTE(buf);
    buf.Read(&sz);
    for (int i=0; i<sz; i++) {
        TPZAutoPointer<TSubStruct > sub = new TSubStruct;
        SAVEABLE_SKIP_NOTE(buf);
        sub->Read(buf,0);
        fGlobal.push_back(sub);
    }
    int classid;
    SAVEABLE_SKIP_NOTE(buf);
    buf.Read(&classid );
    if (classid != ClassId()) {
        DebugStop();
    }
}
コード例 #5
0
ファイル: iRMS.cpp プロジェクト: labmec/neopz
void BoxLinearTracerDual()
{
    // Materials ids and boundary settings
    TPZAutoPointer<TRMRawData> RawData  = new TRMRawData;
    
    bool Is3DGeometry = true;
    
    //    On box reservoir
    //RawData->WaterReservoirBox(Is3DGeometry); // Single-phase flow
    RawData->WaterOilReservoirBox(Is3DGeometry); // Two-phase flow
    //    RawData->WaterOilGasReservoirBox(Is3DGeometry); // Three-phase flow
    
    //    On cricular reservoir
    //    RawData->WaterReservoirCircle(Is3DGeometry);  // Single-phase flow
    //    RawData->WaterOilReservoirCircular(Is3DGeometry); // Two-phase flow
    //    RawData->WaterOilGasReservoirCircular(Is3DGeometry); // Three-phase flow
    
    TRMSimulationData * SimData = new TRMSimulationData;
    SimData->SetRawData(RawData);
    
    TRMOrchestra  * SymphonyX           = new TRMOrchestra;
    SymphonyX->SetSimulationData(SimData);
//    SymphonyX->BuildGeometry(Is3DGeometry); // @omar:: This mesh must to be unique???
    
    SymphonyX->SetSegregatedQ(true);
    SymphonyX->CreateAnalysisDualonBox(true); //  Static Solution
    SymphonyX->RunStaticProblem();
    SymphonyX->CreateAnalysisDualonBox(false);  // Evolutionary Solution
    SymphonyX->RunEvolutionaryProblem();

    std::cout << "Dual complete normally." << std::endl;
    
}
コード例 #6
0
ファイル: pzmaterial.cpp プロジェクト: JoaoFelipe/oceano
void TPZMaterial::Clone(std::map<int, TPZAutoPointer<TPZMaterial> >&matvec) {
	int matid = Id();
	std::map<int, TPZAutoPointer<TPZMaterial> >::iterator matit;
	matit = matvec.find(matid);
	if(matit != matvec.end()) return;
	TPZAutoPointer<TPZMaterial> newmat = NewMaterial();
	newmat->SetForcingFunction(TPZMaterial::fForcingFunction);
	matvec[matid] = newmat;
}
コード例 #7
0
ファイル: tpzdohrmatrix.cpp プロジェクト: labmec/neopz
 /** @brief Computing operator for the parallel for. */
 void operator()(const blocked_range<size_t>& range) const
 {
     
     for(size_t i=range.begin(); i!=range.end(); ++i )
     {
         TPZDohrThreadMultData<TSubStruct> runner = mWorkItems[i];
         TPZFMatrix<TVar> xlocal;
         fAssembly->Extract(runner.fisub,*(fInput),xlocal);
         TPZAutoPointer<TPZDohrAssembleItem<TVar> > assembleItem = new TPZDohrAssembleItem<TVar>(runner.fisub,xlocal.Rows(),xlocal.Cols());
         runner.fSub->ContributeKULocal(fAlpha,xlocal,assembleItem->fAssembleData);
         fAssemblyStructure->AddItem(assembleItem);
     }
 }
コード例 #8
0
ファイル: main.cpp プロジェクト: labmec/neopz
void RefinamentoSingular(TPZAutoPointer<TPZGeoMesh> gmesh,int nref)
{
    int64_t nnodes = gmesh->NNodes();
    int64_t in;
    for (in=0; in<nnodes; in++) {
        TPZGeoNode *gno = &gmesh->NodeVec()[in];
        if (abs(gno->Coord(0))< 1.e-6 && abs(gno->Coord(1)) < 1.e-6) {
            break;
        }
    }
    if (in == nnodes) {
        DebugStop();
    }
    TPZGeoElSide gelside;
    int64_t nelem = gmesh->NElements();
    for (int64_t el = 0; el<nelem; el++) {
        TPZGeoEl *gel = gmesh->ElementVec()[el];
        int ncorner = gel->NCornerNodes();
        for (int ic=0; ic<ncorner; ic++) {
            int64_t nodeindex = gel->NodeIndex(ic);
            if (nodeindex == in) {
                gelside = TPZGeoElSide(gel, ic);
                break;
            }
        }
        if (gelside.Element()) {
            break;
        }
    }
    if (!gelside.Element()) {
        DebugStop();
    }
    for (int iref = 0; iref <nref; iref++) {
        TPZStack<TPZGeoElSide> gelstack;
        gelstack.Push(gelside);
        TPZGeoElSide neighbour = gelside.Neighbour();
        while (neighbour != gelside) {
            gelstack.Push(neighbour);
            neighbour = neighbour.Neighbour();
        }
        int64_t nstack = gelstack.size();
        for (int64_t ist=0; ist < nstack; ist++) {
            if (!gelstack[ist].Element()->HasSubElement()) {
                TPZVec<TPZGeoEl *> subel;
                gelstack[ist].Element()->Divide(subel);
            }
        }
    }
}
コード例 #9
0
ファイル: substruct.cpp プロジェクト: labmec/neopz
void InsertElasticity(TPZAutoPointer<TPZCompMesh> mesh)
{
	mesh->SetDimModel(3);
	int nummat = 1;
	STATE E = 1.e6;
	STATE poisson = 0.3;
	TPZManVector<STATE> force(3,0.);
	force[1] = 20.;
	TPZElasticity3D *elast = new TPZElasticity3D(nummat,E,poisson,force);
	TPZMaterial * elastauto(elast);
	TPZFMatrix<STATE> val1(3,3,0.),val2(3,1,0.);
	TPZBndCond *bc = elast->CreateBC(elastauto, -1, 0, val1, val2);
	TPZMaterial * bcauto(bc);
	mesh->InsertMaterialObject(elastauto);
	mesh->InsertMaterialObject(bcauto);
}
コード例 #10
0
ファイル: TPZDarcyAnalysis.cpp プロジェクト: labmec/neopz
void TPZDarcyAnalysis::PrintLS(TPZAnalysis *an)
{
    TPZAutoPointer< TPZMatrix<REAL> > KGlobal;
    TPZFMatrix<STATE> FGlobal;
    KGlobal =   an->Solver().Matrix();
    FGlobal =   an->Rhs();
    
#ifdef PZDEBUG
    #ifdef LOG4CXX
        if(logger->isDebugEnabled())
        {
            std::stringstream sout;
            KGlobal->Print("KGlobal = ", sout,EMathematicaInput);
            FGlobal.Print("FGlobal = ", sout,EMathematicaInput);
            LOGPZ_DEBUG(logger,sout.str())
        }
コード例 #11
0
ファイル: Main.cpp プロジェクト: labmec/neopz
void IterativeProcess(TPZAnalysis *an, std::ostream &out, int numiter)
{
    int iter = 0;
    REAL error = 1.e10, NormResLambdaLast = 1.e10;;
    const REAL tol = 1.e-5;
    
    int numeq = an->Mesh()->NEquations();
    
    TPZFMatrix<STATE> Uatk0(an->Solution());
    TPZFMatrix<STATE> Uatk(Uatk0),DeltaU(Uatk0);
    if(Uatk0.Rows() != numeq) Uatk0.Redim(numeq,1);
    
    an->Assemble();
    an->Rhs() *= -1.0; //- [R(U0)];
    
    TPZAutoPointer< TPZMatrix<STATE> > matK; // getting X(Uatn)
    
    bool converged = false;
    while(!converged && iter < numiter) {
        
#ifdef LOG4CXX
        if(logger->isDebugEnabled())
        {
            std::stringstream sout;
            matK=an->Solver().Matrix();
            matK->Print("matK = ", sout,EMathematicaInput);
            an->Rhs().Print("Rhs = ", sout, EMathematicaInput);
            LOGPZ_DEBUG(logger,sout.str())
        }
#endif
        
        // Computing Uatk = Uatn + DeltaU;
        an->Solve();
        DeltaU= an->Solution();
        Uatk = Uatk0 + DeltaU;
        
        //Computing ||DeltaU||
        REAL NormOfDeltaU = Norm(DeltaU);
        
#ifdef LOG4CXX
        if(logger->isDebugEnabled())
        {
            std::stringstream sout;
            DeltaU.Print("DeltaU = ", sout,EMathematicaInput);
            Uatk.Print("Uatk = ", sout,EMathematicaInput);
            LOGPZ_DEBUG(logger,sout.str())
        }
コード例 #12
0
//.........................................................................................................................................
void TPZRefPatternDataBase::ReadRefPatternDBase(std::ifstream &filename)
{
    fElTypeRefPatterns.clear();
    fIdRefPatterns.clear();
    
	int nRefpatterns;
	filename >> nRefpatterns;
	for(int i = 0; i < nRefpatterns; i++)
	{
		TPZAutoPointer<TPZRefPattern> refP = new TPZRefPattern;
		refP->ReadPattern(filename);
		
        MElementType eltype = refP->Element(0)->Type();
        fElTypeRefPatterns[eltype].push_back(refP);
        fIdRefPatterns[refP->Id()] = refP;
	}
}
コード例 #13
0
ファイル: pzbndcond.cpp プロジェクト: JoaoFelipe/oceano
void TPZBndCond::Clone(std::map<int, TPZAutoPointer<TPZMaterial> > &matvec) {
    int matid = Id();

    TPZAutoPointer<TPZMaterial> refmaterial = Material();
    TPZAutoPointer<TPZMaterial> newrefmaterial;
    int refmatid = 0;
    if(refmaterial) {
        refmaterial->Clone(matvec);
        refmatid = refmaterial->Id();
        newrefmaterial = matvec[refmatid];
    }
    std::map<int, TPZAutoPointer<TPZMaterial> >::iterator matit;
    matit = matvec.find(matid);
    if(matit == matvec.end())
    {
        TPZAutoPointer<TPZMaterial> newmat = TPZAutoPointer<TPZMaterial>(new TPZBndCond(*this, newrefmaterial));
        matvec[matid] = newmat;
    }
}
コード例 #14
0
ファイル: main.cpp プロジェクト: labmec/neopz
void GetElIndexCoarseMesh(TPZAutoPointer<TPZGeoMesh>  gmesh, std::set<int64_t> &coarseindex)
{
    int nel = gmesh->NElements();
    int iel;
    int hassubel=0;
    int dim = gmesh->Dimension();
    int eldim;
    for(iel = 0; iel<nel; iel++)
    {
        TPZGeoEl * gel = gmesh->ElementVec()[iel];
        if(!gel) DebugStop();
        
        hassubel = gel->HasSubElement();
        eldim = gel->Dimension();
        if(!hassubel && eldim ==dim)
        {
            coarseindex.insert(gel->Index());
        }
    }
    
}
コード例 #15
0
ファイル: c08-Mixed.cpp プロジェクト: labmec/neopz
//*************************************
//************Option 8*****************
//*****All element types Mesh**********
//*************************************
TPZCompMesh * CreateTestMesh() {

  REAL nodeco[12][3] = {
    {0.,0.,0.},
    {1.,0.,0.},
    {2.,0.,0.},
    {0.,1.,0.},
    {1.,1.,0.},
    {2.,1.,0.},
    {0.,0.,1.},
    {1.,0.,1.},
    {2.,0.,1.},
    {0.,1.,1.},
    {1.,1.,1.},
    {2.,1.,1.}
  };

  int nodind[7][8] = {
    {0,1,4,3,6,7,10,9},
    {2,4,10,8,5},
    {8,10,11,5},
    {2,4,1,8,10,7},
    {0,1},
    {0,1,7,6},
    {1,2,7}
  };

  int numnos[7] = {8,5,4,6,2,4,3};

  TPZGeoMesh *gmesh = new TPZGeoMesh();

  int noind[12];
  int no;
  for(no=0; no<12; no++) {
    noind[no] = gmesh->NodeVec().AllocateNewElement();
    TPZVec<REAL> coord(3);
    coord[0] = nodeco[no][0];
    coord[1] = nodeco[no][1];
    coord[2] = nodeco[no][2];
    gmesh->NodeVec()[noind[no]].Initialize(coord,*gmesh);
  }
  int matid = 1;
  TPZVec<int> nodeindex;
  int nel;
  TPZVec<TPZGeoEl *> gelvec;
  gelvec.Resize(4);
  for(nel=0; nel<4; nel++) {
    int in;
    nodeindex.Resize(numnos[nel]);
    for(in=0; in<numnos[nel]; in++) {
      nodeindex[in] = nodind[nel][in];
    }
    int index;
    switch(nel) {
    case 0:
      //      elvec[el] = gmesh->CreateGeoElement(ECube,nodeindex,1,index);
//      gelvec[nel]=new TPZGeoElC3d(nodeindex,matid,*gmesh);
      break;
    case 1:
      gelvec[nel] = gmesh->CreateGeoElement(EPiramide,nodeindex,matid,index);
      //       gelvec[nel]=new TPZGeoElPi3d(nodeindex,matid,*gmesh);
      break;
    case 2:
      gelvec[nel] = gmesh->CreateGeoElement(ETetraedro,nodeindex,matid,index);
    //       gelvec[nel]=new TPZGeoElT3d(nodeindex,matid,*gmesh);
      break;
    case 3:
//       gelvec[nel]=new TPZGeoElPr3d(nodeindex,matid,*gmesh);
//      gelvec[nel] = gmesh->CreateGeoElement(EPrisma,nodeindex,matid,index);
      break;
    case 4:
      //      gelvec[nel]=new TPZGeoEl1d(nodeindex,2,*gmesh);
      break;
    case 5:
      //      gelvec[nel]=new TPZGeoElQ2d(nodeindex,3,*gmesh);
      break;
    case 6:
      //      gelvec[nel]=new TPZGeoElT2d(nodeindex,3,*gmesh);
      break;
    default:
      break;
    }
  }
  gmesh->BuildConnectivity2();

  //TPZVec<TPZGeoEl *> sub;
  //elvec[0]->Divide(sub);
  //   	elvec[1]->Divide(sub);
  //   	elvec[2]->Divide(sub);

//  TPZGeoElBC gbc;

  // bc -1 -> Dirichlet
//  TPZGeoElBC gbc1(gelvec[0],20,-1,*gmesh);
  TPZGeoElBC gbc11(gelvec[1],14,-1,*gmesh);
//  TPZGeoElBC gbc12(gelvec[3],15,-1,*gmesh);



  // bc -2 -> Neumann at the right x==1
//  TPZGeoElBC gbc2(gelvec[0],25,-2,*gmesh);
//  TPZGeoElBC gbc21(gelvec[3],19,-2,*gmesh);
  TPZGeoElBC gbc22(gelvec[2],10,-2,*gmesh);

  TPZCompMesh *cmesh = new TPZCompMesh(gmesh);

  TPZAutoPointer<TPZMaterial> mat;
  //  if(nstate == 3) {
    mat = new TPZMaterialTest3D(1);
    TPZFMatrix mp (3,1,0.);
    TPZMaterialTest3D * mataux = dynamic_cast<TPZMaterialTest3D *> (mat.operator ->());
    TPZMaterialTest3D::geq3=1;
    mataux->SetMaterial(mp);
    /*  } else {
    TPZMat2dLin *mat2d = new TPZMat2dLin(1);
    int ist,jst;
    TPZFMatrix xk(nstate,nstate,1.),xc(nstate,nstate,0.),xf(nstate,1,0.);
    for(ist=0; ist<nstate; ist++) {
      if(nstate != 1) xf(ist,0) = 1.;
      for(jst=0; jst<nstate; jst++) {
	if(ist != jst) xk(ist,jst) = 0.;
      }
    }
    mat2d->SetMaterial(xk,xc,xf);
    mat = mat2d;
    }*/

  TPZFMatrix val1(3,3,0.),val2(3,1,0.);
  TPZAutoPointer<TPZMaterial> bc[2];

  bc[0] = mat->CreateBC(mat,-1,0,val1,val2);
  val2(0,0) = 1.;
  bc[1] = mat->CreateBC(mat,-2,1,val1,val2);
  cmesh->InsertMaterialObject(mat);

  int i;
  for(i=0; i<2; i++) cmesh->InsertMaterialObject(bc[i]);

  gmesh->Print(cout);

  cmesh->AutoBuild();
  cmesh->AdjustBoundaryElements();
  cmesh->CleanUpUnconnectedNodes();

  gmesh->Print(cout);
  return cmesh;
}
コード例 #16
0
ファイル: pzmganalysis.cpp プロジェクト: JoaoFelipe/oceano
REAL TPZMGAnalysis::ElementError(TPZInterpolatedElement *fine, TPZInterpolatedElement *coarse, TPZTransform &tr,
								 void (*f)(TPZVec<REAL> &loc, TPZVec<REAL> &val, TPZFMatrix<REAL> &deriv),REAL &truerror){
	// accumulates the transfer coefficients between the current element and the
	// coarse element into the transfer matrix, using the transformation t
	int locnod = fine->NConnects();
	int cornod = coarse->NConnects();
	int locmatsize = fine->NShapeF();
	int cormatsize = coarse->NShapeF();
	REAL error = 0.;
	truerror = 0.;
	
	REAL loclocmatstore[500] = {0.},loccormatstore[500] = {0.};
	TPZFMatrix<REAL> loclocmat(locmatsize,locmatsize,loclocmatstore,500);
	TPZFMatrix<REAL> loccormat(locmatsize,cormatsize,loccormatstore,500);
	
	TPZAutoPointer<TPZIntPoints> intrule = fine->GetIntegrationRule().Clone();
	int dimension = fine->Dimension();
	int numdof = fine->Material()->NStateVariables();
	TPZBlock<REAL> &locblock = fine->Mesh()->Block();
	TPZFMatrix<REAL> &locsolmesh = fine->Mesh()->Solution();
	
	TPZBlock<REAL> &corblock = coarse->Mesh()->Block();
	TPZFMatrix<REAL> &corsolmesh = coarse->Mesh()->Solution();
	
	TPZVec<REAL> locsol(numdof);
	TPZFMatrix<REAL> locdsol(dimension,numdof);
	
	TPZVec<REAL> corsol(numdof);
	TPZFMatrix<REAL> cordsol(dimension,numdof);
	
	TPZManVector<int> prevorder(dimension),
    order(dimension);
	intrule->GetOrder(prevorder);
	
	TPZManVector<int> interpolation(dimension);
	fine->GetInterpolationOrder(interpolation);
	
	// compute the interpolation order of the shapefunctions squared
	int dim;
	int maxorder = interpolation[0];
	for(dim=0; dim<interpolation.NElements(); dim++) {
		maxorder = interpolation[dim] < maxorder ? maxorder : interpolation[dim];
	}
	for(dim=0; dim<dimension; dim++) {
		order[dim] = 20;
	}
	intrule->SetOrder(order);
	
	
	REAL locphistore[50]={0.},locdphistore[150]={0.};
	TPZFMatrix<REAL> locphi(locmatsize,1,locphistore,50);
	TPZFMatrix<REAL> locdphi(dimension,locmatsize,locdphistore,150),locdphix(dimension,locmatsize);
	// derivative of the shape function
	// in the master domain
	
	REAL corphistore[50]={0.},cordphistore[150]={0.};
	TPZFMatrix<REAL> corphi(cormatsize,1,corphistore,50);
	TPZFMatrix<REAL> cordphi(dimension,cormatsize,cordphistore,150), cordphix(dimension,cormatsize);
	// derivative of the shape function
	// in the master domain
	
	REAL jacobianstore[9],
    axesstore[9];
	TPZManVector<REAL> int_point(dimension),
    coarse_int_point(dimension);
	TPZFMatrix<REAL> jacfine(dimension,dimension,jacobianstore,9),jacinvfine(dimension,dimension);
	TPZFMatrix<REAL> axesfine(3,3,axesstore,9);
	TPZManVector<REAL> xfine(3);
	TPZFMatrix<REAL> jaccoarse(dimension,dimension),jacinvcoarse(dimension,dimension);
	TPZFMatrix<REAL> axescoarse(3,3), axesinner(dimension,dimension);
	TPZManVector<REAL> xcoarse(3);
	
	REAL jacdetcoarse;
	int numintpoints = intrule->NPoints();
	REAL weight;
	int i,j,k;
	
	TPZVec<REAL> truesol(numdof);
	TPZFMatrix<REAL> truedsol(dimension,numdof);
	for(int int_ind = 0; int_ind < numintpoints; ++int_ind) {
		
		intrule->Point(int_ind,int_point,weight);
		REAL jacdetfine;
		fine->Reference()->Jacobian( int_point, jacfine , axesfine, jacdetfine, jacinvfine);
		fine->Reference()->X(int_point, xfine);
		if(f) f(xfine,truesol,truedsol);
		fine->Shape(int_point,locphi,locdphi);
		tr.Apply(int_point,coarse_int_point);
		coarse->Shape(coarse_int_point,corphi,cordphi);
		coarse->Reference()->Jacobian( coarse_int_point,jaccoarse,axescoarse, jacdetcoarse, jacinvcoarse);
		coarse->Reference()->X(coarse_int_point,xcoarse);
		REAL dist = (xfine[0]-xcoarse[0])*(xfine[0]-xcoarse[0])+(xfine[1]-xcoarse[1])*(xfine[1]-xcoarse[1])+(xfine[2]-xcoarse[2])*(xfine[2]-xcoarse[2]);
		if(dist > 1.e-6) cout << "TPZMGAnalysis::ElementError transformation between fine and coarse is wrong\n";
		for(i=0; i<dimension; i++) {
			for(j=0; j<dimension; j++) {
				axesinner(i,j) = 0.;
				for(k=0; k<3; k++) axesinner(i,j) += axesfine(i,k)*axescoarse(j,k);
			}
		}
		if(fabs(axesinner(0,0)-1.) > 1.e-6 || fabs(axesinner(1,1)-1.) > 1.e-6 || fabs(axesinner(0,1)) > 1.e-6 || fabs(axesinner(1,0)) > 1.e-6) {
			cout << "TPZMGAnalysis axesinner is not identify?\n";
		}
		weight *= fabs(jacdetfine);
		
		locdphix.Zero();
		
		int ieq,d;
		switch(dim) {
			case 0:
				//dphix.Redim(1,1);
				//dphix(0,0) = dphi(0,0);
				break;
			case 1:
				for(d=0; d<dimension; d++) {
					for(ieq=0; ieq<locmatsize; ieq++) locdphix(d,ieq) = locdphi(d,ieq)*(1./jacdetfine);
					for(ieq=0; ieq<cormatsize; ieq++) cordphix(d,ieq) = cordphi(d,ieq)*(axesinner(0,0)/jacdetcoarse);
				}
				break;
			case 2:
				for(ieq = 0; ieq < locmatsize; ieq++) {
					locdphix(0,ieq) = jacinvfine(0,0)*locdphi(0,ieq) + jacinvfine(1,0)*locdphi(1,ieq);
					locdphix(1,ieq) = jacinvfine(0,1)*locdphi(0,ieq) + jacinvfine(1,1)*locdphi(1,ieq);
					REAL tmp[2];
					tmp[0] = locdphix(0,ieq)*axesfine(0,0)+locdphix(1,ieq)*axesfine(1,0);
					tmp[1] = locdphix(0,ieq)*axesfine(0,1)+locdphix(1,ieq)*axesfine(1,1);
					locdphix(0,ieq) = tmp[0];
					locdphix(1,ieq) = tmp[1];
				}
				for(ieq = 0; ieq < cormatsize; ieq++) {
					cordphix(0,ieq) = jacinvcoarse(0,0)*cordphi(0,ieq) + jacinvcoarse(1,0)*cordphi(1,ieq);
					cordphix(1,ieq) = jacinvcoarse(0,1)*cordphi(0,ieq) + jacinvcoarse(1,1)*cordphi(1,ieq);
					REAL tmp[2];
					tmp[0] = cordphix(0,ieq)*axescoarse(0,0)+cordphix(1,ieq)*axescoarse(1,0);
					tmp[1] = cordphix(0,ieq)*axescoarse(0,1)+cordphix(1,ieq)*axescoarse(1,1);
					cordphix(0,ieq) = tmp[0];
					cordphix(1,ieq) = tmp[1];
				}
				break;
			case 3:
				for(ieq = 0; ieq < locmatsize; ieq++) {
					locdphix(0,ieq) = jacinvfine(0,0)*locdphi(0,ieq) + jacinvfine(0,1)*locdphi(1,ieq) + jacinvfine(0,2)*locdphi(2,ieq);
					locdphix(1,ieq) = jacinvfine(1,0)*locdphi(0,ieq) + jacinvfine(1,1)*locdphi(1,ieq) + jacinvfine(1,2)*locdphi(2,ieq);
					locdphix(2,ieq) = jacinvfine(2,0)*locdphi(0,ieq) + jacinvfine(2,1)*locdphi(1,ieq) + jacinvfine(2,2)*locdphi(2,ieq);
				}
				for(ieq = 0; ieq < cormatsize; ieq++) {
					cordphix(0,ieq) = jacinvcoarse(0,0)*cordphi(0,ieq) + jacinvcoarse(0,1)*cordphi(1,ieq) + jacinvcoarse(0,2)*cordphi(2,ieq);
					cordphix(1,ieq) = jacinvcoarse(1,0)*cordphi(0,ieq) + jacinvcoarse(1,1)*cordphi(1,ieq) + jacinvcoarse(1,2)*cordphi(2,ieq);
					cordphix(2,ieq) = jacinvcoarse(2,0)*cordphi(0,ieq) + jacinvcoarse(2,1)*cordphi(1,ieq) + jacinvcoarse(2,2)*cordphi(2,ieq);
					REAL tmp[3];
					tmp[0] = cordphix(0,ieq)*axesinner(0,0)+cordphix(1,ieq)*axesinner(0,1)+cordphix(2,ieq)*axesinner(0,2);
					tmp[1] = cordphix(0,ieq)*axesinner(1,0)+cordphix(1,ieq)*axesinner(1,1)+cordphix(2,ieq)*axesinner(1,2);
					tmp[2] = cordphix(0,ieq)*axesinner(2,0)+cordphix(1,ieq)*axesinner(2,1)+cordphix(2,ieq)*axesinner(2,2);
					cordphix(0,ieq) = tmp[0];
					cordphix(1,ieq) = tmp[1];
					cordphix(2,ieq) = tmp[2];
				}
				break;
			default:
				PZError << "pzintel.c please implement the " << dim << "d Jacobian and inverse\n";
				PZError.flush();
		}
		int iv=0;
		locsol.Fill(0.);
		locdsol.Zero();
		iv=0;
		int in;
		for(in=0; in<locnod; in++) {
			TPZConnect *df = &fine->Connect(in);
			int dfseq = df->SequenceNumber();
			int dfvar = locblock.Size(dfseq);
			int pos = locblock.Position(dfseq);
			
			for(int jn=0; jn<dfvar; jn++) {
				locsol[iv%numdof] += locphi(iv/numdof,0)*locsolmesh(pos+jn,0);
				for(d=0; d<dim; d++)
					locdsol(d,iv%numdof) += locdphix(d,iv/numdof)*locsolmesh(pos+jn,0);
				iv++;
			}
		}
		corsol.Fill(0.);
		cordsol.Zero();
		iv=0;
		for(in=0; in<cornod; in++) {
			TPZConnect *df = &coarse->Connect(in);
			int dfseq = df->SequenceNumber();
			int dfvar = corblock.Size(dfseq);
			int pos = corblock.Position(dfseq);
			for(int jn=0; jn<dfvar; jn++) {
				corsol[iv%numdof] += corphi(iv/numdof,0)*corsolmesh(pos+jn,0);
				for(d=0; d<dim; d++)
					cordsol(d,iv%numdof) += cordphix(d,iv/numdof)*corsolmesh(pos+jn,0);
				iv++;
			}
		}
		int jn;
		for(jn=0; jn<numdof; jn++) {
			//       error += (locsol[jn]-corsol[jn])*(locsol[jn]-corsol[jn])*weight;
			//       if(f) truerror += (corsol[jn]-truesol[jn])*(corsol[jn]-truesol[jn])*weight;
			for(d=0; d<dim; d++) {
				error += (locdsol(d,jn)-cordsol(d,jn))*(locdsol(d,jn)-cordsol(d,jn))*weight;
				if(f) truerror += (cordsol(d,jn)-truedsol(d,jn))*(cordsol(d,jn)-truedsol(d,jn))*weight;
			}
		}
	}
	intrule->SetOrder(prevorder);
	return error;
}
コード例 #17
0
void TPZMulticamadaOrthotropic::AddPlacaOrtho(TPZAutoPointer<TPZMaterial> material, REAL height){
	
	TPZAutoPointer<TPZMaterial> bcptr;
	fCompMesh->InsertMaterialObject(material);
	TPZFNMatrix<9> val1(3,3,0.),val2(3,1,0.);
	TPZBCTension *bc = new TPZBCTension(material,-material->Id()*4,4,val1,val2, 1., this,fPlacaOrth.NElements());
	bcptr = TPZAutoPointer<TPZMaterial>(bc);
	fCompMesh->InsertMaterialObject(bcptr);
	bc = new TPZBCTension(material,-material->Id()*4-1,4,val1,val2, 1., this,fPlacaOrth.NElements());
	bcptr = TPZAutoPointer<TPZMaterial>(bc);
	fCompMesh->InsertMaterialObject(bcptr);
	bc = new TPZBCTension(material,-material->Id()*4-2,4,val1,val2, -1., this,fPlacaOrth.NElements());
	bcptr = TPZAutoPointer<TPZMaterial>(bc);
	fCompMesh->InsertMaterialObject(bcptr);
	bc = new TPZBCTension(material,-material->Id()*4-3,4,val1,val2, -1.,this,fPlacaOrth.NElements());
	bcptr = TPZAutoPointer<TPZMaterial>(bc);
	fCompMesh->InsertMaterialObject(bcptr);
	
	//  fPlacaOrth.Push(placa);
	int nnodes = fGeoMesh->NodeVec().NElements();
	fGeoMesh->NodeVec().Resize(nnodes+(fNelx+1)*(fNely+1));
	int ix, iy;
	TPZManVector<REAL,3> coord(3,fZMax+height);
	fZMax += height;
	for(ix=0; ix<= fNelx; ix++) {
		for(iy=0; iy<= fNely; iy++) {
			coord[0] = ix*fDx-fDx*REAL(fNelx/2.);
			coord[1] = iy*fDy-fDy*REAL(fNely/2.);
			fGeoMesh->NodeVec()[nnodes+ix+iy*(fNelx+1)].Initialize(coord,*fGeoMesh);
		}
	}
	int nodebase1 = nnodes - (fNelx+1)*(fNely+1);
	int elx, ely;
	TPZManVector<int,8> nodeindexes(8,-1);
	for(elx=0; elx<fNelx; elx++) {
		for(ely=0; ely<fNely; ely++) {
			nodeindexes[0] = nodebase1+elx+ely*(fNelx+1);
			nodeindexes[1] = nodebase1+elx+1+ely*(fNelx+1);
			nodeindexes[2] = nodebase1+elx+1+(ely+1)*(fNelx+1);
			nodeindexes[3] = nodebase1+elx+(ely+1)*(fNelx+1);
			int i;
			for(i=0; i<4; i++) nodeindexes[i+4] = nodeindexes[i]+(fNelx+1)*(fNely+1);
			int index;
			TPZGeoEl *gel = fGeoMesh->CreateGeoElement (ECube, nodeindexes, material->Id(), index);
			if(ely == 0) TPZGeoElBC gbc1(gel,21,-material->Id()*4);
			if(elx == fNelx-1) TPZGeoElBC gbc2(gel,22,-material->Id()*4-1);
			if(ely == fNely-1) TPZGeoElBC gbc3(gel,23,-material->Id()*4-2);
			if(elx == 0) TPZGeoElBC gbc4(gel,24,-material->Id()*4-3);
			int nplaca = fPlacaOrth.NElements();
			if(nplaca == 0 && elx == 0 && ely == 0) {
				TPZBndCond *bc2 = new TPZBndCond(material,-100,0,val1,val2);
				bcptr = TPZAutoPointer<TPZMaterial>(bc2);
				fCompMesh->InsertMaterialObject(bcptr);
				TPZGeoElBC gbc5(gel,0,-100);
				val1(0,0) = 1.e12;
				val1(2,2) = 1.e12;
				TPZBndCond *bc3 = new TPZBndCond(material,-101,2,val1,val2);
				bcptr = TPZAutoPointer<TPZMaterial>(bc3);
				fCompMesh->InsertMaterialObject(bcptr);
				TPZGeoElBC gbc6(gel,3,-101);
				val1.Zero();
				val1(0,0) = 0.;
				val1(2,2) = 1.e12;
				TPZBndCond *bc4 = new TPZBndCond(material,-102,2,val1,val2);
				bcptr = TPZAutoPointer<TPZMaterial>(bc4);
				
				fCompMesh->InsertMaterialObject(bcptr);
				TPZGeoElBC gbc7(gel,2,-102);
			}
			if(elx == fNelx/2 && ely == fNely/2) {
				TPZPlacaOrthotropic placa(gel,fZMax-height,fZMax);
				fPlacaOrth.Push(placa);
			}
		}
	}
}
コード例 #18
0
ファイル: substruct.cpp プロジェクト: labmec/neopz
int main1(int argc, char *argv[])
{
#ifdef LOG4CXX
	InitializePZLOG();
#endif
	
	TPZTimer total;
	total.start();
	std::cout << "COMECA O TEMPO"<< std::endl;
	
	int dimension = 3;
	int dim = 2;
	int maxlevel = 5;
	int sublevel = 3;
	int plevel = 1;
	TPZPairStructMatrix::gNumThreads = 20;
	int numthreads = 20;
	//	tempo.fNumthreads = numthreads;	// alimenta timeTemp com o numero de threads
	TPZGeoMesh *gmesh = 0;
	{
		TPZCompEl::SetgOrder(plevel);
		
		TPZAutoPointer<TPZCompMesh> cmesh;
		
		if(0)
		{
			TPZGenSubStruct sub(dim,maxlevel,sublevel);
			cmesh = sub.GenerateMesh();
			cmesh->SetDimModel(dim);
			gmesh = cmesh->Reference();
		}
		else 
		{
			dim = 3;
			if (1) // Predio Viscoso
			{
				int dimension = 3;
				gmesh = MalhaPredio();
				cmesh = new TPZCompMesh(gmesh);
				cmesh->SetDimModel(3);
				cmesh->SetDefaultOrder(plevel);
				cmesh->SetAllCreateFunctionsContinuousWithMem(dimension);
				InsertViscoElasticity(cmesh);
				cmesh->AutoBuild();
				
			}
			else // Cubo Viscoso
			{
				int dimension = 3;
				gmesh = MalhaCubo();
				cmesh = new TPZCompMesh(gmesh);
				cmesh->SetDimModel(3);
				cmesh->SetDefaultOrder(plevel);
				cmesh->SetAllCreateFunctionsContinuousWithMem(dimension);
				InsertViscoElasticityCubo(cmesh);
				cmesh->AutoBuild();
			}
		}
		
		std::cout << "Numero de equacoes " << cmesh->NEquations() << std::endl;
		
		int numthread_assemble = 20;
		int numthread_decompose = 20;
		TPZAutoPointer<TPZCompMesh> cmeshauto(cmesh);
		TPZDohrStructMatrix dohrstruct(cmeshauto);
		
		dohrstruct.IdentifyExternalConnectIndexes();
		
		std::cout << "Substructuring the mesh\n";
		//	TPZfTime timetosub; // init of timer
		//REAL height = Height(gmesh);
		//int nsubstruct = SubStructure(cmesh, height/2);
		
		dohrstruct.SubStructure(16);

		//	tempo.ft0sub = timetosub.ReturnTimeDouble();  // end of timer
		//	std::cout << tempo.ft0sub << std::endl;
		
		//	sub.SubStructure();
		
		
		 //Teste Skyline
        /*
		TPZSkylineStructMatrix skyl(cmesh);
		TPZFMatrix<REAL> rhsfake(cmesh->NEquations(),1,0);
		int numsubmesh = cmesh->NElements();
		TPZAutoPointer<TPZGuiInterface> fakegui = new TPZGuiInterface;
		int nel = cmesh->NElements();
		for (int iel = 0 ; iel < nel ; iel++)
		{
			TPZSubCompMesh *subcompmesh = dynamic_cast<TPZSubCompMesh*>(cmesh->ElementVec()[iel]);
			if(subcompmesh)
			{
				subcompmesh->SetAnalysisSkyline(0,0,fakegui);
			}
		}
		TPZMatrix<REAL> *stiff2 = skyl.CreateAssemble(rhsfake, fakegui,numthread_assemble,numthread_decompose);
		*/
		
#ifdef LOG4CXX
		{
			std::stringstream str;
			cmesh->Print(str);
			LOGPZ_DEBUG(logger,str.str());
		}
#endif

		
		dohrstruct.SetNumThreads(numthreads);
		
		TPZAutoPointer<TPZGuiInterface> gui;
		TPZFMatrix<STATE> rhs(cmesh->NEquations(),1,0.);
        
		TPZMatrix<STATE> *matptr = dohrstruct.Create();
		
		 
		dohrstruct.Assemble(*matptr,rhs,gui,numthread_assemble,numthread_decompose);

	
		TPZAutoPointer<TPZMatrix<STATE> > dohr = matptr;
		TPZAutoPointer<TPZMatrix<STATE> > precond = dohrstruct.Preconditioner();
		
		{
			std::ofstream out("DohrCerta2.txt");
			TPZFMatrix<REAL> Subtract(dohr->Rows(),dohr->Rows()), unitary(dohr->Rows(),dohr->Rows());
			unitary.Identity();
			TPZFMatrix<REAL> result;
			dohr->Multiply(unitary, result);
			result.Print("DohrCerta2", out);
			
		}

/*	
#ifdef LOG4CXX
		{  
			std::ofstream out("DohrErrada.txt"), outRhsCerto("RhsSkyl.txt"), outRhsErrado("RhsDohrmann.txt");
			TPZFMatrix<REAL> Subtract(dohr->Rows(),dohr->Rows()), unitary(dohr->Rows(),dohr->Rows());
			unitary.Identity();
			TPZFMatrix<REAL> result;
			dohr->Multiply(unitary, result);
			std::ofstream out2("Dohr_Certa.txt");
			result.Print("DohrCerta",out2);
			for (int i = 0 ; i < dohr->Rows(); i++) 
			{
				for (int j = 0 ; j < dohr->Rows(); j++) 
				{
					double temp = result(i,j) - stiff2->Get(i,j); 
					if (temp < 1e-10) 
					{
							temp = 0;
					}
					Subtract(i,j) = temp; 
				}
			}
			std::stringstream str;
			result.Print("DohrmannErrada", out);
			stiff2->Print("Skyl",out);
			Subtract.Print("Subtract", out);
			rhsfake.Print("RhsSkyl", outRhsCerto);
			rhs.Print("RhsDohrmann", outRhsErrado);
			LOGPZ_DEBUG(logger,str.str());
		}
#endif
 */
		
        
		int neq = dohr->Rows();
        
		TPZFMatrix<STATE> diag(neq,1,0.), produto(neq,1);
        
		std::cout << "Numero de equacoes " << neq << std::endl;
        
		TPZStepSolver<STATE> pre(precond);
		pre.SetMultiply();
		TPZStepSolver<STATE> cg(dohr);
		//  void SetCG(const int numiterations,const TPZMatrixSolver &pre,const STATE tol,const int FromCurrent);
		
		cg.SetCG(500,pre,5.e-6,0);
		cg.Solve(rhs,diag);

		diag.Print("diag");

        
		TPZDohrMatrix<STATE,TPZDohrSubstructCondense<STATE> > *dohrptr = dynamic_cast<TPZDohrMatrix<STATE,TPZDohrSubstructCondense<STATE> > *> (dohr.operator->());
		if (!dohrptr) {
			DebugStop(); 
		}
         
		
		dohrptr->AddInternalSolution(diag);
        
        TPZMaterial * mat = cmeshauto->FindMaterial(1);
		int nstate = mat->NStateVariables();
		int nscal = 0, nvec = 0;
		if(nstate ==1) 
		{
			nscal = 1;
		}
		else
		{
			nvec = 1;
		}
		TPZManVector<std::string> scalnames(nscal),vecnames(nvec);
		if(nscal == 1)
		{
			scalnames[0]="state";            
		}
		else
		{
			vecnames[0] = "state";
		}
		
		//cmeshauto->Solution().Print();
		
		std::string postprocessname("ugabuga.vtk");
		TPZVTKGraphMesh vtkmesh(cmesh.operator->(),dim,mat,scalnames,vecnames);
		vtkmesh.SetFileName(postprocessname);
		vtkmesh.SetResolution(0);
		int numcases = 1;
		
		// Iteracoes de tempo
		int istep = 0, nsteps = 80;
		vtkmesh.DrawMesh(numcases);
		vtkmesh.DrawSolution(istep, 1.);

		
		typedef std::list<TPZAutoPointer<TPZDohrSubstructCondense<STATE> > > subtype;
		const subtype &sublist = dohrptr->SubStructures(); 
		subtype::const_iterator it = sublist.begin();
		int subcount=0;
		while (it != sublist.end()) 
		{
			TPZFMatrix<STATE> subext,subu;
			dohrptr->fAssembly->Extract(subcount,diag,subext);
			(*it)->UGlobal(subext,subu);
			TPZCompMesh *submesh = SubMesh(cmeshauto, subcount);
			submesh->LoadSolution(subu);
			subu.Print();
			
		
			std::map<int ,TPZMaterial * > materialmap(submesh->MaterialVec());
			std::map<int ,TPZMaterial * >::iterator itmat;
			for (itmat = materialmap.begin(); itmat != materialmap.end() ; itmat++) 
			{
				TPZMaterial * mat = itmat->second;
				TPZViscoelastic *vmat = dynamic_cast< TPZViscoelastic *> (mat);
				if(vmat)
				{
					vmat->SetUpdateMem();
				}
			}	
			         
			subcount++;
			it++;
		}
		
        /*
#ifdef LOG4CXX
		{
			std::stringstream sout;
			diag.Print("Resultado do processo iterativo",sout);
			LOGPZ_INFO(loggernathan,sout.str())
		}
#endif	
	*/	
		
		//ViscoElastico
		
        vtkmesh.DrawMesh(numcases);
		vtkmesh.DrawSolution(istep+1, 1.);
        
		std::cout << "To seguindo!!!" << std::endl;
		for (istep = 2 ; istep < nsteps ; istep++)
		{
			TPZAutoPointer<TPZGuiInterface> guifake;
			dohrstruct.Assemble(rhs, guifake);
			cg.Solve(rhs,diag);	
			
			dohrptr->AddInternalSolution(diag);
			
			// Colocando a solucao na malha
			typedef std::list<TPZAutoPointer<TPZDohrSubstructCondense<STATE> > > subtype;
			const subtype &sublist = dohrptr->SubStructures(); 
			subtype::const_iterator it = sublist.begin();
			int subcount=0;
			while (it != sublist.end()) 
			{
				TPZFMatrix<STATE> subext,subu;
				dohrptr->fAssembly->Extract(subcount,diag,subext);
				(*it)->UGlobal(subext,subu);
				TPZCompMesh *submesh = SubMesh(cmeshauto, subcount);
				submesh->LoadSolution(subu);
				subcount++;
				it++;
			}

			vtkmesh.DrawMesh(numcases);
			vtkmesh.DrawSolution(istep, 1.);	
		}
	}
	
	total.stop();
	std::cout << "TEMPO = " << total.seconds() << std::endl;
	
	delete gmesh;

	return EXIT_SUCCESS;
}
コード例 #19
0
ファイル: substruct.cpp プロジェクト: labmec/neopz
void InsertViscoElasticityCubo(TPZAutoPointer<TPZCompMesh> mesh)
{
	mesh->SetDimModel(3);
	int nummat = 1, neumann = 1, mixed = 2;
	//	int dirichlet = 0;
	int dir1 = -1, dir2 = -2, dir3 = -3, neumann1 = -4., neumann2 = -5, dirp2 = -6;
	TPZManVector<STATE> force(3,0.);
	//force[1] = 0.;

	STATE ElaE = 1000., poissonE = 0.2, ElaV = 970., poissonV = 0.14; 

	STATE lambdaV = 0, muV = 0, alpha = 0, deltaT = 0;
	lambdaV = 11.3636;
	muV = 45.4545;
	alpha = 1.;	
	deltaT = 0.1;
	
	TPZViscoelastic *viscoelast = new TPZViscoelastic(nummat);
	viscoelast->SetMaterialDataHooke(ElaE, poissonE, ElaV, poissonV, alpha, deltaT, force);
	//TPZViscoelastic *viscoelast = new TPZViscoelastic(nummat, ElaE, poissonE, lambdaV, muV, alphaT, force);
	//TPZElasticity3D *viscoelast = new TPZElasticity3D(nummat, ElaE, poissonE, force);
	
	TPZFNMatrix<6> qsi(6,1,0.);
	viscoelast->SetDefaultMem(qsi); //elast
	int index = viscoelast->PushMemItem(); //elast
	TPZMaterial * viscoelastauto(viscoelast);
	mesh->InsertMaterialObject(viscoelastauto);
	
	// Neumann em x = 1;
	TPZFMatrix<STATE> val1(3,3,0.),val2(3,1,0.);
	val2(0,0) = 1.;
	TPZBndCond *bc4 = viscoelast->CreateBC(viscoelastauto, neumann1, neumann, val1, val2);
	TPZMaterial * bcauto4(bc4);
	mesh->InsertMaterialObject(bcauto4);
	
	// Neumann em x = -1;
	val2(0,0) = -1.;
	TPZBndCond *bc5 = viscoelast->CreateBC(viscoelastauto, neumann2, neumann, val1, val2);
	TPZMaterial * bcauto5(bc5);
	mesh->InsertMaterialObject(bcauto5);
	
	val2.Zero();
	// Dirichlet em -1 -1 -1 xyz;
	val1(0,0) = 1e4;
	val1(1,1) = 1e4;
	val1(2,2) = 1e4;
	TPZBndCond *bc1 = viscoelast->CreateBC(viscoelastauto, dir1, mixed, val1, val2);
	TPZMaterial * bcauto1(bc1);
	mesh->InsertMaterialObject(bcauto1);
	
	// Dirichlet em 1 -1 -1 yz;
	val1(0,0) = 0.;
	val1(1,1) = 1e4;
	val1(2,2) = 1e4;
	TPZBndCond *bc2 = viscoelast->CreateBC(viscoelastauto, dir2, mixed, val1, val2);
	TPZMaterial * bcauto2(bc2);
	mesh->InsertMaterialObject(bcauto2);
	
	// Dirichlet em 1 1 -1 z;
	val1(0,0) = 0.;
	val1(1,1) = 0.;
	val1(2,2) = 1e4;
	TPZBndCond *bc3 = viscoelast->CreateBC(viscoelastauto, dir3, mixed, val1, val2);
	TPZMaterial * bcauto3(bc3);
	mesh->InsertMaterialObject(bcauto3);
	
}
コード例 #20
0
ファイル: pzdxmesh.cpp プロジェクト: JoaoFelipe/oceano
void TPZDXGraphMesh::DrawSolution(int step, REAL time){//0,
	//								  TPZVec<char *> &scalarnames, TPZVec<char *> &vectornames) {
	
	TPZAutoPointer<TPZMaterial> matp = Material();
	int i,nel;
	if(!matp) return;
	int dim = matp->Dimension();
	int dim1 = dim-1;
	
	int numscal = fScalarNames.NElements();
	int numvec = fVecNames.NElements();
	TPZVec<int> scalind(0);
	TPZVec<int> vecind(0);
	scalind.Resize(numscal);
	vecind.Resize(numvec);
	scalind.Fill(-1);
	vecind.Fill(-1);
	int n;
	for(n=0; n<numscal; n++) {
		scalind[n] = matp->VariableIndex( fScalarNames[n]);
	}
	for(n=0; n<numvec; n++) {
		vecind[n] = matp->VariableIndex( fVecNames[n]);
	}
	fFirstFieldValues[dim1].Push(fNextDataField+1);
	fTimes.Push(time);
	cout << "TPZDXGraphMesh.DrawSolution step = " << step << " time = " << time << endl;
	long numpoints = NPoints();
	TPZVec<int> scal(1);
	for(n=0; n<numscal; n++) {
		(fOutFile) << "object " << fNextDataField << " class array type float rank 0 items "
		<< numpoints << " data follows " << endl;
		scal[0] = scalind[n];
		nel = fNodeMap.NElements();
		for(i=0;i<nel;i++) {
			TPZGraphNode *np = &fNodeMap[i];
			if(np) np->DrawSolution(scal, fStyle);
		}
		(fOutFile) << "attribute \"dep\" string \"positions\"" << endl;
		(fOutFile) << "#" << endl;
		fNextDataField ++;
		
		
		//+++++ Cubes    
		if(dim == 3 && (NNodes() == 8 || NNodes() == 6)) {
			(fOutFile) << "object " << (fNextDataField) << " class field" << endl;
			(fOutFile) << "component \"data\" value " << (fNextDataField-1) << endl;
			(fOutFile) << "component \"positions\" value " << fNodePosObject[dim1] << endl;
			(fOutFile) << "component \"connections\" value " << fElConnectivityObject[ECube] << endl;
			(fOutFile) << "attribute \"name\" string \"" << (std::string) fScalarNames[n]
			<< step << (0) << "\"" << endl;
			(fOutFile) << "#" << endl;
			fNextDataField ++;
		}
		
		if(dim == 2 && (NNodes() == 4 || NNodes() == 3)) {
			(fOutFile) << "object " << (fNextDataField) << " class field" << endl;
			(fOutFile) << "component \"data\" value " << (fNextDataField-1) << endl;
			(fOutFile) << "component \"positions\" value " << fNodePosObject[dim1] << endl;
			(fOutFile) << "component \"connections\" value " << fElConnectivityObject[EQuadrilateral] << endl;
			(fOutFile) << "attribute \"name\" string \"" << (std::string) fScalarNames[n]; (fOutFile).flush();
			(fOutFile) << step; (fOutFile).flush();
			(fOutFile) << (0); (fOutFile).flush();
			(fOutFile) << "\""; (fOutFile).flush();
			(fOutFile) << endl; (fOutFile).flush();
			(fOutFile) << "#" << endl; (fOutFile).flush();
			fNextDataField ++;
		}
		if(dim == 1) {
			(fOutFile) << "object " << (fNextDataField) << " class field" << endl;
			(fOutFile) << "component \"data\" value " << (fNextDataField-1) << endl;
			(fOutFile) << "component \"positions\" value " << fNodePosObject[dim1] << endl;
			(fOutFile) << "component \"connections\" value " << fElConnectivityObject[EOned] << endl;
			if(fNormalObject > 0) (fOutFile) << "component \"normals\" value " << fNormalObject << endl;
			(fOutFile) << "attribute \"name\" string \"" << (std::string) fScalarNames[n]
			<< step << (0) << "\"" << endl;
			(fOutFile) << "#" << endl;
			fNextDataField ++;
		}
	}
	TPZVec<int> vec(1);
	for(n=0; n<numvec; n++) {
		(fOutFile) << "object " << fNextDataField << " class array type float rank 1 shape " <<
		matp->NSolutionVariables(vecind[n]) << " items "
		<< numpoints << " data follows " << endl;
		vec[0] = vecind[n];
		nel = fNodeMap.NElements();
		for(i=0;i<nel;i++) {
			TPZGraphNode *np = &fNodeMap[i];
			if(np) np->DrawSolution(vec, fStyle);
		}
		(fOutFile) << "attribute \"dep\" string \"positions\"" << endl;
		(fOutFile) << "#" << endl;
		fNextDataField ++;
		//+++++ Cubes        
		if(dim == 3 && fElConnectivityObject[ECube]) {
			(fOutFile) << "object " << (fNextDataField) << " class field" << endl;
			(fOutFile) << "component \"data\" value " << (fNextDataField-1) << endl;
			(fOutFile) << "component \"positions\" value " << fNodePosObject[dim1] << endl;
			(fOutFile) << "component \"connections\" value " << fElConnectivityObject[ECube] << endl;
			(fOutFile) << "attribute \"name\" string \"" << (std::string) fVecNames[n]
			<< step << (0) << "\"" << endl;
			(fOutFile) << "#" << endl;
			fNextDataField ++;
		}
		//|\|\|\|\|\|\|\|\|\|\|
		if(dim == 2 && fElConnectivityObject[EQuadrilateral]) {
			(fOutFile) << "object " << (fNextDataField) << " class field" << endl;
			(fOutFile) << "component \"data\" value " << (fNextDataField-1) << endl;
			(fOutFile) << "component \"positions\" value " << fNodePosObject[dim1] << endl;
			(fOutFile) << "component \"connections\" value " << fElConnectivityObject[EQuadrilateral] << endl;
			(fOutFile) << "attribute \"name\" string \"" << (std::string) fVecNames[n]
			<< step << (0) << "\"" << endl;
			(fOutFile) << "#" << endl;
			fNextDataField ++;
		}
		if(dim == 2 && fElConnectivityObject[ETriangle]) {
			(fOutFile) << "object " << (fNextDataField) << " class field" << endl;
			(fOutFile) << "component \"data\" value " << (fNextDataField-1) << endl;
			(fOutFile) << "component \"positions\" value " << fNodePosObject[dim1] << endl;
			(fOutFile) << "component \"connections\" value " << fElConnectivityObject[ETriangle] << endl;
			(fOutFile) << "attribute \"name\" string \"" << (std::string) fVecNames[n]
			<< step << (1) << "\"" << endl;
			(fOutFile) << "#" << endl;
			fNextDataField ++;
		}
		if(dim == 1) {
			(fOutFile) << "object " << (fNextDataField) << " class field" << endl;
			(fOutFile) << "component \"data\" value " << (fNextDataField-1) << endl;
			(fOutFile) << "component \"positions\" value " << fNodePosObject[dim1] << endl;
			(fOutFile) << "component \"connections\" value " << fElConnectivityObject[EOned] << endl;
			(fOutFile) << "attribute \"name\" string \"" << (std::string) fVecNames[n]
			<< step << (0) << "\"" << endl;
			(fOutFile) << "#" << endl;
			fNextDataField ++;
		}
	}
}
コード例 #21
0
ファイル: pzanalysis.cpp プロジェクト: JoaoFelipe/oceano
void TPZAnalysis::SetStructuralMatrix(TPZAutoPointer<TPZStructMatrix> strmatrix){
	fStructMatrix = TPZAutoPointer<TPZStructMatrix>(strmatrix->Clone());
}
コード例 #22
0
ファイル: TPZDarcyAnalysis.cpp プロジェクト: labmec/neopz
void TPZDarcyAnalysis::Run()
{
    
    std::string dirname = PZSOURCEDIR;
//    gRefDBase.InitializeUniformRefPattern(EOned);
//    gRefDBase.InitializeUniformRefPattern(EQuadrilateral);
//    gRefDBase.InitializeUniformRefPattern(ETriangle);
//    gRefDBase.InitializeUniformRefPattern(ECube);
    
#ifdef PZDEBUG
    #ifdef LOG4CXX
        
        std::string FileName = dirname;
        FileName = dirname + "/Projects/DarcyflowHdiv3D/";
        FileName += "DarcyFlowLog3D.cfg";
        InitializePZLOG(FileName);
        
    #endif
#endif
    
    //  Reading mesh
    std::string GridFileName;
    GridFileName = dirname + "/Projects/DarcyflowHdiv3D/";
    GridFileName += "SingleLayer.dump";
    //GridFileName += "MixLayer.dump";
    //GridFileName += "BatatacoarseQ.dump";
    //GridFileName += "QUAD4.dump";
    
    if(fLayers[0]->GetIsGIDGeometry())
    {
        ReadGeoMesh(GridFileName);
    }
    else
    {
        int nx = 2;
        int ny = 2;
        int nz = 2;
        Geometry(nx,ny,nz);
        //        CreatedGeoMesh();
    }
    
    
    REAL deg = 0.0;
    int hcont = 0;
    RotateGeomesh(deg * M_PI/180.0);
    this->UniformRefinement(fSimulationData->GetHrefinement());
    
    std::set<int> matidstoRef;
    //    matidstoRef.insert(2);
    //    matidstoRef.insert(3);
    //    matidstoRef.insert(4);
    matidstoRef.insert(3);
    matidstoRef.insert(5);
    this->UniformRefinement(hcont, matidstoRef);
    this->PrintGeoMesh();
    
    
    
    int q = fSimulationData->Getqorder();
    int p = fSimulationData->Getporder();
    int s = 0;
    
    //    if (fSimulationData->GetIsH1approx())
    if (false)
    {
        //        CmeshH1(p);
    }
    else
    {
        CreateMultiphysicsMesh(q,p,s);
//        CreateInterfaces();
    }
    
    
    // Analysis
    bool mustOptimizeBandwidth = true;
    TPZAnalysis *an = new TPZAnalysis(fcmeshdarcy,mustOptimizeBandwidth);
    int numofThreads = 0;
    
    bool IsDirecSolver = fSimulationData->GetIsDirect();
    
    if (IsDirecSolver) {
        
        if (fSimulationData->GetIsBroyden()) {
            TPZFStructMatrix fullMatrix(fcmeshdarcy);
            TPZStepSolver<STATE> step;
            fullMatrix.SetNumThreads(numofThreads);
            step.SetDirect(ELU);
            an->SetStructuralMatrix(fullMatrix);
            an->SetSolver(step);
        }
        else{
            
            TPZSkylineNSymStructMatrix skylnsym(fcmeshdarcy);
            TPZStepSolver<STATE> step;
            skylnsym.SetNumThreads(numofThreads);
            step.SetDirect(ELU);
            an->SetStructuralMatrix(skylnsym);
            an->SetSolver(step);
        }
        
    }
    else
    {
        if (fSimulationData->GetIsBroyden()) {
            TPZFStructMatrix fullMatrix(fcmeshdarcy);
            fullMatrix.SetNumThreads(numofThreads);
            
            TPZAutoPointer<TPZMatrix<STATE> > fullMatrixa = fullMatrix.Create();
            TPZAutoPointer<TPZMatrix<STATE> > fullMatrixaClone = fullMatrixa->Clone();
            
            TPZStepSolver<STATE> *stepre = new TPZStepSolver<STATE>(fullMatrixaClone);
            TPZStepSolver<STATE> *stepGMRES = new TPZStepSolver<STATE>(fullMatrixa);
            TPZStepSolver<STATE> *stepGC = new TPZStepSolver<STATE>(fullMatrixa);
            stepre->SetDirect(ELU);
            stepre->SetReferenceMatrix(fullMatrixa);
            stepGMRES->SetGMRES(10, 20, *stepre, 1.0e-10, 0);
            stepGC->SetCG(10, *stepre, 1.0e-10, 0);
            if (fSimulationData->GetIsCG()) {
                an->SetSolver(*stepGC);
            }
            else{
                an->SetSolver(*stepGMRES);
            }
            
        }
        else{
            
            TPZSkylineNSymStructMatrix skylnsym(fcmeshdarcy);
            skylnsym.SetNumThreads(numofThreads);
            
            TPZAutoPointer<TPZMatrix<STATE> > skylnsyma = skylnsym.Create();
            TPZAutoPointer<TPZMatrix<STATE> > skylnsymaClone = skylnsyma->Clone();
            
            TPZStepSolver<STATE> *stepre = new TPZStepSolver<STATE>(skylnsymaClone);
            TPZStepSolver<STATE> *stepGMRES = new TPZStepSolver<STATE>(skylnsyma);
            TPZStepSolver<STATE> *stepGC = new TPZStepSolver<STATE>(skylnsyma);
            
            stepre->SetDirect(ELU);
            stepre->SetReferenceMatrix(skylnsyma);
            stepGMRES->SetGMRES(10, 20, *stepre, 1.0e-10, 0);
            stepGC->SetCG(10, *stepre, 1.0e-10, 0);
            if (fSimulationData->GetIsCG()) {
                an->SetSolver(*stepGC);
            }
            else{
                an->SetSolver(*stepGMRES);
            }
        }
        
    }
    
    this->InitializeSolution(an);
    this->TimeForward(an);
    
}
コード例 #23
0
//.........................................................................................................................................
void TPZRefPatternDataBase::InitializeUniformRefPattern(MElementType elType)
{
	switch (elType)
	{
		case 0://EPoint
		{
			break;
		}
		case 1://EOned
		{
			std::cout << "\n\tinserting uniform refpattern: line\n";
			char buf[] =
			"3     3  "
			"-50       UnifLin	"
			"-1.     0.     0. "
			" 1.     0.     0. "
			" 0.     0.     0. "
			" 1     2     0     1 "
			" 1     2     0     2 "
			" 1     2     2     1 ";
			std::istringstream str(buf);
			TPZAutoPointer<TPZRefPattern> refpat = new TPZRefPattern(str);
			TPZAutoPointer<TPZRefPattern> refpatFound = FindRefPattern(refpat);
			if(!refpatFound)
			{
				InsertRefPattern(refpat);
			}
			else
			{
				refpatFound->SetName(refpat->Name());
			}
			refpat->InsertPermuted();
			
			break;
		}
		case 2://ETriangle
		{
			std::cout << "\n\tinserting uniform refpattern: triangle\n";
			char buf[] =
			"6     5  "
			"-50       UnifTri	"
			"0.     0.     0. "
			"1.     0.     0. "
			"0.     1.     0. "
			"0.5    0.     0. "
			"0.5    0.5    0. "
			"0.     0.5     0. "
			"2     3     0     1     2 "
			"2     3     0     3     5 "
			"2     3     3     1     4 "
			"2     3     5     4     2 "
			"2     3     4     5     3 ";
			std::istringstream str(buf);
			TPZAutoPointer<TPZRefPattern> refpat = new TPZRefPattern(str);
			TPZAutoPointer<TPZRefPattern> refpatFound = FindRefPattern(refpat);
			if(!refpatFound)
			{
				InsertRefPattern(refpat);
			}
			else
			{
				refpatFound->SetName(refpat->Name());
			}
			refpat->InsertPermuted();
			
			break;
		}
		case 3://EQuadrilateral
		{
			std::cout << "\n\tinserting uniform refpattern: quadrilateral\n";
			char buf[] =
			"9     5  "
			"-50       UnifQua	"
			"-1.    -1.     0. "
			" 1.    -1.     0. "
			" 1.     1.     0. "
			"-1.     1.     0.	"
			" 0.    -1.     0. "
			" 1.     0.     0. "
			" 0.     1.     0. "
			"-1.     0.     0. "
			" 0.     0.     0. "
			" 3     4     0     1     2     3 "
			" 3     4     0     4     8     7 "
			" 3     4     4     1     5     8 "
			" 3     4     8     5     2     6 "
			" 3     4     7     8     6     3 ";
			std::istringstream str(buf);
			TPZAutoPointer<TPZRefPattern> refpat = new TPZRefPattern(str);
			TPZAutoPointer<TPZRefPattern> refpatFound = FindRefPattern(refpat);
			if(!refpatFound)
			{
				InsertRefPattern(refpat);
			}
			else
			{
				refpatFound->SetName(refpat->Name());
			}
			refpat->InsertPermuted();
#ifdef LOG4CXX
            if (logger->isDebugEnabled()) {
                std::stringstream sout;
                refpat->PrintMore(sout);
                LOGPZ_DEBUG(logger, sout.str())
            }
#endif
			
			break;
		}
		case 4://ETetraedro
		{
			std::cout << "\n\tinserting uniform refpattern: tetrahedra\n";
			char buf[] =
			"10     7"
			"-50       UnifTet	"
			"0.     0.     0. "
			"1.     0.     0. "
			"0.     1.     0. "
			"0.     0.     1. "
			"0.5    0.     0. "
			"0.5    0.5    0. "
			"0.     0.5    0. "
			"0.     0.     0.5 "
			"0.5    0.     0.5 "
			"0.     0.5    0.5 "
			"4     4     0     1     2     3 "
			"4     4     0     4     6     7 "
			"4     4     4     1     5     8 "
			"4     4     6     5     2     9 "
			"4     4     7     8     9     3 "
			"5     5     4     8     9     6     7 "
			"5     5     8     4     6     9     5 ";
			std::istringstream str(buf);
			TPZAutoPointer<TPZRefPattern> refpat = new TPZRefPattern(str);
			TPZAutoPointer<TPZRefPattern> refpatFound = FindRefPattern(refpat);
			if(!refpatFound)
			{
				InsertRefPattern(refpat);
			}
			else
			{
				refpatFound->SetName(refpat->Name());
			}
			refpat->InsertPermuted();
			
			break;
		}
		case 5://EPiramide
		{
			std::cout << "\n\tinserting uniform refpattern: pyramid\n";
			char buf[] =
			"14     11	"
			"-50       UnifPyr	"
			"-1.    -1.     0. "
			" 1.    -1.     0. "
			" 1.     1.     0. "
			"-1.     1.     0. "
			" 0.     0.     1. "
			" 0.    -1.     0. "
			" 1.     0.     0. "
			" 0.     1.     0. "
			"-1.     0.     0. "
			"-0.5   -0.5    0.5 "
			" 0.5   -0.5    0.5 "
			" 0.5    0.5    0.5 "
			"-0.5    0.5    0.5 "
			" 0.     0.     0. "
			" 5     5     0     1     2     3     4 "
			" 5     5     0     5    13     8     9	"
			" 5     5     5     1     6    13    10	"
			" 5     5    13     6     2     7    11	"
			" 5     5     8    13     7     3    12	"
			" 5     5     9    10    11    12     4	"
			" 5     5     9    12    11    10    13	"
			" 4     4     9     5    13    10	"
			" 4     4    10     6    13    11	"
			" 4     4    11     7    12    13	"
			" 4     4     8    13    12     9	";
			std::istringstream str(buf);
			TPZAutoPointer<TPZRefPattern> refpat = new TPZRefPattern(str);
			TPZAutoPointer<TPZRefPattern> refpatFound = FindRefPattern(refpat);
			if(!refpatFound)
			{
				InsertRefPattern(refpat);
			}
			else
			{
				refpatFound->SetName(refpat->Name());
			}
			refpat->InsertPermuted();
			
			break;
		}
		case 6://EPrisma
		{
			std::cout << "\n\tinserting uniform refpattern: prism\n";
			char buf[] =
			"18     9  "
			"-50       UnifPri 	"
			" 0.     0.    -1.	"
			" 1.     0.    -1.	"
			" 0.     1.    -1.	"
			" 0.     0.     1.	"
			" 1.     0.     1.	"
			" 0.     1.     1.	"
			" 0.5    0.    -1.	"
			" 0.5    0.5   -1.	"
			" 0.     0.5   -1.	"
			" 0.     0.     0.	"
			" 1.     0.     0.	"
			" 0.     1.     0.	"
			" 0.5    0.     1.	"
			" 0.5    0.5    1.	"
			" 0.     0.5    1.	"
			" 0.5    0.     0.	"
			" 0.5    0.5    0.	"
			" 0.     0.5    0.	"
			" 6     6     0     1     2     3     4     5	"
			" 6     6     0     6     8     9    15    17	"
			" 6     6     6     1     7    15    10    16	"
			" 6     6     8     7     2    17    16    11	"
			" 6     6    17    16    15     8     7     6	"
			" 6     6     9    15    17     3    12    14	"
			" 6     6    15    10    16    12     4    13	"
			" 6     6    17    16    11    14    13     5	"
			" 6     6    14    13    12    17    16    15	";
			std::istringstream str(buf);
			TPZAutoPointer<TPZRefPattern> refpat = new TPZRefPattern(str);
			TPZAutoPointer<TPZRefPattern> refpatFound = FindRefPattern(refpat);
			if(!refpatFound)
			{
				InsertRefPattern(refpat);
			}
			else
			{
				refpatFound->SetName(refpat->Name());
			}
			refpat->InsertPermuted();
			
			break;
		}
		case 7://ECube
		{
			std::cout << "\n\tinserting uniform refpattern: hexahedre\n";
			char buf[] =
			"27     9  "
			"-50     UnifHex  "
			"-1.    -1.    -1.  "
			" 1.    -1.    -1.  "
			" 1.     1.    -1.  "
			"-1.     1.    -1.  "
			"-1.    -1.     1.  "
			" 1.    -1.     1.  "
			" 1.     1.     1.  "
			"-1.     1.     1.  "
			" 0.    -1.    -1.  "
			" 1.     0.    -1.  "
			" 0.     1.    -1.  "
			"-1.     0.    -1.  "
			"-1.    -1.     0.  "
			" 1.    -1.     0.  "
			" 1.     1.     0.  "
			"-1.     1.     0.  "
			" 0.    -1.     1.  "
			" 1.     0.     1.  "
			" 0.     1.     1.  "
			"-1.     0.     1.  "
			" 0.     0.    -1.  "
			" 0.    -1.     0.  "
			" 1.     0.     0.  "
			" 0.     1.     0.  "
			"-1.     0.     0.  "
			" 0.     0.     1.  "
			" 0.     0.     0.  "
			"7     8     0     1     2     3     4     5     6     7  "
			"7     8     0     8    20    11    12    21    26    24  "
			"7     8     8     1     9    20    21    13    22    26  "
			"7     8    20     9     2    10    26    22    14    23  "
			"7     8    11    20    10     3    24    26    23    15  "
			"7     8    12    21    26    24     4    16    25    19  "
			"7     8    21    13    22    26    16     5    17    25  "
			"7     8    26    22    14    23    25    17     6    18  "
			"7     8    24    26    23    15    19    25    18     7  ";
			std::istringstream str(buf);
			TPZAutoPointer<TPZRefPattern> refpat = new TPZRefPattern(str);
			TPZAutoPointer<TPZRefPattern> refpatFound = FindRefPattern(refpat);
			if(!refpatFound)
			{
				InsertRefPattern(refpat);
			}
			else
			{
				refpatFound->SetName(refpat->Name());
			}
			refpat->InsertPermuted();
			
			break;
		}
		default:
		{
			cout << "Cant generate uniform refpattern because MElementType was not found on " << __PRETTY_FUNCTION__ << endl;
			DebugStop();
		}
	}
コード例 #24
0
ファイル: oopdatamanager.cpp プロジェクト: labmec/oopar
void * OOPDataManager::ServiceThread(void * data)
{
#ifdef LOG4CXX
	{
		stringstream sout;
		sout << "Starting service thread for DM";
		LOGPZ_DEBUG(logger, sout.str().c_str());
	}
#endif
	OOPDataManager * lDMStar = static_cast<OOPDataManager *> (data);
	TPZAutoPointer<OOPTaskManager> TM = lDMStar->TM();
	TPZAutoPointer<OOPDataManager> lDM = TM->DM();
	//  lDM->fKeepGoing = true;
	while (lDM->fKeepGoing)
	{
		lDM->WaitWakeUpCall();
#ifdef STEP_MUTEX
		OOPLock<OOPGenericLockService> lock(&gMutex);
#endif
		{
			stringstream sout;
			sout << lDM->GetProcID()
			<< " Woke Up | One more round ------------------------------------------------------------------"
			<< endl;
#ifdef LOG4CXX
			LOGPZ_DEBUG(ServiceLogger, sout.str().c_str());
#endif
		}
		{
			stringstream sout;
			sout << "Calling DM->HandleMessages()";
#ifdef LOG4CXX
			LOGPZ_DEBUG(ServiceLogger, sout.str().c_str());
#endif
		}
		lDM->HandleMessages();
		{
			stringstream sout;
			sout << "Called DM->HandleMessages() | Calling lDM->FlushData()";
#ifdef LOG4CXX
			LOGPZ_DEBUG(ServiceLogger, sout.str().c_str());
#endif
		}
		lDM->FlushData();
		{
			stringstream sout;
			sout
			<< "Called DM->FlushData() | Going to Sleep on WaitWakeUpCall()";
#ifdef LOG4CXX
			LOGPZ_DEBUG(ServiceLogger, sout.str().c_str());
#endif
		}
#ifdef STEP_MUTEX
		lock.Unlock();
#endif
	}
	{
#ifdef LOG4CXX
		stringstream sout;
		sout << "Leaving DM ServiceThread calling HandleMessages and FlushData";
		LOGPZ_DEBUG(ServiceLogger, sout.str().c_str());
		std::cout << sout.str().c_str() << " for Proc " << lDM->GetProcID()
		<< endl;
#endif
	}
	lDM->HandleMessages();
	lDM->FlushData();
	{
#ifdef LOG4CXX
		stringstream sout;
		sout
		<< "HandleMessages and FlushData called, DM->ServiceThread Finished";
		LOGPZ_DEBUG(ServiceLogger, sout.str().c_str());
		std::cout << sout.str().c_str() << " for Proc " << lDM->GetProcID()
		<< endl;
#endif
	}
	return NULL;
}
コード例 #25
0
ファイル: substruct.cpp プロジェクト: labmec/neopz
int SubStructure(TPZAutoPointer<TPZCompMesh> cmesh, REAL height)
{
	int nelem = cmesh->NElements();
	TPZManVector<int> subindex(nelem,-1);
	int iel;
	int nsub = 0;
	for (iel=0; iel<nelem; iel++) 
	{
		TPZCompEl *cel = cmesh->ElementVec()[iel];
		if (!cel) {
			continue;
		}
		TPZGeoEl *gel = cel->Reference();
		if (!gel) {
			continue;
		}
		int nsides = gel->NSides();
		TPZManVector<REAL> center(gel->Dimension(),0.), xco(3,0.);
		gel->CenterPoint(nsides-1,center);
		gel->X(center,xco);
		REAL z = xco[2];
		int floor = (int) z/height;
		nsub = (floor+1) > nsub ? (floor+1) : nsub;
		subindex[iel] = floor;
	}
	
#ifdef DEBUG 
	{
		TPZGeoMesh *gmesh = cmesh->Reference();
		int nelgeo = gmesh->NElements();
		TPZVec<int> domaincolor(nelgeo,-999);
		int cel;
		int nel = cmesh->NElements();
		for (cel=0; cel<nel; cel++) {
			TPZCompEl *compel = cmesh->ElementVec()[cel];
			if(!compel) continue;
			TPZGeoEl *gel = compel->Reference();
			if (!gel) {
				continue;
			}
			domaincolor[gel->Index()] = subindex[cel];
		}
		ofstream vtkfile("partition.vtk");
		TPZVTKGeoMesh::PrintGMeshVTK(gmesh, vtkfile, domaincolor);
	}
#endif
	
	int isub;
	TPZManVector<TPZSubCompMesh *> submeshes(nsub,0);
	for (isub=0; isub<nsub; isub++) 
	{
		int index;
		std::cout << '^'; std::cout.flush();
		submeshes[isub] = new TPZSubCompMesh(cmesh,index);
		
		if (index < subindex.NElements()) 
		{
			subindex[index] = -1;
		}
	}
	for (iel=0; iel<nelem; iel++) 
	{
		int domindex = subindex[iel];
		if (domindex >= 0) 
		{
			TPZCompEl *cel = cmesh->ElementVec()[iel];
			if (!cel) 
			{
				continue;
			}
			submeshes[domindex]->TransferElement(cmesh.operator->(),iel);
		}
	}
	cmesh->ComputeNodElCon();
	for (isub=0; isub<nsub; isub++) 
	{
		submeshes[isub]->MakeAllInternal();
		std::cout << '*'; std::cout.flush();
	}
	
	cmesh->ComputeNodElCon();
	cmesh->CleanUpUnconnectedNodes();
	return nsub;
}
コード例 #26
0
ファイル: pzadaptmesh.cpp プロジェクト: labmec/neopz
REAL TPZAdaptMesh::UseTrueError(TPZInterpolatedElement *coarse, 
                                void (*f)(const TPZVec<REAL> &loc, TPZVec<REAL> &val, TPZFMatrix<REAL> &deriv)){
    if (coarse->Material()->Id() < 0) return 0.0;
    
    REAL error = 0.;
    
    //  REAL loclocmatstore[500] = {0.},loccormatstore[500] = {0.};
    // TPZFMatrix loccormat(locmatsize,cormatsize,loccormatstore,500);
    
    //Cesar 25/06/03 - Uso a ordem m�xima???
    TPZAutoPointer<TPZIntPoints> intrule = coarse->GetIntegrationRule().Clone();
    
    int dimension = coarse->Dimension();
    int numdof = coarse->Material()->NStateVariables();
        
    //TPZSolVec corsol;
    //TPZGradSolVec cordsol;
    TPZGradSolVec cordsolxy;
//    TPZVec<REAL> corsol(numdof);
//    TPZFNMatrix<9,REAL> cordsol(dimension,numdof),cordsolxy(dimension,numdof);
    
    TPZManVector<int> order(dimension,20);
    intrule->SetOrder(order);
    
    // derivative of the shape function
    // in the master domain
    TPZManVector<REAL,3> coarse_int_point(dimension);
//    TPZFNMatrix<9,REAL> jaccoarse(dimension,dimension),jacinvcoarse(dimension,dimension);
//    TPZFNMatrix<9,REAL> axescoarse(3,3);
//    TPZManVector<REAL,3> xcoarse(3);
    TPZFNMatrix<9,REAL> axesinner(3,3);
    
    
    TPZMaterialData datacoarse;
    coarse->InitMaterialData(datacoarse);
    
//    REAL jacdetcoarse;
    int numintpoints = intrule->NPoints();
    REAL weight;
    
    TPZVec<REAL> truesol(numdof);
    TPZFMatrix<REAL> truedsol(dimension,numdof);
    for(int int_ind = 0; int_ind < numintpoints; ++int_ind) {
        intrule->Point(int_ind,coarse_int_point,weight);
        //coarse->Reference()->X(coarse_int_point, xcoarse);
        coarse->Reference()->X(coarse_int_point, datacoarse.x);
        //if(f) f(xcoarse,truesol,truedsol);
        if(f) f(datacoarse.x,truesol,truedsol);

//        coarse->Reference()->Jacobian(coarse_int_point, jaccoarse, axescoarse, jacdetcoarse, jacinvcoarse);
        coarse->Reference()->Jacobian(coarse_int_point, datacoarse.jacobian, datacoarse.axes, datacoarse.detjac, datacoarse.jacinv);
        //weight *= fabs(jacdetcoarse);
        weight *= fabs(datacoarse.detjac);
//Er        int iv=0;
//        corsol[0].Fill(0.);
//        cordsol[0].Zero();

        //coarse->ComputeSolution(coarse_int_point, corsol, cordsol, axescoarse);
        coarse->ComputeShape(coarse_int_point,datacoarse);
        coarse->ComputeSolution(coarse_int_point,datacoarse);
        
        //int nc = cordsol[0].Cols();
        int nc = datacoarse.dsol[0].Cols();
        for (int col=0; col<nc; col++)
        {
            for (int d=0; d<dimension; d++) {
                REAL deriv = 0.;
                for (int d2=0; d2<dimension; d2++) {
                    deriv += datacoarse.dsol[0](d2,col)*datacoarse.axes(d2,d);
                }
               // cordsolxy[0](d,col) = deriv;
            }
        }
        int jn;
        for(jn=0; jn<numdof; jn++) {
            for(int d=0; d<dimension; d++) {
                error += (datacoarse.dsol[0](d,jn)-truedsol(d,jn))*(datacoarse.dsol[0](d,jn)-truedsol(d,jn))*weight;
            }
        }
    }
    return error;
}
コード例 #27
0
ファイル: pzmatred.cpp プロジェクト: labmec/neopz
void TPZMatRed<TVar,TSideMatrix>::SetSolver(TPZAutoPointer<TPZMatrixSolver<TVar> > solver)
{
	fK00=solver->Matrix();
	fSolver = solver;
}
コード例 #28
0
ファイル: main.cpp プロジェクト: labmec/neopz
int mainfem(int argc, char *argv[])
{
    //InitializePZLOG();
    gRefDBase.InitializeUniformRefPattern(EOned);
    gRefDBase.InitializeUniformRefPattern(EQuadrilateral);
    gRefDBase.InitializeUniformRefPattern(ETriangle);
    
    ofstream saidaerros("ErroProjecaoSemiH1.txt");
    saidaerros << "\nCalculo do Erro\n";
    int h= 0;
    int p=0;
    
    saidaerros.precision(16);
    
    for(p=1; p<5; p++)
    {
        saidaerros << "\n";
        saidaerros << "Ordens p = " << p <<"\n";
        for(h=0; h<6; h++)
        {
            saidaerros << "\nRefinamento: h = "<< h <<"\n";
            
            //TPZGeoMesh * gmesh = MalhaGeom(1.,1.,false);
            TPZAutoPointer<TPZGeoMesh> gmesh = MalhaGeom(1.,1.,false);
            TPZVec<int> dims(2,0);
            dims[0]=1; dims[1]=2;
            int nref = h;
            RefinamentoUniforme(gmesh, nref, dims);
            
            
            TPZCompMesh * cmesh = CompMesh(gmesh.operator->(),p);
            
            //analysis
            TPZAnalysis an(cmesh,false);
            TPZSkylineStructMatrix skyl(cmesh);
            an.SetStructuralMatrix(skyl);
            TPZStepSolver<STATE> step;
            step.SetDirect(ELDLt);
            an.SetSolver(step);
            an.Assemble();
            an.Solve();
            
//            std::string plotfile("result.vtk");
//            TPZStack<std::string> scalnames,vecnames;
//            scalnames.Push("Solution");
//            scalnames.Push("ExactPressure");
//            an.DefineGraphMesh(cmesh->Dimension(), scalnames, vecnames, plotfile);
//            an.PostProcess(0,2);
            
 //           TPZVec<REAL> erros(3);
//            an.SetExact(*SolSuave);
//            an.PostProcessError(erros,saidaerros);
            ErrorH1(cmesh, saidaerros);
            
            cmesh->CleanUp();
            gmesh->CleanUp();
            delete cmesh;
        }
    }
    
    return EXIT_SUCCESS;
}
コード例 #29
0
ファイル: pzstepsolver.cpp プロジェクト: JoaoFelipe/oceano
void TPZStepSolver<TVar>::Solve(const TPZFMatrix<TVar> &F, TPZFMatrix<TVar> &result, TPZFMatrix<TVar> *residual){
	if(!this->Matrix()) {
		cout << "TPZMatrixSolver::Solve called without a matrix pointer\n";
		DebugStop();
	}
	
	TPZAutoPointer<TPZMatrix<TVar> > mat = this->Matrix();
    // update the matrix to which the preconditioner refers
    if(fPrecond)
    {
        
        fPrecond->UpdateFrom(this->Matrix());
    }
    
	if(result.Rows() != mat->Rows() || result.Cols() != F.Cols()) {
		result.Redim(mat->Rows(),F.Cols());
	}
	
	if(this->fScratch.Rows() != result.Rows() || this->fScratch.Cols() != result.Cols()) {
		this->fScratch.Redim(result.Rows(),result.Cols());
	}
	
	TVar tol = fTol;
	int numiterations = fNumIterations;
	switch(fSolver) {
		case TPZStepSolver::ENoSolver:
		default:
			cout << "TPZMatrixSolver::Solve called without initialized solver, Jacobi used\n";
			SetJacobi(1,0.,0);
		case TPZStepSolver::EJacobi:
			//    cout << "fScratch dimension " << fScratch.Rows() << ' ' << fScratch.Cols() << endl;
			mat->SolveJacobi(numiterations,F,result,residual,this->fScratch,tol,fFromCurrent);
			break;
		case TPZStepSolver::ESOR:
			mat->SolveSOR(numiterations,F,result,residual,this->fScratch,fOverRelax,tol,fFromCurrent);
			break;
		case TPZStepSolver::ESSOR:
			mat->SolveSSOR(numiterations,F,result,residual,this->fScratch,fOverRelax,tol,fFromCurrent);
			break;
		case TPZStepSolver::ECG:
			mat->SolveCG(numiterations,*fPrecond,F,result,residual,tol,fFromCurrent);
#ifdef LOG4CXX
		{
			std::stringstream sout;
			sout << "Number of equations " << mat->Rows() << std::endl;
			sout << "Number of CG iterations " << numiterations << " tol = " << tol;
			LOGPZ_DEBUG(logger,sout.str().c_str());
		}
#endif
			break;
		case TPZStepSolver::EGMRES: {
			TPZFMatrix<TVar> H(fNumVectors+1,fNumVectors+1,0.);
			mat->SolveGMRES(numiterations,*fPrecond,H,fNumVectors,F,result,residual,tol,fFromCurrent);
			if(numiterations == fNumIterations || tol >= fTol)
			{
				std::cout << "GMRes tolerance was not achieved : numiter " << numiterations <<
				" tol " << tol << endl;
			}
#ifdef LOG4CXX
			{
				std::stringstream sout;
				sout << "Number of GMRES iterations " << numiterations << " tol = " << tol;
				LOGPZ_DEBUG(logger,sout.str().c_str());
			}
#endif
		}
			break;
		case TPZStepSolver::EBICGSTAB: 
			mat->SolveBICGStab(numiterations, *fPrecond, F, result,residual,tol,fFromCurrent);
			
			if(numiterations == fNumIterations || tol >= fTol)
			{
				std::cout << "BiCGStab tolerance was not achieved : numiter " << numiterations <<
				" tol " << tol << endl;
			}
#ifdef LOG4CXX
		{
			std::stringstream sout;
			sout << "Number of BiCGStab iterations " << numiterations << " tol = " << tol;
			LOGPZ_DEBUG(logger,sout.str().c_str());
		}
#endif
			break;
		case TPZStepSolver::EDirect:
			result = F;
			mat->SolveDirect(result,fDecompose,fSingular);
			if(residual) residual->Redim(F.Rows(),F.Cols());
			break;
		case TPZStepSolver::EMultiply:
			mat->Multiply(F,result);
			if(residual) mat->Residual(result,F,*residual);
			
	}
}
コード例 #30
0
//.........................................................................................................................................
int TPZRefPatternDataBase::ImportRefPatterns(std::string &Path, int maxdim)
{
	std::string bar = "/";
	
	std::string FileTypes ("*.rpt");
	std::string Command = std::string("ls -1 ") + Path + bar + FileTypes;
	std::cout << "Generated command: " << Command.c_str() << std::endl;
	FILE   *fp;
	
#ifdef VC
	fp = _popen(Command.c_str(), "r");
#else
	#ifndef BORLAND
		fp = popen(Command.c_str(), "r");
	#else
		fp = (FILE *)open(Command.c_str(), O_RDONLY );
	#endif
#endif
	
	if (!fp)
	{
		return -1;
	}
	
	int count = 0;
	char psBuffer[1024];
	
	while( !feof( fp ) )
	{
		if( fgets(psBuffer, sizeof(psBuffer), fp ) != NULL )
		{
			if (psBuffer[strlen(psBuffer)-1] == '\n') 
			{
				psBuffer[strlen(psBuffer)-1] = 0;
			}
			std::cout << "Reading refinement patern file : " << psBuffer << std::endl;
			std::string filref(psBuffer);
			
			TPZAutoPointer<TPZRefPattern> refpat = new TPZRefPattern(filref);
            
            if (refpat->fRefPatternMesh.Dimension() > maxdim) {
                std::cout << "skipped\n";
                continue;
            }
			
			if(!this->FindRefPattern(refpat))
			{
				this->InsertRefPattern(refpat);
			}
			refpat->InsertPermuted();
			
			count++;
		}
	}

#ifndef BORLAND
#ifdef VC
	_pclose(fp);
#else
	pclose(fp);
#endif
#else
	close((int)fp);
#endif
	
	return count;
}