moab-dev
Threads by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
August 2009
- 8 participants
- 34 discussions
Author: bmsmith
Date: 2009-08-31 14:25:49 -0500 (Mon, 31 Aug 2009)
New Revision: 3123
Modified:
MOAB/trunk/ReadMCNP5.cpp
MOAB/trunk/ReadMCNP5.hpp
Log:
Describe the structure of sets, tags, and mesh elements created by this reader.
Modified: MOAB/trunk/ReadMCNP5.cpp
===================================================================
--- MOAB/trunk/ReadMCNP5.cpp 2009-08-27 17:28:21 UTC (rev 3122)
+++ MOAB/trunk/ReadMCNP5.cpp 2009-08-31 19:25:49 UTC (rev 3123)
@@ -1,8 +1,18 @@
-/**
- * \class ReadMCNP5
- * \brief Read output from MCNP5
- * \author Brandon Smith
- **/
+/**
+ * MOAB, a Mesh-Oriented datABase, is a software component for creating,
+ * storing and accessing finite element mesh data.
+ *
+ * Copyright 2004 Sandia Corporation. Under the terms of Contract
+ * DE-AC04-94AL85000 with Sandia Coroporation, the U.S. Government
+ * retains certain rights in this software.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ */
+
#include "ReadMCNP5.hpp"
#include "MBInterface.hpp"
#include "MBReadUtilIface.hpp"
Modified: MOAB/trunk/ReadMCNP5.hpp
===================================================================
--- MOAB/trunk/ReadMCNP5.hpp 2009-08-27 17:28:21 UTC (rev 3122)
+++ MOAB/trunk/ReadMCNP5.hpp 2009-08-31 19:25:49 UTC (rev 3123)
@@ -1,3 +1,42 @@
+/**
+ * MOAB, a Mesh-Oriented datABase, is a software component for creating,
+ * storing and accessing finite element mesh data.
+ *
+ * Copyright 2004 Sandia Corporation. Under the terms of Contract
+ * DE-AC04-94AL85000 with Sandia Coroporation, the U.S. Government
+ * retains certain rights in this software.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ */
+
+//----------------------------------------------------------------------
+// Filename : ReadMCNP5.hpp
+// Purpose : Read a meshtal file created by MCNP5 into MOAB
+// Creator : Brandon Smith
+// Date : 07/2009
+//----------------------------------------------------------------------
+
+/**
+ * Data structure of MCNP5 data created by this reader:
+ *
+ * each file_meshset contains
+ * DATA_AND_TIME_TAG
+ * TITLE_TAG
+ * NPS_TAG
+ * each tally_meshset contains
+ * TALLY_NUMBER_TAG
+ * TALLY_COMMENT_TAG
+ * TALLY_PARTICLE_TAG
+ * TALLY_COORD_SYS_TAG
+ * each mesh element contains
+ * TALLY_TAG
+ * ERROR_TAG
+ */
+
#include "MBInterface.hpp"
#include "MBReaderIface.hpp"
#include <iostream>
1
0
Author: bmsmith
Date: 2009-08-27 12:28:21 -0500 (Thu, 27 Aug 2009)
New Revision: 3122
Added:
MOAB/trunk/ReadNASTRAN.cpp
MOAB/trunk/ReadNASTRAN.hpp
Modified:
MOAB/trunk/MBReaderWriterSet.cpp
MOAB/trunk/Makefile.am
Log:
Initial commit of NASTRAN reader
Modified: MOAB/trunk/MBReaderWriterSet.cpp
===================================================================
--- MOAB/trunk/MBReaderWriterSet.cpp 2009-08-27 17:18:02 UTC (rev 3121)
+++ MOAB/trunk/MBReaderWriterSet.cpp 2009-08-27 17:28:21 UTC (rev 3122)
@@ -25,6 +25,7 @@
#include "ReadGmsh.hpp"
#include "ReadIDEAS.hpp"
#include "ReadMCNP5.hpp"
+#include "ReadNASTRAN.hpp"
#include "ReadABAQUS.hpp"
#include "ReadSms.hpp"
#include "Tqdcfr.hpp"
@@ -79,6 +80,8 @@
register_factory( ReadMCNP5::factory, NULL, "MCNP5 format", "meshtal", "MESHTAL" );
+ register_factory( ReadNASTRAN::factory, NULL, "NASTRAN format", "nas", "NAS" );
+
register_factory( ReadABAQUS::factory, NULL, "ABAQUS INP mesh format", "abq", "Abaqus mesh" );
register_factory( ReadVtk::factory, WriteVtk::factory, "Kitware VTK", "vtk", "VTK" );
Modified: MOAB/trunk/Makefile.am
===================================================================
--- MOAB/trunk/Makefile.am 2009-08-27 17:18:02 UTC (rev 3121)
+++ MOAB/trunk/Makefile.am 2009-08-27 17:28:21 UTC (rev 3122)
@@ -177,6 +177,8 @@
ReadIDEAS.hpp \
ReadMCNP5.cpp \
ReadMCNP5.hpp \
+ ReadNASTRAN.cpp \
+ ReadNASTRAN.hpp \
ReadABAQUS.cpp \
ReadABAQUS.hpp \
ReadTetGen.cpp \
Added: MOAB/trunk/ReadNASTRAN.cpp
===================================================================
--- MOAB/trunk/ReadNASTRAN.cpp (rev 0)
+++ MOAB/trunk/ReadNASTRAN.cpp 2009-08-27 17:28:21 UTC (rev 3122)
@@ -0,0 +1,360 @@
+/**
+ * MOAB, a Mesh-Oriented datABase, is a software component for creating,
+ * storing and accessing finite element mesh data.
+ *
+ * Copyright 2004 Sandia Corporation. Under the terms of Contract
+ * DE-AC04-94AL85000 with Sandia Coroporation, the U.S. Government
+ * retains certain rights in this software.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ */
+
+#include "ReadNASTRAN.hpp"
+
+#include <iostream>
+#include <sstream>
+#include <fstream>
+#include <vector>
+#include <cstdlib>
+#include <assert.h>
+#include <cmath>
+
+#include "MBInterface.hpp"
+#include "MBReadUtilIface.hpp"
+#include "MBInternals.hpp" // for MB_START_ID
+#include "MBRange.hpp"
+#include "FileOptions.hpp"
+#include "FileTokenizer.hpp"
+#include "MBTagConventions.hpp"
+#include "MBCN.hpp"
+
+MBReaderIface* ReadNASTRAN::factory( MBInterface* iface ) {
+ return new ReadNASTRAN( iface );
+}
+
+// constructor
+ReadNASTRAN::ReadNASTRAN(MBInterface* impl)
+ : MBI(impl), fileIDTag(0) {
+ assert(NULL != impl);
+ void *ptr = 0;
+ MBI->query_interface("MBReadUtilIface", &ptr);
+ assert(NULL != ptr);
+ readMeshIface = reinterpret_cast<MBReadUtilIface*>(ptr);
+}
+
+// destructor
+ReadNASTRAN::~ReadNASTRAN() {
+ if (readMeshIface) {
+ MBI->release_interface("MBReadUtilIface", readMeshIface);
+ readMeshIface = 0;
+ }
+}
+
+MBErrorCode ReadNASTRAN::read_tag_values( const char* file_name,
+ const char* tag_name,
+ const FileOptions& opts,
+ std::vector<int>& tag_values_out,
+ const IDTag* subset_list,
+ int subset_list_length )
+{
+ return MB_NOT_IMPLEMENTED;
+}
+
+// load the file as called by the MBInterface function
+MBErrorCode ReadNASTRAN::load_file(const char *filename,
+ MBEntityHandle &file_set,
+ const FileOptions &options,
+ const MBReaderIface::IDTag *subset_list,
+ int subset_list_length,
+ const MBTag* file_id_tag) {
+ // at this time there is no support for reading a subset of the file
+ if (subset_list && subset_list_length) {
+ readMeshIface->report_error( "Reading subset of files not supported for NASTRAN." );
+ return MB_UNSUPPORTED_OPERATION;
+ }
+
+ nodeId = elemId = 0;
+ fileIDTag = file_id_tag;
+
+ bool debug = false;
+ if (debug) std::cout << "begin ReadNASTRAN::load_file" << std::endl;
+ MBErrorCode result;
+ FILE* file = fopen( filename, "r" );
+
+ // create the file set
+ result = MBI->create_meshset(MESHSET_SET, file_set);
+ if(MB_SUCCESS != result) return result;
+
+ // create tags
+ MBTag id_tag, material_tag;
+ result = MBI->tag_create(GLOBAL_ID_TAG_NAME, sizeof(int), MB_TAG_DENSE,
+ MB_TYPE_INTEGER, id_tag, 0);
+ if(MB_SUCCESS!=result && MB_ALREADY_ALLOCATED!=result) return result;
+ result = MBI->tag_create(MATERIAL_SET_TAG_NAME, sizeof(int), MB_TAG_DENSE,
+ MB_TYPE_INTEGER, material_tag, 0);
+ if(MB_SUCCESS!=result && MB_ALREADY_ALLOCATED!=result) return result;
+
+ // IMPORTANT: these are the same as the MOAB enums. Currently only vertices,
+ // tets, and prisms are supported. Implement more as needed.
+ const char* const data_type_names[] = { "GRID", // MBVERTEX
+ "MBEDGE",
+ "MBTRI",
+ "MBQUAD",
+ "MBPOLYGON",
+ "CTETRA", // MBTET
+ "MBPYRAMID",
+ "CPENTA", // MBPRISM
+ "MBKNIFE",
+ "MBHEX",
+ "MBPOLYHEDRON",
+ "MBENTITYSET",
+ "MBMAXTYPE" };
+
+ /* Count the entities of each type in the file. If the token is not
+ matched assume that it is something else in the file (not an error).
+ During the next read we will check for errors.
+ This is used to allocate the node array. Let the tokenizer run out of
+ scope (and thus call fclose). There is no other way to rewind the
+ tokenizer. */
+ int entity_count[MBMAXTYPE];
+ for(int i=0; i<MBMAXTYPE; i++) entity_count[i] = 0;
+ { FileTokenizer tokens( file, readMeshIface );
+ while( !tokens.eof() ) {
+ int data = tokens.match_token( data_type_names ) -1;
+ if(-1 != data) entity_count[data]++;
+ }
+ }
+ if(debug) {
+ for(int i=0; i<MBMAXTYPE; i++) {
+ std::cout << "entity_count[" << i << "]=" << entity_count[i] << std::endl;
+ }
+ }
+
+ /* If we assume that the node ids are continuous, then the node ids can be
+ easily mapped to vertex handles. If they are not continuous then the node
+ ids themselves will need to be used to create connectivity. It is very
+ slow to find each node by its id because this is a tag call. */
+ bool node_ids_are_continuous = true;
+
+ // Now that the number of vertices is known, create the vertices.
+ MBEntityHandle start_vert = NULL;
+ std::vector<double*> coord_arrays(3);
+ result = readMeshIface->get_node_arrays( 3, entity_count[0], MB_START_ID,
+ start_vert, coord_arrays );
+ if(MB_SUCCESS != result) return result;
+ if(0 == start_vert) return MB_FAILURE; // check for NULL
+ int vert_index = 0;
+ if(debug) std::cout << "allocated coord arrays" << std::endl;
+
+ // Read the file again and build the entities. Each line in the file
+ // represents one entity.
+ file = fopen( filename, "r" );
+ FileTokenizer tokens( file, readMeshIface );
+ while( !tokens.eof() ) {
+ // these have been enumerated to match MBEntityTypes
+ int data = tokens.match_token( data_type_names ) -1;
+ MBEntityType datatype = (MBEntityType)data;
+ if(debug) {
+ std::cout << "MBVERTEX=" << MBVERTEX << " datatype=" << datatype << std::endl;
+ }
+
+ // the eof was found
+ if( tokens.eof() ) {
+ break;
+
+ // no matching entity was found
+ } else if(-1 == datatype ) {
+ return MB_NOT_IMPLEMENTED;
+
+ // a vertex line was found
+ } else if(MBVERTEX == datatype) {
+ result = read_node(tokens, id_tag, file_set, debug, coord_arrays,
+ vert_index, start_vert, node_ids_are_continuous );
+ if(MB_SUCCESS != result) return result;
+
+ // an element line was found
+ } else {
+ result = read_element(tokens, id_tag, material_tag, datatype, file_set,
+ debug, start_vert, node_ids_are_continuous );
+ if(MB_SUCCESS != result) return result;
+ }
+ }
+ return MB_SUCCESS;
+}
+
+/* It has been determined that this line is a vertex. Read the rest of
+ the line and create the vertex. */
+MBErrorCode ReadNASTRAN::read_node( FileTokenizer &tokens,
+ MBTag id_tag,
+ const MBEntityHandle file_set,
+ const bool debug,
+ std::vector<double*> coord_arrays,
+ int &vert_index,
+ const MBEntityHandle start_vert,
+ bool &node_ids_are_continuous ) {
+ // read the node's id (unique)
+ MBErrorCode result;
+ int id;
+ if( !tokens.get_integers(1, &id) ) return MB_FAILURE;;
+
+ // read the coordinates
+ const char* coords_string = tokens.get_string();
+ if (!coords_string) return MB_FAILURE;
+ if(debug) std::cout << "coords_string=" << coords_string << std::endl;
+ double coords[3];
+ result = parse_coords( coords_string, coords, debug );
+ if(MB_SUCCESS != result) return result;
+
+ // create the node
+ MBEntityHandle vert = start_vert+vert_index;
+ for(int i=0; i<3; i++) coord_arrays[i][vert_index] = coords[i];
+ vert_index++;
+
+ // check to see if the node ids are still continuous
+ if(id != vert_index) {
+ node_ids_are_continuous = false;
+ std::cout << "node ids are not continuous" << std::endl;
+ }
+
+ // tag with the global id from the NASTRAN file
+ result = MBI->tag_set_data( id_tag, &vert, 1, &id );
+ if(MB_SUCCESS != result) return result;
+
+ // add to the file set
+ result = MBI->add_entities( file_set, &vert, 1 );
+ if(MB_SUCCESS != result) return result;
+
+ return MB_SUCCESS;
+}
+
+/* The coordinates are difficult to parse. Below are some samples. */
+MBErrorCode ReadNASTRAN::parse_coords( const char *coords_string,
+ double coords[],
+ const bool debug ) {
+ /* GRID 1 03.9804546.9052-15.6008-1
+ has the coordinates: ( 3.980454, 6.9052e-1, 5.6008e-1 )
+ GRID 200005 04.004752-3.985-15.4955-1
+ has the coordinates: ( 4.004752, -3.985e-1, 5.4955e-1 ) */
+ char x[9], y[8], z[8];
+ strncpy(x, coords_string, 9); //will copy first 4 characters
+ strncpy(y, coords_string+sizeof(x), 8);
+ strncpy(z, coords_string+sizeof(x)+sizeof(y), 8);
+ if(debug) std::cout << "x=" << x << " y=" << y << " z=" << z << std::endl;
+
+ // returns memory location of last match if found. returns null if not found.
+ char *x_loc, *y_loc, *z_loc;
+ x_loc = strrchr(x,'-'); // - x + 1;
+ y_loc = strrchr(y,'-'); // - y + 1;
+ z_loc = strrchr(z,'-'); // - z + 1;
+ if(debug) std::cout << "loc=" << x_loc << " " << y_loc << " " << z_loc << std::endl;
+
+ // copies( destination memory address, source memory address, size to copy)
+ // copy only the exponent, if it exists.
+ char exp_x[9], exp_y[8], exp_z[8];
+ if(0 != x_loc) {
+ memcpy(exp_x, x_loc, 9);
+ coords[0] = atof(x) * pow(10, atof(exp_x));
+ } else {
+ coords[0] = atof(x);
+ }
+ if(0 != y_loc) {
+ memcpy(exp_y, y_loc, 8 );
+ coords[1] = atof(y) * pow(10, atof(exp_y));
+ } else {
+ coords[1] = atof(y);
+ }
+ if(0 != z_loc) {
+ memcpy(exp_z, z_loc, 8-(int)(z_loc-z) );
+ coords[2] = atof(z)*pow(10, atof(exp_z));;
+ } else {
+ coords[2] = atof(z);
+ }
+ //std::cout << "exp=" << exp_x << " " << exp_y << " " << exp_z << std::endl;
+ if(debug) std::cout << "coords[]=" << coords[0] << " " << coords[1]
+ << " " << coords[2] << std::endl;
+
+ return MB_SUCCESS;
+}
+
+/* The type of element has already been identified. Read the rest of the
+ line and create the element. Assume that all of the nodes have already
+ been created. */
+MBErrorCode ReadNASTRAN::read_element( FileTokenizer &tokens,
+ MBTag id_tag,
+ MBTag material_tag,
+ const MBEntityType element_type,
+ const MBEntityHandle file_set,
+ const bool debug,
+ const MBEntityHandle start_vert,
+ const bool node_ids_are_continuous ) {
+
+ // read the element's id (unique) and material set
+ MBErrorCode result;
+ int id;
+ bool res = tokens.get_integers(1, &id);
+ if(false == res) return MB_FAILURE;
+ int material;
+ res = tokens.get_integers(1, &material);
+ if(false == res) return MB_FAILURE;
+
+ // the size of the connectivity array depends on the element type
+ int n_conn = MBCN::VerticesPerEntity(element_type);
+
+ // read the connected node ids from the file
+ int conn[n_conn];
+ res = tokens.get_integers(n_conn, conn);
+ if(false == res) return MB_FAILURE;
+
+ /* Get the vertex handles with those node ids. If the nodes do not have
+ continuous ids we need to do a very slow tag search for global ids.
+ The cannonical numbering between NASTRAN and MOAB is the same for
+ tets and prisms. */
+ MBEntityHandle conn_verts[n_conn];
+ for(int i=0; i<n_conn; i++) {
+ if(node_ids_are_continuous) {
+ conn_verts[i] = start_vert + conn[i] -1;
+ } else {
+ void *vert_id_val[] = {&conn[i]};
+ MBRange vert;
+ result = MBI->get_entities_by_type_and_tag( file_set, MBVERTEX, &id_tag,
+ vert_id_val, 1, vert );
+ if(MB_SUCCESS != result) return result;
+ if(1 != vert.size()) return MB_FAILURE; // only one vertex should have this global id
+ conn_verts[i] = vert.front();
+ }
+ if(debug) std::cout << "conn[" << i << "]=" << conn[i] << std::endl;
+ }
+
+ // Create the element and set the global id from the NASTRAN file
+ MBEntityHandle element;
+ result = MBI->create_element( element_type, conn_verts, n_conn, element );
+ if(MB_SUCCESS != result) return result;
+ result = MBI->tag_set_data( id_tag, &element, 1, &id );
+ if(MB_SUCCESS != result) return result;
+
+ // Create the material set for the element if it does not already exist.
+ void *mat_val[] = {&material};
+ MBRange material_set;
+ result = MBI->get_entities_by_type_and_tag( file_set, MBENTITYSET, &material_tag,
+ mat_val, 1, material_set );
+ if(MB_SUCCESS != result) return result;
+ if(0 == material_set.size()) {
+ MBEntityHandle new_material_set;
+ result = MBI->create_meshset( 0, new_material_set );
+ if(MB_SUCCESS != result) return result;
+ result = MBI->add_entities( file_set, &new_material_set, 1 );
+ result = MBI->tag_set_data( material_tag, &new_material_set, 1, &material );
+ if(MB_SUCCESS != result) return result;
+ material_set.insert( new_material_set );
+ } else if(1 < material_set.size()) {
+ return MB_MULTIPLE_ENTITIES_FOUND;
+ }
+ result = MBI->add_entities( material_set.front(), &element, 1 );
+ if(MB_SUCCESS != result) return result;
+
+ return MB_SUCCESS;
+}
Added: MOAB/trunk/ReadNASTRAN.hpp
===================================================================
--- MOAB/trunk/ReadNASTRAN.hpp (rev 0)
+++ MOAB/trunk/ReadNASTRAN.hpp 2009-08-27 17:28:21 UTC (rev 3122)
@@ -0,0 +1,105 @@
+/**
+ * MOAB, a Mesh-Oriented datABase, is a software component for creating,
+ * storing and accessing finite element mesh data.
+ *
+ * Copyright 2004 Sandia Corporation. Under the terms of Contract
+ * DE-AC04-94AL85000 with Sandia Coroporation, the U.S. Government
+ * retains certain rights in this software.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ */
+
+//-------------------------------------------------------------------------
+// Filename : ReadNASTRAN.hpp
+//
+// Purpose : NASTRAN file reader
+//
+// Creator : Brandon Smith
+//
+// Date : 08/2009
+//
+//-------------------------------------------------------------------------
+
+#ifndef READNASTRAN_HPP
+#define READNASTRAN_HPP
+
+#ifndef IS_BUILDING_MB
+ #error "ReadNASTRAN.hpp isn't supposed to be included into an application"
+#endif
+
+#include <iostream>
+#include <fstream>
+#include <sstream>
+#include <vector>
+
+#include "MBInterface.hpp"
+#include "MBReaderIface.hpp"
+#include "FileTokenizer.hpp"
+
+class MBReadUtilIface;
+
+class ReadNASTRAN : public MBReaderIface
+{
+
+public:
+ // factory method
+ static MBReaderIface* factory( MBInterface* );
+
+ MBErrorCode load_file( const char *filename,
+ MBEntityHandle &file_set,
+ const FileOptions &options,
+ const MBReaderIface::IDTag *subset_list = 0,
+ int subset_list_length = 0,
+ const MBTag *file_id_tag = 0 );
+ // constructor
+ ReadNASTRAN(MBInterface* impl = NULL);
+
+ // destructor
+ virtual ~ReadNASTRAN();
+
+ MBErrorCode read_tag_values( const char *file_name,
+ const char *tag_name,
+ const FileOptions &opts,
+ std::vector<int> &tag_values_out,
+ const IDTag *subset_list,
+ int subset_list_length );
+
+protected:
+
+private:
+ // read mesh interface
+ MBReadUtilIface* readMeshIface;
+
+ // MOAB Interface
+ MBInterface* MBI;
+
+ const MBTag* fileIDTag;
+ int nodeId, elemId;
+
+ MBErrorCode read_node(FileTokenizer &tokens,
+ MBTag id_tag,
+ const MBEntityHandle file_set,
+ const bool debug,
+ std::vector<double*> coord_arrays,
+ int &vert_index,
+ const MBEntityHandle start_vert,
+ bool &node_ids_are_continuous );
+
+ MBErrorCode parse_coords( const char *coords_string,
+ double coords[],
+ const bool debug );
+
+ MBErrorCode read_element(FileTokenizer &tokens,
+ MBTag id_tag,
+ MBTag material_tag,
+ const MBEntityType element_type,
+ const MBEntityHandle file_set,
+ const bool debug,
+ const MBEntityHandle start_vert,
+ const bool node_ids_are_continuous );
+};
+#endif
1
0
Author: jvporter
Date: 2009-08-27 12:18:02 -0500 (Thu, 27 Aug 2009)
New Revision: 3121
Modified:
MOAB/trunk/tools/iMesh/python/doc/ibase.rst
Log:
Another quick test commit to check the buildbot...
Modified: MOAB/trunk/tools/iMesh/python/doc/ibase.rst
===================================================================
--- MOAB/trunk/tools/iMesh/python/doc/ibase.rst 2009-08-27 16:03:04 UTC (rev 3120)
+++ MOAB/trunk/tools/iMesh/python/doc/ibase.rst 2009-08-27 17:18:02 UTC (rev 3121)
@@ -107,4 +107,4 @@
.. data:: failed
- Creation failed
\ No newline at end of file
+ Creation failed
1
0
Author: bmsmith
Date: 2009-08-27 11:03:04 -0500 (Thu, 27 Aug 2009)
New Revision: 3120
Modified:
MOAB/trunk/tools/measure.cpp
Log:
Fix ordering to calculate volume
Modified: MOAB/trunk/tools/measure.cpp
===================================================================
--- MOAB/trunk/tools/measure.cpp 2009-08-26 18:25:53 UTC (rev 3119)
+++ MOAB/trunk/tools/measure.cpp 2009-08-27 16:03:04 UTC (rev 3120)
@@ -185,8 +185,8 @@
tet_volume( coords[0], coords[2], coords[3], coords[4] ) ;
case MBPRISM:
return tet_volume( coords[0], coords[1], coords[2], coords[5] ) +
- tet_volume( coords[3], coords[4], coords[5], coords[0] ) +
- tet_volume( coords[0], coords[1], coords[4], coords[5] ) ;
+ tet_volume( coords[3], coords[5], coords[4], coords[0] ) +
+ tet_volume( coords[1], coords[4], coords[5], coords[0] ) ;
case MBHEX:
return tet_volume( coords[0], coords[1], coords[3], coords[4] ) +
tet_volume( coords[7], coords[3], coords[6], coords[4] ) +
1
0
Hi there,
I have been digging through the interface and I can't seem to find a
function that will return an MBRange of entities formed by matching a
single tag against a set of tag values. As far as I can tell,
get_entities_by_type_and_tag will return an MBRange of entities formed
by matching N tags against N corresponding values, but will not match 1
tag against M values.
Is there such a function? If not, is there a recommended way to resolve
this? My first attempt was to get each entity one at a time, but that
is extremely slow. Perhaps better to get the tag data for all possible
entities and then throw out the ones that are not needed?
Thanks,
Paul
--
-- --------------------------------------------------------- --
Paul P H Wilson UW-Madison Engineering Physics
Associate Professor 419 Engineering Research Bldg
wilsonp(a)engr.wisc.edu 1500 Engineering Dr
608/263-0807 fax:608/263-4499 Madison, WI 53706
http://www.cae.wisc.edu/~wilsonp http://www.engr.wisc.edu/ep
My calendar
http://www.google.com/calendar/[email protected]
Contributing to the joy and improvement
of all those around me
3
3
Author: jvporter
Date: 2009-08-24 15:58:43 -0500 (Mon, 24 Aug 2009)
New Revision: 3117
Modified:
MOAB/trunk/ReadABAQUS.cpp
MOAB/trunk/ReadABAQUS.hpp
Log:
Eliminate warnings when building
Modified: MOAB/trunk/ReadABAQUS.cpp
===================================================================
--- MOAB/trunk/ReadABAQUS.cpp 2009-08-24 20:33:43 UTC (rev 3116)
+++ MOAB/trunk/ReadABAQUS.cpp 2009-08-24 20:58:43 UTC (rev 3117)
@@ -1641,7 +1641,7 @@
}
-MBTag ReadABAQUS::get_tag(char* tag_name,
+MBTag ReadABAQUS::get_tag(const char* tag_name,
int tag_size,
MBTagType tag_type,
MBDataType tag_data_type)
@@ -1652,7 +1652,7 @@
}
-MBTag ReadABAQUS::get_tag(char* tag_name,
+MBTag ReadABAQUS::get_tag(const char* tag_name,
int tag_size,
MBTagType tag_type,
MBDataType tag_data_type,
Modified: MOAB/trunk/ReadABAQUS.hpp
===================================================================
--- MOAB/trunk/ReadABAQUS.hpp 2009-08-24 20:33:43 UTC (rev 3116)
+++ MOAB/trunk/ReadABAQUS.hpp 2009-08-24 20:58:43 UTC (rev 3117)
@@ -242,8 +242,10 @@
const std::vector<double> &translation,
const std::vector<double> &rotation);
- MBTag get_tag(char* tag_name, int tag_size, MBTagType tag_type, MBDataType tag_data_type);
- MBTag get_tag(char* tag_name, int tag_size, MBTagType tag_type, MBDataType tag_data_type, const void* def_val);
+ MBTag get_tag(const char* tag_name, int tag_size, MBTagType tag_type,
+ MBDataType tag_data_type);
+ MBTag get_tag(const char* tag_name, int tag_size, MBTagType tag_type,
+ MBDataType tag_data_type, const void* def_val);
void cyl2rect(std::vector<double> coord_list);
1
0
Author: jvporter
Date: 2009-08-24 15:33:43 -0500 (Mon, 24 Aug 2009)
New Revision: 3116
Modified:
MOAB/trunk/tools/iMesh/python/doc/index.rst
Log:
Test commit to make sure Buildbot SVNPoller is working
Modified: MOAB/trunk/tools/iMesh/python/doc/index.rst
===================================================================
--- MOAB/trunk/tools/iMesh/python/doc/index.rst 2009-08-21 16:06:01 UTC (rev 3115)
+++ MOAB/trunk/tools/iMesh/python/doc/index.rst 2009-08-24 20:33:43 UTC (rev 3116)
@@ -12,4 +12,4 @@
build
ibase
imesh
- helpers
\ No newline at end of file
+ helpers
1
0
On Thu, 2009-08-20 at 14:30 -0400, Alfred von Loebbecke wrote:
> James Porter wrote:
> > On Thu, 2009-08-20 at 13:40 -0400, Alfred von Loebbecke wrote:
> >
> >> Hi Jim,
> >> thank you for your response.
> >> the thing is that visual studio 2005 is requesting the use of of the
> >> /clr switch
> >> in a number of places when building MOAB. for example:
> >>
> >>
> >> MBRange.cpp
> >> c:\win_xp_create_mg\3rd_party\moab\MBRange.hpp(664) : error C4980:
> >> '__value' : use of this keyword requires /clr:oldSyntax command line option
> >> c:\win_xp_create_mg\3rd_party\moab\MBRange.hpp(664) : error C3630: error
> >> when processing the token '__value'
> >> c:\win_xp_create_mg\3rd_party\moab\MBRange.hpp(664) : fatal error C1190:
> >> managed targeted code requires a '/clr' option
> >> MBOrientedBoxTreeTool.cpp
> >>
> >
> > That's a bug in MOAB (sort of). "__value" is a keyword[1] in MSVC, so it
> > won't compile because it knows that keyword can't be used without
> > managed code. It can't be used *with* managed code in that context
> > either, since it won't parse correctly.
> >
> > It's not technically legal for us to prefix identifiers with two
> > underscores, since that's reserved for compiler authors, so I've changed
> > it in SVN. If you don't want to use the latest SVN build, you can just
> > change "__value" to "value" on that line and on line 666.
> >
> > - Jim
> >
> > [1] http://msdn.microsoft.com/en-us/library/k7kkeb76.aspx
> >
>
> ok, thank you, that worked well.
> I don't have access to the MOAB svn but I'll ask my colleague (Clinton
> Stimpson)
> if he can get me the newest source. In the meantime I'd appreciate any
> tips for the
> three remaining errors:
>
> ..\..\..\Win_XP_Create_MG\3rd_party\MOAB\MBSysUtil.cpp(20) : error
> C2146: syntax error : missing ';' before identifier 'uint16_t'
> ..\..\..\Win_XP_Create_MG\3rd_party\MOAB\MBSysUtil.cpp(20) : error
> C4430: missing type specifier - int assumed. Note: C++ does not support
> default-int
>
> c:\win_xp_create_mg\3rd_party\moab\MBMatrix3.hpp(255) : error C3861:
> 'finite': identifier not found
>
> thank you and regards,
> Alfred
>
>
The first two errors can be resolved by adding "typedef unsigned __int16
uint16_t;" somewhere near the top of the file (it may be necessary to
put it in a common header somewhere in MOAB). The last one can be
resolved by adding a single underscore before "finite". These are a
little bit harder to fix in general than the previous errors, but I'll
figure something out.
- Jim
4
8
Author: wilsonp
Date: 2009-08-20 20:51:30 -0500 (Thu, 20 Aug 2009)
New Revision: 3114
Added:
MOAB/trunk/ReadABAQUS.cpp
MOAB/trunk/ReadABAQUS.hpp
Modified:
MOAB/trunk/MBReaderWriterSet.cpp
MOAB/trunk/Makefile.am
Log:
Add support for reading mesh generated for use in ABAQUS.
[Note: these files typiclly use the extension ".inp"
but that seemed to generic so I set up automatic
support for ".abq" instead.]
This mesh format implements a part/assembly/instance
paradigm with nodes & elements collected in node sets
and element sets. This was implemented in MOAB using
tags and meshsets (but no parent-child) relationships.
For example, assembly meshsets contain instance meshsets
and instance meshsets are tagged with the handle of the
assembly meshset that contains them. At the moment an
extensive set of cross-referencing was done with this
general technique. This should probably be documented
in more detail for this implementation, but could probably
have portions of it abstracted in order to support other
mesh formats with a similar paradigm.
At this point, the reader supports a limited set of
keywords, largely for determining which material is
in each mesh element.
The reader also only supports a limited set of
ABAQUS element types, but extending for additional types
is straightforward. The corollary is that the purpose
of this reader is so limited that the type of element
rarely matters beyond mapping it onto the correct
MBEntityType and knowning the correct connectivity size.
Modified: MOAB/trunk/MBReaderWriterSet.cpp
===================================================================
--- MOAB/trunk/MBReaderWriterSet.cpp 2009-08-20 21:32:24 UTC (rev 3113)
+++ MOAB/trunk/MBReaderWriterSet.cpp 2009-08-21 01:51:30 UTC (rev 3114)
@@ -25,6 +25,7 @@
#include "ReadGmsh.hpp"
#include "ReadIDEAS.hpp"
#include "ReadMCNP5.hpp"
+#include "ReadABAQUS.hpp"
#include "ReadSms.hpp"
#include "Tqdcfr.hpp"
#include "ReadTetGen.hpp"
@@ -78,6 +79,8 @@
register_factory( ReadMCNP5::factory, NULL, "MCNP5 format", "meshtal", "MESHTAL" );
+ register_factory( ReadABAQUS::factory, NULL, "ABAQUS INP mesh format", "abq", "Abaqus mesh" );
+
register_factory( ReadVtk::factory, WriteVtk::factory, "Kitware VTK", "vtk", "VTK" );
register_factory( ReadSms::factory, NULL, "RPI SMS", "sms", "SMS" );
Modified: MOAB/trunk/Makefile.am
===================================================================
--- MOAB/trunk/Makefile.am 2009-08-20 21:32:24 UTC (rev 3113)
+++ MOAB/trunk/Makefile.am 2009-08-21 01:51:30 UTC (rev 3114)
@@ -177,6 +177,8 @@
ReadIDEAS.hpp \
ReadMCNP5.cpp \
ReadMCNP5.hpp \
+ ReadABAQUS.cpp \
+ ReadABAQUS.hpp \
ReadTetGen.cpp \
ReadTetGen.hpp \
ScdElementData.cpp \
Added: MOAB/trunk/ReadABAQUS.cpp
===================================================================
--- MOAB/trunk/ReadABAQUS.cpp (rev 0)
+++ MOAB/trunk/ReadABAQUS.cpp 2009-08-21 01:51:30 UTC (rev 3114)
@@ -0,0 +1,2225 @@
+/**
+ * MOAB, a Mesh-Oriented datABase, is a software component for creating,
+ * storing and accessing finite element mesh data.
+ *
+ * Copyright 2004 Sandia Corporation. Under the terms of Contract
+ * DE-AC04-94AL85000 with Sandia Coroporation, the U.S. Government
+ * retains certain rights in this software.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ */
+
+
+
+
+#ifdef WIN32
+#pragma warning(disable:4786)
+#endif
+
+#include "ReadABAQUS.hpp"
+
+#include <algorithm>
+#include <time.h>
+#include <string>
+#include <assert.h>
+#include <stdio.h>
+#include <cmath>
+
+#include "MBCN.hpp"
+#include "MBRange.hpp"
+#include "MBInterface.hpp"
+#include "MBTagConventions.hpp"
+#include "MBInternals.hpp"
+#include "MBReadUtilIface.hpp"
+#include "MBAffineXform.hpp"
+// #include "abaqus_order.h"
+#include "FileOptions.hpp"
+
+#define ABQ_AMBIGUOUS "AMBIGUOUS"
+#define ABQ_UNDEFINED "UNDEFINED"
+#define DEG2RAD 0.017453292519943295769236907684886
+
+#define MB_RETURN_IF_FAIL if (MB_SUCCESS != status) return status
+
+MBReaderIface* ReadABAQUS::factory( MBInterface* iface )
+ { return new ReadABAQUS( iface ); }
+
+
+
+ReadABAQUS::ReadABAQUS(MBInterface* impl)
+ : mdbImpl(impl)
+{
+ assert(impl != NULL);
+ reset();
+
+ void* ptr = 0;
+ impl->query_interface( "MBReadUtilIface", &ptr );
+ readMeshIface = reinterpret_cast<MBReadUtilIface*>(ptr);
+
+ // initialize in case tag_get_handle fails below
+ mMaterialSetTag = 0;
+ mDirichletSetTag = 0;
+ mNeumannSetTag = 0;
+ mHasMidNodesTag = 0;
+
+ mSetTypeTag = 0;
+ mPartHandleTag = 0;
+ mInstancePIDTag = 0;
+ mInstanceGIDTag = 0;
+ mLocalIDTag = 0;
+ mInstanceHandleTag = 0;
+ mAssemblyHandleTag = 0;
+ mSetNameTag = 0;
+ mMatNameTag = 0;
+
+ mat_id = 0;
+
+ //! get and cache predefined tag handles
+ mMaterialSetTag = get_tag(MATERIAL_SET_TAG_NAME, sizeof(int),MB_TAG_SPARSE,MB_TYPE_INTEGER);
+ mDirichletSetTag = get_tag(DIRICHLET_SET_TAG_NAME, sizeof(int),MB_TAG_SPARSE,MB_TYPE_INTEGER);
+ mNeumannSetTag = get_tag(NEUMANN_SET_TAG_NAME, sizeof(int),MB_TAG_SPARSE,MB_TYPE_INTEGER);
+ int def_val[4] = {0,0,0,0};
+ mHasMidNodesTag = get_tag(HAS_MID_NODES_TAG_NAME,4*sizeof(int),MB_TAG_SPARSE,MB_TYPE_INTEGER,def_val);
+
+ mSetTypeTag = get_tag(ABAQUS_SET_TYPE_TAG_NAME, sizeof(int), MB_TAG_SPARSE,MB_TYPE_INTEGER);
+ mPartHandleTag = get_tag(ABAQUS_PART_HANDLE_TAG_NAME, sizeof(MBEntityHandle),MB_TAG_SPARSE,MB_TYPE_HANDLE);
+ mInstanceHandleTag = get_tag(ABAQUS_INSTANCE_HANDLE_TAG_NAME, sizeof(MBEntityHandle),MB_TAG_DENSE, MB_TYPE_HANDLE);
+ mAssemblyHandleTag = get_tag(ABAQUS_ASSEMBLY_HANDLE_TAG_NAME, sizeof(MBEntityHandle),MB_TAG_DENSE, MB_TYPE_HANDLE);
+ mInstancePIDTag = get_tag(ABAQUS_INSTANCE_PART_ID_TAG_NAME, sizeof(int), MB_TAG_SPARSE,MB_TYPE_INTEGER);
+ mInstanceGIDTag = get_tag(ABAQUS_INSTANCE_GLOBAL_ID_TAG_NAME,sizeof(int), MB_TAG_SPARSE,MB_TYPE_INTEGER);
+ mLocalIDTag = get_tag(ABAQUS_LOCAL_ID_TAG_NAME, sizeof(int), MB_TAG_DENSE, MB_TYPE_INTEGER);
+ mSetNameTag = get_tag(ABAQUS_SET_NAME_TAG_NAME, ABAQUS_SET_NAME_LENGTH, MB_TAG_SPARSE,MB_TYPE_OPAQUE,0);
+ mMatNameTag = get_tag(ABAQUS_MAT_NAME_TAG_NAME, ABAQUS_MAT_NAME_LENGTH, MB_TAG_SPARSE,MB_TYPE_OPAQUE,0);
+
+}
+
+void ReadABAQUS::reset()
+{
+
+}
+
+
+ReadABAQUS::~ReadABAQUS()
+{
+ std::string iface_name = "MBReadUtilIface";
+ mdbImpl->release_interface(iface_name, readMeshIface);
+ if (NULL != abFile)
+ abFile.close();
+}
+
+/*
+
+MBErrorCode ReadABAQUS::check_file_stats()
+* check for existence of file
+* initialize meshsets, and offsets if necessary
+
+*/
+
+MBErrorCode ReadABAQUS::read_tag_values( const char* /* file_name */,
+ const char* /* tag_name */,
+ const FileOptions& /* opts */,
+ std::vector<int>& /* tag_values_out */,
+ const IDTag* /* subset_list */,
+ int /* subset_list_length */ )
+{
+ return MB_NOT_IMPLEMENTED;
+}
+
+
+
+MBErrorCode ReadABAQUS::load_file(const char *abaqus_file_name,
+ MBEntityHandle& file_set,
+ const FileOptions& opts,
+ const MBReaderIface::IDTag* subset_list,
+ int subset_list_length,
+ const MBTag* file_id_tag)
+{
+ MBErrorCode status;
+
+ // open file
+ abFile.open(abaqus_file_name);
+
+ bool in_unsupported = false;
+
+ // initialize meshset, etc
+ status = mdbImpl->create_meshset(MESHSET_SET, file_set);
+ MB_RETURN_IF_FAIL;
+
+ next_line_type = get_next_line_type();
+ while (next_line_type != abq_eof)
+ {
+ switch (next_line_type)
+ {
+ case abq_keyword_line:
+ in_unsupported=false;
+ switch (get_keyword())
+ {
+ case abq_heading:
+ // read header
+ status = read_heading(file_set);
+ break;
+
+ case abq_part:
+ // read parts until done
+ status = read_part(file_set);
+ break;
+
+ case abq_assembly:
+ // read assembly (or assemblies?)
+ status = read_assembly(file_set);
+ break;
+
+ default:
+ // skip reading other content for now
+ // (e.g. material properties, loads, surface interactions, etc)
+ in_unsupported = true;
+ // std::cout << "Ignoring unsupported keyword: " << readline << std::endl;
+ }
+ MB_RETURN_IF_FAIL;
+ break;
+ case abq_comment_line:
+ break;
+ case abq_data_line:
+ if (!in_unsupported)
+ {
+ std::cerr << "Internal Error: found ABAQUS data line outside a keyword block."
+ << std::endl << readline << std::endl;
+ return MB_FAILURE;
+ }
+ break;
+ default:
+ std::cerr << "Internal Error: found unrecognized ABAQUS line."
+ << std::endl << readline << std::endl;
+ return MB_FAILURE;
+ }
+ next_line_type = get_next_line_type();
+ }
+
+
+ // temporary??? delete parts
+ // get all node sets in part
+ MBRange part_sets;
+ int tag_val = ABQ_PART_SET;
+ void* tag_data[] = {&tag_val};
+ status = mdbImpl->get_entities_by_type_and_tag(file_set,
+ MBENTITYSET,
+ &mSetTypeTag,
+ tag_data, 1, part_sets);
+ MB_RETURN_IF_FAIL;
+
+ for (MBRange::iterator part_set = part_sets.begin();
+ part_set != part_sets.end();
+ part_set++)
+ {
+ MBRange ent_sets;
+ tag_val = ABQ_NODE_SET;
+ tag_data[0] = &tag_val;
+
+ status = mdbImpl->get_entities_by_type_and_tag(*part_set,
+ MBENTITYSET,
+ &mSetTypeTag,
+ tag_data, 1, ent_sets);
+ MB_RETURN_IF_FAIL;
+
+ status = mdbImpl->delete_entities(ent_sets);
+ MB_RETURN_IF_FAIL;
+
+ tag_val = ABQ_ELEMENT_SET;
+ tag_data[0] = &tag_val;
+
+ status = mdbImpl->get_entities_by_type_and_tag(*part_set,
+ MBENTITYSET,
+ &mSetTypeTag,
+ tag_data, 1, ent_sets);
+ MB_RETURN_IF_FAIL;
+
+ status = mdbImpl->delete_entities(ent_sets);
+ MB_RETURN_IF_FAIL;
+
+ MBRange node_list,ele_list;
+ status = get_set_elements(*part_set,ele_list);
+ MB_RETURN_IF_FAIL;
+
+ status = mdbImpl->delete_entities(ele_list);
+ MB_RETURN_IF_FAIL;
+
+ status = mdbImpl->get_entities_by_dimension(*part_set,0,node_list);
+ MB_RETURN_IF_FAIL;
+
+ status = mdbImpl->delete_entities(node_list);
+ MB_RETURN_IF_FAIL;
+
+
+
+ }
+
+
+ return MB_SUCCESS;
+}
+
+
+MBErrorCode ReadABAQUS::read_heading(MBEntityHandle file_set)
+{
+
+ std::vector<std::string> tokens;
+
+ // current line is only heading token. get next line
+ next_line_type = get_next_line_type();
+
+ // perhaps keep first line and tag gometry with title?
+
+ while (abq_data_line == next_line_type ||
+ abq_comment_line == next_line_type )
+ next_line_type = get_next_line_type();
+
+ return MB_SUCCESS;
+}
+
+MBErrorCode ReadABAQUS::read_assembly(MBEntityHandle file_set)
+{
+ MBErrorCode status = MB_SUCCESS;
+
+ std::vector<std::string> tokens;
+ std::map<std::string,std::string> params;
+ std::map<std::string,abaqus_assembly_params> requiredParams;
+ requiredParams["NAME"] = abq_assembly_name;
+
+ std::map<std::string,abaqus_assembly_params> allowableParams;
+ allowableParams[ABQ_AMBIGUOUS] = abq_assembly_ambiguous;
+
+ abaqus_assembly_params param;
+
+ std::string assembly_name;
+
+ // tokenize last line read
+ tokenize(readline,tokens,",\n");
+ extract_keyword_parameters(tokens,params);
+
+ // search for required parameters
+ for (std::map<std::string,abaqus_assembly_params>::iterator thisParam=requiredParams.begin();
+ thisParam != requiredParams.end();
+ thisParam++)
+ {
+ std::string param_key = match( (*thisParam).first,params );
+ param = requiredParams[param_key];
+ switch (param)
+ {
+ case abq_assembly_name:
+ assembly_name = params[param_key];
+ params.erase(param_key);
+ // std::cout << "Adding ASSEMBLY with name: " << assembly_name << std::endl; // REMOVE
+ break;
+ default:
+ // std::cout << "Missing required ASSEMBLY parameter " << (*thisParam).first << std::endl;
+ return MB_FAILURE;
+ }
+ }
+
+ // process parameters
+ for (std::map<std::string,std::string>::iterator thisParam=params.begin();
+ thisParam != params.end();
+ thisParam++)
+ {
+ // look for unambiguous match with this node parameter
+ param = allowableParams[match( (*thisParam).first, allowableParams )];
+ switch (param)
+ {
+ case abq_assembly_ambiguous:
+ // std::cout << "\tIgnoring ambiguous ASSEMBLY parameter: " << (*thisParam).first
+ // << "=" << (*thisParam).second << std::endl;
+ break;
+ default:
+ // std::cout << "\tIgnoring unsupported ASSEMBLY parameter: " << (*thisParam).first
+ // << "=" << (*thisParam).second << std::endl;
+ break;
+ }
+ }
+
+
+ MBEntityHandle assembly_set;
+
+ status = add_entity_set(file_set,ABQ_ASSEMBLY_SET,assembly_name,assembly_set);
+
+ next_line_type = get_next_line_type();
+
+ bool end_assembly = false;
+ bool in_unsupported = false;
+
+ while (next_line_type != abq_eof && !end_assembly)
+ {
+ switch(next_line_type)
+ {
+ case abq_keyword_line:
+ in_unsupported = false;
+ switch(get_keyword())
+ {
+ case abq_end_assembly:
+ end_assembly = true;
+ break;
+ case abq_instance:
+ status = read_instance(assembly_set,file_set);
+ break;
+ case abq_nset:
+ status = read_node_set(assembly_set,file_set);
+ break;
+ default:
+ in_unsupported = true;
+ // std::cout << "\tIgnoring unsupported keyword in this ASSEMBLY: "
+ // << readline << std::endl;
+ next_line_type = get_next_line_type();
+ break;
+ }
+ break;
+ case abq_comment_line:
+ next_line_type = get_next_line_type();
+ break;
+ case abq_data_line:
+ if (!in_unsupported)
+ {
+ // std::cout << "Internal Error: Data lines not allowed in ASSEMBLY keyword."
+ // << std::endl << readline << std::endl;
+ return MB_FAILURE;
+ }
+ next_line_type = get_next_line_type();
+ break;
+ case abq_blank_line:
+ // std::cout << "Error: Blank lines are not allowed." << std::endl;
+ return MB_FAILURE;
+ default:
+ // std::cout << "Error reading ASSEMBLY " << assembly_name << std::endl;
+ return MB_FAILURE;
+
+ }
+ MB_RETURN_IF_FAIL;
+
+ }
+
+
+ num_assembly_instances[assembly_set] = 0;
+
+ return MB_SUCCESS;
+}
+
+
+MBErrorCode ReadABAQUS::read_instance(MBEntityHandle assembly_set,MBEntityHandle file_set)
+{
+ MBErrorCode status = MB_SUCCESS;
+
+ std::vector<std::string> tokens;
+ std::map<std::string,std::string> params;
+ std::map<std::string,abaqus_instance_params> requiredParams;
+ requiredParams["NAME"] = abq_instance_name;
+ requiredParams["PART"] = abq_instance_part;
+
+ std::map<std::string,abaqus_instance_params> allowableParams;
+ allowableParams[ABQ_AMBIGUOUS] = abq_instance_ambiguous;
+
+ abaqus_instance_params param;
+
+ std::string instance_name,part_name;
+
+ // tokenize last line read
+ tokenize(readline,tokens,",\n");
+ extract_keyword_parameters(tokens,params);
+
+ // search for required parameters
+ for (std::map<std::string,abaqus_instance_params>::iterator thisParam=requiredParams.begin();
+ thisParam != requiredParams.end();
+ thisParam++)
+ {
+ std::string param_key = match( (*thisParam).first,params );
+ param = requiredParams[param_key];
+ switch (param)
+ {
+ case abq_instance_name:
+ instance_name = params[param_key];
+ params.erase(param_key);
+ break;
+ case abq_instance_part:
+ part_name = params[param_key];
+ params.erase(param_key);
+ break;
+ default:
+ // std::cout << "Missing required INSTANCE parameter " << (*thisParam).first << std::endl;
+ return MB_FAILURE;
+ }
+ }
+ // std::cout << "\tAdding INSTANCE with name: " << instance_name << " of PART wit name: " << part_name << std::endl; // REMOVE
+
+ // process parameters
+ for (std::map<std::string,std::string>::iterator thisParam=params.begin();
+ thisParam != params.end();
+ thisParam++)
+ {
+ // look for unambiguous match with this node parameter
+ param = allowableParams[match( (*thisParam).first, allowableParams )];
+ switch (param)
+ {
+ case abq_instance_ambiguous:
+ // std::cout << "\t\tIgnoring ambiguous INSTANCE parameter: " << (*thisParam).first
+ // << "=" << (*thisParam).second << std::endl;
+ break;
+ default:
+ // std::cout << "\t\tIgnoring unsupported INSTANCE parameter: " << (*thisParam).first
+ // << "=" << (*thisParam).second << std::endl;
+ break;
+ }
+ }
+
+
+ next_line_type = get_next_line_type();
+
+ bool read_translation = false;
+ bool read_rotation = false;
+ std::vector<double> translation(3,0);
+ std::vector<double> rotation(7,0);
+ bool end_instance = false;
+ bool in_unsupported = false;
+
+ while (next_line_type != abq_eof && !end_instance)
+ {
+ switch(next_line_type)
+ {
+ case abq_keyword_line:
+ in_unsupported=false;
+ switch(get_keyword())
+ {
+ case abq_end_instance:
+ end_instance = true;
+ break;
+ default:
+ in_unsupported = true;
+ // std::cout << "\t\tIgnoring unsupported keyword in this INSTANCE: "
+ // << readline << std::endl;
+ next_line_type = get_next_line_type();
+ break;
+ }
+ case abq_comment_line:
+ next_line_type = get_next_line_type();
+ break;
+ case abq_data_line:
+ if (!in_unsupported)
+ {
+ tokenize(readline,tokens,", \n");
+ if (!read_translation)
+ {
+ if (tokens.size() != 3)
+ {
+ std::cerr << "Wrong number of entries on INSTANCE translation line:"
+ << std::endl << readline << std::endl;
+ return MB_FAILURE;
+ }
+
+ for (unsigned int i=0;i<3;i++)
+ translation[i] = atof(tokens[i].c_str());
+
+ read_translation = true;
+ }
+ else
+ if (!read_rotation)
+ {
+ if (tokens.size() != 7)
+ {
+ std::cerr << "Wrong number of entries on INSTANCE rotation line:"
+ << std::endl << readline << std::endl;
+ return MB_FAILURE;
+ }
+ for (unsigned int i=0;i<7;i++)
+ rotation[i] = atof(tokens[i].c_str());
+
+ read_rotation = true;
+ }
+ else
+ {
+ std::cerr << "Too many data lines for this INSTANCE: " << instance_name << std::endl;
+ return MB_FAILURE;
+ }
+ }
+ next_line_type = get_next_line_type();
+ break;
+ case abq_blank_line:
+ std::cerr << "Error: Blank lines are not allowed." << std::endl;
+ return MB_FAILURE;
+ default:
+ std::cerr << "Error reading INSTANCE " << instance_name << std::endl;
+ return MB_FAILURE;
+
+ }
+
+ }
+
+ MBEntityHandle instance_set;
+
+ status = create_instance_of_part(file_set,assembly_set,part_name,
+ instance_name,instance_set,translation,rotation);
+ MB_RETURN_IF_FAIL;
+
+ return MB_SUCCESS;
+
+}
+
+
+MBErrorCode ReadABAQUS::read_part(MBEntityHandle file_set)
+{
+ MBErrorCode status = MB_SUCCESS;
+
+ std::vector<std::string> tokens;
+ std::map<std::string,std::string> params;
+ std::map<std::string,abaqus_part_params> requiredParams;
+ requiredParams["NAME"] = abq_part_name;
+
+ std::map<std::string,abaqus_part_params> allowableParams;
+ allowableParams[ABQ_AMBIGUOUS] = abq_part_ambiguous;
+
+ abaqus_part_params param;
+
+ std::string part_name;
+
+ // tokenize last line read
+ tokenize(readline,tokens,",\n");
+ extract_keyword_parameters(tokens,params);
+
+ // search for required parameters
+ for (std::map<std::string,abaqus_part_params>::iterator thisParam=requiredParams.begin();
+ thisParam != requiredParams.end();
+ thisParam++)
+ {
+ std::string param_key = match( (*thisParam).first,params );
+ param = requiredParams[param_key];
+ switch (param)
+ {
+ case abq_part_name:
+ part_name = params[param_key];
+ params.erase(param_key);
+ // std::cout << "Adding PART with name: " << part_name << std::endl; // REMOVE
+ break;
+ default:
+ std::cerr << "Missing required PART parameter " << (*thisParam).first << std::endl;
+ return MB_FAILURE;
+ }
+ }
+
+ // process parameters
+ for (std::map<std::string,std::string>::iterator thisParam=params.begin();
+ thisParam != params.end();
+ thisParam++)
+ {
+ // look for unambiguous match with this node parameter
+ param = allowableParams[match( (*thisParam).first, allowableParams )];
+ switch (param)
+ {
+ case abq_part_ambiguous:
+ // std::cout << "\tIgnoring ambiguous PART parameter: " << (*thisParam).first
+ // << "=" << (*thisParam).second << std::endl;
+ break;
+ default:
+ // std::cout << "\tIgnoring unsupported PART parameter: " << (*thisParam).first
+ // << "=" << (*thisParam).second << std::endl;
+ break;
+ }
+ }
+
+
+ MBEntityHandle part_set;
+
+ status = add_entity_set(file_set,ABQ_PART_SET,part_name,part_set);
+
+ next_line_type = get_next_line_type();
+
+ bool end_part = false;
+ bool in_unsupported = false;
+
+ while (next_line_type != abq_eof && !end_part)
+ {
+ switch(next_line_type)
+ {
+ case abq_keyword_line:
+ in_unsupported=false;
+ switch(get_keyword())
+ {
+ case abq_end_part:
+ end_part = true;
+ break;
+ case abq_node:
+ status = read_node_list(part_set);
+ break;
+ case abq_element:
+ status = read_element_list(part_set);
+ break;
+ case abq_nset:
+ status = read_node_set(part_set);
+ break;
+ case abq_elset:
+ status = read_element_set(part_set);
+ break;
+ case abq_solid_section:
+ status = read_solid_section(part_set);
+ break;
+ default:
+ in_unsupported = true;
+ // std::cout << "\tIgnoring unsupported keyword in this PART: "
+ // << readline << std::endl;
+ next_line_type = get_next_line_type();
+ break;
+ }
+ MB_RETURN_IF_FAIL;
+ break;
+ case abq_comment_line:
+ next_line_type = get_next_line_type();
+ break;
+ case abq_data_line:
+ if (!in_unsupported)
+ {
+ std::cerr << "Internal Error: Data lines not allowed in PART keyword."
+ << std::endl << readline << std::endl;
+ return MB_FAILURE;
+ }
+ next_line_type = get_next_line_type();
+ break;
+ case abq_blank_line:
+ std::cerr << "Error: Blank lines are not allowed." << std::endl;
+ return MB_FAILURE;
+ default:
+ std::cerr << "Error reading PART " << part_name << std::endl;
+ return MB_FAILURE;
+
+ }
+ }
+
+ num_part_instances[part_set] = 0;
+
+ return MB_SUCCESS;
+}
+
+MBErrorCode ReadABAQUS::read_solid_section(MBEntityHandle parent_set)
+{
+ MBErrorCode status;
+
+ std::vector<std::string> tokens;
+ std::map<std::string,std::string> params;
+ std::map<std::string,abaqus_solid_section_params> requiredParams;
+ requiredParams["ELSET"] = abq_solid_section_elset;
+ requiredParams["MATERIAL"] = abq_solid_section_matname;
+
+ std::map<std::string,abaqus_solid_section_params> allowableParams;
+ allowableParams[ABQ_AMBIGUOUS] = abq_solid_section_ambiguous;
+
+ abaqus_solid_section_params param;
+
+ // tokenize last line read
+ tokenize(readline,tokens,",\n");
+ extract_keyword_parameters(tokens,params);
+
+ std::string elset_name,mat_name;
+
+ // search for required parameters
+ for (std::map<std::string,abaqus_solid_section_params>::iterator thisParam=requiredParams.begin();
+ thisParam != requiredParams.end();
+ thisParam++)
+ {
+ std::string param_key = match( (*thisParam).first,params );
+ param = requiredParams[param_key];
+ switch (param)
+ {
+ case abq_solid_section_elset:
+ elset_name = params[param_key];
+ params.erase(param_key);
+ break;
+ case abq_solid_section_matname:
+ mat_name = params[param_key];
+ params.erase(param_key);
+ break;
+ default:
+ std::cerr << "Missing required SOLID SECTION parameter " << (*thisParam).first << std::endl;
+ return MB_FAILURE;
+ }
+ }
+ // std::cout << "\tAdding SOLID SECTION with to ELEMENT SET: " << elset_name << " with material: " << mat_name << std::endl; // REMOVE
+
+ // process parameters
+ for (std::map<std::string,std::string>::iterator thisParam=params.begin();
+ thisParam != params.end();
+ thisParam++)
+ {
+ // look for unambiguous match with this node parameter
+ param = allowableParams[match( (*thisParam).first, allowableParams )];
+ switch (param)
+ {
+ case abq_solid_section_ambiguous:
+ // std::cout << "\t\tIgnoring ambiguous SOLID_SECTION parameter: " << (*thisParam).first
+ // << "=" << (*thisParam).second << std::endl;
+ break;
+ default:
+ // std::cout << "\t\tIgnoring unsupported SOLID_SECTION parameter: " << (*thisParam).first
+ // << "=" << (*thisParam).second << std::endl;
+ break;
+ }
+ }
+
+ MBEntityHandle set_handle;
+ status = get_set_by_name(parent_set,ABQ_ELEMENT_SET,elset_name,set_handle);
+
+ status = mdbImpl->tag_set_data(mMatNameTag,&set_handle,1,mat_name.c_str());
+ MB_RETURN_IF_FAIL;
+
+ if (0 == matIDmap[mat_name])
+ matIDmap[mat_name] = ++mat_id;
+
+ status = mdbImpl->tag_set_data(mMaterialSetTag,&set_handle,1,&(matIDmap[mat_name]));
+ MB_RETURN_IF_FAIL;
+
+ next_line_type = get_next_line_type();
+
+ while (next_line_type != abq_eof &&
+ next_line_type != abq_keyword_line)
+ next_line_type = get_next_line_type();
+
+ return MB_SUCCESS;
+
+}
+
+MBErrorCode ReadABAQUS::read_element_set(MBEntityHandle parent_set, MBEntityHandle file_set, MBEntityHandle assembly_set)
+{
+ MBErrorCode status;
+
+ std::vector<std::string> tokens;
+ std::map<std::string,std::string> params;
+ std::map<std::string,abaqus_elset_params> requiredParams;
+ requiredParams["ELSET"] = abq_elset_elset;
+
+ std::map<std::string,abaqus_elset_params> allowableParams;
+ allowableParams[ABQ_AMBIGUOUS] = abq_elset_ambiguous;
+ allowableParams["GENERATE"] = abq_elset_generate;
+ allowableParams["INSTANCE"] = abq_elset_instance;
+
+ abaqus_elset_params param;
+
+ std::string elset_name;
+ bool generate_elset = false;
+ std::string instance_name;
+ MBEntityHandle element_container_set = parent_set;
+
+ // tokenize last line read
+ tokenize(readline,tokens,",\n");
+ extract_keyword_parameters(tokens,params);
+
+ MBRange element_range;
+
+ // search for required parameters
+ for (std::map<std::string,abaqus_elset_params>::iterator thisParam=requiredParams.begin();
+ thisParam != requiredParams.end();
+ thisParam++)
+ {
+ std::string param_key = match( (*thisParam).first,params );
+ param = requiredParams[param_key];
+ switch (param)
+ {
+ case abq_elset_elset:
+ elset_name = params[param_key];
+ params.erase(param_key);
+ // std::cout << "\tAdding ELSET with name: " << elset_name << std::endl; // REMOVE
+ break;
+ default:
+ std::cerr << "Missing required ELSET parameter " << (*thisParam).first << std::endl;
+ return MB_FAILURE;
+ }
+ }
+
+ // process parameters
+ for (std::map<std::string,std::string>::iterator thisParam=params.begin();
+ thisParam != params.end();
+ thisParam++)
+ {
+ // look for unambiguous match with this node parameter
+ param = allowableParams[match( (*thisParam).first, allowableParams )];
+ switch (param)
+ {
+ case abq_elset_generate:
+ generate_elset = true;
+ break;
+ case abq_elset_instance:
+ instance_name = (*thisParam).second;
+ status = get_set_by_name(parent_set,ABQ_INSTANCE_SET,instance_name,element_container_set);
+ MB_RETURN_IF_FAIL;
+ break;
+ case abq_elset_ambiguous:
+ // std::cout << "\t\tIgnoring ambiguous ELSET parameter: " << (*thisParam).first
+ // << "=" << (*thisParam).second << std::endl;
+ break;
+ default:
+ // std::cout << "\t\tIgnoring unsupported ELSET parameter: " << (*thisParam).first
+ // << "=" << (*thisParam).second << std::endl;
+ break;
+ }
+ }
+
+
+ std::vector<int> element_list;
+ MBRange tmp_element_range;
+
+ next_line_type = get_next_line_type();
+
+ while (next_line_type != abq_eof &&
+ next_line_type != abq_keyword_line)
+ {
+ if (abq_data_line == next_line_type)
+ {
+ tokenize(readline,tokens,", \n");
+ if (generate_elset)
+ {
+ if (tokens.size() != 3)
+ {
+ std::cerr << "Wrong number (" << tokens.size() << ") of entries on GENERATE element set data line:"
+ << std::endl << readline << std::endl;
+ return MB_FAILURE;
+ }
+ int e1 = atoi(tokens[0].c_str());
+ int e2 = atoi(tokens[1].c_str());
+ int incr = atoi(tokens[2].c_str());
+ if ( ( (e2-e1)%incr ) != 0)
+ {
+ std::cerr << "Invalid data on GENERATE element set data line:"
+ << std::endl << readline << std::endl;
+ return MB_FAILURE;
+ }
+ for (int element_id=e1; element_id<=e2;element_id+=incr)
+ element_list.push_back(element_id);
+ }
+ else
+ for (unsigned int idx=0;idx<tokens.size();idx++)
+ if(isalpha(tokens[idx][0]))
+ {
+ tmp_element_range.clear();
+ status = get_set_elements_by_name(element_container_set,ABQ_ELEMENT_SET,tokens[idx],tmp_element_range);
+ MB_RETURN_IF_FAIL;
+
+ element_range.merge(tmp_element_range);
+ }
+ else
+ element_list.push_back(atoi(tokens[idx].c_str()));
+ }
+
+ next_line_type = get_next_line_type();
+ }
+
+ tmp_element_range.clear();
+ status = get_elements_by_id(element_container_set,element_list,tmp_element_range);
+ MB_RETURN_IF_FAIL;
+
+ element_range.merge(tmp_element_range);
+
+ MBEntityHandle element_set;
+
+ status = add_entity_set(parent_set,ABQ_ELEMENT_SET,elset_name,element_set);
+ MB_RETURN_IF_FAIL;
+
+ status = mdbImpl->add_entities(element_set,element_range);
+ MB_RETURN_IF_FAIL;
+
+ // SHOULD WE EVER DO THIS???
+ if (file_set)
+ {
+ status = mdbImpl->add_entities(file_set,&element_set,1);
+ MB_RETURN_IF_FAIL;
+ }
+
+ // SHOULD WE EVER DO THIS???
+ if (assembly_set)
+ {
+ status = mdbImpl->add_entities(assembly_set,&element_set,1);
+ MB_RETURN_IF_FAIL;
+
+ status = mdbImpl->tag_set_data(mAssemblyHandleTag,&element_set,1,&assembly_set);
+ MB_RETURN_IF_FAIL;
+ }
+
+ return MB_SUCCESS;
+
+}
+
+
+
+MBErrorCode ReadABAQUS::read_node_set(MBEntityHandle parent_set,MBEntityHandle file_set, MBEntityHandle assembly_set)
+{
+ MBErrorCode status;
+
+ std::vector<std::string> tokens;
+ std::map<std::string,std::string> params;
+ std::map<std::string,abaqus_nset_params> requiredParams;
+ requiredParams["NSET"] = abq_nset_nset;
+
+ std::map<std::string,abaqus_nset_params> allowableParams;
+ allowableParams[ABQ_AMBIGUOUS] = abq_nset_ambiguous;
+ allowableParams["ELSET"] = abq_nset_elset;
+ allowableParams["GENERATE"] = abq_nset_generate;
+ allowableParams["INSTANCE"] = abq_nset_instance;
+
+ abaqus_nset_params param;
+
+ std::string nset_name;
+ bool make_from_elset = false;
+ bool generate_nset = false;
+ std::string elset_name, instance_name;
+ MBEntityHandle node_container_set = parent_set;
+
+ // tokenize last line read
+ tokenize(readline,tokens,",\n");
+ extract_keyword_parameters(tokens,params);
+
+ MBRange node_range;
+
+ // search for required parameters
+ for (std::map<std::string,abaqus_nset_params>::iterator thisParam=requiredParams.begin();
+ thisParam != requiredParams.end();
+ thisParam++)
+ {
+ std::string param_key = match( (*thisParam).first,params );
+ param = requiredParams[param_key];
+ switch (param)
+ {
+ case abq_nset_nset:
+ nset_name = params[param_key];
+ params.erase(param_key);
+ // std::cout << "\tAdding NSET with name: " << nset_name << std::endl; // REMOVE
+ break;
+ default:
+ std::cerr << "Missing required NSET parameter " << (*thisParam).first << std::endl;
+ return MB_FAILURE;
+ }
+ }
+
+ // process parameters
+ for (std::map<std::string,std::string>::iterator thisParam=params.begin();
+ thisParam != params.end();
+ thisParam++)
+ {
+ // look for unambiguous match with this node parameter
+ param = allowableParams[match( (*thisParam).first, allowableParams )];
+ switch (param)
+ {
+ case abq_nset_elset:
+ make_from_elset = true;
+ elset_name = (*thisParam).second;
+ break;
+ case abq_nset_generate:
+ generate_nset = true;
+ break;
+ case abq_nset_instance:
+ instance_name = (*thisParam).second;
+ status = get_set_by_name(parent_set, ABQ_INSTANCE_SET, instance_name,node_container_set);
+ MB_RETURN_IF_FAIL;
+ break;
+ case abq_nset_ambiguous:
+ // std::cout << "\t\tIgnoring ambiguous NSET parameter: " << (*thisParam).first
+ // << "=" << (*thisParam).second << std::endl;
+ break;
+ default:
+ // std::cout << "\t\tIgnoring unsupported NSET parameter: " << (*thisParam).first
+ // << "=" << (*thisParam).second << std::endl;
+ break;
+ }
+ }
+
+ if (make_from_elset && generate_nset)
+ {
+ std::cerr << "Incompatible NSET parameters ELSET & GENERATE " << std::endl;
+ return MB_FAILURE;
+ }
+
+ if (make_from_elset)
+ {
+ status = get_set_nodes(parent_set,ABQ_ELEMENT_SET,elset_name,node_range);
+ MB_RETURN_IF_FAIL;
+ }
+ else
+ {
+ std::vector<int> node_list;
+ MBRange tmp_node_range;
+
+ next_line_type = get_next_line_type();
+
+ while (next_line_type != abq_eof &&
+ next_line_type != abq_keyword_line)
+ {
+ if (abq_data_line == next_line_type)
+ {
+ tokenize(readline,tokens,", \n");
+ if (generate_nset)
+ {
+ if (tokens.size() != 3)
+ {
+ std::cerr << "Wrong number of entries on GENERATE node set data line:"
+ << std::endl << readline << std::endl;
+ return MB_FAILURE;
+ }
+ int n1 = atoi(tokens[0].c_str());
+ int n2 = atoi(tokens[1].c_str());
+ int incr = atoi(tokens[2].c_str());
+ if ( ( (n2-n1) % incr ) != 0)
+ {
+ std::cerr << "Invalid data on GENERATE node set data line:"
+ << std::endl << readline << std::endl;
+ return MB_FAILURE;
+ }
+ for (int node_id=n1; node_id<=n2;node_id+=incr)
+ node_list.push_back(node_id);
+ }
+ else
+ for (unsigned int idx=0;idx<tokens.size();idx++)
+ if(isalpha(tokens[idx][0]))
+ {
+ tmp_node_range.clear();
+ status = get_set_nodes(parent_set,ABQ_NODE_SET,tokens[idx],tmp_node_range);
+ MB_RETURN_IF_FAIL;
+
+ node_range.merge(tmp_node_range);
+ }
+ else
+ node_list.push_back(atoi(tokens[idx].c_str()));
+ }
+
+ next_line_type = get_next_line_type();
+ }
+
+ tmp_node_range.clear();
+
+ status = get_nodes_by_id(node_container_set,node_list,tmp_node_range);
+ MB_RETURN_IF_FAIL;
+
+ node_range.merge(tmp_node_range);
+
+ }
+
+ MBEntityHandle node_set;
+
+ status = add_entity_set(parent_set,ABQ_NODE_SET,nset_name,node_set);
+ MB_RETURN_IF_FAIL;
+
+ status = mdbImpl->add_entities(node_set,node_range);
+ MB_RETURN_IF_FAIL;
+
+ if (file_set)
+ {
+ status = mdbImpl->add_entities(file_set,&node_set,1);
+ MB_RETURN_IF_FAIL;
+ }
+
+ if (assembly_set)
+ {
+ status = mdbImpl->add_entities(assembly_set,&node_set,1);
+ MB_RETURN_IF_FAIL;
+
+ status = mdbImpl->tag_set_data(mAssemblyHandleTag,&node_set,1,&assembly_set);
+ MB_RETURN_IF_FAIL;
+ }
+
+ return MB_SUCCESS;
+
+}
+
+MBErrorCode ReadABAQUS::read_element_list(MBEntityHandle parent_set)
+{
+ MBErrorCode status;
+
+ std::vector<std::string> tokens;
+ std::map<std::string,std::string> params;
+ std::map<std::string,abaqus_element_params> requiredParams;
+ requiredParams["TYPE"] = abq_element_type;
+
+ std::map<std::string,abaqus_element_params> allowableParams;
+ allowableParams[ABQ_AMBIGUOUS] = abq_element_ambiguous;
+ allowableParams["ELSET"] = abq_element_elset;
+
+ abaqus_element_params param;
+
+ std::map<std::string,abaqus_element_type> elementTypes;
+ std::map<abaqus_element_type,unsigned int> nodes_per_element;
+ std::map<abaqus_element_type,MBEntityType> entityTypeMap;
+ elementTypes["DC3D8"] = abq_eletype_dc3d8;
+ nodes_per_element[abq_eletype_dc3d8] = 8;
+ entityTypeMap[abq_eletype_dc3d8] = MBHEX;
+
+ elementTypes["DCC3D8"] = abq_eletype_dcc3d8;
+ nodes_per_element[abq_eletype_dcc3d8] = 8;
+ entityTypeMap[abq_eletype_dcc3d8] = MBHEX;
+
+ elementTypes["C3D4"] = abq_eletype_c3d4;
+ nodes_per_element[abq_eletype_c3d4] = 4;
+ entityTypeMap[abq_eletype_c3d4] = MBTET;
+
+ elementTypes["C3D8R"] = abq_eletype_c3d8r;
+ nodes_per_element[abq_eletype_c3d8r] = 8;
+ entityTypeMap[abq_eletype_c3d8r] = MBHEX;
+
+ elementTypes["DS4"] = abq_eletype_ds4;
+ nodes_per_element[abq_eletype_ds4] = 4;
+ entityTypeMap[abq_eletype_ds4] = MBQUAD;
+
+ abaqus_element_type element_type;
+
+ bool make_element_set = false;
+ std::string element_set_name;
+
+ // tokenize last line read
+ tokenize(readline,tokens,",\n");
+ extract_keyword_parameters(tokens,params);
+
+ // search for required parameters
+ for (std::map<std::string,abaqus_element_params>::iterator thisParam=requiredParams.begin();
+ thisParam != requiredParams.end();
+ thisParam++)
+ {
+ std::string param_key = match( (*thisParam).first,params );
+ param = requiredParams[param_key];
+ switch (param)
+ {
+ case abq_element_type:
+ element_type = elementTypes[ params[param_key]];
+ if (abq_eletype_unsupported == element_type)
+ {
+ std::cerr << "MOAB doesn't currently support this element type: "
+ << (*thisParam).second << std::endl;
+ return MB_FAILURE;
+ }
+ // std::cout << "\tAdding ELEMENTS of type: " << params[param_key] << std::endl; // REMOVE
+ params.erase(param_key);
+ break;
+ case abq_element_undefined:
+ std::cerr << "Missing required ELEMENT parameter " << (*thisParam).first << std::endl
+ << readline << std::endl;
+ return MB_FAILURE;
+ default:
+ break;
+ }
+ }
+
+ // process parameters
+ for (std::map<std::string,std::string>::iterator thisParam=params.begin();
+ thisParam != params.end();
+ thisParam++)
+ {
+ // look for unambiguous match with this node parameter
+ param = allowableParams[match( (*thisParam).first, allowableParams )];
+ switch (param)
+ {
+ case abq_element_elset:
+ make_element_set = true;
+ element_set_name = (*thisParam).second;
+ break;
+ case abq_element_ambiguous:
+ // std::cout << "\t\tIgnoring ambiguous ELEMENT parameter: " << (*thisParam).first
+ // << "=" << (*thisParam).second << std::endl;
+ break;
+ default:
+ // std::cout << "\t\tIgnoring unsupported ELEMENT parameter: " << (*thisParam).first
+ // << "=" << (*thisParam).second << std::endl;
+ break;
+ }
+ }
+
+ std::vector<int> connect_list, element_ids;
+
+ next_line_type = get_next_line_type();
+
+ while (next_line_type != abq_eof &&
+ next_line_type != abq_keyword_line)
+ {
+ if (abq_data_line == next_line_type)
+ {
+ tokenize(readline,tokens,", \n");
+ if (tokens.size() < nodes_per_element[element_type]+1)
+ {
+ std::cerr << "Not enough data on node data line:"
+ << std::endl << readline << std::endl;
+ return MB_FAILURE;
+ }
+ element_ids.push_back(atoi(tokens[0].c_str()));
+ for (unsigned int i=1;i<nodes_per_element[element_type]+1;i++)
+ connect_list.push_back(atoi(tokens[i].c_str()));
+ }
+ next_line_type = get_next_line_type();
+ }
+
+ int num_elements = element_ids.size();
+
+ // get and fill element arrays
+ MBEntityHandle start_element = 0;
+ MBEntityHandle *connect;
+
+ status = readMeshIface->get_element_array( num_elements, nodes_per_element[element_type],
+ entityTypeMap[element_type], MB_START_ID,
+ start_element, connect);
+ MB_RETURN_IF_FAIL;
+ if (0 == start_element) return MB_FAILURE;
+
+ // ASSUME: elements must be defined after nodes!
+ // get list of node entity handles and node IDs
+ MBRange node_list;
+ status = mdbImpl->get_entities_by_dimension(parent_set, 0, node_list);
+ MB_RETURN_IF_FAIL;
+
+ std::vector<int> node_ids(node_list.size());
+ status = mdbImpl->tag_get_data(mLocalIDTag,node_list,&node_ids[0]);
+ MB_RETURN_IF_FAIL;
+
+ std::map<int,MBEntityHandle> nodeIdMap;
+ for (unsigned int idx=0;idx<node_list.size();idx++)
+ nodeIdMap[node_ids[idx]] = node_list[idx];
+
+ for (unsigned int node=0;node<connect_list.size();node++)
+ connect[node] = nodeIdMap[connect_list[node]];
+
+ MBRange element_range(start_element, start_element+num_elements-1);
+
+ // add elements to file_set
+ // status = mdbImpl->add_entities(file_set,element_range);
+ // MB_RETURN_IF_FAIL;
+
+ // add elements to this parent_set
+ status = mdbImpl->add_entities(parent_set,element_range);
+ MB_RETURN_IF_FAIL;
+
+ // tag elements with their local ID's
+ status = mdbImpl->tag_set_data(mLocalIDTag,element_range,&element_ids[0]);
+ MB_RETURN_IF_FAIL;
+
+ // these elements don't know their instance_set (probably not defined)
+
+ if (make_element_set)
+ {
+ MBEntityHandle element_set;
+
+ status = add_entity_set(parent_set,ABQ_ELEMENT_SET,element_set_name,element_set);
+ MB_RETURN_IF_FAIL;
+
+ status = mdbImpl->add_entities(element_set,element_range);
+ MB_RETURN_IF_FAIL;
+
+ // this ad-hoc element set doesn't know its:
+ // * part_set (probably parent_set)
+ // * instance_set (probably not defined)
+ // * assembly_set (probably not defined)
+
+ }
+
+ return MB_SUCCESS;
+
+
+}
+
+MBErrorCode ReadABAQUS::read_node_list(MBEntityHandle parent_set)
+{
+ MBErrorCode status;
+
+ std::vector<std::string> tokens;
+ std::map<std::string,std::string> params;
+ std::map<std::string,abaqus_node_params> allowableParams;
+
+ allowableParams[ABQ_AMBIGUOUS] = abq_node_ambiguous;
+ allowableParams["NSET"] = abq_node_nset;
+ allowableParams["SYSTEM"] = abq_node_system;
+
+ abaqus_node_params param;
+
+ bool make_node_set = false;
+ std::string node_set_name;
+
+ char coord_system = 'R';
+
+ // tokenize last line read
+ tokenize(readline,tokens,",\n");
+ extract_keyword_parameters(tokens,params);
+
+ // std::cout << "\tAdding NODES" << std::endl; // REMOVE
+
+
+ // process parameters
+ for (std::map<std::string,std::string>::iterator thisParam=params.begin();
+ thisParam != params.end();
+ thisParam++)
+ {
+ // look for unambiguous match with this node parameter
+ param = allowableParams[match( (*thisParam).first, allowableParams )];
+ switch (param)
+ {
+ case abq_node_nset:
+ make_node_set = true;
+ node_set_name = (*thisParam).second;
+ break;
+ case abq_node_system:
+ // store coordinate system
+ coord_system = (*thisParam).second[0];
+ break;
+ case abq_node_ambiguous:
+ // std::cout << "\t\tIgnoring ambiguous NODE parameter: " << (*thisParam).first
+ // << "=" << (*thisParam).second << std::endl;
+ break;
+ default:
+ // std::cout << "\t\tIgnoring unsupported NODE parameter: " << (*thisParam).first
+ // << "=" << (*thisParam).second << std::endl;
+ break;
+ }
+ }
+
+ std::vector<double> coord_list;
+ std::vector<int> node_ids;
+
+ next_line_type = get_next_line_type();
+
+ while (next_line_type != abq_eof &&
+ next_line_type != abq_keyword_line)
+ {
+ if (abq_data_line == next_line_type)
+ {
+ tokenize(readline,tokens,", \n");
+ if (tokens.size() < 4)
+ {
+ std::cerr << "Not enough data on node data line:"
+ << std::endl << readline << std::endl;
+ return MB_FAILURE;
+ }
+ node_ids.push_back(atoi(tokens[0].c_str()));
+ for (unsigned int i=1;i<4;i++)
+ coord_list.push_back(atof(tokens[i].c_str()));
+ }
+ next_line_type = get_next_line_type();
+ }
+
+ unsigned int num_nodes = node_ids.size();
+
+ // transform coordinate systems
+ switch (coord_system)
+ {
+ case 'R':
+ break;
+ case 'C':
+ cyl2rect(coord_list);
+ break;
+ case 'S':
+ sph2rect(coord_list);
+ break;
+ default:
+ // std::cout << "Treating undefined coordinate system: " << coord_system
+ // << " as rectangular/Cartesian." << std::endl;
+ break;
+ }
+
+ // get and fill coordinate arrays
+ std::vector<double*> coord_arrays(3);
+ MBEntityHandle start_node = 0;
+ status = readMeshIface->get_node_arrays(3, num_nodes,MB_START_ID,
+ start_node,coord_arrays);
+ MB_RETURN_IF_FAIL;
+
+ if (0 == start_node) return MB_FAILURE;
+
+ for (unsigned int idx=0;idx<num_nodes;idx++)
+ {
+ coord_arrays[0][idx] = coord_list[idx*3];
+ coord_arrays[1][idx] = coord_list[idx*3+1];
+ coord_arrays[2][idx] = coord_list[idx*3+2];
+ }
+
+ MBRange node_range(start_node, start_node+num_nodes-1);
+ // add nodes to file_set
+ // status = mdbImpl->add_entities(file_set,node_range);
+ // MB_RETURN_IF_FAIL;
+
+ // add nodes to this parent_set
+ status = mdbImpl->add_entities(parent_set,node_range);
+ MB_RETURN_IF_FAIL;
+
+ // tag nodes with their local ID's
+ status = mdbImpl->tag_set_data(mLocalIDTag,node_range,&node_ids[0]);
+ MB_RETURN_IF_FAIL;
+
+ // these nodes don't know their instance_set (probably not defined)
+
+ if (make_node_set)
+ {
+ MBEntityHandle node_set;
+
+ status = add_entity_set(parent_set,ABQ_NODE_SET,node_set_name,node_set);
+ MB_RETURN_IF_FAIL;
+
+ status = mdbImpl->add_entities(node_set,node_range);
+ MB_RETURN_IF_FAIL;
+
+ // this ad-hoc node set doesn't know its:
+ // * part_set (probably parent_set)
+ // * instance_set (probably not defined)
+ // * assembly_set (probably not defined)
+
+ }
+
+ return MB_SUCCESS;
+}
+
+// SET CREATION & ACCESS UTILITIES
+
+MBErrorCode ReadABAQUS::get_elements_by_id(MBEntityHandle parent_set,
+ std::vector<int> element_ids_subset,
+ MBRange &element_range)
+{
+ MBErrorCode status;
+ MBRange all_elements;
+
+ status = get_set_elements(parent_set,all_elements);
+ MB_RETURN_IF_FAIL;
+
+ std::vector<int> element_ids(all_elements.size());
+ status = mdbImpl->tag_get_data(mLocalIDTag,all_elements,&element_ids[0]);
+ MB_RETURN_IF_FAIL;
+
+ std::map<int,MBEntityHandle> elementIdMap;
+ for (unsigned int idx=0;idx<all_elements.size();idx++)
+ elementIdMap[element_ids[idx]] = all_elements[idx];
+
+ for (std::vector<int>::iterator element=element_ids_subset.begin();
+ element != element_ids_subset.end();
+ element++)
+ element_range.insert(elementIdMap[*element]);
+
+ return MB_SUCCESS;
+
+}
+MBErrorCode ReadABAQUS::get_nodes_by_id(MBEntityHandle parent_set,
+ std::vector<int> node_ids_subset,
+ MBRange &node_range)
+{
+ MBErrorCode status;
+
+ MBRange all_nodes;
+ status = mdbImpl->get_entities_by_type(parent_set,MBVERTEX,all_nodes);
+ MB_RETURN_IF_FAIL;
+
+ std::vector<int> node_ids(all_nodes.size());
+ status = mdbImpl->tag_get_data(mLocalIDTag,all_nodes,&node_ids[0]);
+ MB_RETURN_IF_FAIL;
+
+ std::map<int,MBEntityHandle> nodeIdMap;
+ for (unsigned int idx=0;idx<all_nodes.size();idx++)
+ nodeIdMap[node_ids[idx]] = all_nodes[idx];
+
+ for (std::vector<int>::iterator node=node_ids_subset.begin();
+ node != node_ids_subset.end();
+ node++)
+ {
+ node_range.insert(nodeIdMap[*node]);
+ }
+
+ return MB_SUCCESS;
+
+}
+
+
+MBErrorCode ReadABAQUS::get_set_by_name(MBEntityHandle parent_set,
+ int ABQ_set_type,
+ std::string set_name,
+ MBEntityHandle &set_handle)
+{
+ MBErrorCode status;
+
+ char this_set_name[ABAQUS_SET_NAME_LENGTH];
+
+ set_handle = 0;
+
+ MBRange sets;
+ void* tag_data[] = {&ABQ_set_type};
+ status = mdbImpl->get_entities_by_type_and_tag(parent_set,
+ MBENTITYSET,
+ &mSetTypeTag,
+ tag_data, 1, sets);
+ if (MB_SUCCESS != status)
+ {
+ std::cerr << "Did not find any sets of that type" << std::endl;
+ return status;
+ }
+
+ for (MBRange::iterator this_set=sets.begin();
+ this_set != sets.end() && 0 == set_handle;
+ this_set++)
+ {
+ std::fill(this_set_name,this_set_name+ABAQUS_SET_NAME_LENGTH,'\0');
+ status = mdbImpl->tag_get_data(mSetNameTag, &(*this_set), 1, &this_set_name[0]);
+ if (MB_SUCCESS != status && MB_TAG_NOT_FOUND != status) return status;
+
+ if (set_name == std::string(this_set_name))
+ set_handle = *this_set;
+ }
+
+ if (0 == set_handle)
+ {
+ std::cerr << "Did not find requested set: " << set_name
+ << std::endl;
+ return MB_FAILURE;
+ }
+
+ return MB_SUCCESS;
+}
+
+MBErrorCode ReadABAQUS::get_set_elements(MBEntityHandle set_handle,
+ MBRange &element_range)
+{
+ MBErrorCode status;
+
+ MBRange dim_ent_list;
+
+ // could have elements of multiple dimensions in this set???
+ for (int dim=1;dim<=3;dim++)
+ {
+ dim_ent_list.clear();
+ status = mdbImpl->get_entities_by_dimension(set_handle,dim,dim_ent_list);
+ MB_RETURN_IF_FAIL;
+
+ element_range.merge(dim_ent_list);
+ }
+
+ return MB_SUCCESS;
+}
+
+MBErrorCode ReadABAQUS::get_set_elements_by_name(MBEntityHandle parent_set,
+ int ABQ_set_type,
+ std::string set_name,
+ MBRange &element_range)
+{
+ MBErrorCode status;
+
+ MBEntityHandle set_handle;
+ status = get_set_by_name(parent_set,ABQ_set_type,set_name,set_handle);
+ MB_RETURN_IF_FAIL;
+
+ status = get_set_elements(set_handle,element_range);
+ MB_RETURN_IF_FAIL;
+
+ if (element_range.size() == 0)
+ {
+ //std::cout << "No elements were found in set " << set_name << std::endl;
+ }
+
+ return MB_SUCCESS;
+
+}
+
+
+MBErrorCode ReadABAQUS::get_set_nodes(MBEntityHandle parent_set,
+ int ABQ_set_type,
+ std::string set_name,
+ MBRange &node_range)
+{
+ MBErrorCode status;
+
+ MBEntityHandle set_handle;
+ status = get_set_by_name(parent_set,ABQ_set_type,set_name,set_handle);
+ MB_RETURN_IF_FAIL;
+
+ MBRange ent_list;
+ MBRange dim_ent_list;
+ // could have elements of multiple dimensions in this set???
+ for (int dim=0;dim<=3;dim++)
+ {
+ dim_ent_list.clear();
+ status = mdbImpl->get_entities_by_dimension(set_handle,dim,dim_ent_list);
+ MB_RETURN_IF_FAIL;
+
+ ent_list.merge(dim_ent_list);
+ }
+
+ status = mdbImpl->get_adjacencies(ent_list,0,false,node_range);
+ MB_RETURN_IF_FAIL;
+
+ if (node_range.size() == 0)
+ {
+ std::cout << "No nodes were found in set " << set_name << std::endl;
+ }
+
+ return MB_SUCCESS;
+}
+
+
+MBTag ReadABAQUS::get_tag(char* tag_name,
+ int tag_size,
+ MBTagType tag_type,
+ MBDataType tag_data_type)
+{
+ int def_val = 0;
+
+ return get_tag(tag_name,tag_size,tag_type,tag_data_type,&def_val);
+
+}
+
+MBTag ReadABAQUS::get_tag(char* tag_name,
+ int tag_size,
+ MBTagType tag_type,
+ MBDataType tag_data_type,
+ const void* def_val)
+{
+ MBTag retval;
+
+ if (MB_TAG_NOT_FOUND == mdbImpl->tag_get_handle(tag_name, retval) )
+ mdbImpl->tag_create(tag_name,tag_size,tag_type,tag_data_type,retval,def_val);
+
+ return retval;
+
+
+}
+
+MBErrorCode ReadABAQUS::create_instance_of_part(const MBEntityHandle file_set,
+ const MBEntityHandle assembly_set,
+ const std::string part_name,
+ const std::string instance_name,
+ MBEntityHandle &instance_set,
+ const std::vector<double> &translation,
+ const std::vector<double> &rotation)
+{
+ MBErrorCode status;
+
+ MBEntityHandle part_set;
+ status = get_set_by_name(file_set,ABQ_PART_SET,part_name,part_set);
+ MB_RETURN_IF_FAIL;
+
+ status = add_entity_set(assembly_set,ABQ_INSTANCE_SET,instance_name,instance_set);
+ MB_RETURN_IF_FAIL;
+
+ // cross-reference
+ status = mdbImpl->tag_set_data(mPartHandleTag,&instance_set,1,&part_set);
+ MB_RETURN_IF_FAIL;
+
+ int instance_id = ++num_part_instances[part_set];
+ status = mdbImpl->tag_set_data(mInstancePIDTag,&instance_set,1,&instance_id);
+ MB_RETURN_IF_FAIL;
+
+ status = mdbImpl->tag_set_data(mAssemblyHandleTag,&instance_set,1,&assembly_set);
+ MB_RETURN_IF_FAIL;
+
+ instance_id = ++num_assembly_instances[assembly_set];
+ status = mdbImpl->tag_set_data(mInstanceGIDTag,&instance_set,1,&instance_id);
+
+ // ---- NODES ----
+
+ // get all nodes and IDs
+ MBRange part_node_list;
+ status = mdbImpl->get_entities_by_dimension(part_set,0,part_node_list);
+ MB_RETURN_IF_FAIL;
+
+ std::vector<int> node_ids(part_node_list.size());
+ status = mdbImpl->tag_get_data(mLocalIDTag,part_node_list,&node_ids[0]);
+ MB_RETURN_IF_FAIL;
+
+ std::map<int,MBEntityHandle> nodeIdMap;
+ for (unsigned int idx=0;idx<part_node_list.size();idx++)
+ nodeIdMap[node_ids[idx]] = part_node_list[idx];
+
+ // create new nodes
+ std::vector<double*> coord_arrays(3);
+ MBEntityHandle start_node = 0;
+ status = readMeshIface->get_node_arrays(3, part_node_list.size(),MB_START_ID,
+ start_node,coord_arrays);
+ MB_RETURN_IF_FAIL;
+
+ if (0 == start_node) return MB_FAILURE;
+
+ // copy coordinates into new coord_arrays
+ status = mdbImpl->get_coords(part_node_list,coord_arrays[0],coord_arrays[1],coord_arrays[2]);
+
+ // rotate to new position
+ double rot_axis[3];
+ rot_axis[0] = rotation[3]-rotation[0];
+ rot_axis[1] = rotation[4]-rotation[1];
+ rot_axis[2] = rotation[5]-rotation[2];
+
+ MBAffineXform rotationXform;
+ if (rotation[6] != 0)
+ rotationXform = MBAffineXform::rotation(rotation[6]*DEG2RAD,rot_axis);
+
+ // translate to new position
+ for (unsigned int idx=0;idx<part_node_list.size();idx++)
+ {
+ double coords[3];
+
+ // transform to new location and then shift origin of rotation
+ for (unsigned int dim=0;dim<3;dim++)
+ coords[dim] = coord_arrays[dim][idx] + translation[dim] - rotation[dim];
+
+ // rotate around this origin
+ if (rotation[6] != 0)
+ rotationXform.xform_vector(coords);
+
+ // transform irigin of rotation back
+ for (unsigned int dim=0;dim<3;dim++)
+ coord_arrays[dim][idx] = coords[dim] + rotation[dim];
+
+ }
+
+ MBRange instance_node_list(start_node, start_node+part_node_list.size()-1);
+
+ // (DO NOT) add nodes to file_set
+ // status = mdbImpl->add_entities(file_set,instance_node_list);
+ // MB_RETURN_IF_FAIL;
+
+ // add nodes to this instance_set
+ status = mdbImpl->add_entities(instance_set,instance_node_list);
+ MB_RETURN_IF_FAIL;
+
+ // add nodes to this assembly_set
+ status = mdbImpl->add_entities(assembly_set,instance_node_list);
+ MB_RETURN_IF_FAIL;
+
+ // tag nodes with their local ID's
+ status = mdbImpl->tag_set_data(mLocalIDTag,instance_node_list,&node_ids[0]);
+ MB_RETURN_IF_FAIL;
+
+ // tag nodes with their instance handle
+ std::vector<MBEntityHandle> tmp_instance_handles;
+ tmp_instance_handles.assign(part_node_list.size(),instance_set);
+ status = mdbImpl->tag_set_data(mInstanceHandleTag,instance_node_list,&tmp_instance_handles[0]);
+ MB_RETURN_IF_FAIL;
+
+ // create a map of old handles to new handles!!!
+ std::map<MBEntityHandle,MBEntityHandle> p2i_nodes;
+ for (unsigned int idx=0;idx<part_node_list.size();idx++)
+ p2i_nodes[part_node_list[idx]]=instance_node_list[idx];
+
+ // ---- ELEMENTS ----
+
+ MBRange part_element_list;
+ status = get_set_elements(part_set,part_element_list);
+ MB_RETURN_IF_FAIL;
+
+ std::vector<int> part_element_ids(part_element_list.size());
+ status = mdbImpl->tag_get_data(mLocalIDTag,part_element_list,&part_element_ids[0]);
+ MB_RETURN_IF_FAIL;
+
+ std::map<int,MBEntityHandle> elementIdMap;
+ for (unsigned int idx=0;idx<part_element_list.size();idx++)
+ elementIdMap[part_element_ids[idx]] = part_element_list[idx];
+
+ // create new elements
+ MBRange instance_element_list;
+ instance_element_list.clear();
+
+ // cross-referencing storage and pointers/iterators
+ std::map<MBEntityHandle,MBEntityHandle> p2i_elements;
+ std::vector<int> instance_element_ids;
+ std::vector<int>::iterator part_element_id = part_element_ids.begin();
+
+ for (MBRange::iterator part_element=part_element_list.begin();
+ part_element != part_element_list.end();
+ part_element++,part_element_id++)
+ {
+ MBEntityType element_type = mdbImpl->type_from_handle(*part_element);
+ std::vector<MBEntityHandle> part_connectivity,instance_connectivity;
+ MBEntityHandle new_element;
+ status = mdbImpl->get_connectivity(&(*part_element),1,part_connectivity);
+ MB_RETURN_IF_FAIL;
+
+ instance_connectivity.clear();
+ for (std::vector<MBEntityHandle>::iterator connectivity_node=part_connectivity.begin();
+ connectivity_node != part_connectivity.end();
+ connectivity_node++)
+ instance_connectivity.push_back(p2i_nodes[*connectivity_node]);
+
+ status = mdbImpl->create_element(element_type,&instance_connectivity[0],instance_connectivity.size(),new_element);
+ MB_RETURN_IF_FAIL;
+
+ instance_element_list.insert(new_element);
+ p2i_elements[*part_element] = new_element;
+ instance_element_ids.push_back(*part_element_id);
+ }
+
+ // (DO NOT) add elements to file_set
+ // status = mdbImpl->add_entities(file_set,instance_element_list);
+ // MB_RETURN_IF_FAIL;
+
+ // add elements to this instance_set
+ status = mdbImpl->add_entities(instance_set,instance_element_list);
+ MB_RETURN_IF_FAIL;
+
+ // add elements to this assembly_set
+ status = mdbImpl->add_entities(assembly_set,instance_element_list);
+ MB_RETURN_IF_FAIL;
+
+ // tag elements with their local ID's
+ status = mdbImpl->tag_set_data(mLocalIDTag,instance_element_list,&(instance_element_ids[0]));
+ MB_RETURN_IF_FAIL;
+
+ // tag elements with their instance handle
+ tmp_instance_handles.assign(part_element_list.size(),instance_set);
+ status = mdbImpl->tag_set_data(mInstanceHandleTag,instance_element_list,&(tmp_instance_handles[0]));
+ MB_RETURN_IF_FAIL;
+
+ // ----- NODE SETS -----
+
+ // get all node sets in part
+ MBRange part_node_sets;
+ int tag_val = ABQ_NODE_SET;
+ void* tag_data[] = {&tag_val};
+ status = mdbImpl->get_entities_by_type_and_tag(part_set,
+ MBENTITYSET,
+ &mSetTypeTag,
+ tag_data, 1, part_node_sets);
+ MB_RETURN_IF_FAIL;
+
+ MBRange part_node_set_list, instance_node_set_list;
+ for (MBRange::iterator part_node_set = part_node_sets.begin();
+ part_node_set != part_node_sets.end();
+ part_node_set++)
+ {
+ char node_set_name[ABAQUS_SET_NAME_LENGTH];
+ std::fill(node_set_name,node_set_name+ABAQUS_SET_NAME_LENGTH,'\0');
+ status = mdbImpl->tag_get_data(mSetNameTag, &(*part_node_set), 1, &node_set_name[0]);
+ if (MB_SUCCESS != status && MB_TAG_NOT_FOUND != status) return status;
+
+ part_node_set_list.clear();
+ status = mdbImpl->get_entities_by_dimension(*part_node_set,0,part_node_set_list);
+
+ instance_node_set_list.clear();
+ for (MBRange::iterator set_node = part_node_set_list.begin();
+ set_node != part_node_set_list.end();
+ set_node++)
+ instance_node_set_list.insert(p2i_nodes[*set_node]);
+
+ MBEntityHandle instance_node_set;
+
+ status = add_entity_set(instance_set,ABQ_NODE_SET,node_set_name,instance_node_set);
+ MB_RETURN_IF_FAIL;
+
+ status = mdbImpl->add_entities(instance_node_set,instance_node_set_list);
+ MB_RETURN_IF_FAIL;
+
+ status = mdbImpl->add_entities(assembly_set,&instance_node_set,1);
+ MB_RETURN_IF_FAIL;
+
+ status = mdbImpl->tag_set_data(mPartHandleTag,&instance_node_set,1,&part_set);
+ MB_RETURN_IF_FAIL;
+
+ status = mdbImpl->tag_set_data(mInstanceHandleTag,&instance_node_set,1,&instance_set);
+ MB_RETURN_IF_FAIL;
+
+ status = mdbImpl->tag_set_data(mAssemblyHandleTag,&instance_node_set,1,&assembly_set);
+ MB_RETURN_IF_FAIL;
+
+ }
+
+ // ----- ELEMENT SETS -----
+
+ // get all element sets in part
+ MBRange part_element_sets;
+ tag_val = ABQ_ELEMENT_SET;
+ tag_data[0] = &tag_val;
+ status = mdbImpl->get_entities_by_type_and_tag(part_set,
+ MBENTITYSET,
+ &mSetTypeTag,
+ tag_data, 1, part_element_sets);
+ MB_RETURN_IF_FAIL;
+
+ MBRange part_element_set_list, instance_element_set_list;
+ for (MBRange::iterator part_element_set = part_element_sets.begin();
+ part_element_set != part_element_sets.end();
+ part_element_set++)
+ {
+ char element_set_name[ABAQUS_SET_NAME_LENGTH];
+ std::fill(element_set_name,element_set_name+ABAQUS_SET_NAME_LENGTH,'\0');
+ status = mdbImpl->tag_get_data(mSetNameTag, &(*part_element_set), 1, &element_set_name[0]);
+ if (MB_SUCCESS != status && MB_TAG_NOT_FOUND != status) return status;
+
+ part_element_set_list.clear();
+ status = get_set_elements(*part_element_set,part_element_set_list);
+
+ instance_element_set_list.clear();
+ for (MBRange::iterator set_element = part_element_set_list.begin();
+ set_element != part_element_set_list.end();
+ set_element++)
+ instance_element_set_list.insert(p2i_elements[*set_element]);
+
+ MBEntityHandle instance_element_set;
+ status = add_entity_set(instance_set,ABQ_ELEMENT_SET,element_set_name,instance_element_set);
+ MB_RETURN_IF_FAIL;
+
+ std::cerr << instance_set << "\t" << instance_element_set << std::endl;
+ status = mdbImpl->add_entities(instance_element_set,instance_element_set_list);
+ MB_RETURN_IF_FAIL;
+
+ status = mdbImpl->add_entities(assembly_set,&instance_element_set,1);
+ MB_RETURN_IF_FAIL;
+
+ // status = mdbImpl->add_entities(file_set,&instance_element_set,1);
+ //MB_RETURN_IF_FAIL;
+
+ status = mdbImpl->tag_set_data(mPartHandleTag,&instance_element_set,1,&part_set);
+ MB_RETURN_IF_FAIL;
+
+ status = mdbImpl->tag_set_data(mInstanceHandleTag,&instance_element_set,1,&instance_set);
+ MB_RETURN_IF_FAIL;
+
+ status = mdbImpl->tag_set_data(mAssemblyHandleTag,&instance_element_set,1,&assembly_set);
+ MB_RETURN_IF_FAIL;
+
+ char element_set_matname[ABAQUS_SET_NAME_LENGTH];
+ std::fill(element_set_matname,element_set_matname+ABAQUS_SET_NAME_LENGTH,'\0');
+ status = mdbImpl->tag_get_data(mMatNameTag, &(*part_element_set), 1, &element_set_matname[0]);
+ if (MB_SUCCESS != status && MB_TAG_NOT_FOUND != status) return status;
+
+ if (MB_TAG_NOT_FOUND != status)
+ {
+ status = mdbImpl->tag_set_data(mMatNameTag,&instance_element_set,1,element_set_matname);
+ MB_RETURN_IF_FAIL;
+ }
+
+ int element_set_mat_id;
+ status = mdbImpl->tag_get_data(mMaterialSetTag,&(*part_element_set), 1, &element_set_mat_id);
+ if (MB_SUCCESS != status && MB_TAG_NOT_FOUND != status) return status;
+
+ if (MB_TAG_NOT_FOUND != status)
+ {
+ status = mdbImpl->tag_set_data(mMaterialSetTag,&instance_element_set,1,&element_set_mat_id);
+ MB_RETURN_IF_FAIL;
+ }
+
+
+
+ }
+
+
+
+ return MB_SUCCESS;
+}
+
+
+MBErrorCode ReadABAQUS::add_entity_set(MBEntityHandle parent_set,
+ int ABQ_Set_Type,
+ std::string set_name,
+ MBEntityHandle &entity_set)
+{
+ MBErrorCode status;
+
+ status = mdbImpl->create_meshset(MESHSET_SET, entity_set);
+ MB_RETURN_IF_FAIL;
+
+ status = mdbImpl->tag_set_data(mSetTypeTag,&entity_set,1,&ABQ_Set_Type);
+ MB_RETURN_IF_FAIL;
+
+ status = mdbImpl->tag_set_data(mSetNameTag,&entity_set,1,set_name.c_str());
+ MB_RETURN_IF_FAIL;
+
+ status = mdbImpl->add_entities(parent_set,&entity_set,1);
+ MB_RETURN_IF_FAIL;
+
+ return MB_SUCCESS;
+}
+
+
+
+
+void ReadABAQUS::cyl2rect(std::vector<double> coord_list)
+{
+ int num_nodes = coord_list.size()/3;
+ double x,y,r,t;
+
+ for (int node=0;node<num_nodes;node++)
+ {
+ r = coord_list[3*node];
+ t = coord_list[3*node+1]*DEG2RAD;
+
+ x = r*cos(t);
+ y = r*sin(t);
+
+ coord_list[3*node] = x;
+ coord_list[3*node+1] = y;
+ }
+}
+
+void ReadABAQUS::sph2rect(std::vector<double> coord_list)
+{
+ int num_nodes = coord_list.size()/3;
+ double x,y,z,r,t,p;
+
+ for (int node=0;node<num_nodes;node++)
+ {
+ r = coord_list[3*node];
+ t = coord_list[3*node+1]*DEG2RAD;
+ p = coord_list[3*node+2]*DEG2RAD;
+
+ x = r*cos(p)*cos(t);
+ y = r*cos(p)*sin(t);
+ z = r*sin(p);
+
+ coord_list[3*node] = x;
+ coord_list[3*node+1] = y;
+ coord_list[3*node+2] = z;
+ }
+}
+
+
+// PARSING RECOGNITION
+
+abaqus_line_types ReadABAQUS::get_next_line_type()
+{
+
+ readline.clear();
+ std::getline(abFile,readline);
+
+ if (abFile.eof())
+ return abq_eof;
+
+ std::string::size_type pos = readline.find_first_not_of(' ');
+
+ if (std::string::npos == pos)
+ return abq_blank_line;
+
+ if ('*' == readline[pos])
+ if ('*' == readline[pos+1])
+ return abq_comment_line;
+ else
+ return abq_keyword_line;
+ else
+ return abq_data_line;
+}
+
+
+abaqus_keyword_type ReadABAQUS::get_keyword()
+{
+
+ std::vector<std::string> tokens;
+ std::map<std::string,abaqus_keyword_type> keywords;
+
+ // set up list of supported keywords
+ // Note: any attempt to match something not in the keyword list
+ // using the [] operator will create a new entry in the map
+ // but that entry will have value abq_undefined based on the
+ // definition of the abaqus_keyword_type enum.
+ keywords[ABQ_AMBIGUOUS] = abq_ambiguous;
+ keywords["HEADING"] = abq_heading;
+ keywords["PART"] = abq_part;
+ keywords["END PART"] = abq_end_part;
+ keywords["ASSEMBLY"] = abq_assembly;
+ keywords["END ASSEMBLY"] = abq_end_assembly;
+ keywords["NODE"] = abq_node;
+ keywords["ELEMENT"] = abq_element;
+ keywords["NSET"] = abq_nset;
+ keywords["ELSET"] = abq_elset;
+ keywords["SOLID SECTION"] = abq_solid_section;
+ keywords["INSTANCE"] = abq_instance;
+ keywords["END INSTANCE"] = abq_end_instance;
+
+ tokenize(readline,tokens,"*,\n");
+
+ // convert to upper case and test for unambiguous match/partial match
+ stringToUpper(tokens[0],tokens[0]);
+ return keywords[match(tokens[0],keywords)];
+
+}
+
+
+
+// PARSING UTILITY FUNCTIONS
+
+// for a map of strings to values of type T
+// search the key list of the map for an unambiguous partial match with the token
+template <typename T>
+std::string ReadABAQUS::match(const std::string &token,
+ std::map<std::string,T> &tokenList)
+{
+ // initialize with no match and ABQ_UNDEFINED as return string
+ bool found_match = false;
+ std::string best_match = ABQ_UNDEFINED;
+
+ // search the map
+ for (typename std::map<std::string,T>::iterator thisToken=tokenList.begin();
+ thisToken != tokenList.end();
+ thisToken++)
+ {
+ // if a perfect match break the loop (assume keyword list is unambiguous)
+ if (token == (*thisToken).first)
+ {
+ best_match = token;
+ break;
+ }
+ else
+ {
+ int short_length = ( token.length()<(*thisToken).first.length()?token.length():(*thisToken).first.length() );
+ // if the token matches the first token.length() characters of the keyword
+ // consider this a match
+ if ( token.substr(short_length) == (*thisToken).first.substr(short_length) )
+ {
+ if (!found_match)
+ {
+ // if no match already, record match and matching keyword
+ found_match = true;
+ best_match = (*thisToken).first;
+ }
+ else
+ // if match already set matching keyword to ABQ_AMBIGUOUS
+ best_match = ABQ_AMBIGUOUS;
+ }
+ }
+ }
+
+ // Possible return values: ABQ_UNDEFINED, keyword from list, ABQ_AMBIGUOUS
+ return best_match;
+}
+
+// convert a string to upper case
+void ReadABAQUS::stringToUpper(std::string toBeConverted, std::string& converted)
+{
+ converted = toBeConverted;
+
+ for (unsigned int i=0;i<toBeConverted.length();i++)
+ converted[i] = toupper(toBeConverted[i]);
+
+}
+
+// extract key/value pairs from parameter list
+void ReadABAQUS::extract_keyword_parameters(std::vector<std::string> tokens,
+ std::map<std::string,std::string>& params)
+{
+
+ std::string key, value;
+
+
+ // NOTE: skip first token - it is the keyword
+ for (std::vector<std::string>::iterator token=tokens.begin()+1;
+ token!=tokens.end(); token++)
+ {
+ std::string::size_type pos = token->find('=');
+ stringToUpper(token->substr(0,pos),key);
+ if(std::string::npos != pos)
+ value = token->substr(pos+1);
+ else
+ value = "";
+ pos = key.find_first_not_of(' ',0);
+ key = key.substr(pos);
+ params[key] = value;
+ }
+}
+
+// tokenize a string based on a set of possible delimiters
+void ReadABAQUS::tokenize( const std::string& str,
+ std::vector<std::string>& tokens,
+ const char* delimiters )
+{
+ tokens.clear();
+
+ std::string::size_type pos, last = str.find_first_not_of( delimiters, 0 );
+
+ while ( std::string::npos != last )
+ {
+ pos = str.find_first_of( delimiters, last );
+ if ( std::string::npos == pos )
+ {
+ tokens.push_back(str.substr(last));
+ last = std::string::npos;
+ }
+ else
+ {
+ tokens.push_back( str.substr( last, pos - last ) );
+ last = str.find_first_not_of( delimiters, pos );
+ }
+ }
+}
+
+
Added: MOAB/trunk/ReadABAQUS.hpp
===================================================================
--- MOAB/trunk/ReadABAQUS.hpp (rev 0)
+++ MOAB/trunk/ReadABAQUS.hpp 2009-08-21 01:51:30 UTC (rev 3114)
@@ -0,0 +1,304 @@
+/**
+ * MOAB, a Mesh-Oriented datABase, is a software component for creating,
+ * storing and accessing finite element mesh data.
+ *
+ * Copyright 2004 Sandia Corporation. Under the terms of Contract
+ * DE-AC04-94AL85000 with Sandia Coroporation, the U.S. Government
+ * retains certain rights in this software.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ */
+
+//-------------------------------------------------------------------------
+// Filename : ReadABAQUS.hpp
+//
+// Purpose : ABAQUS inp file reader
+//
+// Special Notes : Started with NetCDF EXODUS II reader
+//
+// Creator : Paul Wilson & Patrick Snouffer
+//
+// Date : 08/2009
+//
+// Owner : Paul Wilson
+//-------------------------------------------------------------------------
+
+#ifndef READABAQUS_HPP
+#define READABAQUS_HPP
+
+#ifndef IS_BUILDING_MB
+ #error "ReadABAQUS.hpp isn't supposed to be included into an application"
+#endif
+
+
+#include <vector>
+#include <map>
+#include <string>
+#include <iostream>
+#include <fstream>
+
+#include "MBForward.hpp"
+#include "MBReaderIface.hpp"
+#include "MBRange.hpp"
+
+#define ABAQUS_SET_TYPE_TAG_NAME "abaqus_set_type"
+#define ABAQUS_SET_NAME_TAG_NAME "abaqus_set_name"
+#define ABAQUS_SET_NAME_LENGTH 100
+#define ABAQUS_LOCAL_ID_TAG_NAME "abaqus_local_id"
+
+// many sets should know who contains them
+#define ABAQUS_INSTANCE_HANDLE_TAG_NAME "abaqus_instance_handle"
+#define ABAQUS_ASSEMBLY_HANDLE_TAG_NAME "abaqus_assembly_handle"
+#define ABAQUS_PART_HANDLE_TAG_NAME "abaqus_part_handle"
+
+// instances should know things about themselves:
+// * which part they derive from (see ABAQUS_PART_HANDLE_TAG_NAME above)
+// * which instance of a part this is
+// * which instance of an assembly this is
+#define ABAQUS_INSTANCE_PART_ID_TAG_NAME "abaqus_instance_part_id"
+#define ABAQUS_INSTANCE_GLOBAL_ID_TAG_NAME "abaqus_instance_global_id"
+
+// element sets have material name
+// using MOAB's general MATERIAL_SET to store material id
+#define ABAQUS_MAT_NAME_TAG_NAME "abaqus_mat_name"
+#define ABAQUS_MAT_NAME_LENGTH 100
+
+#define ABQ_ASSEMBLY_SET 1
+#define ABQ_PART_SET 2
+#define ABQ_INSTANCE_SET 3
+#define ABQ_NODE_SET 4
+#define ABQ_ELEMENT_SET 5
+
+
+enum abaqus_line_types { abq_undefined_line = 0,
+ abq_blank_line,
+ abq_comment_line,
+ abq_keyword_line,
+ abq_data_line,
+ abq_eof };
+
+enum abaqus_keyword_type { abq_undefined = 0,
+ abq_unsupported,
+ abq_ambiguous,
+ abq_heading,
+ abq_part,
+ abq_end_part,
+ abq_assembly,
+ abq_end_assembly,
+ abq_node,
+ abq_element,
+ abq_nset,
+ abq_elset,
+ abq_instance,
+ abq_end_instance,
+ abq_solid_section};
+
+enum abaqus_part_params { abq_part_undefined = 0,
+ abq_part_ambiguous,
+ abq_part_name};
+
+enum abaqus_instance_params { abq_instance_undefined = 0,
+ abq_instance_ambiguous,
+ abq_instance_name,
+ abq_instance_part};
+
+enum abaqus_assembly_params { abq_assembly_undefined = 0,
+ abq_assembly_ambiguous,
+ abq_assembly_name};
+
+enum abaqus_node_params { abq_node_undefined = 0,
+ abq_node_ambiguous,
+ abq_node_nset,
+ abq_node_system};
+
+enum abaqus_element_params { abq_element_undefined = 0,
+ abq_element_ambiguous,
+ abq_element_elset,
+ abq_element_type};
+
+enum abaqus_element_type { abq_eletype_unsupported = 0,
+ abq_eletype_dc3d8,
+ abq_eletype_c3d8r,
+ abq_eletype_dcc3d8,
+ abq_eletype_c3d4,
+ abq_eletype_ds4};
+
+enum abaqus_nset_params { abq_nset_undefined = 0,
+ abq_nset_ambiguous,
+ abq_nset_nset,
+ abq_nset_elset,
+ abq_nset_generate,
+ abq_nset_instance};
+
+enum abaqus_elset_params { abq_elset_undefined = 0,
+ abq_elset_ambiguous,
+ abq_elset_elset,
+ abq_elset_generate,
+ abq_elset_instance};
+
+enum abaqus_solid_section_params { abq_solid_section_undefined = 0,
+ abq_solid_section_ambiguous,
+ abq_solid_section_elset,
+ abq_solid_section_matname};
+
+
+
+
+class MBReadUtilIface;
+
+class ReadABAQUS : public MBReaderIface
+{
+public:
+
+ static MBReaderIface* factory( MBInterface* );
+
+ void tokenize( const std::string& str,
+ std::vector<std::string>& tokens,
+ const char* delimiters );
+
+ //! load an ABAQUS file
+ MBErrorCode load_file( const char *exodus_file_name,
+ MBEntityHandle& file_set,
+ const FileOptions& opts,
+ const MBReaderIface::IDTag* subset_list = 0,
+ int subset_list_length = 0,
+ const MBTag* file_id_tag = 0 );
+
+ MBErrorCode read_tag_values( const char* file_name,
+ const char* tag_name,
+ const FileOptions& opts,
+ std::vector<int>& tag_values_out,
+ const IDTag* subset_list = 0,
+ int subset_list_length = 0 );
+
+ //! Constructor
+ ReadABAQUS(MBInterface* impl = NULL);
+
+ //! Destructor
+ virtual ~ReadABAQUS();
+
+private:
+
+ void reset();
+
+ MBErrorCode read_heading(MBEntityHandle file_set);
+ MBErrorCode read_part(MBEntityHandle file_set);
+ MBErrorCode read_assembly(MBEntityHandle file_set);
+ MBErrorCode read_unsupported(MBEntityHandle file_set);
+ MBErrorCode read_node_list(MBEntityHandle parent_set);
+ MBErrorCode read_element_list(MBEntityHandle parent_set);
+ MBErrorCode read_node_set(MBEntityHandle parent_set,
+ MBEntityHandle file_set = 0,
+ MBEntityHandle assembly_set = 0);
+ MBErrorCode read_element_set(MBEntityHandle parent_set,
+ MBEntityHandle file_set = 0,
+ MBEntityHandle assembly_set = 0);
+ MBErrorCode read_solid_section(MBEntityHandle parent_set);
+ MBErrorCode read_instance(MBEntityHandle assembly_set,
+ MBEntityHandle file_set);
+
+
+ MBErrorCode get_elements_by_id(MBEntityHandle parent_set,
+ std::vector<int> element_ids_subset,
+ MBRange &element_range);
+
+ MBErrorCode get_nodes_by_id(MBEntityHandle parent_set,
+ std::vector<int> node_ids_subset,
+ MBRange &node_range);
+
+ MBErrorCode get_set_by_name(MBEntityHandle parent_set,
+ int ABQ_set_type,
+ std::string set_name,
+ MBEntityHandle &set_handle);
+
+ MBErrorCode get_set_elements(MBEntityHandle set_handle,
+ MBRange &element_range);
+
+ MBErrorCode get_set_elements_by_name(MBEntityHandle parent_set,
+ int ABQ_set_type,
+ std::string set_name,
+ MBRange &element_range);
+
+
+ MBErrorCode get_set_nodes(MBEntityHandle parent_set,
+ int ABQ_set_type,
+ std::string set_name,
+ MBRange &node_range);
+
+ MBErrorCode add_entity_set(MBEntityHandle parent_set,
+ int ABQ_set_type,
+ std::string set_name,
+ MBEntityHandle &entity_set);
+
+ MBErrorCode create_instance_of_part(const MBEntityHandle file_set,
+ const MBEntityHandle parent_set,
+ const std::string part_name,
+ const std::string instance_name,
+ MBEntityHandle &entity_set,
+ const std::vector<double> &translation,
+ const std::vector<double> &rotation);
+
+ MBTag get_tag(char* tag_name, int tag_size, MBTagType tag_type, MBDataType tag_data_type);
+ MBTag get_tag(char* tag_name, int tag_size, MBTagType tag_type, MBDataType tag_data_type, const void* def_val);
+
+ void cyl2rect(std::vector<double> coord_list);
+
+ void sph2rect(std::vector<double> coord_list);
+
+ abaqus_line_types get_next_line_type();
+ abaqus_keyword_type get_keyword();
+
+ template <class T>
+ std::string match(const std::string &token,
+ std::map<std::string,T> &tokenList);
+
+ void stringToUpper(std::string toBeConverted,std::string& converted);
+
+
+ void extract_keyword_parameters(std::vector<std::string> tokens,
+ std::map<std::string,std::string>& params);
+
+ //! interface instance
+ MBInterface* mdbImpl;
+
+ // read mesh interface
+ MBReadUtilIface* readMeshIface;
+
+ std::ifstream abFile; // abaqus file
+
+ std::string readline;
+
+ //! Cached tags for reading. Note that all these tags are defined when the
+ //! core is initialized.
+ MBTag mMaterialSetTag;
+ MBTag mDirichletSetTag;
+ MBTag mNeumannSetTag;
+ MBTag mHasMidNodesTag;
+
+ MBTag mSetTypeTag;
+ MBTag mPartHandleTag;
+ MBTag mInstancePIDTag;
+ MBTag mInstanceGIDTag;
+
+ MBTag mLocalIDTag;
+ MBTag mInstanceHandleTag;
+ MBTag mAssemblyHandleTag;
+
+ MBTag mSetNameTag;
+ MBTag mMatNameTag;
+
+ abaqus_line_types next_line_type;
+
+ std::map<MBEntityHandle,unsigned int> num_part_instances;
+ std::map<MBEntityHandle,unsigned int> num_assembly_instances;
+ std::map<std::string,unsigned int> matIDmap;
+ unsigned mat_id;
+
+};
+
+
+#endif
1
0
Author: jvporter
Date: 2009-08-20 16:23:30 -0500 (Thu, 20 Aug 2009)
New Revision: 3112
Modified:
MOAB/trunk/MBEntityHandle.h.in
MOAB/trunk/MBMatrix3.hpp
MOAB/trunk/MBSysUtil.cpp
MOAB/trunk/ReadSTL.cpp
MOAB/trunk/WriteSTL.cpp
MOAB/trunk/tools/dagmc/cubfile.c
Log:
* Consolidate fixed-width integer typedefs (stdint.h and friends)
* Fix compile failure in MBMatrix3.hpp due to lack of finite()
Modified: MOAB/trunk/MBEntityHandle.h.in
===================================================================
--- MOAB/trunk/MBEntityHandle.h.in 2009-08-20 19:19:03 UTC (rev 3111)
+++ MOAB/trunk/MBEntityHandle.h.in 2009-08-20 21:23:30 UTC (rev 3112)
@@ -32,6 +32,15 @@
# include <inttypes.h>
#elif defined (MOAB_HAVE_STDINT_H)
# include <stdint.h>
+#elif defined (_MSC_VER)
+ typedef __int8 int8_t;
+ typedef __int16 int16_t;
+ typedef __int32 int32_t;
+ typedef __int64 int64_t;
+ typedef unsigned __int8 uint8_t;
+ typedef unsigned __int16 uint16_t;
+ typedef unsigned __int32 uint32_t;
+ typedef unsigned __int64 uint64_t;
#endif
#ifdef MOAB_HAVE_STDDEF_H
Modified: MOAB/trunk/MBMatrix3.hpp
===================================================================
--- MOAB/trunk/MBMatrix3.hpp 2009-08-20 19:19:03 UTC (rev 3111)
+++ MOAB/trunk/MBMatrix3.hpp 2009-08-20 21:23:30 UTC (rev 3112)
@@ -26,6 +26,10 @@
#include <iosfwd>
#include <limits>
+#ifdef _MSC_VER
+# define finite _finite
+#endif
+
class MBMatrix3
{
double d[9];
Modified: MOAB/trunk/MBSysUtil.cpp
===================================================================
--- MOAB/trunk/MBSysUtil.cpp 2009-08-20 19:19:03 UTC (rev 3111)
+++ MOAB/trunk/MBSysUtil.cpp 2009-08-20 21:23:30 UTC (rev 3112)
@@ -5,22 +5,7 @@
#include <assert.h>
#include "MBEntityHandle.h"
-#ifdef MOAB_HAVE_INTTYPES_H
-#include <inttypes.h>
-#endif
-#ifdef MOAB_HAVE_STDDEF_H
-#include <stddef.h>
-#endif
-#ifdef MOAB_HAVE_STDINT_H
-#include <stdint.h>
-#endif
-#if defined(_MSC_VER) /* windows */
-typedef unsigned __int16 uint16_t;
-typedef unsigned __int32 uint32_t;
-typedef unsigned __int64 uint64_t;
-#endif
-
namespace MBSysUtil
{
Modified: MOAB/trunk/ReadSTL.cpp
===================================================================
--- MOAB/trunk/ReadSTL.cpp 2009-08-20 19:19:03 UTC (rev 3111)
+++ MOAB/trunk/ReadSTL.cpp 2009-08-20 21:23:30 UTC (rev 3112)
@@ -29,20 +29,7 @@
#include "MBSysUtil.hpp"
#include "MBEntityHandle.h"
-#ifdef MOAB_HAVE_INTTYPES_H
-#include <inttypes.h>
-#endif
-#ifdef MOAB_HAVE_STDDEF_H
-#include <stddef.h>
-#endif
-#ifdef MOAB_HAVE_STDINT_H
-#include <stdint.h>
-#endif
-#if defined(_MSC_VER) /* Windows */
-typedef unsigned __int32 uint32_t;
-#endif
-
#include <errno.h>
#include <string.h>
#include <limits.h>
Modified: MOAB/trunk/WriteSTL.cpp
===================================================================
--- MOAB/trunk/WriteSTL.cpp 2009-08-20 19:19:03 UTC (rev 3111)
+++ MOAB/trunk/WriteSTL.cpp 2009-08-20 21:23:30 UTC (rev 3112)
@@ -29,15 +29,6 @@
#include "MBSysUtil.hpp"
#include "MBEntityHandle.h"
-#ifdef MOAB_HAVE_INTTYPES_H
-#include <inttypes.h>
-#endif
-#ifdef MOAB_HAVE_STDDEF_H
-#include <stddef.h>
-#endif
-#ifdef MOAB_HAVE_STDINT_H
-#include <stdint.h>
-#endif
#include <stdio.h>
#include <sys/types.h>
Modified: MOAB/trunk/tools/dagmc/cubfile.c
===================================================================
--- MOAB/trunk/tools/dagmc/cubfile.c 2009-08-20 19:19:03 UTC (rev 3111)
+++ MOAB/trunk/tools/dagmc/cubfile.c 2009-08-20 21:23:30 UTC (rev 3112)
@@ -14,13 +14,9 @@
#include <stdlib.h>
#include "MBEntityHandle.h" // for MOAB_HAVE_STDINT_H
-#ifdef MOAB_HAVE_STDINT_H
-# include <stdint.h>
-#endif
#ifdef _MSC_VER /* windows */
# include <BaseTsd.h>
-typedef ULONG32 uint32_t;
#endif
#include <errno.h>
1
0