Example #1
0
bool CEqnSystem_Fluid2D::UpdateDomain_FieldVeloPress(
    unsigned int id_base_field_v, unsigned int id_base_field_p, Fem::Field::CFieldWorld& world)
{
    m_id_press = world.MakeField_FieldElemDim(id_base_field_p,2,
                 Fem::Field::SCALAR, VELOCITY|ACCELERATION,CORNER);
    assert( world.IsIdField(m_id_press) );
    //    std::cout << "press " << m_id_press << std::endl;

    m_IsntCombine = true;
    if( m_IsntInterpolationBubble) {
        std::cout << "corner intp" << std::endl;
        m_id_velo  = world.MakeField_FieldElemDim(id_base_field_v,2,
                     Fem::Field::VECTOR2,VELOCITY|ACCELERATION,CORNER);
    }
    else {
        std::cout << "bubble intp" << std::endl;
        m_id_velo  = world.MakeField_FieldElemDim(id_base_field_v,2,
                     Fem::Field::VECTOR2,VELOCITY|ACCELERATION,CORNER|BUBBLE);
    }
    //    std::cout << "velo : " << m_id_velo << std::endl;
    assert( world.IsIdField(m_id_velo) );

    {   // 同じ要素配列IDを持つ方程式があったら,それを使う.なければ新規に追加
        std::vector<CEqn_Fluid2D> aEqn_old = m_aEqn;
        m_aEqn.clear();
        const CField& field = world.GetField(m_id_velo);
        const std::vector<unsigned int>& aIdEA = field.GetAryIdEA();
        for(unsigned int iiea=0; iiea<aIdEA.size(); iiea++) {
            const unsigned int id_ea = aIdEA[iiea];
            unsigned int ieqn0=0;
            for(; ieqn0<aEqn_old.size(); ieqn0++) {
                if( aEqn_old[ieqn0].GetIdEA() == id_ea ) {
                    const unsigned int ieqn1 = m_aEqn.size();
                    m_aEqn.push_back( aEqn_old[ieqn0] );
                    m_aEqn[ieqn1].SetIdFieldVelocity(m_id_velo);
                    m_aEqn[ieqn1].SetIdFieldPressure(m_id_press);
                    break;
                }
            }
            if( ieqn0 != aEqn_old.size() ) {
                continue;
            }
            CEqn_Fluid2D eqn1(id_ea,m_id_velo,m_id_press);
            eqn1.SetRho(m_rho_back);
            eqn1.SetMyu(m_myu_back);
            if( this->m_is_stokes_back ) {
                //                std::cout << "Stokes" << std::endl;
                eqn1.SetStokes();
            }
            else {
                //                std::cout << "Navier-Stokes" << std::endl;
                eqn1.SetNavierStokes();
            }
            m_aEqn.push_back( eqn1 );
        }
    }
    if( !world.IsIdField(m_id_velo) ) return false;
    this->ClearLinearSystemPreconditioner();
    return true;
}
Example #2
0
bool CEqn_Fluid3D::SetDomain(unsigned int id_base, Fem::Field::CFieldWorld& world)
{
    bool is_mixed = false;
    Field::ELEM_TYPE elem_type = (Field::ELEM_TYPE)0;
    {
        assert( world.IsIdField(id_base) );
        const CField& field_base = world.GetField(id_base);
        const std::vector<unsigned int>& aIdEA = field_base.GetAryIdEA();
        for(unsigned int iiea=0; iiea<aIdEA.size(); iiea++) {
            unsigned int id_ea = aIdEA[iiea];
            CElemAry& ea = world.GetEA(id_ea);
            if( ea.ElemType() == TET ) {
                if( elem_type == 0 ) {
                    elem_type = TET;
                }
                else if( elem_type == HEX ) {
                    is_mixed = true;
                    break;
                }
            }
            else if( ea.ElemType() == HEX ) {
                if( elem_type == 0 ) {
                    elem_type = HEX;
                }
                else if( elem_type == TET ) {
                    is_mixed = true;
                    break;
                }
            }
        }
    }
    if( is_mixed ) {
        assert(0);
        std::cout << "Not Implimented" << std::endl;
        m_id_press = 0;
        m_id_velo = 0;
        return false;
    }
    if( elem_type == TET ) {
        m_id_press = world.MakeField_FieldElemDim(id_base,3,
                     Fem::Field::SCALAR, VELOCITY|ACCELERATION,CORNER);
    }
    else if( elem_type == HEX ) {
        m_id_press = world.MakeField_FieldElemDim(id_base,3,
                     Fem::Field::SCALAR, VELOCITY|ACCELERATION,BUBBLE);
    }
    m_id_velo  = world.MakeField_FieldElemDim(id_base,3,
                 Fem::Field::VECTOR3,VELOCITY|ACCELERATION,CORNER);
    this->ClearLinearSystemPreconditioner();
    return true;
}
Example #3
0
bool CEqn_Scalar3D::SetDomain(unsigned int id_base, Fem::Field::CFieldWorld& world)
{
	m_IdFieldVal = world.MakeField_FieldElemDim(id_base,3,SCALAR,VALUE,CORNER);
	this->ClearLinearSystemPreconditioner();
	this->m_aIdFixField.clear();
	return true;
}
Example #4
0
bool CEqn_Solid3D_Linear::SetDomain_Field(unsigned int id_field_base, Fem::Field::CFieldWorld& world){
	{	// ì¸óÕÉtÉBÅ[ÉãÉhÇÃç¿ïWêflì_ÉZÉOÉÅÉìÉgÇÃdofÇ™3ǩǫǧǩÉ`ÉFÉbÉNÇ∑ÇÈ
//		unsigned int id_field_base = world.GetFieldBaseID();
		assert( world.IsIdField(id_field_base) );
		const CField& field_base = world.GetField(id_field_base);
		assert( field_base.GetNDimCoord() == 3 );
	}
	m_IdFieldDisp = world.MakeField_FieldElemDim(id_field_base, 3, 
        VECTOR3,VALUE|VELOCITY|ACCELERATION,CORNER);
	this->ClearLinearSystemPreconditioner();
	return true;
}
Example #5
0
bool CEqnSystem_Scalar2D::SetDomain_Field(unsigned int id_base, Fem::Field::CFieldWorld& world)
{
	m_IdFieldVal = world.MakeField_FieldElemDim(id_base,2,SCALAR,VELOCITY|VALUE,CORNER);
	{
		m_aEqn.clear();
		const CField& field = world.GetField(m_IdFieldVal);
		const std::vector<unsigned int>& aIdEA = field.GetAryIdEA();
		for(unsigned int iiea=0;iiea<aIdEA.size();iiea++){
			const unsigned int id_ea = aIdEA[iiea];
			m_aEqn.push_back( CEqn_Scalar2D(id_ea,m_IdFieldVal) );
		}
	}
	this->ClearLinearSystemPreconditioner();
	this->m_aIdFixField.clear();
	return true;
}
Example #6
0
bool CEqnSystem_Solid2D::UpdateDomain_Field(unsigned int id_base, Fem::Field::CFieldWorld& world)
{
	m_IdFieldDisp  = world.MakeField_FieldElemDim(id_base,2,
		Fem::Field::VECTOR2,VALUE|VELOCITY|ACCELERATION,CORNER);
    assert( world.IsIdField(m_IdFieldDisp) );

	{	// ìØÇ∂óvëfîzóÒIDÇéùǬï˚íˆéÆÇ™Ç Ç¡ÇΩÇÁÅCǪÇÍÇégǧÅDÇ»ÇØÇÍÇŒêVãKÇ…í«â¡
		std::vector<CEqn_Solid2D> aEqn_old = m_aEqn;
		m_aEqn.clear();
		const CField& field = world.GetField(m_IdFieldDisp);
		const std::vector<unsigned int>& aIdEA = field.GetAryIdEA();
		for(unsigned int iiea=0;iiea<aIdEA.size();iiea++){
			const unsigned int id_ea = aIdEA[iiea];
			unsigned int ieqn0=0;
			for(;ieqn0<aEqn_old.size();ieqn0++){
				if( aEqn_old[ieqn0].GetIdEA() == id_ea ){ 
					const unsigned int ieqn1 = m_aEqn.size();
					m_aEqn.push_back( aEqn_old[ieqn0] );
					m_aEqn[ieqn1].SetIdFieldDisp(m_IdFieldDisp);
					break; 
				}
			}
			if( ieqn0 != aEqn_old.size() ){ continue; }
            CEqn_Solid2D eqn1(id_ea,m_IdFieldDisp);
			eqn1.SetYoungPoisson(m_young_back, m_poisson_back, m_is_plane_stress_back);
			eqn1.SetRho(m_rho_back);
			eqn1.SetGeometricalNonlinear(m_is_geom_nonlin_back);
            m_aEqn.push_back( eqn1 );
		}
	}

    std::cout << "Size Eqn : " << m_aEqn.size() << std::endl;
    for(unsigned int ieqn=0;ieqn<m_aEqn.size();ieqn++){
        const CEqn_Solid2D& eqn = m_aEqn[ieqn];
		double young, poisson;
		eqn.GetYoungPoisson(young,poisson);
//        std::cout << ieqn << " " << eqn.GetIdEA() << " " << young << " " << poisson << " " << std::endl;
//		m_aEqn[ieqn].SetGravitation(0,-0.0);
    }
	

	if( !world.IsIdField(m_IdFieldDisp) ) return false;
	this->ClearLinearSystemPreconditioner();
	this->m_aIdFixField.clear();
	return true;
}
Example #7
0
void SetNewProblem()
{
	const unsigned int nprob = 2;
	static unsigned int iprob = 0;

	static int id_val_bc0=0, id_val_bc1=0, id_val_bc2=0;
	
	if( iprob == 0 ){	// 2次元問題の設定
		Cad::CCadObj2D cad_2d;
		{	// 形を作る
            std::vector<Com::CVector2D> vec_ary;
            vec_ary.push_back( Com::CVector2D(-0.5,-0.5) );
            vec_ary.push_back( Com::CVector2D( 0.5,-0.5) );
            vec_ary.push_back( Com::CVector2D( 0.5, 0.5) );
            vec_ary.push_back( Com::CVector2D(-0.5, 0.5) );
			cad_2d.AddPolygon( vec_ary );
            cad_2d.AddVertex(Cad::LOOP,1,Com::CVector2D(0.0,0.0));
		}
		world.Clear();
		const unsigned int id_base = world.AddMesh( Msh::CMesher2D(cad_2d,0.05) );
		const Fem::Field::CIDConvEAMshCad& conv = world.GetIDConverter(id_base);

		unsigned int id_field_rot = world.MakeField_FieldElemDim(id_base,2,VECTOR2,VALUE,CORNER);
		unsigned int id_field_deflect = world.MakeField_FieldElemDim(id_base,2,SCALAR,VALUE,CORNER);

		Fem::Ls::CLinearSystem_Field ls;
		LsSol::CPreconditioner_ILU prec;
		ls.AddPattern_Field(id_field_deflect,world);
		ls.AddPattern_Field(id_field_rot,id_field_deflect,world);
		prec.SetLinearSystem(ls.m_ls);

		unsigned int id_field_rot_fix0 = world.GetPartialField(id_field_rot,conv.GetIdEA_fromCad(2,Cad::EDGE));
		unsigned int id_field_rot_fix1 = world.GetPartialField(id_field_rot,conv.GetIdEA_fromCad(4,Cad::EDGE));
		ls.SetFixedBoundaryCondition_Field(id_field_rot_fix0,world);
		ls.SetFixedBoundaryCondition_Field(id_field_rot_fix1,world);

		unsigned int id_field_def_fix0 = world.GetPartialField(id_field_deflect,conv.GetIdEA_fromCad(2,Cad::EDGE));
		unsigned int id_field_def_fix1 = world.GetPartialField(id_field_deflect,conv.GetIdEA_fromCad(4,Cad::EDGE));
    Fem::Field::SetFieldValue_Constant(id_field_rot_fix1,1,Fem::Field::VALUE,world, -1);
    
		ls.SetFixedBoundaryCondition_Field(id_field_def_fix0,world);
		ls.SetFixedBoundaryCondition_Field(id_field_def_fix1,world);    
    
		ls.InitializeMarge();
		Fem::Eqn::AddLinearSystem_DKT2D_Static(ls,world,id_field_deflect,id_field_rot);
		double res = ls.FinalizeMarge();
		prec.SetValue(ls.m_ls);

		std::cout << "Residual : " << res << std::endl;
		{
			double tol = 1.0e-6;
			unsigned int iter = 10000;
			LsSol::Solve_CG(tol,iter,ls);
//			Fem::Sol::Solve_PCG(tol,iter,ls,prec);
			std::cout << iter << " " << tol << std::endl;
		}
		ls.UpdateValueOfField(id_field_deflect,world,VALUE);
		ls.UpdateValueOfField(id_field_rot,world,VALUE);

		drawer_ary.Clear();
	//	drawer_ary.PushBack( new View::CDrawerVector(id_field_rot,world) );
		drawer_ary.PushBack( new View::CDrawerFace(id_field_deflect,false,world) );
		drawer_ary.PushBack( new View::CDrawerEdge(id_field_deflect,false,world) );
		drawer_ary.PushBack( new View::CDrawerEdge(id_field_deflect,true,world) );
    camera.Fit( drawer_ary.GetBoundingBox(camera.GetRotMatrix3() ) );
	}
	else if( iprob == 1 ){
		Msh::CMesher2D msh;
		msh.ReadFromFile_GiDMsh("../input_file/rect_tri.msh");
		world.Clear();
		const unsigned int id_base = world.AddMesh( msh );

		unsigned int id_field_rot = world.MakeField_FieldElemDim(id_base,2,  VECTOR2,VALUE,CORNER);
		unsigned int id_field_deflect = world.MakeField_FieldElemDim(id_base,2,  SCALAR,VALUE,CORNER);

		unsigned int id_field_rot_fix0 = world.GetPartialField(id_field_rot,3);
		unsigned int id_field_rot_fix1 = world.GetPartialField(id_field_rot,4);
		unsigned int id_field_def_fix0 = world.GetPartialField(id_field_deflect,3);
		unsigned int id_field_def_fix1 = world.GetPartialField(id_field_deflect,4);
    
    Fem::Field::SetFieldValue_Constant(id_field_def_fix1,0,Fem::Field::VALUE,world, -3);    

		Fem::Ls::CLinearSystem_Field ls;
		LsSol::CPreconditioner_ILU prec;
		ls.AddPattern_Field(id_field_deflect,world);
		ls.AddPattern_Field(id_field_rot,id_field_deflect,world);
		prec.SetLinearSystem(ls.m_ls);

		ls.SetFixedBoundaryCondition_Field(id_field_rot_fix0,world);
		ls.SetFixedBoundaryCondition_Field(id_field_rot_fix1,world);
		ls.SetFixedBoundaryCondition_Field(id_field_def_fix0,world);
		ls.SetFixedBoundaryCondition_Field(id_field_def_fix1,world);
		ls.InitializeMarge();
		Fem::Eqn::AddLinearSystem_DKT2D_Static(ls,world,id_field_deflect,id_field_rot);
		double res = ls.FinalizeMarge();
		prec.SetValue(ls.m_ls);

		std::cout << "Residual : " << res << std::endl;
		{
			double tol = 1.0e-6;
			unsigned int iter = 10000;
			LsSol::Solve_CG(tol,iter,ls);
//			Fem::Sol::Solve_PCG(tol,iter,ls,prec);
			std::cout << iter << " " << tol << std::endl;
		}
		ls.UpdateValueOfField(id_field_deflect,world,VALUE);
		ls.UpdateValueOfField(id_field_rot,world,VALUE);

		drawer_ary.Clear();
	//	drawer_ary.PushBack( new View::CDrawerVector(id_field_rot,world) );
		drawer_ary.PushBack( new View::CDrawerFace(id_field_deflect,false,world) );
		drawer_ary.PushBack( new View::CDrawerEdge(id_field_deflect,false,world) );
		drawer_ary.PushBack( new View::CDrawerEdge(id_field_deflect,true,world) );
    camera.Fit( drawer_ary.GetBoundingBox(camera.GetRotMatrix3() ) );    
	}

	iprob++;
	if( iprob == nprob ) iprob=0;
}