41 using namespace common;
55 .description(
"Reads neu Groups and splits the mesh in these subgroups")
56 .pretty_name(
"Unified Zones");
58 options().
add(
"part", PE::Comm::instance().rank())
59 .description(
"Number of the part of the mesh to read. (e.g. rank of processor)")
62 options().
add(
"nb_parts", PE::Comm::instance().size())
63 .description(
"Total nb_partitions. (e.g. number of processors)");
66 .description(
"Read the surface elements for the boundary")
67 .pretty_name(
"Read Boundaries");
69 properties()[
"brief"] = std::string(
"neutral file mesh reader component");
72 desc +=
"This component can read in parallel.\n";
73 desc +=
"Available coolfluid-element types are:\n";
75 desc +=
" - " + supported_type +
"\n";
83 std::vector<std::string> extensions;
84 extensions.push_back(
".neu");
94 boost::filesystem::path fp (file.
path());
95 if( boost::filesystem::exists(fp) )
98 m_file.open(fp,std::ios_base::in);
102 throw boost::filesystem::filesystem_error( fp.string() +
" does not exist", boost::system::error_code() );
119 m_hash = create_component<MergedParallelDistribution>(
"hash");
120 std::vector<Uint> num_obj(2);
123 m_hash->options().set(
"nb_obj",num_obj);
134 if (
options().value<bool>(
"read_boundaries"))
137 if (
options().value<bool>(
"read_groups"))
165 m_mesh->update_statistics();
167 boost::shared_ptr<MeshTransformer> global_numbering = build_component_abstract_type<MeshTransformer>(
"cf3.mesh.actions.GlobalNumbering",
"glb_numbering");
168 global_numbering->transform(
m_mesh);
177 std::string nodal_coordinates(
"NODAL COORDINATES");
178 std::string elements_cells(
"ELEMENTS/CELLS");
179 std::string element_group(
"ELEMENT GROUP");
180 std::string boundary_condition(
"BOUNDARY CONDITIONS");
191 if (line.find(nodal_coordinates)!=std::string::npos)
193 else if (line.find(elements_cells)!=std::string::npos)
195 else if (line.find(element_group)!=std::string::npos)
197 else if (line.find(boundary_condition)!=std::string::npos)
208 m_file.seekg(0,std::ios::beg);
210 Uint NUMNP, NELEM, NGRPS, NBSETS, NDFCD, NDFVL;
214 for (
Uint i=0; i<2; ++i)
220 for (
Uint i=0; i<3; ++i)
225 std::stringstream ss(line);
226 ss >> NUMNP >> NELEM >> NGRPS >> NBSETS >> NDFCD >> NDFVL;
245 if (
options().value<Uint>(
"nb_parts") > 1)
254 Uint elementNumber, elementType, nbElementNodes, dummy_node;
266 m_file >> elementNumber >> elementType >> nbElementNodes;
269 std::vector<Uint> neu_element_nodes(nbElementNodes);
270 for (
Uint j=0; j<nbElementNodes; ++j)
272 m_file >> neu_element_nodes[j];
273 if (!
m_hash->subhash(
NODES).owns(neu_element_nodes[j]-1))
282 m_file >> elementNumber >> elementType >> nbElementNodes;
285 std::vector<Uint> neu_element_nodes(nbElementNodes);
286 for (
Uint j=0; j<nbElementNodes; ++j)
316 std::set<Uint>::const_iterator not_found =
m_ghost_nodes.end();
329 nodes.
rank()[coord_idx] =
m_hash->subhash(
NODES).part_of_obj(neu_node_idx-1);
330 nodes.
glb_idx()[coord_idx] = neu_node_idx;
332 std::stringstream ss(line);
345 nodes.
rank()[coord_idx] =
m_hash->subhash(
NODES).part_of_obj(neu_node_idx-1);
346 nodes.
glb_idx()[coord_idx] = neu_node_idx;
348 std::stringstream ss(line);
379 std::string etype_CF;
380 std::vector<Uint> cf_element;
381 Uint neu_node_number;
395 Uint elementNumber, elementType, nbElementNodes;
396 m_file >> elementNumber >> elementType >> nbElementNodes;
404 cf_element.resize(nbElementNodes);
405 for (
Uint j=0; j<nbElementNodes; ++j)
408 m_file >> neu_node_number;
412 cf_element[cf_idx] = cf_node_number;
415 table_idx = buffer[etype_CF]->add_row(cf_element);
416 m_global_to_tmp[elementNumber] = std::make_pair(elements[etype_CF],table_idx);
420 for (
Uint j=0; j<nbElementNodes; ++j)
422 m_file >> neu_node_number;
446 std::set<Uint>::const_iterator it;
453 Uint NGP, NELGP, MTYP, NFLAGS, I;
455 m_file >> line >> NGP >> line >> NELGP >> line >> MTYP >> line >> NFLAGS >> ELMMAT;
457 groups[
g].NELGP = NELGP;
458 groups[
g].MTYP = MTYP;
459 groups[
g].NFLAGS = NFLAGS;
460 groups[
g].ELMMAT = ELMMAT;
463 for (
Uint i=0; i<NFLAGS; ++i)
472 m_tmp->rename(groups[0].ELMMAT);
483 Uint nb_elems_in_group = 0;
484 for (
Uint i=0; i<NELGP; ++i)
491 groups[
g].ELEM.reserve(nb_elems_in_group);
492 m_file.seekg(p,std::ios::beg);
493 for (
Uint i=0; i<NELGP; ++i)
497 groups[g].ELEM.push_back(I);
520 std::string etype = tmp_elems->element_type().derived_type_name();
522 Uint idx = buffer[etype]->add_row(tmp_elems->geometry_space().connectivity().array()[local_element]);
523 std::string new_elems_name = tmp_elems->name();
545 int ITYPE, NENTRY, NVALUES, IBCODE1, IBCODE2, IBCODE3, IBCODE4, IBCODE5;
550 std::stringstream ss(line);
551 ss >> NAME >> ITYPE >> NENTRY >> NVALUES >> IBCODE1 >> IBCODE2 >> IBCODE3 >> IBCODE4 >> IBCODE5;
567 for (
int i=0; i<NENTRY; ++i)
569 int ELEM,
ETYPE, FACE;
570 m_file >> ELEM >> ETYPE >> FACE;
572 Uint global_element = ELEM;
574 std::map<Uint,Region_TableIndex_pair>::iterator it =
m_global_to_tmp.find(global_element);
578 Uint local_element = it->second.second;
583 const ElementType& etype = tmp_elements->element_type();
587 const Connectivity::Row& elem_nodes = tmp_elements->geometry_space().connectivity()[local_element];
588 std::vector<Uint> row;
589 row.reserve(face_connectivity.
stride[faceIdx]);
593 row.push_back(elem_nodes[node]);
598 cf3_assert_desc(
to_str(row.size())+
"!="+
to_str(buffer[face_type]->get_appointed().shape()[1]),row.size() == buffer[face_type]->get_appointed().shape()[1]);
599 buffer[face_type]->add_row(row);
614 if (neu_type==
LINE && nb_nodes==2) cf_type =
"cf3.mesh.LagrangeP1.Line" + dim +
"D";
615 else if (neu_type==
QUAD && nb_nodes==4) cf_type =
"cf3.mesh.LagrangeP1.Quad" + dim +
"D";
616 else if (neu_type==
TRIAG && nb_nodes==3) cf_type =
"cf3.mesh.LagrangeP1.Triag" + dim +
"D";
617 else if (neu_type==
HEXA && nb_nodes==8) cf_type =
"cf3.mesh.LagrangeP1.Hexa" + dim +
"D";
618 else if (neu_type==
TETRA && nb_nodes==4) cf_type =
"cf3.mesh.LagrangeP1.Tetra" + dim +
"D";
619 else if (neu_type==5 && nb_nodes==6) cf_type =
"cf3.mesh.LagrangeP1.Prism3D";
621 else if (neu_type==7 && nb_nodes==5)
626 " in neutral format");
std::set< Uint > m_supported_neu_types
#define CFinfo
these are always defined
std::string name(ComponentWrapper &self)
std::vector< Uint > m_element_group_positions
void resize(const Uint new_size)
Helper class to create the Builder and place it in the factory.
Handle< MergedParallelDistribution > m_hash
Handle< Region > m_region
void remove_empty_element_regions(Region &parent_region)
virtual std::string derived_type_name() const =0
common::List< Uint > & rank()
Return the rank of every field row.
Reader(const std::string &name)
constructor
#define boost_foreach
lowercase version of BOOST_FOREACH
const Field & coordinates() const
common::List< Uint > & rank()
std::vector< std::vector< Uint > > m_nodes_neu_to_cf
Common_API std::string to_str< int >(const int &v)
boost::filesystem::fstream m_file
Conversions from and to std::string.
Real e()
Definition of the Unit charge [C].
boost::proto::terminal< SFOp< NodesOp > >::type const nodes
virtual const FaceConnectivity & faces() const =0
Common_API std::string to_str(const T &v)
Converts to std::string.
virtual void do_read_mesh_into(const common::URI &fp, Mesh &mesh)
std::vector< Uint > m_boundary_condition_positions
std::map< std::string, Handle< Elements > > create_faces_in_region(Region &parent_region, Dictionary &nodes, const std::vector< std::string > &etypes)
std::map< std::string, Handle< Elements > > create_cells_in_region(Region &parent_region, Dictionary &nodes, const std::vector< std::string > &etypes)
Uint size() const
return the number of elements
std::map< Uint, Uint > m_neu_node_to_coord_idx
#define cf3_assert_desc(m, a)
PropertyList & properties()
std::map< Uint, Region_TableIndex_pair > m_global_to_tmp
Handle< Component > get_child(const std::string &name)
virtual std::vector< std::string > get_extensions()
Top-level namespace for coolfluid.
const TYPE value(const std::string &opt_name) const
Get the value of the option with given name.
common::List< Uint > & glb_idx()
Return the global index of every field row.
struct cf3::mesh::neu::Reader::HeaderData m_headerData
Uint m_nodal_coordinates_position
Stores connectivity information about the faces that form the cell boundary.
TableRow< Uint >::type Row
the type of a row in the internal structure of the table
LoadBalance::LoadBalance(const std::string &name) std::string desc
std::vector< std::vector< Uint > > m_faces_neu_to_cf
static boost::proto::terminal< ExpressionGroupTag >::type group
Use group(expr1, expr2, ..., exprN) to evaluate a group of expressions.
std::set< Uint > m_ghost_nodes
unsigned int Uint
typedef for unsigned int
virtual const ElementType & face_type(const Uint face) const =0
void get_file_positions()
void resize(const Uint size)
Resize the contained fields.
std::map< std::string, boost::shared_ptr< common::Table< Uint >::Buffer > > create_connectivity_buffermap(std::map< std::string, Handle< Elements > > &elems_map)
RangeT nodes_range(const Uint face) const
Iterator range over the nodes of the given face.
Handle< Component > handle()
Get a handle to the component.
std::vector< Uint > stride
Number of nodes for each face.
std::string element_type(const Uint neu_type, const Uint nb_nodes)
SelectOptionType< T >::type & add(const std::string &name, const T &default_value=T())
Base class for defining CF components.
Uint size() const
Number of rows of contained fields.
Uint m_elements_cells_position
std::vector< std::string > m_supported_types
cf3::common::ComponentBuilder< neu::Reader, MeshReader, LibNeu > aneuReader_Builder