7 #include <boost/foreach.hpp>
8 #include <boost/tokenizer.hpp>
46 using namespace common;
69 .description(
"Read the data from the mesh")
70 .pretty_name(
"Read Fields")
75 properties()[
"brief"] = std::string(
"Smurf file reader component");
92 std::vector<std::string> extensions;
93 extensions.push_back(
".smurf");
103 boost::filesystem::path fp (file.
path());
104 if(!boost::filesystem::exists(fp))
105 throw boost::filesystem::filesystem_error( fp.string() +
" does not exist", boost::system::error_code() );
116 CFinfo <<
"smurf: opening file " << fp.string() <<
CFendl;
120 std::vector<std::string> vn_;
125 CFdebug <<
"smurf: reading mesh \"" << title_ <<
"\"" <<
CFendl;
128 std::vector< SmURF::TecZone > zheaders = mreader.readZoneHeaders();
134 std::vector< std::vector< unsigned > > ve;
135 std::vector< std::vector< double > > dump;
138 mreader.readZoneData(zone,ve,!i?
m_vv:dump);
140 throw NotSupported(
FromHere(),
"Sorry! Only binary tecplot files with varsharelists are supported (i.e. all node data should be attributed to the first zone)");
142 std::string cf_elem_name;
147 if (ve[0][0]==ve[0][1]) {
148 cf_elem_name =
"cf3.mesh.LagrangeP0.Point1D";
149 for (
unsigned c=0; c<ve.size(); ++c) {
156 if (ve[0][2]==ve[0][3] && ve[0][6]==ve[0][7]) {
159 cf_elem_name =
"cf3.mesh.LagrangeP1.Prism3D";
160 for (
unsigned c=0; c<ve.size(); ++c) {
161 const std::vector< unsigned > ent = ve[c];
162 std::vector< unsigned >& eng = ve[c];
173 else if ((ve[0][4]==ve[0][5]) && (ve[0][4]==ve[0][6]) && (ve[0][4]==ve[0][7])) {
176 cf_elem_name =
"cf3.mesh.LagrangeP1.Pyramid3D";
177 for (
unsigned c=0; c<ve.size(); ++c) {
178 const std::vector< unsigned > ent = ve[c];
179 std::vector< unsigned >& eng = ve[c];
192 for (
unsigned c=0; c<ve.size(); ++c) {
193 std::swap(ve[c][2],ve[c][3]);
194 std::swap(ve[c][6],ve[c][7]);
202 CFdebug <<
"smurf: reading zone \"" << zone.
title <<
"\"" << CFendl
203 <<
" time : " << zone.
time << CFendl
204 <<
" nodes: " << zone.
i << CFendl
205 <<
" elems: " << zone.
j << CFendl
206 <<
" etype: " << cf_elem_name <<
CFendl;
214 boost::shared_ptr< ElementType > allocated_type = build_component_abstract_type<ElementType>(cf_elem_name,
"tmp");
215 boost::shared_ptr< Entities > elements;
216 if (allocated_type->dimensionality() == allocated_type->dimension()-1)
217 elements = build_component_abstract_type<Entities>(
"cf3.mesh.Faces",
"elements_"+allocated_type->derived_type_name());
218 else if(allocated_type->dimensionality() == allocated_type->dimension())
219 elements = build_component_abstract_type<Entities>(
"cf3.mesh.Cells",
"elements_"+allocated_type->derived_type_name());
221 elements = build_component_abstract_type<Entities>(
"cf3.mesh.Elements",
"elements_"+allocated_type->derived_type_name());
222 region->add_component(elements);
223 elements->initialize(cf_elem_name,nodes);
227 elem_table.
resize(ve.size());
228 elements->rank() .resize(ve.size());
229 elements->glb_idx().resize(ve.size());
230 for (
int i=0; i<ve.size(); ++i)
231 for (
int j=0; j<ve[i].size(); ++j)
232 elem_table[i][j] = ve[i][j];
249 for (
Uint j=0; j<
m_vv[0].size(); ++j)
253 for (
Uint i=m_mesh_dimension; i<
m_vv.size(); ++i)
257 for (
Uint j=0; j<
m_vv[0].size(); ++j)
258 field[j][0] =
m_vv[i][j];
270 typedef boost::tokenizer<boost::char_separator<char> > Tokenizer;
271 boost::char_separator<char> sep(
"/");
272 Tokenizer tokens(relative_path, sep);
275 for (Tokenizer::iterator tok_iter = tokens.begin(); tok_iter != tokens.end(); ++tok_iter)
277 std::string
name = *tok_iter;
296 std::vector<Uint> tmp_nodes(nb_nodes_per_elem);
300 if (jacobian_determinant < 0)
303 for (
Uint n=0;
n<nb_nodes_per_elem; ++
n)
#define CFinfo
these are always defined
const ShapeFunction & shape_function() const
std::string name(ComponentWrapper &self)
Field & create_field(const std::string &name, const Uint cols)
Create a new field in this group.
boost::proto::terminal< SFOp< JacobianDeterminantOp > >::type const jacobian_determinant
bool is_null(T ptr)
predicate for comparison to nullptr
Helper class to create the Builder and place it in the factory.
Space & geometry_space() const
virtual Real jacobian_determinant(const RealVector &mapped_coord, const RealMatrix &nodes) const =0
virtual const RealMatrix & local_coordinates() const =0
virtual std::string derived_type_name() const =0
ElementType & element_type() const
return the elementType
#define boost_foreach
lowercase version of BOOST_FOREACH
const std::string & name() const
Access the name of the component.
const Field & coordinates() const
static const Uint m_tp_elem_dim[nb_tp_types]
static const Uint m_nodes_in_tp_elem[nb_tp_types]
Conversions from and to std::string.
Real max(const Real a, const Real b)
Maximum between two scalars.
Real e()
Definition of the Unit charge [C].
boost::proto::terminal< SFOp< NodesOp > >::type const nodes
Uint size() const
return the number of elements
Handle< Region > create_region(std::string const &relative_path)
cf3::common::ComponentBuilder< smurf::Reader, MeshReader, LibSmurf > aSmurfReader_Builder
PropertyList & properties()
static std::string tp_name_to_cf_name(const Uint dim, const Uint tp_type)
std::string m_file_basename
Handle< Component > get_child(const std::string &name)
Top-level namespace for coolfluid.
const TYPE value(const std::string &opt_name) const
Get the value of the option with given name.
Handle< Region > m_region
virtual std::vector< std::string > get_extensions()
virtual void do_read_mesh_into(const common::URI &fp, Mesh &mesh)
RealMatrix get_coordinates(const Uint elem_idx) const
Lookup element coordinates.
void readMainHeader(std::string &htitle, std::vector< std::string > &hvnames)
std::vector< std::vector< double > > m_vv
Reader(const std::string &name)
constructor
void set_row_size(const Uint nb_cols)
unsigned int Uint
typedef for unsigned int
static const std::string dim_name[4]
void resize(const Uint size)
Resize the contained fields.
std::set< Uint > m_used_nodes
Region & topology() const
void fix_negative_volumes(Mesh &mesh)
Handle< Component > handle()
Get a handle to the component.
SelectOptionType< T >::type & add(const std::string &name, const T &default_value=T())
Base class for defining CF components.
Connectivity & connectivity()
connectivity table to dictionary entries
bool is_not_null(T ptr)
predicate for comparison to nullptr
virtual void resize(const Uint nb_rows)