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
2 changes: 1 addition & 1 deletion src/ASM/ASMbase.C
Original file line number Diff line number Diff line change
Expand Up @@ -1831,7 +1831,7 @@ bool ASMbase::inActive (double time) const
if (myElActive)
{
for (size_t iel = 0; iel < nel; iel++)
if (MLGE[iel] > 0 && time+1.0e-12 > (*myElActive)(iel))
if (MLGE[iel] > 0 && time+1.0e-12 > (*myElActive)(1+iel))
return false; // we have at least one active element
return true; // no elements activated at this time
}
Expand Down
7 changes: 4 additions & 3 deletions src/Utility/DataExporter.C
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ bool DataExporter::dumpTimeLevel (const TimeStep* tp, bool geoUpd, bool doLog)
PROFILE1("DataExporter::dumpTimeLevel");

++m_level;
double time = tp ? tp->time.t : 0.0;
if (tp && doLog)
IFEM::cout <<" Dumping results for step="<< tp->step <<" time="
<< tp->time.t <<" (time level "<< m_level <<")"<< std::endl;
<< time <<" (time level "<< m_level <<")"<< std::endl;

for (DataWriter* writer : m_writers) {
writer->openFile(m_level);
Expand All @@ -131,7 +132,7 @@ bool DataExporter::dumpTimeLevel (const TimeStep* tp, bool geoUpd, bool doLog)
writer->writeVector(m_level,it);
break;
case SIM:
writer->writeSIM(m_level,it,geoUpd,it.second.prefix);
writer->writeSIM(m_level,time,it,geoUpd,it.second.prefix);
break;
case NODALFORCES:
writer->writeNodalForces(m_level,it);
Expand All @@ -149,7 +150,7 @@ bool DataExporter::dumpTimeLevel (const TimeStep* tp, bool geoUpd, bool doLog)
}
}
if (tp && tp->multiSteps())
writer->writeTimeInfo(m_level,m_ndump,*tp);
writer->writeTimeInfo(m_level,time);

writer->closeFile(m_level);
}
Expand Down
16 changes: 8 additions & 8 deletions src/Utility/DataExporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ class DataExporter : public ControlCallback
ONCE = 32, //!< Only write field once
GRID = 128, //!< Always store an updated grid
REDUNDANT = 256, //!< Field is redundantly calculated on all processes
L2G_NODE = 512 //!< Store local-to-global node mapping
L2G_NODE = 512, //!< Storage of local-to-global node mapping
ELEMENT_MASK = 1024 //!< Storage of element activation flags
};

//! \brief A structure holding information about registered fields
Expand Down Expand Up @@ -144,8 +145,8 @@ class DataExporter : public ControlCallback
int m_last_step; //!< Last time step we dumped for
};

//! \brief Convenience type
typedef std::pair<std::string,DataExporter::FileEntry> DataEntry;
//! \brief Convenience type alias
using DataEntry = std::pair<std::string,DataExporter::FileEntry>;


/*!
Expand Down Expand Up @@ -184,10 +185,11 @@ class DataWriter

//! \brief Writes data from a SIM object to file.
//! \param[in] level The time level to write the data at
//! \param[in] time Current time
//! \param[in] entry The DataEntry describing the vector
//! \param[in] geometryUpdated Whether or not geometries should be written
//! \param[in] prefix Field name prefix
virtual void writeSIM(int level, const DataEntry& entry,
virtual void writeSIM(int level, double time, const DataEntry& entry,
bool geometryUpdated, const std::string& prefix) = 0;

//! \brief Writes nodal forces to file.
Expand All @@ -211,10 +213,8 @@ class DataWriter

//! \brief Writes time stepping info to file.
//! \param[in] level The time level to write the info at
//! \param[in] interval The number of time steps between each data dump
//! \param[in] tp The current time stepping info
virtual bool writeTimeInfo(int level, int interval,
const TimeStep& tp) = 0;
//! \param[in] time Current time
virtual bool writeTimeInfo(int level, double time) = 0;

//! \brief Write a log to output file.
//! \param data Text to write
Expand Down
21 changes: 14 additions & 7 deletions src/Utility/Functions.C
Original file line number Diff line number Diff line change
Expand Up @@ -849,15 +849,18 @@ const RealFunc* utl::parseRealFunc (char* cline, Real A, bool print)

IntFunc* utl::parseIntFunc (const std::string& func, const std::string& type)
{
class Identity : public IntFunc
class Linear : public IntFunc
{
Real s; // Scaling factor
Real s, o; // Scaling factor and offset

public:
Identity(Real sf) : s(sf) {}
Linear(Real sf, Real ofs) : s(sf), o(ofs) {}

protected:
Real evaluate(const int& x) const override { return s*Real(x > 1 ? x : 0); }
Real evaluate(const int& x) const override
{
return s*Real(x > 1 || o > Real(0) ? x : 0) + o;
}
};

// This class can be used as an element activation function, where a bunch of
Expand Down Expand Up @@ -919,17 +922,21 @@ IntFunc* utl::parseIntFunc (const std::string& func, const std::string& type)
return new Parametric(ne0,ne1,ts,sf);
}

Real scaling(1);
Real scaling(1), offset(0);
if (func.empty())
IFEM::cout <<" ** utl::parseIntFunc: \""<< type
<<"\" not implemented - returning identity"<< std::endl;
else
{
// This will take simple expressions on the form <a>*t+/-<b>
// where <a> and <b> are numerical values, and not much else
char* prms = strdup(func.c_str());
scaling = atof(strtok(prms," "));
scaling = atof(strtok(prms," *t"));
if (char* s = strtok(nullptr," *t"); s)
offset = atof(s);
free(prms);
}
return new Identity(scaling);
return new Linear(scaling,offset);
}


Expand Down
Loading