9 #include <boost/assign/list_of.hpp>
55 std::vector<std::string> extensions;
56 extensions.push_back(
".cf3mesh");
70 if(!mesh_node.is_valid())
73 if(mesh_node.attribute_value(
"version") !=
"1")
81 if(!dictionaries_node.is_valid())
84 data_reader = common::allocate_component<common::BinaryDataReader>(
"DataReader");
87 const Uint nb_parts = common::from_str<Uint>(mesh_node.attribute_value(
"nb_procs"));
88 if(nb_parts == comm.size())
90 read_mesh_part(topology_node, dictionaries_node, mesh, comm.rank());
92 else if(comm.size() != 1)
94 throw common::FileFormatError(
FromHere(),
"File " + path.
path() +
" was created for " + mesh_node.attribute_value(
"nb_procs") +
" processes. Use the correct number of processes or use one process to merge the file");
100 for(
Uint part=0; part != nb_parts; ++part)
102 boost::shared_ptr<Mesh> tmp_mesh = common::allocate_component<Mesh>(mesh.
name() +
common::to_str(part));
103 read_mesh_part(topology_node, dictionaries_node, *tmp_mesh, part);
124 for(; dictionary_node.is_valid(); dictionary_node.content = dictionary_node.content->next_sibling(
"dictionary"))
127 if(dict_name ==
"geometry")
130 for(; field_node.is_valid(); field_node.content = field_node.content->next_sibling(
"field"))
132 if(field_node.attribute_value(
"name") ==
"coordinates")
134 const Uint table_idx = common::from_str<Uint>(field_node.attribute_value(
"table_idx"));
141 if(
is_not_null(dictionary_node.content->first_attribute(
"periodic_links_nodes")) &&
is_not_null(dictionary_node.content->first_attribute(
"periodic_links_active")))
147 data_reader->read_list(*periodic_links_nodes, common::from_str<Uint>(dictionary_node.attribute_value(
"periodic_links_nodes")));
148 data_reader->read_list(*periodic_links_active, common::from_str<Uint>(dictionary_node.attribute_value(
"periodic_links_active")));
154 dictionary_node.content = dictionaries_node.
content->first_node(
"dictionary");
155 for(; dictionary_node.is_valid(); dictionary_node.content = dictionary_node.content->next_sibling(
"dictionary"))
157 const std::string dict_name = dictionary_node.attribute_value(
"name");
158 const std::string space_lib_name = dictionary_node.attribute_value(
"space_lib_name");
162 std::vector< Handle<Entities> > entities_list;
163 std::vector<Uint> entities_binary_file_indices;
172 entities_list.push_back(entities);
173 entities_binary_file_indices.push_back(common::from_str<Uint>(entities_node.
attribute_value(
"table_idx")));
177 dict_name ==
"geometry" ?
184 data_reader->read_list(dictionary.
glb_idx(), common::from_str<Uint>(dictionary_node.attribute_value(
"global_indices")));
185 data_reader->read_list(dictionary.
rank(), common::from_str<Uint>(dictionary_node.attribute_value(
"ranks")));
189 for(; field_node.is_valid(); field_node.content = field_node.content->next_sibling(
"field"))
191 if(field_node.attribute_value(
"name") ==
"coordinates")
193 const Uint table_idx = common::from_str<Uint>(field_node.attribute_value(
"table_idx"));
194 Field& field = dictionary.
create_field(field_node.attribute_value(
"name"), field_node.attribute_value(
"description"));
203 for(
Uint i = 0; i != entities_list.size(); ++i)
205 data_reader->read_table(entities_list[i]->space(dictionary).connectivity(), entities_binary_file_indices[i]);
217 for(; region_node.is_valid(); region_node.content = region_node.content->next_sibling(
"region"))
222 for(; elements_node.is_valid(); elements_node.content = elements_node.content->next_sibling(
"elements"))
225 elems.
rename(elements_node.attribute_value(
"name"));
226 const Uint entities_idx = common::from_str<Uint>(elements_node.attribute_value(
"idx"));
236 for(; region_node.is_valid(); region_node.content = region_node.content->next_sibling(
"region"))
241 for(; elements_node.is_valid(); elements_node.content = elements_node.content->next_sibling(
"elements"))
246 data_reader->read_list(elems.
glb_idx(), common::from_str<Uint>(elements_node.attribute_value(
"global_indices")));
249 data_reader->read_list(elems.
rank(), common::from_str<Uint>(elements_node.attribute_value(
"ranks")));
252 common::XML::XmlNode periodic_node(elements_node.content->first_node(
"periodic_links_elements"));
253 if(periodic_node.is_valid())
256 data_reader->read_list(*periodic_links_elements, common::from_str<Uint>(periodic_node.attribute_value(
"index")));
261 link->link_to(*elements_to_link);
265 common::XML::XmlNode connectivity_cell2face_node(elements_node.content->first_node(
"connectivity_cell2face"));
266 if(connectivity_cell2face_node.is_valid())
268 using namespace common;
269 boost::shared_ptr< Table<Uint> > conn = allocate_component< Table<Uint> >(
"tmp");
270 data_reader->read_table(*conn, common::from_str<Uint>(connectivity_cell2face_node.attribute_value(
"connectivity")));
274 const Uint cols = conn->row_size()/2;
290 common::XML::XmlNode connectivity_face2cell_node(elements_node.content->first_node(
"connectivity_face2cell"));
291 if(connectivity_face2cell_node.is_valid())
293 using namespace common;
294 boost::shared_ptr< Table<Uint> > conn = allocate_component< Table<Uint> >(
"tmp");
295 data_reader->read_table(*conn, common::from_str<Uint>(connectivity_face2cell_node.attribute_value(
"connectivity")));
298 const Uint cols = conn->row_size()/2;
313 data_reader->read_table(elems.
connectivity_face2cell()->cell_orientation(), common::from_str<Uint>(connectivity_face2cell_node.attribute_value(
"cell_orientation")));
317 common::XML::XmlNode connectivity_cell2cell_node(elements_node.content->first_node(
"connectivity_cell2cell"));
318 if(connectivity_cell2cell_node.is_valid())
std::string name(ComponentWrapper &self)
Field & create_field(const std::string &name, const Uint cols)
Create a new field in this group.
bool check_sanity() const
bool is_null(T ptr)
predicate for comparison to nullptr
Safe pointer to an object. This is the supported method for referring to components.
Dictionary & create_discontinuous_space(const std::string &space_name, const std::string &space_lib_name, const std::vector< Handle< Entities > > &entities)
Helper class to create the Builder and place it in the factory.
void initialize_nodes(const Uint nb_nodes, const Uint dimension)
will among others set the coordinate dimension for the nodes
Dictionary & create_continuous_space(const std::string &space_name, const std::string &space_lib_name, const std::vector< Handle< Entities > > &entities)
Region & create_region(const std::string &name)
common::List< Uint > & rank()
Return the rank of every field row.
Common_API bool from_str< bool >(const std::string &str)
boost::shared_ptr< common::BinaryDataReader > data_reader
Elements & create_elements(const std::string &element_type_name, Dictionary &geometry)
const std::string & name() const
Access the name of the component.
const Field & coordinates() const
common::List< Uint > & rank()
rapidxml::xml_node< char > * content
Pointer to the underlying XML implementation.
virtual void do_read_mesh_into(const common::URI &path, Mesh &mesh)
Reader(const std::string &name)
constructor
Conversions from and to std::string.
virtual std::vector< std::string > get_extensions()
Real e()
Definition of the Unit charge [C].
common::Libraries & libraries() const
void read_elements(const common::XML::XmlNode ®ion_node, Region ®ion, Dictionary &geometry, Mesh &mesh)
Handle< Component > access_component(const URI &path) const
Common_API std::string to_str(const T &v)
Converts to std::string.
void fix_node_ranks()
Correct ranks of nodes to be unique in all pid's.
std::vector< Handle< Entities > > m_entities
common::List< Uint > & glb_idx()
Mutable access to the list of nodes.
common::ComponentBuilder< cf3mesh::Reader, MeshReader, LibCF3Mesh > aCF3MeshReader_Builder
void remove_duplicate_elements_and_nodes()
Add another mesh to this mesh.
Handle< Component > get_child(const std::string &name)
Top-level namespace for coolfluid.
common::List< Uint > & glb_idx()
Return the global index of every field row.
Handle< ElementConnectivity > & connectivity_cell2face()
void read_mesh_part(const common::XML::XmlNode &topology_node, const common::XML::XmlNode &dictionaries_node, Mesh &mesh, const Uint rank)
void finish()
Apply the changes the mesh adaptor for changes and fix inconsistent state.
Component holding a 2 dimensional array of a templated type.
void rename(const std::string &name)
Rename the component.
Low storage struct to uniquely identify one element.
unsigned int Uint
typedef for unsigned int
Handle< Library > autoload_library_with_namespace(const std::string &libnamespace)
std::string attribute_value(const std::string &name) const
Region & topology() const
void read_topology(const common::XML::XmlNode ®ion_node, Region ®ion, Dictionary &geometry)
Handle< Component > handle()
Get a handle to the component.
Handle< FaceCellConnectivity > & connectivity_face2cell()
Dictionary & geometry_fields() const
static Comm & instance()
Return a reference to the current PE.
Handle< Component > create_component(const std::string &name, const std::string &builder)
Build a (sub)component of this component using the extended type_name of the component.
void combine_mesh(const Mesh &other_mesh)
Add another mesh to this mesh.
bool is_not_null(T ptr)
predicate for comparison to nullptr
boost::shared_ptr< XmlDoc > parse_file(const URI &file)
Handle< Component > access_component_checked(const URI &path)