예제 #1
0
bool CZMatDia_BlkCrs::SetBoundaryCondition(const MatVec::CBCFlag& bc_flag){

	assert( m_len_BlkCol == m_len_BlkRow );
	const unsigned int BlkSize = m_len_BlkCol*m_len_BlkRow;
	const unsigned int BlkLen = m_len_BlkCol;
	
	for(unsigned int iblk=0;iblk<m_nblk_MatRow;iblk++){
		for(unsigned int idof=0;idof<BlkLen;idof++){
			if( bc_flag.GetBCFlag(iblk,idof) == 0 ) continue;
			{
				for(unsigned int kdof=0;kdof<BlkLen;kdof++){ m_valDia_Blk[iblk*BlkSize+kdof*BlkLen+idof] = 0.0; }
				for(unsigned int jdof=0;jdof<BlkLen;jdof++){ m_valDia_Blk[iblk*BlkSize+idof*BlkLen+jdof] = 0.0; }
				m_valDia_Blk[iblk*BlkSize+idof*BlkLen+idof] = 1.0;
			}
			for(unsigned int ipsup=m_colInd_Blk[iblk];ipsup<m_colInd_Blk[iblk+1];ipsup++){
				for(unsigned int jdof=0;jdof<BlkLen;jdof++){ m_valCrs_Blk[ipsup*BlkSize+idof*BlkLen+jdof] = 0.0; }
			}
		}
	}
	for(unsigned int ipsup=0;ipsup<m_colInd_Blk[m_nblk_MatRow];ipsup++){
		const int jblk1 = m_rowPtr_Blk[ipsup];
		for(unsigned int jdof=0;jdof<BlkLen;jdof++){
			if( bc_flag.GetBCFlag(jblk1,jdof) == 0 ) continue;
			for(unsigned int idof=0;idof<BlkLen;idof++){
				m_valCrs_Blk[ipsup*BlkSize+idof*BlkLen+jdof] = 0.0;
			}
		}
	}
	return true;
}
static void BoundaryCondition
(unsigned int id_field, const ELSEG_TYPE& elseg_type,  
 MatVec::CBCFlag& bc_flag, const CFieldWorld& world,  
 unsigned int ioffset=0)
{
  if( !world.IsIdField(id_field) ) return;
  const Fem::Field::CField& field = world.GetField(id_field);  
  {	// Assert
    const unsigned int len = bc_flag.LenBlk();
    assert( ioffset < len );
  }
  const unsigned int nlen = field.GetNLenValue();
  
  const std::vector<unsigned int>& aIdEA = field.GetAryIdEA();
  for(unsigned int iea=0;iea<aIdEA.size();iea++){
    unsigned int id_ea = aIdEA[iea];
    const CElemAry& ea = world.GetEA(id_ea);
    unsigned int noes[256];
    if( elseg_type == CORNER && field.GetIdElemSeg(id_ea,CORNER,true,world) != 0 ){
      const Fem::Field::CElemAry::CElemSeg& es = field.GetElemSeg(id_ea,CORNER,true,world);
      unsigned int nnoes = es.Length();
      for(unsigned int ielem=0;ielem<ea.Size();ielem++){
        es.GetNodes(ielem,noes);
        for(unsigned int inoes=0;inoes<nnoes;inoes++){
          for(unsigned int ilen=0;ilen<nlen;ilen++){
            bc_flag.SetBC(noes[inoes],ilen+ioffset);
          }
        }
      }
    }
    if( elseg_type == BUBBLE && field.GetIdElemSeg(id_ea,BUBBLE,true,world) != 0 ){
      const Fem::Field::CElemAry::CElemSeg& es = field.GetElemSeg(id_ea,BUBBLE,true,world);
      unsigned int nnoes = es.Length();
      for(unsigned int ielem=0;ielem<ea.Size();ielem++){
        es.GetNodes(ielem,noes);
        for(unsigned int inoes=0;inoes<nnoes;inoes++){
          for(unsigned int ilen=0;ilen<nlen;ilen++){
            bc_flag.SetBC(noes[inoes],ilen+ioffset);
          }
        }
      }
    }
    if( elseg_type == EDGE   && field.GetIdElemSeg(id_ea,EDGE,true,world) != 0 ){
      const Fem::Field::CElemAry::CElemSeg& es = field.GetElemSeg(id_ea,EDGE,true,world);
      unsigned int nnoes = es.Length();
      for(unsigned int ielem=0;ielem<ea.Size();ielem++){
        es.GetNodes(ielem,noes);
        for(unsigned int inoes=0;inoes<nnoes;inoes++){
          for(unsigned int ilen=0;ilen<nlen;ilen++){
            bc_flag.SetBC(noes[inoes],ilen+ioffset);
          }
        }
      }
    }
  }
}
예제 #3
0
//----------------------------------------------------------------------
// CBCFlag
//----------------------------------------------------------------------
MatVec::CBCFlag * CBCFlag::CreateNativeInstance(const MatVec::CBCFlag& rhs)
{
    MatVec::CBCFlag * ptr = NULL;

    int len = rhs.LenBlk();
    unsigned int nblk = rhs.NBlk();


    if (len != -1)
    {
        ptr = new MatVec::CBCFlag(nblk, len);
    }
    else
    {
        std::vector<unsigned int> alen;
        for (unsigned int iblk = 0; iblk < nblk; iblk++)
        {
            unsigned int nlen_blk = rhs.LenBlk(iblk);
            alen.push_back(nlen_blk);
        }
        ptr = new MatVec::CBCFlag(nblk, alen);
    }

    ptr->SetAllFlagZero(); // フラグをすべてOFFにする
    // ONの箇所だけ設定
    for (unsigned int iblk = 0; iblk < nblk; iblk++)
    {
        unsigned int nlen_blk = rhs.LenBlk(iblk);
        for (unsigned int idofblk = 0; idofblk < nlen_blk; idofblk++)
        {
            int bc_flag = rhs.GetBCFlag(iblk, idofblk);
            if (bc_flag != 0)
            {
                // len != -1の場合の処理しかない?
                assert(nlen_blk == len);
                ptr->SetBC(iblk, idofblk); // ONにする
            }
        }
    }

    return ptr;
}
// elem_aryに含まれる節点全てidofblk番目の自由度を固定する
static bool SetBCFlagToES
(unsigned int id_field,
 MatVec::CBCFlag& bc_flag, 
 const Fem::Field::CElemAry& ea, unsigned int id_es, unsigned int idofblk)
{
  assert( (int)idofblk < bc_flag.LenBlk() );
  if( (int)idofblk >= bc_flag.LenBlk() ) return false;
  assert( ea.IsSegID(id_es) );
  const Fem::Field::CElemAry::CElemSeg& es = ea.GetSeg(id_es);
  unsigned int noes[256];
  unsigned int nnoes = es.Length();
  for(unsigned int ielem=0;ielem<ea.Size();ielem++){
    es.GetNodes(ielem,noes);
    for(unsigned int inoes=0;inoes<nnoes;inoes++){
      const unsigned int inode0 = noes[inoes];
      bc_flag.SetBC(inode0,idofblk);
      //			m_Flag[inode0*m_lenBlk+idofblk] = 1;
    }
  }
  return true;
}
static void BoundaryCondition
(unsigned int id_field, const ELSEG_TYPE& elseg_type, unsigned int idofns, 
 MatVec::CBCFlag& bc_flag, const CFieldWorld& world)
{
  if( !world.IsIdField(id_field) ) return;
  const Fem::Field::CField& field = world.GetField(id_field);
  assert( (int)idofns < bc_flag.LenBlk()  );
  const std::vector<unsigned int>& aIdEA = field.GetAryIdEA();
  for(unsigned int iea=0;iea<aIdEA.size();iea++){
    const unsigned int id_ea = aIdEA[iea];
    const CElemAry& ea = world.GetEA(id_ea);
    if( elseg_type == CORNER && field.GetIdElemSeg(id_ea,CORNER,true,world) != 0 ){
      SetBCFlagToES(id_field,bc_flag, ea, field.GetIdElemSeg(id_ea,CORNER,true,world), idofns);
    }
    if( elseg_type == BUBBLE && field.GetIdElemSeg(id_ea,BUBBLE,true,world) != 0 ){
      SetBCFlagToES(id_field,bc_flag, ea, field.GetIdElemSeg(id_ea,BUBBLE,true,world), idofns);
    }
    if( elseg_type == EDGE   && field.GetIdElemSeg(id_ea,EDGE,  true,world) != 0 ){
      SetBCFlagToES(id_field,bc_flag, ea, field.GetIdElemSeg(id_ea,EDGE,  true,world), idofns);
    }
  }
}