10 #include <boost/date_time/gregorian/gregorian.hpp>
11 #include <boost/progress.hpp>
43 common::ComponentBuilder < mesh::neu::Writer,
61 std::vector<std::string> extensions;
62 extensions.push_back(
".neu");
71 boost::filesystem::fstream file;
74 file.open(path,std::ios_base::out);
77 throw boost::filesystem::filesystem_error( path.string() +
" failed to open",
78 boost::system::error_code() );
106 Uint group_counter(0);
107 Uint element_counter(0);
115 bool isGroupBC(
false);
118 bool isElementBC(
false);
139 file.setf(std::ios::right);
143 file <<
" CONTROL INFO 2.3.16\n";
144 file <<
"** GAMBIT NEUTRAL FILE\n";
146 file <<
"PROGRAM: Gambit VERSION: 2.3.16\n";
147 file << std::setw(4) << std::string(date.month().as_long_string()).substr(0,3) <<
" " << int(date.year()) <<
"\n";
148 file << std::setw(10) <<
"NUMNP" << std::setw(10) <<
"NELEM" << std::setw(10) <<
"NGRPS"
149 << std::setw(10) <<
"NBSETS" << std::setw(10) <<
"NDFCD" << std::setw(10) <<
"NDFVL" << std::endl;
150 file << std::setw(10) << node_counter << std::setw(10) << element_counter << std::setw(10) << group_counter
151 << std::setw(10) << bc_counter << std::setw(10) << mesh.
dimension() << std::setw(10) << mesh.
dimension() << std::endl;
152 file <<
"ENDOFSECTION" << std::endl ;
160 Uint prec = file.precision();
164 file <<
" NODAL COORDINATES 2.3.16" << std::endl;
165 file.setf(std::ios::fixed);
166 Uint node_number = 0;
170 file << std::setw(10) << node_number;
172 file << std::setw(20) << std::scientific << row[d];
175 file <<
"ENDOFSECTION" << std::endl;
177 file.precision(prec);
184 file <<
" ELEMENTS/CELLS 2.3.16" << std::endl;
212 file << std::setw(8) << ++elm_number << std::setw(3) << elm_type << std::setw(3) << nb_nodes <<
" ";
213 std::vector<Uint> neu_element(nb_nodes);
216 for (
Uint j=0; j<nb_nodes; ++j)
221 neu_element[neu_idx] = node_idx+cf_element[j]+1;
227 if (eol_counter == 8)
229 file << std::endl << std::setw(15) <<
" ";
232 file << std::setw(8) << neu_node;
239 file <<
"ENDOFSECTION" << std::endl;
246 Uint group_counter(0);
261 Uint element_counter(0);
266 file <<
" ELEMENT GROUP 2.3.16\n";
267 file <<
"GROUP:" << std::setw(11) << ++group_counter <<
" ELEMENTS:" << std::setw(11) << element_counter <<
" MATERIAL:" << std::setw(11) << 2 <<
" NFLAGS:" << std::setw(11) << 1 << std::endl;
268 file << std::setw(32) << group.
name() << std::endl << std::setw(8) << 0 << std::endl;
275 for (
Uint elm=elm_global_start_idx; elm<elm_global_end_idx; elm++, line_counter++)
277 if (line_counter == 10)
282 file << std::setw(8) << elm;
286 file <<
"ENDOFSECTION" << std::endl;
299 std::map<Handle< Elements const >,boost::shared_ptr< FaceConnectivity > > element_2_face_connecitivity;
307 Uint total_nbElements=0;
308 std::set<Handle< Region const > > bc_regions;
315 if (total_nbElements > 0)
318 boost::progress_display progress(total_nbElements,std::cout,
"writing boundary conditions\n");
322 file <<
" BOUNDARY CONDITIONS 2.3.16\n";
323 file << std::setw(32) << group->name() << std::setw(8) << 1 << std::setw(8) << group->recursive_elements_count(
m_enable_overlap) << std::setw(8) << 0 << std::setw(8) << 6 << std::endl;
334 for(
Uint face = 0; face != nb_faces; ++face)
343 Uint elm_local_idx = connected.second;
344 Uint elm_global_idx = connected_region_start_idx + elm_local_idx;
348 file << std::setw(10) << elm_global_idx+1 << std::setw(5) << neu_elm_type << std::setw(5) << neu_elm_face_idx << std::endl;
353 std::stringstream error_msg;
354 error_msg <<
"\nFace " << face <<
" of element " <<
elem
355 <<
" of " << elementregion.
uri().
string() <<
" has no neighbour." << std::endl;
356 error_msg <<
"nb_elems = " << nb_elems << std::endl;
357 error_msg <<
"nb_faces per elem = " << nb_faces << std::endl;
358 error_msg <<
"elem coordinates:\n";
367 error_msg <<
" connected elems: \n";
370 const Entities& nc_entities = *node_connectivity->entities()[element.first];
371 error_msg <<
" " << nc_entities.
uri() <<
"[" << element.second <<
"] ";
375 error_msg << elem_n <<
" ";
377 error_msg <<
")" << std::endl;
381 error_msg <<
"It could be that faces are oriented in the wrong way!!!" << std::endl;
388 file <<
"ENDOFSECTION" << std::endl;
#define CFinfo
these are always defined
NodeConnectivity::ElementReferenceT ElementReferenceT
Uniquely refer an element by its Elements and local element index.
std::string name(ComponentWrapper &self)
Writer(const std::string &name)
constructor
void write_headerData(std::fstream &file, const Mesh &mesh)
std::vector< std::vector< Uint > > m_nodes_cf_to_neu
Safe pointer to an object. This is the supported method for referring to components.
Space & geometry_space() const
bool m_enable_overlap
If true, writing of overlap will be enabled.
const EntitiesT & entities() const
Access to the raw data.
MeshMetadata & metadata()
Handle< Mesh const > m_mesh
Handle to configured mesh.
ElementType & element_type() const
return the elementType
URI uri() const
Construct the full path.
#define boost_foreach
lowercase version of BOOST_FOREACH
const std::string & name() const
Access the name of the component.
const Field & coordinates() const
RegionFilter m_region_filter
Filters regions.
std::map< GeoShape::Type, Uint > m_CFelement_to_neuElement
common::URI m_file_path
File path to be configured.
Conversions from and to std::string.
virtual const FaceConnectivity & faces() const =0
void write_boundaries(std::fstream &file, const Mesh &mesh)
Uint dimensionality() const
PropertyList & properties()
std::vector< std::vector< Uint > > m_faces_cf_to_neu
Handle< Component > parent() const
ElementReferenceT adjacent_element(const Uint element, const Uint face) const
Get the element that is adjacent to the given face of the given element.
GeoShape::Type shape() const
void write_connectivity(std::fstream &file, const Mesh &mesh)
std::string value_str(const std::string &pname) const
std::pair< Uint, Uint > ElementReferenceT
Uniquely refer an element by its index into the list of entities and it's local element index...
TableConstRow< ValueT >::type ConstRow
the const type of a row in the internal structure of the table
Top-level namespace for coolfluid.
std::map< Handle< Elements const >, Uint > m_global_start_idx
implementation detail, raw pointers are safe as keys
const NodeConnectivity & node_connectivity() const
RealMatrix get_coordinates(const Uint elem_idx) const
Lookup element coordinates.
virtual std::vector< std::string > get_extensions()
void write_groups(std::fstream &file, const Mesh &mesh)
static boost::proto::terminal< ExpressionGroupTag >::type group
Use group(expr1, expr2, ..., exprN) to evaluate a group of expressions.
std::string m_fileBasename
Uint dimensionality() const
unsigned int Uint
typedef for unsigned int
RangeT nodes_range(const Uint face) const
Iterator range over the nodes of the given face.
Region & topology() const
Handle< Component > handle()
Get a handle to the component.
common::ComponentBuilder< mesh::neu::Writer, mesh::MeshWriter, mesh::neu::LibNeu > aneuWriter_Builder
Uint adjacent_face(const Uint element, const Uint face) const
Get the face that is adjacent to the given face of the given element.
Dictionary & geometry_fields() const
Base class for defining CF components.
void write_coordinates(std::fstream &file, const Mesh &mesh)
Uint size() const
Number of rows of contained fields.
Most basic kernel library.
std::string string() const
bool has_adjacent_element(const Uint element, const Uint face) const
True if the given face of the given element has an adjacent element.
Connectivity & connectivity()
connectivity table to dictionary entries