Hi, 

could you just tell me how you implemented the public members
'element_attributes' and 'node_attributes'? In tetgen_io.C I just tried:

std::vector<Real> el_attr;
 // Read attributes from the stream.
      for (unsigned int j=0; j<nAttri; j++){
                ele_stream >> dummy;  
                ///roberts_region.push_back(dummy);  /// by R.B.
                el_attr.push_back(dummy);
          }
          if (el_attr.size()>0)   /// by R.B.
                 element_attributes.push_back(el_attr);  /// by R.B.
          nAttriel = nAttri;    /// by R.B.
          
    }

where element_attributes is defined as public: std::vector<
std::vector<Real>  > in tetgen_io.h. I did the same for node_attributes.
However, I get some bad alloc when reading the mesh.

Thank you, 
Robert




Am Mittwoch, den 03.08.2011, 16:48 -0600 schrieb John Peterson:
> On Wed, Aug 3, 2011 at 12:36 PM, robert <robert.bod...@unil.ch> wrote:
> > Hi John,
> >
> > I found a simple way to work around the problem. I just added a public
> > vector
> >
> > std::vector<Real> roberts_region;
> >
> > to the class TetGenIO. In the according function TetGenIO::read(...) the
> > following is already implemented:
> >
> > // Read attributes from the stream.
> > for (unsigned int j=0; j<nAttri; j++)
> >  ele_stream >> dummy;
> >
> > . This can be found around line 251 of tetgen_io.C  (version 0.7.1).
> > Here, I just added
> >
> > roberts_region.push_back(dummy);
> >
> > Now, I just have to create an object TetGenIO TETGEN when reading the
> > mesh and with TETGEN.roberts_region.at(...) I can get my attributes.
> > I do this immediately after reading the mesh and before any refinement.
> >
> > This is maybe not the most elegant way to do it. However, it seems to
> > work.
> 
> I just checked in something similar but slightly more general in that
> it will read multiple attributes per element as well as node
> attributes.
> 
> They are stored in the public members "element_attributes" and
> "node_attributes" respectively, which are vector<vector<Real> >'s.
> 
> Here's some test code you can try out, it seemed to work fine with the
> mesh file you sent me...
> 
> // Manual IO object creation.  We need to use this if
> // we want the attributes to hang around after the reading is finished...
> TetGenIO t(mesh);
> t.read(filename);
> 
> unsigned n_elem_attributes = t.element_attributes.size();
> unsigned n_node_attributes = t.node_attributes.size();
> 
> // Assign subdomain IDs based on the read in element attributes
> if (n_elem_attributes == 1)
>   {
>     MeshBase::element_iterator it = mesh.elements_begin();
>     const MeshBase::element_iterator end = mesh.elements_end();
>     unsigned ctr=0;
>     for ( ; it != end; ++it, ctr++)
>       {
>          Elem* elem = *it;
>       
>        // Assign the subdomain ID from t.element_attributes[0]
>        elem->subdomain_id() =
> static_cast<subdomain_id_type>(t.element_attributes[0][ctr]);
>       } // end loop over elements
>   } // end if n_elem_attributes
> 
> // Write out the mesh in a different (Exodus) format
> mesh.write("tetgen_read_test.e");
> 



------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
Libmesh-users mailing list
Libmesh-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-users

Reply via email to