bool View::CIndexArrayElem::Set_Hex
(unsigned int id_ea, unsigned int id_es, 
 const Fem::Field::CFieldWorld& world)
{
	if( !world.IsIdEA(id_ea) ) return false;
	const CElemAry& ea = world.GetEA(id_ea);
	if( !ea.IsSegID(id_es) ) return false;
	if( ea.ElemType() != HEX ) return false;
	////////////////
	itype = Fem::Field::HEX;
	this->id_ea = id_ea;
	this->id_es = id_es;
	unsigned int id_es_add = 0;
	CElemAry* pEA = ea.MakeBoundElemAry(id_es,id_es_add,aIndElem);
	nElem = pEA->Size();
	nnoel = 4;
	assert( aIndElem.size() == nElem );
	assert( pEA->IsSegID(id_es_add) );
	const CElemAry::CElemSeg& es = pEA->GetSeg(id_es_add);
	const unsigned int npofa = 4;
	pIA_Elem = new unsigned int [nElem*npofa];
	for(unsigned int iface=0;iface<nElem;iface++){
		es.GetNodes(iface,pIA_Elem+iface*npofa);
	}
	delete pEA;
	return true;
}
CIndexArrayElem::CIndexArrayElem(unsigned int id_ea, unsigned int id_es, const Fem::Field::CFieldWorld& world)
{
//	std::cout << "CIndexArrayElem::CIndexArrayElem" << std::endl;
	itype = ELEM_TYPE_NOT_SET; 
	is_selected = false;
	this->id_ea=id_ea;
	this->id_es=id_es;
	color[0] = 0.8; color[1] = 0.8; color[2] = 0.8;
//	color[0] = 1.0; color[1] = 1.0; color[2] = 1.0;  
//	color[0] = 0.8; color[1] = 0.2; color[2] = 0.2;
//	color[0] = 0.2; color[1] = 0.8; color[2] = 0.2;
	nElem = 0;
	pIA_Elem = 0;
	pColor = 0;
	ilayer = 0;
	////////////////
	if( !world.IsIdEA(id_ea) ) return;
	const CElemAry& ea = world.GetEA(id_ea);
	if(      ea.ElemType() == Fem::Field::POINT){ color[0]=0; color[1]=0; color[2]=0; }
	else if( ea.ElemType() == Fem::Field::LINE ){ Set_Line(id_ea,id_es, world); color[0]=0; color[1]=0; color[2]=0; }
	else if( ea.ElemType() == Fem::Field::TRI  ){ Set_Tri( id_ea,id_es, world); }
	else if( ea.ElemType() == Fem::Field::QUAD ){ Set_Quad(id_ea,id_es, world); }
	else if( ea.ElemType() == Fem::Field::TET  ){ Set_Tet( id_ea,id_es, world); }
	else if( ea.ElemType() == Fem::Field::HEX  ){ Set_Hex( id_ea,id_es, world); }
}
예제 #3
0
/*
bool CEqnSystem_Solid2D::SetDomain_Field(unsigned int id_field_base, Fem::Field::CFieldWorld& world)
{
	{	// ì¸óÕÉtÉBÅ[ÉãÉhÇÃç¿ïWêflì_ÉZÉOÉÅÉìÉgÇÃdofÇ™2ǩǫǧǩÉ`É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() == 2 );
	}
	m_IdFieldDisp = world.MakeField_FieldElemDim(id_field_base, 2,
        VECTOR2,VALUE|VELOCITY|ACCELERATION,CORNER);
	const CIDConvEAMshCad conv = world.GetIDConverter(id_field_base);
	{
		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];
			assert( world.IsIdEA(id_ea) );
			const CElemAry& ea = world.GetEA(id_ea);
			if( ea.ElemType() != TRI && ea.ElemType() != QUAD ) continue;
			m_aEqn.push_back( CEqn_Solid2D(id_ea,m_IdFieldDisp) );
		}
	}
	this->ClearLinearSystemPreconditioner();
	this->m_aIdFixField.clear();
	return true;
}
*/
bool CEqnSystem_Solid2D::SetDomain_FieldEA(unsigned int id_field_base, unsigned int id_ea, 
                                           Fem::Field::CFieldWorld& world)
{
	{	// ì¸óÕÉtÉBÅ[ÉãÉhÇÃç¿ïWêflì_ÉZÉOÉÅÉìÉgÇÃdofÇ™2ǩǫǧǩÉ`É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() == 2 );
	}
	m_IdFieldDisp = world.MakeField_FieldElemAry(id_field_base, id_ea,
        VECTOR2,VALUE|VELOCITY|ACCELERATION,CORNER);
	{
		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];
			assert( world.IsIdEA(id_ea) );
			const CElemAry& ea = world.GetEA(id_ea);
			if( ea.ElemType() != TRI && ea.ElemType() != QUAD ) continue;
			m_aEqn.push_back( CEqn_Solid2D(id_ea,m_IdFieldDisp) );
		}
	}
	this->ClearLinearSystemPreconditioner();
	this->m_aIdFixField.clear();
	return true;
}
// add pattern to the diagonal
bool Ls::CLinearSystem_RigidField2::AddPattern_Field(const unsigned int id_field, const Fem::Field::CFieldWorld& world)
{
	if( !world.IsIdField(id_field) ) return false;
  const Fem::Field::CField& field = world.GetField(id_field);
	unsigned int id_field_parent;
	{
		if( field.GetIDFieldParent() == 0 ){ id_field_parent = id_field; }
		else{ id_field_parent = field.GetIDFieldParent(); }
	}

	const unsigned int nlen_value = field.GetNLenValue();

	int ilss_add;
	{	// Cornerブロックを作る
    unsigned int id_na_val = field.GetNodeSegInNodeAry(Fem::Field::CORNER).id_na_va;
		if( id_na_val != 0 ){
			assert( world.IsIdNA(id_na_val) );
      const Fem::Field::CNodeAry& na = world.GetNA(id_na_val);
      assert( m_ls.GetNLinSysSeg() == this->m_aSegRF.size() );
      ilss_add = m_ls.GetNLinSysSeg();
      this->m_aSegRF.push_back( CLinSysSegRF(id_field_parent,Fem::Field::CORNER) );
      int ires = m_ls.AddLinSysSeg( na.Size(), field.GetNLenValue() );
      assert( ires == ilss_add );
		}
		else{ ilss_add = -1; }
	}
	////////////////////////////////
	const std::vector<unsigned int> aIdEA = field.GetAryIdEA();
  assert( aIdEA.size() > 0 );
	for(unsigned int iiea=0;iiea<aIdEA.size();iiea++){
		const unsigned int id_ea = aIdEA[iiea];
    const Fem::Field::CElemAry& ea = world.GetEA(id_ea);
		// CORNER節点について
    if( field.GetIdElemSeg(id_ea,Fem::Field::CORNER,true,world) != 0 ){
			assert( world.IsIdEA(id_ea) );
      const unsigned int id_es_c = field.GetIdElemSeg(id_ea,Fem::Field::CORNER,true,world);
			assert( ea.IsSegID(id_es_c) );
      {
        Com::CIndexedArray crs;
        ea.MakePattern_FEM(id_es_c,crs);
        m_ls.AddMat_Dia(ilss_add, crs );			// cc行列を作る
      }
      if( field.GetIdElemSeg(id_ea,Fem::Field::BUBBLE,true,world) != 0 ){	// CORNER-BUBBLE
        assert(0);
			}
      if( field.GetIdElemSeg(id_ea,Fem::Field::EDGE,true,world) != 0 ){	// CONRER-EDGE
        assert(0);
			}
		}
		// EDGE節点について
    if( field.GetIdElemSeg(id_ea,Fem::Field::EDGE,true,world) != 0 ){
      assert(0);
		}
		// BUBBLE節点について
    if( field.GetIdElemSeg(id_ea,Fem::Field::BUBBLE,true,world) != 0 ){
      assert(0);
		}
	}
	return true;
}
예제 #5
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;
}
bool CEdgeTextureColor::Update(const Fem::Field::CFieldWorld& world)
{
	if( !world.IsIdField(this->id_field_velo) ){ return false; }
	if( !world.IsIdField(this->id_part_field_velo) ){ return false; }
	if( !world.IsIdEA(this->id_ea) ){ return false; }
	const Fem::Field::CElemAry& ea = world.GetEA(id_ea);
	assert( ea.ElemType() == Fem::Field::LINE );
	if( nelem != ea.Size() ){
		nelem  = ea.Size();
		if( m_aXYVeloElem != 0 ){ delete[] m_aXYVeloElem; }
		if( m_aXYElem     != 0 ){ delete[] m_aXYElem; }
		m_aXYVeloElem = new double [nelem*4];
		m_aXYElem     = new double [nelem*4];
	}
	const Fem::Field::CField& fv = world.GetField(this->id_part_field_velo);
//	const Fem::Field::CField::CNodeSegInNodeAry& nans = fv.GetNodeSegInNodeAry(Fem::Field::CORNER);
	const Fem::Field::CNodeAry::CNodeSeg& ns_v = fv.GetNodeSeg(CORNER,true, world,VELOCITY);
	const Fem::Field::CNodeAry::CNodeSeg& ns_c = fv.GetNodeSeg(CORNER,false,world,VELOCITY);
	const Fem::Field::CElemAry::CElemSeg& es_v = fv.GetElemSeg(id_ea,CORNER,true, world);
	const Fem::Field::CElemAry::CElemSeg& es_c = fv.GetElemSeg(id_ea,CORNER,false,world);
	assert( es_v.Length() == 2 );
	assert( es_c.Length() == 2 );
	for(unsigned int ielem=0;ielem<nelem;ielem++)
	{
		unsigned int noes[2];
		es_c.GetNodes(ielem,noes);
		double co[2][2];
		ns_c.GetValue(noes[0],co[0]);
		ns_c.GetValue(noes[1],co[1]);
		////////////////
		es_v.GetNodes(ielem,noes);
		double velo[2][2];
		ns_v.GetValue(noes[0],velo[0]);	
		ns_v.GetValue(noes[1],velo[1]);
		////////////////
		m_aXYElem[ielem*4+0] = co[0][0];
		m_aXYElem[ielem*4+1] = co[0][1];
		m_aXYElem[ielem*4+2] = co[1][0];
		m_aXYElem[ielem*4+3] = co[1][1];
		////////////////
		const double r = velo_scale;
		m_aXYVeloElem[ielem*4+0] = co[0][0] + r*velo[0][0];	
		m_aXYVeloElem[ielem*4+1] = co[0][1] + r*velo[0][1];
		m_aXYVeloElem[ielem*4+2] = co[1][0] + r*velo[1][0];
		m_aXYVeloElem[ielem*4+3] = co[1][1] + r*velo[1][1];
	}
	return true;
}
bool View::CIndexArrayElem::Set_Quad(unsigned int id_ea, unsigned int id_es, 
									 const Fem::Field::CFieldWorld& world)
{
	if( !world.IsIdEA(id_ea) ) return false;
	const CElemAry& ea = world.GetEA(id_ea);
	if( !ea.IsSegID(id_es) ) return false;
	if( ea.ElemType() != QUAD ) return false;
	////////////////
	itype = Fem::Field::QUAD;
	this->id_ea = id_ea;
	this->id_es = id_es;
	const CElemAry::CElemSeg& es = ea.GetSeg(id_es);
	nElem = ea.Size();
	nnoel = 4;
	if( this->pIA_Elem != 0 ) delete[] pIA_Elem;
	pIA_Elem = new unsigned int [nElem*4];
	const unsigned int nnoes = es.Length();
	assert( nnoes == 4 );
	for(unsigned int iquad=0;iquad<nElem;iquad++){
		es.GetNodes(iquad,pIA_Elem+iquad*4);
	}
	return true;
}
bool View::CIndexArrayElem::Set_Line(unsigned int id_ea, unsigned int id_es, 
									 const Fem::Field::CFieldWorld& world)
{
	if( !world.IsIdEA(id_ea) ) return false;
	const CElemAry& ea = world.GetEA(id_ea);
	if( !ea.IsSegID(id_es) ) return false;
	if( ea.ElemType() != LINE ) return false;
	////////////////
	itype = Fem::Field::LINE;
	this->id_ea = id_ea;
	this->id_es = id_es;
	const CElemAry::CElemSeg& es = ea.GetSeg(id_es);
	nElem = ea.Size();
	nnoel = 2;
	if( this->pIA_Elem != 0 ) delete[] pIA_Elem;
	pIA_Elem = new unsigned int [nElem*2];
	unsigned int nnoes = es.Length();
	assert( nnoes == 2 );
	for(unsigned int iedge=0;iedge<nElem;iedge++){
		es.GetNodes(iedge,pIA_Elem+iedge*2);
	}
	return true;
}
bool View::CIndexArrayElem::Set_Tri(unsigned int id_ea, unsigned int id_es, 
									const Fem::Field::CFieldWorld& world)
{	
//	std::cout << "View::CIndexArrayElem::Set_Tri" << std::endl;
	if( !world.IsIdEA(id_ea) ) return false;
	const CElemAry& ea = world.GetEA(id_ea);
	if( !ea.IsSegID(id_es) ) return false;
	if( ea.ElemType() != TRI ) return false;
	////////////////
	itype = Fem::Field::TRI;
	this->id_ea = id_ea;
	this->id_es = id_es;
	const CElemAry::CElemSeg& es = ea.GetSeg(id_es);
	nElem = ea.Size();
	nnoel = 3;
	if( this->pIA_Elem != 0 ) delete[] pIA_Elem;
	pIA_Elem = new unsigned int [nElem*3];
	unsigned int nnoes = es.Length();
	assert( nnoes == 3 );
	for(unsigned int itri=0;itri<nElem;itri++){
		es.GetNodes(itri,pIA_Elem+itri*3);
	}
	return true;
}
bool View::CIndexArrayElem::SetColor
(unsigned int id_es_v, unsigned int id_ns_v, const Fem::Field::CFieldWorld& world,
 const std::auto_ptr<CColorMap>& color_map )
{
	if( itype == Fem::Field::TRI )	// TRI
	{
		if( !world.IsIdEA(id_ea) ) return false;
		const CElemAry& ea = world.GetEA(id_ea);
		if( !ea.IsSegID(id_es) ) return false;
		if( ea.ElemType() != TRI ) return false;
		const CElemAry::CElemSeg& es_v = ea.GetSeg(id_es_v);
//		assert( es_v.Size() == 1 );
		unsigned int id_na_v = es_v.GetIdNA();
		assert( world.IsIdNA(id_na_v) );
		const CNodeAry& na = world.GetNA(id_na_v);
		assert( es_v.GetMaxNoes() < na.Size() );
		assert( na.IsSegID(id_ns_v) );
		const CNodeAry::CNodeSeg& ns = na.GetSeg(id_ns_v);
		assert( ns.Length() == 1 );
		if( this->pColor == 0 ){ this->pColor = new float [nElem*3]; }
		for(unsigned int itri=0;itri<nElem;itri++){
			unsigned int inode0;
			es_v.GetNodes(itri,&inode0);
			double val;
			ns.GetValue(inode0,&val);
			color_map->GetColor(pColor+itri*3,val);
		}
		return true;
	}
	else if( itype == Fem::Field::QUAD )
	{
		if( !world.IsIdEA(id_ea) ) return false;
		const CElemAry& ea = world.GetEA(id_ea);
		if( !ea.IsSegID(id_es) ) return false;
		if( ea.ElemType() != QUAD ) return false;
		const CElemAry::CElemSeg& es_v = ea.GetSeg(id_es_v);
		assert( es_v.Length() == 1 );
		unsigned int id_na_v = es_v.GetIdNA();
		assert( world.IsIdNA(id_na_v) );
		const CNodeAry& na = world.GetNA(id_na_v);
		assert( es_v.GetMaxNoes() < na.Size() );
		assert( na.IsSegID(id_ns_v) );
		const CNodeAry::CNodeSeg& ns = na.GetSeg(id_ns_v);
		assert( ns.Length() == 1 );
		if( this->pColor == 0 ){ this->pColor = new float [nElem*3]; }
		for(unsigned int iquad=0;iquad<nElem;iquad++){
			unsigned int inode0;
			es_v.GetNodes(iquad,&inode0);
			double val;
			ns.GetValue(inode0,&val);
			color_map->GetColor(pColor+iquad*3,val);
		}
		return true;
	}
	else if( itype == Fem::Field::TET )
	{
		if( !world.IsIdEA(id_ea) ) return false;
		const CElemAry& ea = world.GetEA(id_ea);
		const unsigned int ntet = ea.Size();
		if( !ea.IsSegID(id_es) ) return false;
		if( ea.ElemType() != TET ) return false;
		const CElemAry::CElemSeg& es_v = ea.GetSeg(id_es_v);
		assert( es_v.Length() == 1 );
		unsigned int id_na_v = es_v.GetIdNA();
		assert( world.IsIdNA(id_na_v) );
		const CNodeAry& na = world.GetNA(id_na_v);
		assert( es_v.GetMaxNoes() < na.Size() );
		assert( na.IsSegID(id_ns_v) );
		const CNodeAry::CNodeSeg& ns = na.GetSeg(id_ns_v);
		assert( ns.Length() == 1 );
		if( this->pColor == 0 ){ this->pColor = new float [nElem*3]; }
		for(unsigned int iface=0;iface<nElem;iface++){
			unsigned int itet = aIndElem[iface];
			assert( itet < ntet );
			unsigned int inode0;
			es_v.GetNodes(itet,&inode0);
			double val;
			ns.GetValue(inode0,&val);
			color_map->GetColor(pColor+iface*3,val);
		}
		return true;
	}
	else if( itype == Fem::Field::HEX )
	{	
		if( !world.IsIdEA(id_ea) ) return false;
		const CElemAry& ea = world.GetEA(id_ea);
		const unsigned int nhex = ea.Size();
		if( !ea.IsSegID(id_es) ) return false;
		if( ea.ElemType() != HEX ) return false;
		const CElemAry::CElemSeg& es_v = ea.GetSeg(id_es_v);
		assert( es_v.Length() == 1 );
		unsigned int id_na_v = es_v.GetIdNA();
		assert( world.IsIdNA(id_na_v) );
		const CNodeAry& na = world.GetNA(id_na_v);
		assert( es_v.GetMaxNoes() < na.Size() );
		assert( na.IsSegID(id_ns_v) );
		const CNodeAry::CNodeSeg& ns = na.GetSeg(id_ns_v);
		assert( ns.Length() == 1 );
		if( this->pColor == 0 ){ this->pColor = new float [nElem*3]; }
		for(unsigned int iface=0;iface<nElem;iface++){
			unsigned int ihex = aIndElem[iface];
			assert( ihex < nhex );
			unsigned int inode0;
			es_v.GetNodes(ihex,&inode0);
			double val;
			ns.GetValue(inode0,&val);			
			color_map->GetColor(pColor+iface*3,val);
		}
		return true;
	}
	return true;
}
예제 #11
0
//! set gradient value to the field
bool Fem::Field::SetFieldValue_Gradient
(unsigned int id_field_to, Fem::Field::CFieldWorld& world,
 unsigned int id_field_from)
{  
	if( !world.IsIdField(id_field_from) ) return false;
	Fem::Field::CField& field_from = world.GetField(id_field_from);
  
	if( !world.IsIdField(id_field_to) ) return false;
	Fem::Field::CField& field_to = world.GetField(id_field_to);  
  
	if( field_to.GetAryIdEA().size() != 1 ){
		std::cout << "Error!-->Not Implimented" << std::endl;
		getchar();
		assert(0);
	}
  
	Fem::Field::INTERPOLATION_TYPE type_from, type_to;
	{
		const std::vector<unsigned int>& aIdEA_from = field_from.GetAryIdEA();
		const std::vector<unsigned int>& aIdEA_to   = field_to.GetAryIdEA();
		if( aIdEA_from.size() != aIdEA_to.size() ) return false;
		const unsigned int niea = aIdEA_from.size();
		assert( niea == 1 );
		if( aIdEA_from[0] != aIdEA_to[0] ) return false;
		const unsigned int id_ea = aIdEA_from[0];
		type_from = field_from.GetInterpolationType(id_ea,world);
		type_to   = field_to.GetInterpolationType(id_ea,world);
	}
  
	unsigned int nnoes, ndim;
	if( type_from==HEX11 && type_to==HEX1001 ){
		nnoes = 8; ndim = 3;
	}
	else if( type_from==TET11 && type_to==TET1001 ){
		nnoes = 4; ndim = 3;
	}
	else if( type_from==TRI11 && type_to==TRI1001 ){
		nnoes = 3; ndim = 2;
	}
	else{
		std::cout << "NotImplimented!" << std::endl;
		assert(0);
		getchar();
	}
  
	unsigned int id_ea = field_to.GetAryIdEA()[0];
	const CElemAry& ea = world.GetEA(id_ea);
	const CElemAry::CElemSeg& es_c_co = field_from.GetElemSeg(id_ea,CORNER,false,world);
	const CElemAry::CElemSeg& es_c_va = field_from.GetElemSeg(id_ea,CORNER,true, world);
	const CElemAry::CElemSeg& es_b_va = field_to.GetElemSeg(id_ea,BUBBLE,true, world);
  
	const Fem::Field::CField::CNodeSegInNodeAry& nsna_c = field_from.GetNodeSegInNodeAry(CORNER);
	assert( world.IsIdNA(nsna_c.id_na_co) );
	assert( world.IsIdNA(nsna_c.id_na_va) );
	const CNodeAry& na_c_co = world.GetNA(nsna_c.id_na_co);
	const CNodeAry::CNodeSeg& ns_c_co = na_c_co.GetSeg(nsna_c.id_ns_co);
	const CNodeAry& na_c_va = world.GetNA(nsna_c.id_na_va);
	const CNodeAry::CNodeSeg& ns_c_va = na_c_va.GetSeg(nsna_c.id_ns_va);
	unsigned int id_na_b_va = field_to.GetNodeSegInNodeAry(BUBBLE).id_na_va;
	unsigned int id_ns_b_va = field_to.GetNodeSegInNodeAry(BUBBLE).id_ns_va;
  
	assert( world.IsIdNA(id_na_b_va) );
	CNodeAry& na_b_va = world.GetNA(id_na_b_va);
	CNodeAry::CNodeSeg& ns_b_va = na_b_va.GetSeg(id_ns_b_va);
  
	double coord[16][3];
	double value[16];
	double grad[3];
  
  //	const unsigned int nnoes_c = es_c_co.GetSizeNoes();
	unsigned int noes[64];
  
	for(unsigned int ielem=0;ielem<ea.Size();ielem++){
		{	// 座標(coord)と値(value)を作る
			es_c_co.GetNodes(ielem,noes);
			for(unsigned int inoes=0;inoes<nnoes;inoes++){
				unsigned int ipoi0 = noes[inoes];
				assert( ipoi0 < na_c_co.Size() );
				ns_c_co.GetValue(ipoi0,coord[inoes]);
			}
      /*			if( id_es_c_va == id_es_c_co ){	
       for(unsigned int inoes=0;inoes<nnoes;inoes++){
       unsigned int ipoi0 = noes[inoes];
       assert( ipoi0 < na_c_va.Size() );
       na_c_va.GetValueFromNode(ipoi0,id_ns_c_va,0,val);
       value[inoes] = val;
       }
       }
       else{*/
      es_c_va.GetNodes(ielem,noes);
      for(unsigned int inoes=0;inoes<nnoes;inoes++){
        unsigned int ipoi0 = noes[inoes];
        assert( ipoi0 < na_c_va.Size() );
        ns_c_va.GetValue(ipoi0,&value[inoes]);
      }
      //			}
		}
		if( type_from == HEX11 ){
			double dndx[8][3];
			double an[8];
			double detjac;
			ShapeFunc_Hex8(0.0,0.0,0.0, coord, detjac,dndx,an);
			for(unsigned int idim=0;idim<ndim;idim++){ grad[idim] = 0.0; }
			for(unsigned int inoes=0;inoes<nnoes;inoes++){
        for(unsigned int idim=0;idim<ndim;idim++){
          grad[idim] += value[inoes]*dndx[inoes][idim];
        }
			}
		}
		else if( type_from == TET11 ){
			double dldx[4][3];
			double const_term[4];
			TetDlDx(dldx,const_term, coord[0],coord[1],coord[2],coord[3]);
			for(unsigned int idim=0;idim<ndim;idim++){ grad[idim] = 0.0; }
			for(unsigned int inoes=0;inoes<nnoes;inoes++){
        for(unsigned int idim=0;idim<ndim;idim++){
          grad[idim] += value[inoes]*dldx[inoes][idim];
        }
			}
		}
		else if( type_from == TRI11 ){
			double dldx[3][2];
			double const_term[3];
			TriDlDx(dldx,const_term, coord[0],coord[1],coord[2]);
			for(unsigned int idim=0;idim<ndim;idim++){ grad[idim] = 0.0; }
			for(unsigned int inoes=0;inoes<nnoes;inoes++){
        for(unsigned int idim=0;idim<ndim;idim++){
          grad[idim] += value[inoes]*dldx[inoes][idim];
        }
			}
			grad[2] = 0.0;
		}
    //		std::cout << grad[0] << " " << grad[1] << " " << grad[2] << std::endl;
		{
			double norm = sqrt(grad[0]*grad[0]+grad[1]*grad[1]+grad[2]*grad[2]);
			norm *=0.2;
      //			norm = 15.0;
			grad[0] /= norm;
			grad[1] /= norm;
			grad[2] /= norm;
		}
		{
			unsigned int noes[16];
			es_b_va.GetNodes(ielem,noes);
			unsigned int ipoi0 = noes[0];
			assert( ipoi0 < na_b_va.Size() );
			for(unsigned int idim=0;idim<ndim;idim++){
				ns_b_va.SetValue(ipoi0,idim,grad[idim]);
			}
		}
	}  
  return true;
}
예제 #12
0
//! set constant value to the field
bool Fem::Field::SetFieldValue_Constant
(unsigned int id_field_to, unsigned int idofns, Fem::Field::FIELD_DERIVATION_TYPE fdt, 
 Fem::Field::CFieldWorld& world,
 double val)
{
  if( !world.IsIdField(id_field_to) ){ return false; }
  Fem::Field::CField& field = world.GetField(id_field_to);
  
	if( idofns >= field.GetNLenValue() ) return false;
	if( !(field.GetFieldDerivativeType() & fdt) ) return false;
  
  const std::vector<unsigned int>& aIdEA = field.GetAryIdEA();
  
  if( field.GetNodeSegInNodeAry(CORNER).id_na_va != 0 ){
    const CField::CNodeSegInNodeAry& nsna = field.GetNodeSegInNodeAry(CORNER);      
    assert( world.IsIdNA(nsna.id_na_va) );
    CNodeAry& na = world.GetNA(nsna.id_na_va);			
    unsigned int id_ns = 0;	// target node segment;
    {
      if(      fdt & VALUE        ) id_ns = nsna.id_ns_va;
      else if( fdt & VELOCITY     ) id_ns = nsna.id_ns_ve;
      else if( fdt & ACCELERATION ) id_ns = nsna.id_ns_ac;
      else{ assert(0); }
      assert( na.IsSegID(id_ns) );
      const CNodeAry::CNodeSeg& ns = na.GetSeg(id_ns);
      assert( idofns < ns.Length() );
    }
    /*
     if( m_aElemIntp.size() == 0 || !this->IsPartial() ){	// 剛体の場合
     const unsigned int nnode = na.Size();
     CNodeAry::CNodeSeg& ns = na.GetSeg(id_ns);
     for(unsigned int inode=0;inode<nnode;inode++){
     ns.SetValue(inode,idofns,const_val);
     }
     }*/
    {
      for(unsigned int iei=0;iei<aIdEA.size();iei++){
        const unsigned int id_ea = aIdEA[iei];
        assert( world.IsIdEA(id_ea) );
        const CElemAry& ea = world.GetEA(id_ea);
        unsigned int id_es_c_va = field.GetIdElemSeg(id_ea,CORNER,true,world);
        assert( ea.IsSegID(id_es_c_va) );
        na.SetValueToNodeSegment(ea,id_es_c_va,id_ns,idofns,val);
      }
    }
  }
  /*		if( m_na_e.id_na_va != 0 ){
   assert( world.IsIdNA(m_na_e.id_na_va) );
   CNodeAry& na = world.GetNA(m_na_e.id_na_va);
   const CNodeAry::CNodeSeg& ns_val = na.GetSeg(m_na_e.id_ns_va);
   for(unsigned int iei=0;iei<m_aElemIntp.size();iei++){
   unsigned int id_ea = m_aElemIntp[iei].id_ea;
   assert( world.IsIdEA(id_ea) );
   const CElemAry& ea = world.GetEA(id_ea);
   assert( ea.IsSegID( m_aElemIntp[iei].id_es_e_va ) );
   na.SetValueToNodeSegment(ea,m_aElemIntp[iei].id_es_e_va,
   m_na_e.id_ns_va,idofns,const_val);
   }
   }*/
  if( field.GetNodeSegInNodeAry(BUBBLE).id_na_va != 0 ){
    const CField::CNodeSegInNodeAry& nsna = field.GetNodeSegInNodeAry(BUBBLE);
    assert( world.IsIdNA(nsna.id_na_va) );
    CNodeAry& na = world.GetNA(nsna.id_na_va);
    unsigned int id_ns = 0;	// target node segment;
    {
      if(      fdt & VALUE        ) id_ns = nsna.id_ns_va;
      else if( fdt & VELOCITY     ) id_ns = nsna.id_ns_ve;
      else if( fdt & ACCELERATION ) id_ns = nsna.id_ns_ac;
      else{ assert(0); }
      assert( na.IsSegID(id_ns) );
      const CNodeAry::CNodeSeg& ns = na.GetSeg(id_ns);
      assert( idofns < ns.Length() );
    }
    //			const CNodeAry::CNodeSeg& ns_val = na.GetSeg(id_ns);
    for(unsigned int iea=0;iea<aIdEA.size();iea++){
      const unsigned int id_ea = aIdEA[iea];
      assert( world.IsIdEA(id_ea) );
      const CElemAry& ea = world.GetEA(id_ea);
      unsigned int id_es_b_va = field.GetIdElemSeg(id_ea,BUBBLE,true,world);
      assert( ea.IsSegID(id_es_b_va) );
      na.SetValueToNodeSegment(ea,id_es_b_va,id_ns,idofns,val);
    }
  }  
  return true;
}
예제 #13
0
//! set mathematical expression to the field
bool Fem::Field::SetFieldValue_MathExp
(unsigned int id_field_to, unsigned int idofns, Fem::Field::FIELD_DERIVATION_TYPE fdt, 
 Fem::Field::CFieldWorld& world,
 std::string math_exp, double t)
{
  Fem::Field::CField& field = world.GetField(id_field_to);
  
	if( idofns >= field.GetNLenValue() ) return false;
	if( !(field.GetFieldDerivativeType() & fdt) ) return false;
  
  const std::vector<unsigned int>& aIdEA = field.GetAryIdEA();  
  
  if( field.GetNodeSegInNodeAry(CORNER).id_na_va != 0 ){
    CEval eval;
    {
      eval.SetKey("x",0.0 );
      eval.SetKey("y",0.0 );
      eval.SetKey("z",0.0 );
      eval.SetKey("t",t   );
      if( !eval.SetExp(math_exp) ) return false;
    }
    const CField::CNodeSegInNodeAry& nsna = field.GetNodeSegInNodeAry(CORNER);
    assert( world.IsIdNA(nsna.id_na_va) );
    CNodeAry& na_va = world.GetNA(nsna.id_na_va);	
    unsigned int id_ns_va;
    {
      if(      fdt & VALUE        ) id_ns_va = nsna.id_ns_va;
      else if( fdt & VELOCITY     ) id_ns_va = nsna.id_ns_ve;
      else if( fdt & ACCELERATION ) id_ns_va = nsna.id_ns_ac;
      else{ assert(0); }
      assert( na_va.IsSegID(id_ns_va) );
      const CNodeAry::CNodeSeg& ns = na_va.GetSeg(id_ns_va);
      assert( idofns < ns.Length() );
    }
    assert( na_va.IsSegID(id_ns_va) );
    CNodeAry::CNodeSeg& ns_va = na_va.GetSeg(id_ns_va);
    assert( world.IsIdNA(nsna.id_na_co) );
    CNodeAry& na_co = world.GetNA(nsna.id_na_co);
    unsigned int id_ns_co = nsna.id_ns_co;
    assert( na_co.IsSegID(id_ns_co) );
    const CNodeAry::CNodeSeg& ns_co = na_co.GetSeg(id_ns_co);
    const unsigned int ndim = field.GetNDimCoord();
    assert( ns_co.Length() == ndim );
    assert( ndim <= 3 );
    double coord[3];
    if( !field.IsPartial() ){	// 親フィールドなら節点を全部参照している。
      for(unsigned int inode=0;inode<na_va.Size();inode++){
        unsigned int inode_co = field.GetMapVal2Co(inode);
        ns_co.GetValue(inode_co,coord);
        switch(ndim){
          case 3: eval.SetKey("z",coord[2]);
          case 2: eval.SetKey("y",coord[1]);
          case 1: eval.SetKey("x",coord[0]);
            break;
          default:
            assert(0);
            break;
        }
        double val = eval.Calc();
        ns_va.SetValue(inode,idofns,val);
      }
    }
    else{	// 要素に参照される節点だけを指している。
      for(unsigned int iei=0;iei<aIdEA.size();iei++){
        unsigned int id_ea = aIdEA[iei];          
        CElemAry& ea = world.GetEA(id_ea);
        unsigned int id_es_c_va = field.GetIdElemSeg(id_ea,CORNER,true,world);
        assert( ea.IsSegID(id_es_c_va) );
        const CElemAry::CElemSeg& es_c_va = ea.GetSeg(id_es_c_va);
        const unsigned int nnoes = es_c_va.Length();
        unsigned int noes[16];
        for(unsigned int ielem=0;ielem<ea.Size();ielem++){
          es_c_va.GetNodes(ielem,noes);
          for(unsigned int inoes=0;inoes<nnoes;inoes++){
            const unsigned int inode0 = noes[inoes];
            unsigned int inode_co0 = field.GetMapVal2Co(inode0);
            ns_co.GetValue(inode_co0,coord);
            switch(ndim){
              case 3: eval.SetKey("z",coord[2]);
              case 2: eval.SetKey("y",coord[1]);
              case 1: eval.SetKey("x",coord[0]);
                break;
              default:
                assert(0);
                break;
            }
            double val = eval.Calc();
            ns_va.SetValue(inode0,idofns,val);
          }
        }
      }
    }
  }
  ////////////////////////////////
  if( field.GetNodeSegInNodeAry(BUBBLE).id_na_va != 0 ){		
    CEval eval;
    {
      eval.SetKey("x",0.0 );
      eval.SetKey("y",0.0 );
      eval.SetKey("z",0.0 );
      eval.SetKey("t",t );
      if( !eval.SetExp(math_exp) ) return false;
    }
    const CField::CNodeSegInNodeAry& nsna_b = field.GetNodeSegInNodeAry(BUBBLE);
    assert( world.IsIdNA(nsna_b.id_na_va) );
    CNodeAry& na_va = world.GetNA(nsna_b.id_na_va);	
    unsigned int id_ns;
    {
      if(      fdt & VALUE        ) id_ns = nsna_b.id_ns_va;
      else if( fdt & VELOCITY     ) id_ns = nsna_b.id_ns_ve;
      else if( fdt & ACCELERATION ) id_ns = nsna_b.id_ns_ac;
      else{ assert(0); }
    }
    assert( na_va.IsSegID(id_ns) );
    CNodeAry::CNodeSeg& ns_va = na_va.GetSeg(id_ns);
    if( !field.IsPartial() && nsna_b.id_na_co ){ // the bubble ns have coordinate and this is not partial
      std::cout << "Error!-->Not Implimented" << std::endl;
      assert(0);
      for(unsigned int inode=0;inode<na_va.Size();inode++){
        double val = eval.Calc();
        ns_va.SetValue(inode,idofns,val);
      }
    }
    else{
      assert( field.IsNodeSeg(CORNER,false,world) );
      const CNodeAry::CNodeSeg& ns_c_co = field.GetNodeSeg(CORNER,false,world);
      const unsigned int ndim = ns_c_co.Length();      
      for(unsigned int iei=0;iei<aIdEA.size();iei++){
        unsigned int id_ea = aIdEA[iei];
        assert( world.IsIdEA(id_ea) );
        CElemAry& ea = world.GetEA(id_ea);
        ////////////////
        unsigned int id_es_b_va = field.GetIdElemSeg(id_ea,BUBBLE,true,world);
        assert( ea.IsSegID(id_es_b_va) );
        const CElemAry::CElemSeg& es_b_va = ea.GetSeg(id_es_b_va);
        assert( es_b_va.Length() == 1);
        ////////////////
        const unsigned int id_es_c_co = field.GetIdElemSeg(id_ea,CORNER, false, world);
        assert( ea.IsSegID(id_es_c_co) );
        const CElemAry::CElemSeg& es_c_co = ea.GetSeg(id_es_c_co);
        const unsigned int nnoes = es_c_co.Length();
        ////////////////
        unsigned int noes_c[16];
        double coord[3], coord_cnt[3];
        unsigned int inoes_b;
        for(unsigned int ielem=0;ielem<ea.Size();ielem++){
          // calc the position of element center
          es_c_co.GetNodes(ielem,noes_c);
          es_b_va.GetNodes(ielem,&inoes_b);
          for(unsigned int idim=0;idim<ndim;idim++){ coord_cnt[idim] = 0.0; }
          for(unsigned int inoes=0;inoes<nnoes;inoes++){
            const unsigned int inode0 = noes_c[inoes];
            ns_c_co.GetValue(inode0,coord);
            for(unsigned int idim=0;idim<ndim;idim++){ coord_cnt[idim] += coord[idim]; }
          }
          for(unsigned int idim=0;idim<ndim;idim++){ coord_cnt[idim] /= nnoes; }
          ////////////////
          switch(ndim){
            case 3: eval.SetKey("z",coord_cnt[2]);
            case 2: eval.SetKey("y",coord_cnt[1]);
            case 1: eval.SetKey("x",coord_cnt[0]);
              break;
            default:
              assert(0);
              break;
          }
          double val = eval.Calc();
          ns_va.SetValue(inoes_b,idofns,val);
//          std::cout << inoes_b << " " << idofns << " " << val << std::endl;
        }
      }
    }
  }
  if( field.GetNodeSegInNodeAry(EDGE).id_na_va != 0 ){
    std::cout << "Error!-->Not Implimented" << std::endl;
    assert(0);
    getchar();
  }  
  return true;
}
예제 #14
0
// ÉXÉJÉâÅ[ÇÃâûóÕëäìñílÇí«â¡Ç∑ÇÈÅDǪÇÃǧÇøÉÇÅ[ÉhÇǬÇØÇÈ
// mode = 0 : É~Å[É[ÉX
// mode = 1 : ç≈ëÂâûóÕ
// äÙâΩäwìIÇ»îÒê¸å`ê´Ççló∂Ç∑ÇÈǩǫǧǩÇÕÅCEqnObjÇå©ÇƒåàÇflÇÈÇÊǧDžÇ∑ÇÈ
bool CEqnSystem_Solid2D::SetEquivStressValue(unsigned int id_field_str, Fem::Field::CFieldWorld& world)
{	
	if( !world.IsIdField(id_field_str) ) return false;
	Fem::Field::CField& field_str = world.GetField(id_field_str);
	if( field_str.GetFieldType() != SCALAR ) return false;

	if( !world.IsIdField(m_IdFieldDisp) ) return false;
	Fem::Field::CField& field_dis = world.GetField(m_IdFieldDisp);

	const std::vector<unsigned int>& aIdEA_from = field_dis.GetAryIdEA();
	const std::vector<unsigned int>& aIdEA_to   = field_str.GetAryIdEA();
	if( aIdEA_from.size() != aIdEA_to.size() ) return false;

	const unsigned int niea = aIdEA_from.size();
	for(unsigned int iiea=0;iiea<niea;iiea++)
	{
		Fem::Field::INTERPOLATION_TYPE type_from, type_to;
		{
			if( aIdEA_from[iiea] != aIdEA_to[iiea] ){
				assert(0);
				return false;
			}
			const unsigned int id_ea = aIdEA_from[iiea];
			type_from = field_dis.GetInterpolationType(id_ea,world);
			type_to   = field_str.GetInterpolationType(id_ea,world);
		}

		unsigned int nnoes, ndim;
		if( type_from==TRI11 && type_to==TRI1001 ){
			nnoes = 3; ndim = 2;
		}
		else{
			std::cout << "Error!-->Not Implimented!" << std::endl;
			std::cout << type_from << " " << type_to << std::endl;
			assert(0);
			getchar();
		}

		unsigned int id_ea = aIdEA_to[iiea];
		const CElemAry& ea = world.GetEA(id_ea);
		const CElemAry::CElemSeg& es_c_co = field_dis.GetElemSeg(id_ea,CORNER,false,world);
		const CElemAry::CElemSeg& es_c_va = field_dis.GetElemSeg(id_ea,CORNER,true, world);
		const CElemAry::CElemSeg& es_b_va = field_str.GetElemSeg(id_ea,BUBBLE,true, world);

		Fem::Field::CField::CNodeSegInNodeAry nans_c = field_dis.GetNodeSegInNodeAry(CORNER);
		assert( world.IsIdNA(nans_c.id_na_co) );
		assert( world.IsIdNA(nans_c.id_na_va) );
		const CNodeAry& na_c_co = world.GetNA( nans_c.id_na_co);
		const CNodeAry::CNodeSeg& ns_c_co = na_c_co.GetSeg( nans_c.id_ns_co);
		const CNodeAry& na_c_va = world.GetNA( nans_c.id_na_va);
		const CNodeAry::CNodeSeg& ns_c_va = na_c_va.GetSeg( nans_c.id_ns_va);

		Fem::Field::CField::CNodeSegInNodeAry nans_b = field_str.GetNodeSegInNodeAry(BUBBLE);
		unsigned int id_na_b_va = nans_b.id_na_va;
		unsigned int id_ns_b_va = nans_b.id_ns_va;

		assert( world.IsIdNA(id_na_b_va) );
		CNodeAry& na_b_va = world.GetNA(id_na_b_va);
		CNodeAry::CNodeSeg& ns_b_va = na_b_va.GetSeg(id_ns_b_va);

    const unsigned int nnoes_c = es_c_co.Length();
    assert( nnoes_c < 64 );
		unsigned int noes[64];
    const CEqn_Solid2D& eqn = this->GetEquation(id_ea);
		for(unsigned int ielem=0;ielem<ea.Size();ielem++){
			////////////////
			double coord[16][3];
			// ç¿ïW(coord)Ç∆íl(value)ÇçÏÇÈ
			es_c_co.GetNodes(ielem,noes);
			for(unsigned int inoes=0;inoes<nnoes;inoes++){
				unsigned int ipoi0 = noes[inoes];
				assert( ipoi0 < na_c_co.Size() );
				ns_c_co.GetValue(ipoi0,coord[inoes]);
			}
			////////////////
			double disp[16][3];	// êflì_ïœà 
			es_c_va.GetNodes(ielem,noes);
			for(unsigned int inoes=0;inoes<nnoes;inoes++){
				unsigned int ipoi0 = noes[inoes];
				assert( ipoi0 < na_c_va.Size() );
				for(unsigned int idim=0;idim<ndim;idim++){
					ns_c_va.GetValue(ipoi0,disp[inoes]);
				}
			}
			////////////////
			double dudx[2][2];	// ïœå`å˘îz
			if( type_from == TRI11 ){
				double dldx[3][2];
				double const_term[3];
				TriDlDx(dldx,const_term, coord[0],coord[1],coord[2]);
				for(unsigned int i=0;i<ndim*ndim;i++){ (&dudx[0][0])[i] = 0.0; }
				for(unsigned int knoes=0;knoes<nnoes;knoes++){
					dudx[0][0] += disp[knoes][0]*dldx[knoes][0];
					dudx[0][1] += disp[knoes][0]*dldx[knoes][1];
					dudx[1][0] += disp[knoes][1]*dldx[knoes][0];
					dudx[1][1] += disp[knoes][1]*dldx[knoes][1];
				}
			}
			double strain[2][2];	// òc
			if( eqn.IsGeometricalNonlinear() ){ // äÙâΩäwìIîÒê¸å`Ç ÇË
				strain[0][0] = 0.5*(dudx[0][0]+dudx[0][0]+dudx[0][0]*dudx[0][0]+dudx[1][0]*dudx[1][0]);
				strain[0][1] = 0.5*(dudx[0][1]+dudx[1][0]+dudx[0][0]*dudx[0][1]+dudx[1][1]*dudx[1][0]);
				strain[1][0] = 0.5*(dudx[1][0]+dudx[0][1]+dudx[0][1]*dudx[0][0]+dudx[1][0]*dudx[1][1]);
				strain[1][1] = 0.5*(dudx[1][1]+dudx[1][1]+dudx[0][1]*dudx[0][1]+dudx[1][1]*dudx[1][1]);
			}
			else { // äÙâΩäwìIîÒê¸å`ǻǵ
				strain[0][0] = 0.5*(dudx[0][0]+dudx[0][0]);
				strain[0][1] = 0.5*(dudx[0][1]+dudx[1][0]);
				strain[1][0] = 0.5*(dudx[1][0]+dudx[0][1]);
				strain[1][1] = 0.5*(dudx[1][1]+dudx[1][1]);
			}
			double stress[2][2];
			{
				double myu, lambda;
				eqn.GetLambdaMyu(lambda,myu);
				stress[0][0] = myu*strain[0][0];
				stress[0][1] = myu*strain[0][1];
				stress[1][0] = myu*strain[1][0];
				stress[1][1] = myu*strain[1][1];
				const double dtmp1 = lambda*(strain[0][0]+strain[1][1]);
				stress[0][0] += dtmp1;
				stress[1][1] += dtmp1;
			}
			double mises;
			{
				const double dtmp1 = 0.5*stress[0][0]*stress[0][0]+0.5*stress[1][1]*stress[1][1]
				+0.5*(stress[1][1]-stress[0][0])*(stress[1][1]-stress[0][0])
				+3*stress[0][1]*stress[0][1];
				mises = sqrt(dtmp1);
			}
			double maxprinciple;
			{
				const double d1 = stress[0][0]+stress[1][1];
				const double d2 = stress[0][0]*stress[1][1]-stress[0][1]*stress[1][0];
				const double d3 = d1*d1-4*d2;
				assert( d3 >= 0 );
				maxprinciple = 0.5*(d1+sqrt(d3));
			}
			{
				unsigned int noes[16];
				es_b_va.GetNodes(ielem,noes);
				unsigned int ipoi0 = noes[0];
				assert( ipoi0 < na_b_va.Size() );
				ns_b_va.SetValue(ipoi0,0,mises);
			}
		}
	}
	return true;
}
// fieldで初期化する、fieldの中の非ゼロパターンで行列を作る
bool Ls::CLinearSystem_RigidField2::AddPattern_Field(
        unsigned int id_field1, 
        unsigned int id_field2, 
        const Fem::Field::CFieldWorld& world)
{
	if( !world.IsIdField(id_field1) ) return false;
    const Fem::Field::CField& field1 = world.GetField(id_field1);
	unsigned int id_field_parent;
	{
		if( field1.GetIDFieldParent() == 0 ){ id_field_parent = id_field1; }
		else{ id_field_parent = field1.GetIDFieldParent(); }
	}
	const unsigned int nlen_value = field1.GetNLenValue();

	int ilss_add_c;
    int ilss_add_b;
	{	// Cornerセグメントを作る
        unsigned int id_na_val = field1.GetNodeSegInNodeAry(Fem::Field::CORNER).id_na_va;
		if( id_na_val != 0 ){
			assert( world.IsIdNA(id_na_val) );
            const Fem::Field::CNodeAry& na = world.GetNA(id_na_val);
            assert( m_ls.GetNLinSysSeg() == this->m_aSegRF.size() );
            ilss_add_c = m_ls.GetNLinSysSeg();
            this->m_aSegRF.push_back( CLinSysSegRF(id_field_parent,Fem::Field::CORNER) );
            int ires = m_ls.AddLinSysSeg( na.Size(), field1.GetNLenValue() );
            assert( ires == ilss_add_c );
		}
		else{ ilss_add_c = -1; }
	}
	{	// Bubbleセグメントを作る
        unsigned int id_na_val = field1.GetNodeSegInNodeAry(Fem::Field::BUBBLE).id_na_va;
		if( id_na_val != 0 ){
			assert( world.IsIdNA(id_na_val) );
            const Fem::Field::CNodeAry& na = world.GetNA(id_na_val);
            assert( m_ls.GetNLinSysSeg() == this->m_aSegRF.size() );
            ilss_add_b = m_ls.GetNLinSysSeg();
            this->m_aSegRF.push_back( CLinSysSegRF(id_field_parent,Fem::Field::BUBBLE) );
            int ires = m_ls.AddLinSysSeg( na.Size(), field1.GetNLenValue() );
            assert( ires == ilss_add_b );
        }
	}

    const Fem::Field::CField& field2 = world.GetField(id_field2);
	const std::vector<unsigned int>& aIdEA1 = field1.GetAryIdEA();
	const std::vector<unsigned int>& aIdEA2 = field2.GetAryIdEA();

	for(;;){	// ダミーのfor文を使ってbreakで抜けられるようにする
		// Corner-Corner関係を作る
		if( ilss_add_c == -1 ) break;
        const unsigned int id_na_va1 = field1.GetNodeSegInNodeAry(Fem::Field::CORNER).id_na_va;
        const unsigned int id_na_co1 = field1.GetNodeSegInNodeAry(Fem::Field::CORNER).id_na_co;
        const unsigned int id_na_va2 = field2.GetNodeSegInNodeAry(Fem::Field::CORNER).id_na_va;
        const unsigned int id_na_co2 = field2.GetNodeSegInNodeAry(Fem::Field::CORNER).id_na_co;
        assert( aIdEA1.size() > 0 );
        if( id_na_co1 != id_na_co2 ) break;

		for(unsigned int iiea1=0;iiea1<aIdEA1.size();iiea1++){
			const unsigned int id_ea1 = aIdEA1[iiea1];
            if( field1.GetIdElemSeg(id_ea1,Fem::Field::CORNER,true,world) == 0 ) continue;
			assert( world.IsIdEA(id_ea1) );
            const Fem::Field::CElemAry& ea1 = world.GetEA(id_ea1);
            const unsigned int id_es_c1 = field1.GetIdElemSeg(id_ea1,Fem::Field::CORNER,true,world);
			assert( ea1.IsSegID(id_es_c1) );
			// CORNER1-CORNER1
            {
                Com::CIndexedArray crs;
                ea1.MakePattern_FEM(id_es_c1,crs);
		        m_ls.AddMat_Dia(ilss_add_c, crs );			// cc行列を作る
            }
			////////////////
			for(unsigned int iiea2=0;iiea2<aIdEA2.size();iiea2++)
			{
				const unsigned int id_ea2 = aIdEA2[iiea2];
				if( id_ea1 == id_ea2 ){
					// CORNER1-CORNER2
                    const int ils2_c = this->FindIndexArray_Seg(id_field2,Fem::Field::CORNER,world);
					if( ils2_c != -1 ){
						assert( ils2_c >= 0 && ils2_c < this->GetNLinSysSeg() );
                        const unsigned int id_es_c2 = field2.GetIdElemSeg(id_ea2,Fem::Field::CORNER,true,world);
						assert( id_es_c1 == id_es_c2 );
						Com::CIndexedArray crs;
						ea1.MakePattern_FEM(id_es_c1,id_es_c2,crs);
						assert( crs.CheckValid() );
						m_ls.AddMat_NonDia(ilss_add_c,ils2_c, crs);		// c1c2行列を足す
						const unsigned int nnode2 = m_ls.GetBlkSizeLinSeg(ils2_c);
						Com::CIndexedArray crs_inv;
						crs_inv.SetTranspose( nnode2, crs );
						m_ls.AddMat_NonDia(ils2_c,ilss_add_c, crs_inv);	// c2c1行列を足す
					}
					// CORNER1-BUBBLE2
          const int ils2_b = this->FindIndexArray_Seg(id_field2,Fem::Field::BUBBLE,world);
					if( ils2_b != -1 ){
            assert(0);
					}
				}
				else{
          const Fem::Field::CNodeAry& na1 = world.GetNA(id_na_co1);
          const unsigned int id_es_c_co1 = field1.GetIdElemSeg(id_ea1,Fem::Field::CORNER,false,world);
          const unsigned int id_es_c_co2 = field2.GetIdElemSeg(id_ea2,Fem::Field::CORNER,false,world);
					if( na1.IsIncludeEaEs_InEaEs( 
						std::make_pair(id_ea1,id_es_c_co1),
						std::make_pair(id_ea2,id_es_c_co2) ) )
					{
						std::cout << "ea : " << id_ea1 << " is included in " << id_ea2 << std::endl;
						assert( ea1.IsSegID(id_es_c_co1) );
            Com::CIndexedArray crs;
						ea1.MakePattern_FEM(id_es_c1,id_es_c1,crs);	// 自分も含む
						assert( crs.CheckValid() );
						if( field2.IsPartial() ){
							std::cout << "Error!-->未実装" << std::endl;
							assert(0);
						}
						for(unsigned int icrs=0;icrs<crs.array.size();icrs++){
							unsigned int jno_va = crs.array[icrs];
							unsigned int jno_co = field1.GetMapVal2Co(jno_va);
//							std::cout << jno_van << " " << jno_co << std::endl;
							// 本当はfield2.GetMapVal2Coの逆写像を使って求める.
							unsigned int jno_va2 = jno_co;
							crs.array[icrs] = jno_va2;
						}
            int ils2 = this->FindIndexArray_Seg(id_field2,Fem::Field::CORNER,world);
						assert( ils2 >= 0 && ils2 < this->GetNLinSysSeg() );
//						std::cout << "ils_seg : " << ils0 << " " << ils2 << std::endl;
						m_ls.AddMat_NonDia(ilss_add_c,ils2, crs);
						const unsigned int nnode2 = m_ls.GetBlkSizeLinSeg(ils2);
						Com::CIndexedArray crs_inv;
						crs_inv.SetTranspose( nnode2, crs );
						m_ls.AddMat_NonDia(ils2,ilss_add_c, crs_inv);
					}
				}
			}
		}
		break;
	}
			
	for(unsigned int iiea=0;iiea<aIdEA1.size();iiea++){
		const unsigned int id_ea1 = aIdEA1[iiea];
        const unsigned int id_es_b1 = field1.GetIdElemSeg(id_ea1,Fem::Field::BUBBLE,true,world);
		if( id_es_b1 == 0 ) continue;
        const Fem::Field::CElemAry& ea1 = world.GetEA(id_ea1);
		assert( world.IsIdEA(id_ea1) );
		assert( ea1.IsSegID(id_es_b1) );
		const unsigned int ils0 = ilss_add_b;
		// BUBLE1-BUBBLE2
        {
			Com::CIndexedArray crs;
			ea1.MakePattern_FEM(id_es_b1,crs);
		    m_ls.AddMat_Dia(ilss_add_b, crs );
        }
		const unsigned int id_ea2 = aIdEA2[iiea];
		assert( id_ea1 == id_ea2 );
        const unsigned int id_es_c2 = field2.GetIdElemSeg(id_ea2,Fem::Field::CORNER,true,world);
		assert( ea1.IsSegID(id_es_c2) );
        int ils2 = this->FindIndexArray_Seg(id_field2,Fem::Field::CORNER,world);
		assert( ils2 >= 0 && ils2 < this->GetNLinSysSeg() );
		assert( ils2 >= 0 && ils2 < m_ls.GetNLinSysSeg() );
		{
			Com::CIndexedArray crs;
			ea1.MakePattern_FEM(id_es_b1,id_es_c2,crs);
			assert( crs.CheckValid() );
			m_ls.AddMat_NonDia(ils0,ils2, crs);		// b1c2行列を作る
			Com::CIndexedArray crs_inv;
			const unsigned nnode2 = m_ls.GetBlkSizeLinSeg(ils2);
			crs_inv.SetTranspose( nnode2, crs );
			m_ls.AddMat_NonDia(ils2,ils0, crs_inv);	// c2b1行列を作る
		}
	}

	// いろいろと追加が必要
	// まずは足りない部分を要求するようになったらエラーを出す関数を実装しよう。

	return true;
}