Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/FEReaders.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is a part of nla3d project. For information about authors and
// licensing go to project's repository on github:
// https://github.com/dmitryikh/nla3d
// https://github.com/dmitryikh/nla3d

#include "FEReaders.h"
#include <unordered_map>
Expand All @@ -27,14 +27,14 @@ void MeshData::clear() {
nodesPos.clear();
loadBcs.clear();
fixBcs.clear();
mpcs.clear();
mpcs.clear();
feComps.clear();
}


void MeshData::compressNumbers() {
// numbers should start from 1
if (nodesNumbers.size() == *std::max_element(nodesNumbers.begin(), nodesNumbers.end())) {
if (nodesNumbers.size() == *std::max_element(nodesNumbers.begin(), nodesNumbers.end())) {
// nothing to do
return;
}
Expand Down Expand Up @@ -77,7 +77,7 @@ void MeshData::compressNumbers() {
if (comp.type == FEComponent::NODES) {
for (auto n : comp.list) {
n = old2new[n];
}
}
}
}
}
Expand Down Expand Up @@ -163,7 +163,7 @@ std::vector<std::string> ssplit(const std::string& line, const std::vector<int>&
return vv;
}


bool iequals(const string& a, const string& b) {
unsigned int sz = a.size();
if (b.size() != sz)
Expand All @@ -175,7 +175,7 @@ bool iequals(const string& a, const string& b) {
}

// taken from
// http://stackoverflow.com/questions/6089231/getting-std-ifstream-to-handle-lf-cr-and-crlf/6089413#6089413
// http://stackoverflow.com/questions/6089231/getting-std-ifstream-to-handle-lf-cr-and-crlf/6089413#6089413
std::istream& getLine(std::istream& is, std::string& t) {
t.clear();

Expand Down Expand Up @@ -273,7 +273,7 @@ bool readCdbFile(std::string filename, MeshData& md) {

// current element type number. We keep the current element type number while proceed the apld
// file. Currently, this info is not used, but in the past it was used to determine element type
// while parsing EBLOCK blocks.
// while parsing EBLOCK blocks.
uint32 type = 0;

Tokenizer t;
Expand Down Expand Up @@ -301,7 +301,7 @@ bool readCdbFile(std::string filename, MeshData& md) {
// 1 2.000000000E+000 6.000000000E+000 0.000000000E+000
// 2 0.000000000E+000 6.000000000E+000 0.000000000E+000
//
// from Ansys WB APDL 17.1:
// from Ansys WB APDL 17.1:
//NBLOCK,6,SOLID, 341, 341
//(3i9,6e21.13e3)
// 1 0 0 0.0000000000000E+000 4.0000000000000E+000
Expand Down Expand Up @@ -352,7 +352,7 @@ bool readCdbFile(std::string filename, MeshData& md) {
md.nodesPos.push_back(pos);
}
}//NBLOCK
else if (iequals(t.tokens[0], "EBLOCK")) {
else if (iequals(t.tokens[0], "EBLOCK")) {
// Example of record:
//EBLOCK,19,SOLID, 7024, 7024
//(19i9)
Expand Down Expand Up @@ -445,7 +445,7 @@ bool readCdbFile(std::string filename, MeshData& md) {
st = 5;
}
vector<uint32> enodes;

if (v.size() != st + nNodes) {
LOG(FATAL) << "Not enought fields to read element nodes";
}
Expand Down Expand Up @@ -484,8 +484,8 @@ bool readCdbFile(std::string filename, MeshData& md) {
else if (iequals(t.tokens[0], "CE")) {
// CE - is a command to declare MPC equation
// How MPC looks like this in cdb file:
//CE,R5.0,DEFI, 2, 1, 0.00000000
//CE,R5.0,NODE, 1700,UX , 1.00000000 , 1700,UZ , 1.00000000
//CE,R5.0,DEFI, 2, 1, 0.00000000
//CE,R5.0,NODE, 1700,UX , 1.00000000 , 1700,UZ , 1.00000000
// TODO: Mpc is dynamicaly allocated, but MeshData won't free this memory (this should be done
// in FEStorage). This is potential memory leak
Mpc* mpc = new Mpc();
Expand Down
4 changes: 2 additions & 2 deletions src/FEReaders.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is a part of nla3d project. For information about authors and
// licensing go to project's repository on github:
// https://github.com/dmitryikh/nla3d
// https://github.com/dmitryikh/nla3d

#pragma once
#include <vector>
Expand Down Expand Up @@ -38,7 +38,7 @@ class MeshData {
std::vector<loadBC> loadBcs;
std::vector<fixBC> fixBcs;

std::vector<Mpc*> mpcs;
std::vector<Mpc*> mpcs;

std::map<std::string, FEComponent> feComps;

Expand Down
4 changes: 4 additions & 0 deletions src/lib/Dof.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// This file is a part of nla3d project. For information about authors and
// licensing go to project's repository on github:
// https://github.com/dmitryikh/nla3d

#include "Dof.h"

namespace nla3d {
Expand Down
10 changes: 5 additions & 5 deletions src/lib/Dof.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// This file is a part of nla3d project. For information about authors and
// licensing go to project's repository on github:
// https://github.com/dmitryikh/nla3d
// https://github.com/dmitryikh/nla3d

#pragma once
#include "sys.h"

namespace nla3d {

class DofCollection;
// class for Degree of Freedom informations
// class for Degree of Freedom informations
// (is it fixed boundary condition, what its number in equation system, ..)
class Dof {
public:
Expand Down Expand Up @@ -65,10 +65,10 @@ class DofCollection {
uint32 numberOfUsedDofs = 0;
uint32 numberOfEntities = 0;

// vector of Dof objects
// vector of Dof objects
std::vector<Dof> dofs;
// array of indexes to find where dofs for particular entity is located in dofs
// Dof for entity n will be located from dofPos[n-1] included to dofPos[n] excluded
// Dof for entity n will be located from dofPos[n-1] included to dofPos[n] excluded
std::vector<uint32> dofPos;
// set of unique dofs used in collection
std::set<Dof::dofType> uniqueDofTypes;
Expand All @@ -95,4 +95,4 @@ inline std::pair<std::vector<Dof>::iterator,
}


} // namespace nla3d
} // namespace nla3d
4 changes: 2 additions & 2 deletions src/lib/FEComponent.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is a part of nla3d project. For information about authors and
// licensing go to project's repository on github:
// https://github.com/dmitryikh/nla3d
// https://github.com/dmitryikh/nla3d

#include "FEComponent.h"

Expand All @@ -14,7 +14,7 @@ FEComponent::FEComponent () {
}
FEComponent::~FEComponent () {
list.clear();
}
}

FEComponent::typeOfComponent FEComponent::typeFromString(const std::string& typeName) {
for (size_t i = 1; i < LAST; i++) {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/FEComponent.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is a part of nla3d project. For information about authors and
// licensing go to project's repository on github:
// https://github.com/dmitryikh/nla3d
// https://github.com/dmitryikh/nla3d

#pragma once
#include "sys.h"
Expand Down Expand Up @@ -32,6 +32,6 @@ class FEComponent {
inline MAKE_LOGGABLE(FEComponent, obj, os) {
os << obj.name << ": " << obj.list.size() << " " << obj.labelsOfComponent[obj.type];
return os;
}
}

} // namespace nla3d
} // namespace nla3d
26 changes: 13 additions & 13 deletions src/lib/FESolver.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is a part of nla3d project. For information about authors and
// licensing go to project's repository on github:
// https://github.com/dmitryikh/nla3d
// https://github.com/dmitryikh/nla3d

#include "FESolver.h"

Expand All @@ -27,7 +27,7 @@ uint16 TimeControl::getCurrentEquilibriumStep() {


uint16 TimeControl::getTotalNumberOfEquilibriumSteps() {
return totalNumberOfEquilibriumSteps;
return totalNumberOfEquilibriumSteps;
}


Expand All @@ -37,7 +37,7 @@ bool TimeControl::nextStep(double delta) {
convergedTimeInstances.push_back(currentTime);
}
if (currentTime >= endTime) {
return false;
return false;
}
// if delta bigger than endTime-currentTime
if (currentTime + delta >= endTime) {
Expand All @@ -58,7 +58,7 @@ bool TimeControl::nextStep(double delta) {

void TimeControl::nextEquilibriumStep() {
currentEquilibriumStep++;
totalNumberOfEquilibriumSteps++;
totalNumberOfEquilibriumSteps++;
LOG(INFO) << "***** Equilibrium iteration = " << currentEquilibriumStep
<< ", Cumulutive iterations = " << totalNumberOfEquilibriumSteps;
}
Expand Down Expand Up @@ -229,7 +229,7 @@ void FESolver::setConstrainedDofs() {
void FESolver::applyBoundaryConditions(double time) {
TIMED_SCOPE(t, "applyBoundaryConditions");
LOG(INFO) << "Applying boundary conditions.. (" << loads.size() << " nodal loads and "
<< fixs.size() << "nodal fixations)";
<< fixs.size() << "nodal fixations)";

// fill nodal loads
for (auto load : loads) {
Expand Down Expand Up @@ -340,7 +340,7 @@ void LinearFESolver::solve () {
CHECK_NOTNULL(storage);
CHECK_NOTNULL(eqSolver);

// setup matrix properties for EquationSolver
// setup matrix properties for EquationSolver
eqSolver->setSymmetric(true);
eqSolver->setPositive(false);

Expand Down Expand Up @@ -410,7 +410,7 @@ void NonlinearFESolver::solve() {
CHECK_NOTNULL(storage);
CHECK_NOTNULL(eqSolver);

// setup matrix properties for EquationSolver
// setup matrix properties for EquationSolver
eqSolver->setSymmetric(true);
eqSolver->setPositive(false);

Expand Down Expand Up @@ -474,16 +474,16 @@ void NonlinearFESolver::solve() {
currentCriteria = calculateCriteria(deltaUs);

// TODO: 1. It seems that currentCriteria is already normalized in calculateCriteria(). we
// need to compare currentCriteria with 1.0
// need to compare currentCriteria with 1.0
// TODO: 2. Current convergence criteria is not good. We need to introduce equilibrium balance
// criteria too along with kinematic one.
// criteria too along with kinematic one.
if (currentCriteria < convergenceCriteria) {
converged = true;
break;
}
LOG_IF(currentCriteria > 1.0e6 || std::isnan(currentCriteria), FATAL) << "The solution is diverged!";

if (timeControl.getCurrentEquilibriumStep() >= numberOfIterations)
if (timeControl.getCurrentEquilibriumStep() >= numberOfIterations)
break;
}//iterations

Expand Down Expand Up @@ -535,7 +535,7 @@ void LinearTransientFESolver::solve() {
CHECK_NOTNULL(storage);
CHECK_NOTNULL(eqSolver);

// setup matrix properties for EquationSolver
// setup matrix properties for EquationSolver
eqSolver->setSymmetric(true);
eqSolver->setPositive(false);

Expand All @@ -558,7 +558,7 @@ void LinearTransientFESolver::solve() {
setConstrainedDofs();
storage->assignEquationNumbers();
initSolutionData();


vecR.zero();

Expand All @@ -582,7 +582,7 @@ void LinearTransientFESolver::solve() {

vecDU.zero();
vecDDU.zero();

for (size_t i = 0; i < getNumberOfPostProcessors(); i++) {
postProcessors[i]->pre();
}
Expand Down
10 changes: 5 additions & 5 deletions src/lib/FESolver.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is a part of nla3d project. For information about authors and
// licensing go to project's repository on github:
// https://github.com/dmitryikh/nla3d
// https://github.com/dmitryikh/nla3d

#pragma once
#include "sys.h"
Expand Down Expand Up @@ -118,11 +118,11 @@ class FESolver {
// this work based on `fixs` array.
void setConstrainedDofs();

// add DoF fixation (constraint) boundary condition
// add DoF fixation (constraint) boundary condition
void addFix(int32 n, Dof::dofType dof, const double value = 0.0);
// add DoF load (force) boundary condition
// add DoF load (force) boundary condition
void addLoad(int32 n, Dof::dofType dof, const double value = 0.0);

// for debug purpose:
// dump matrices matK, matC, matM and vectors vecF, vecR
void dumpMatricesAndVectors(std::string filename);
Expand All @@ -141,7 +141,7 @@ class FESolver {
std::vector<PostProcessor*> postProcessors;

// the references on FEStorage FE data structures which is frequently used by FESolver. This
// references make it easy to operate with important FE data structures.
// references make it easy to operate with important FE data structures.
BlockSparseSymMatrix<2>* matK = nullptr;
BlockSparseSymMatrix<2>* matC = nullptr;
BlockSparseSymMatrix<2>* matM = nullptr;
Expand Down
Loading