Skip to content

Commit

Permalink
Merge pull request #20 from openfedem/small-fixes
Browse files Browse the repository at this point in the history
Minor issues related to Nastran bulk data file parsing
  • Loading branch information
kmokstad authored Dec 29, 2024
2 parents a1713e5 + ef6e23b commit ed00940
Show file tree
Hide file tree
Showing 8 changed files with 168 additions and 115 deletions.
14 changes: 7 additions & 7 deletions src/FFaLib/FFaContainers/FFaFieldContainer.H
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,16 @@ protected:

// The read/writable fields

typedef std::set<std::string> FDict;
typedef FDict::const_iterator FDictIt;
using FDict = std::set<std::string>;
using FDictIt = FDict::const_iterator;

struct FDictLess
{
bool operator()(FDictIt s1, FDictIt s2) const { return *s1 < *s2; }
};

typedef std::map<FDictIt,FFaFieldBase*,FDictLess> FieldContainerMap;
typedef FFaSingelton<FDict,FFaFieldContainer> FieldContainerDict;
using FieldContainerMap = std::map<FDictIt,FFaFieldBase*,FDictLess>;
using FieldContainerDict = FFaSingelton<FDict,FFaFieldContainer>;

FieldContainerMap myFields;

Expand All @@ -173,7 +173,7 @@ private:

// The internal book keeping of who is pointing to whom

typedef std::vector<FFaReferenceBase*> ReferenceSet;
using ReferenceSet = std::vector<FFaReferenceBase*>;

ReferenceSet myRefBy;
std::list<FFaReferenceBase*> myRefTo;
Expand All @@ -189,12 +189,12 @@ private:
#define FFA_FIELD_INIT(field, defaultValue, identifier) \
this->addField(identifier, &field); \
field.setValue(defaultValue,false); \
field.setDefaultValue(defaultValue,false)
field.setDefaultValue(field.getValue(),false)

#define FFA_OBSOLETE_FIELD_INIT(field, defaultValue, identifier, obj) \
obj->addField(identifier, &field); \
field.setValue(defaultValue,false); \
field.setDefaultValue(defaultValue,false)
field.setDefaultValue(field.getValue(),false)

#define FFA_FIELD_DEFAULT_INIT(field, identifier) \
this->addField(identifier, &field)
Expand Down
2 changes: 1 addition & 1 deletion src/FFaLib/FFaContainers/FFaReference.H
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public:
The pointer value in Fields of Ref pointers are not supposed to change.
*/

typedef FFaReferenceBase* FFaRefPtr;
using FFaRefPtr = FFaReferenceBase*;

template<> inline
FFaField<FFaRefPtr>::FFaField()
Expand Down
2 changes: 1 addition & 1 deletion src/FFaLib/FFaContainers/FFaReferenceList.H
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ private:
Specialized methods for FFaField.
*/

typedef FFaReferenceListBase* FFaRefListPtr;
using FFaRefListPtr = FFaReferenceListBase*;

template<> inline
FFaField<FFaRefListPtr>::FFaField()
Expand Down
2 changes: 1 addition & 1 deletion src/FFlLib/FFlIOAdaptors/FFlCrossSection.H
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ struct FFlCrossSection
{
std::string name; //!< Cross section type name
double A = 0.0; //!< Cross section area
double Iyy = 0.0; //!< 2nd moment of inertia about local Y-axis
double Izz = 0.0; //!< 2nd moment of inertia about local Z-axis
double Iyy = 0.0; //!< 2nd moment of inertia about local Y-axis
double Izy = 0.0; //!< Coupling moment of inertia for non-symmetric sections
double J = 0.0; //!< Torsional stiffness parameter
double NSM = 0.0; //!< Non-structural mass per length unit
Expand Down
29 changes: 15 additions & 14 deletions src/FFlLib/FFlIOAdaptors/FFlNastranProcessor.C
Original file line number Diff line number Diff line change
Expand Up @@ -2709,7 +2709,7 @@ bool FFlNastranReader::process_PBARL (std::vector<std::string>& entry)
return false;
}

const std::string& Type = entry[3];
std::string Type = entry[3];
if (Type.empty())
{
ListUI <<"\n *** Error: Cross section type not specified"
Expand All @@ -2731,8 +2731,8 @@ bool FFlNastranReader::process_PBARL (std::vector<std::string>& entry)
if (entry.size() < 9+numDim) entry.resize(9+numDim,"");

std::vector<double> Dim(numDim,0.0);
for (size_t i = 0; i < numDim; i++)
CONVERT_ENTRY ("PBARL", fieldValue(entry[8+i],Dim[i]) && !entry[8+i].empty());
for (size_t i = 8; i < 8+numDim; i++)
CONVERT_ENTRY ("PBARL", fieldValue(entry[i],Dim[i-8]) && !entry[i].empty());
CONVERT_ENTRY ("PBARL", fieldValue(entry[8+numDim],NSMass));

// ======================= Process data =======================
Expand Down Expand Up @@ -2920,7 +2920,7 @@ bool FFlNastranReader::process_PBEAML (std::vector<std::string>& entry)

int PID = 0, MID = 0;
size_t i, numDim = 0;
double NsmA = 0.0, NsmB = 0.0;
double NSMass = 0.0;

static std::vector<std::string> Types4({
"HAT", "CHAN", "CHAN1", "BOX", "CHAN2", "CROSS",
Expand All @@ -2944,7 +2944,7 @@ bool FFlNastranReader::process_PBEAML (std::vector<std::string>& entry)
return false;
}

const std::string& Type = entry[3];
std::string Type = entry[3];
if (Type.empty())
{
ListUI <<"\n *** Error: Cross section type not specified"
Expand All @@ -2966,10 +2966,10 @@ bool FFlNastranReader::process_PBEAML (std::vector<std::string>& entry)
// Read end A data
if (entry.size() < 9+numDim) entry.resize(9+numDim,"");

std::vector<double> DimA(numDim,0.0);
for (i = 0; i < numDim; i++)
CONVERT_ENTRY ("PBEAML",fieldValue(entry[8+i],DimA[i]) && !entry[8+i].empty());
CONVERT_ENTRY ("PBEAML",fieldValue(entry[8+numDim],NsmA));
std::vector<double> Dim(numDim,0.0);
for (i = 8; i < 8+numDim; i++)
CONVERT_ENTRY ("PBEAML",fieldValue(entry[i],Dim[i-8]) && !entry[i].empty());
CONVERT_ENTRY ("PBEAML",fieldValue(entry[8+numDim],NSMass));

// Find starting point of end B data
size_t endBStart = 9+numDim;
Expand All @@ -2979,14 +2979,15 @@ bool FFlNastranReader::process_PBEAML (std::vector<std::string>& entry)
// Read end B data - substitute by data of end A if field is empty
if (entry.size() < endBStart+inc) entry.resize(endBStart+inc,"");

std::vector<double> DimB(DimA); NsmB = NsmA;
std::vector<double> DimB(Dim);
double NsmB = NSMass;
for (i = 0; i < numDim; i++)
CONVERT_ENTRY ("PBEAML", fieldValue(entry[endBStart+2+i],DimB[i]));
CONVERT_ENTRY ("PBEAML",fieldValue(entry[endBStart+2+numDim],NsmB));

// ======================= Process data =======================

if (DimA != DimB || NsmA != NsmB || endBStart > numDim+9)
if (Dim != DimB || NSMass != NsmB || endBStart > numDim+9)
{
nWarnings++;
ListUI <<"\n ** Warning: Beam property "<< PID <<" has tapering.\n"
Expand All @@ -2999,7 +3000,7 @@ bool FFlNastranReader::process_PBEAML (std::vector<std::string>& entry)
<< std::endl;
#endif

FFlCrossSection params(Type,DimA);
FFlCrossSection params(Type,Dim);
if (params.A > 0.0)
{
this->insertBeamPropMat("PBEAML",PID,MID);
Expand All @@ -3008,10 +3009,10 @@ bool FFlNastranReader::process_PBEAML (std::vector<std::string>& entry)
else
ListUI <<" Error occurred when processing PBEAML "<< PID <<".\n";

if (NsmA != 0.0)
if (NSMass != 0.0)
{
beamPIDnsm.insert(PID);
myLink->addAttribute(createNSM(PID,NsmA));
myLink->addAttribute(createNSM(PID,NSMass));
}

STOPP_TIMER("process_PBEAML")
Expand Down
Loading

0 comments on commit ed00940

Please sign in to comment.