Skip to content

Commit

Permalink
Merge branch 'develop' into ci/tag-previous-s3-objects
Browse files Browse the repository at this point in the history
  • Loading branch information
tundranerd committed Apr 24, 2024
2 parents ea7ddf0 + f2ffdd3 commit 74500da
Show file tree
Hide file tree
Showing 54 changed files with 768 additions and 176 deletions.
22 changes: 11 additions & 11 deletions FEBio/FEBioApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@ bool FEBioApp::ParseCmdLine(int nargs, char* argv[])
// set initial configuration file name
if (ops.szcnf[0] == 0)
{
char szpath[1024] = { 0 };
febio::get_app_path(szpath, 1023);
sprintf(ops.szcnf, "%sfebio.xml", szpath);
char szpath[512] = { 0 };
febio::get_app_path(szpath, 511);
snprintf(ops.szcnf, 512, "%sfebio.xml", szpath);
}

// loop over the arguments
Expand Down Expand Up @@ -337,7 +337,7 @@ bool FEBioApp::ParseCmdLine(int nargs, char* argv[])
if (szext == 0)
{
// we assume a default extension of .feb if none is provided
sprintf(ops.szfile, "%s.feb", argv[i]);
snprintf(ops.szfile, sizeof(ops.szfile), "%s.feb", argv[i]);
}
else strcpy(ops.szfile, argv[i]);
ops.binteractive = false;
Expand Down Expand Up @@ -448,7 +448,7 @@ bool FEBioApp::ParseCmdLine(int nargs, char* argv[])
if (szext == 0)
{
// we assume a default extension of .feb if none is provided
sprintf(ops.szfile, "%s.feb", sz);
snprintf(ops.szfile, sizeof(ops.szfile), "%s.feb", sz);
}
else
{
Expand Down Expand Up @@ -494,9 +494,9 @@ bool FEBioApp::ParseCmdLine(int nargs, char* argv[])
}
else strcpy(szlogbase, szbase);

if (!blog) sprintf(ops.szlog, "%s.log", szlogbase);
if (!bplt) sprintf(ops.szplt, "%s.xplt", szbase);
if (!bdmp) sprintf(ops.szdmp, "%s.dmp", szbase);
if (!blog) snprintf(ops.szlog, sizeof(ops.szlog), "%s.log", szlogbase);
if (!bplt) snprintf(ops.szplt, sizeof(ops.szplt), "%s.xplt", szbase);
if (!bdmp) snprintf(ops.szdmp, sizeof(ops.szdmp), "%s.dmp", szbase);
}
else if (ops.szctrl[0])
{
Expand All @@ -505,9 +505,9 @@ bool FEBioApp::ParseCmdLine(int nargs, char* argv[])
char* ch = strrchr(szbase, '.');
if (ch) *ch = 0;

if (!blog) sprintf(ops.szlog, "%s.log", szbase);
if (!bplt) sprintf(ops.szplt, "%s.xplt", szbase);
if (!bdmp) sprintf(ops.szdmp, "%s.dmp", szbase);
if (!blog) snprintf(ops.szlog, sizeof(ops.szlog), "%s.log", szbase);
if (!bplt) snprintf(ops.szplt, sizeof(ops.szplt), "%s.xplt", szbase);
if (!bdmp) snprintf(ops.szdmp, sizeof(ops.szdmp), "%s.dmp", szbase);
}

return brun;
Expand Down
8 changes: 4 additions & 4 deletions FEBio/FEBioCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ int FEBioCmd_Config::run(int nargs, char* argv[])
}
else if (nargs == 2)
{
sprintf(ops.szcnf, "%s", argv[1]);
snprintf(ops.szcnf, sizeof(ops.szcnf), "%s", argv[1]);
feApp->Configure(ops.szcnf);
}
else return invalid_nr_args();
Expand Down Expand Up @@ -510,7 +510,7 @@ int FEBioCmd_svg::run(int nargs, char **argv)
strcpy(buf, szfile);
char* ch = strrchr(buf, '.');
if (ch) *ch = 0;
sprintf(szsvg, "%s.svg", buf);
snprintf(szsvg, 1024, "%s.svg", buf);

std::filebuf fb;
fb.open(szsvg, std::ios::out);
Expand Down Expand Up @@ -547,8 +547,8 @@ int FEBioCmd_out::run(int nargs, char **argv)
strcpy(buf, szfile);
char* ch = strrchr(buf, '.');
if (ch) *ch = 0;
sprintf(szK, "%s.out", buf);
sprintf(szR, "%s_rhs.out", buf);
snprintf(szK, 1024, "%s.out", buf);
snprintf(szR, 1024, "%s_rhs.out", buf);

febio::write_hb(*A, szK, mode);
febio::write_vector(R, szR, mode);
Expand Down
2 changes: 1 addition & 1 deletion FEBio/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void Console::SetTitle(const char* sz, ...)
// make the message
char sztitle[512];
va_start(args, sz);
vsprintf(sztitle, sz, args);
vsnprintf(sztitle, 512, sz, args);
va_end(args);

#ifdef WIN32
Expand Down
4 changes: 2 additions & 2 deletions FEBio/febio_cb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ bool update_console_cb(FEModel* pfem, unsigned int nwhen, void* pd)

char szvers[64] = {0};
#ifndef NDEBUG
sprintf(szvers, "FEBio (DEBUG) %s", szver);
snprintf(szvers, 64, "FEBio (DEBUG) %s", szver);
#else
sprintf(szvers, "FEBio %s", szver);
snprintf(szvers, 64, "FEBio %s", szver);
#endif

// print progress in title bar
Expand Down
4 changes: 2 additions & 2 deletions FEBioLib/FEBioModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1388,7 +1388,7 @@ void FEBioModel::SerializeIOData(DumpStream &ar)
// set the software string
const char* szver = febio::getVersionString();
char szbuf[256] = { 0 };
sprintf(szbuf, "FEBio %s", szver);
snprintf(szbuf, 256, "FEBio %s", szver);
xplt->SetSoftwareString(szbuf);

m_plot = xplt;
Expand Down Expand Up @@ -1480,7 +1480,7 @@ bool FEBioModel::InitPlotFile()
// set the software string
const char* szver = febio::getVersionString();
char szbuf[256] = { 0 };
sprintf(szbuf, "FEBio %s", szver);
snprintf(szbuf, 256, "FEBio %s", szver);
xplt->SetSoftwareString(szbuf);

m_plot = xplt;
Expand Down
2 changes: 1 addition & 1 deletion FEBioLib/LogStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void LogStream::printf(const char* sz, ...)
// make the message
char sztxt[1024] = { 0 };
va_start(args, sz);
vsprintf(sztxt, sz, args);
vsnprintf(sztxt, 1024, sz, args);
va_end(args);

print(sztxt);
Expand Down
16 changes: 8 additions & 8 deletions FEBioLib/Logfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void Logfile::printf(const char* sz, ...)
// make the message
char sztxt[2048] = {0};
va_start(args, sz);
vsprintf(sztxt, sz, args);
vsnprintf(sztxt, 2048, sz, args);
va_end(args);

// print to file
Expand All @@ -123,13 +123,13 @@ void Logfile::printbox(const char* sztitle, const char* sz, ...)
// make the message
char sztxt[1024] = {0};
va_start(args, sz);
vsprintf(sztxt, sz, args);
vsnprintf(sztxt, 1024, sz, args);
va_end(args);

// print the box
char szmsg[1024] = {0};
char* ch = szmsg;
sprintf(szmsg,"\n *************************************************************************\n"); ch += strlen(ch);
snprintf(szmsg,1024, "\n *************************************************************************\n"); ch += strlen(ch);
// print the title
if (sztitle)
{
Expand All @@ -138,9 +138,9 @@ void Logfile::printbox(const char* sztitle, const char* sz, ...)
char right[60] = {0};
strncpy(left, sztitle, l/2);
strncpy(right, sztitle+l/2, l - l/2);
sprintf(ch," * %33s", left); ch += strlen(ch);
sprintf(ch,"%-36s *\n", right); ch += strlen(ch);
// sprintf(ch," *%71s*\n", ""); ch += strlen(ch);
snprintf(ch,1024, " * %33s", left); ch += strlen(ch);
snprintf(ch,1024, "%-36s *\n", right); ch += strlen(ch);
// snprintf(ch,1024, " *%71s*\n", ""); ch += strlen(ch);
}

// print the message
Expand All @@ -162,13 +162,13 @@ void Logfile::printbox(const char* sztitle, const char* sz, ...)
if (cn) *cn = '\n';
cn = ct + n;
}
sprintf(ch," * %-69s *\n", ct); ch += strlen(ch);
snprintf(ch,1024," * %-69s *\n", ct); ch += strlen(ch);
if (wrap) { ct[n] = tmp; }
if (cn) ct = cn+1;
}
while (cn);
// sprintf(ch," * *\n"); ch += strlen(ch);
sprintf(ch," *************************************************************************\n");
snprintf(ch,1024," *************************************************************************\n");

// print the message
printf(szmsg);
Expand Down
18 changes: 9 additions & 9 deletions FEBioLib/cmdoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ bool febio::ProcessOptionsString(const std::string& s, CMDOPTIONS& ops)
{
char szpath[1024] = { 0 };
febio::get_app_path(szpath, 1023);
sprintf(ops.szcnf, "%sfebio.xml", szpath);
snprintf(ops.szcnf, 1024, "%sfebio.xml", szpath);
}

// loop over the arguments
Expand Down Expand Up @@ -151,7 +151,7 @@ bool febio::ProcessOptionsString(const std::string& s, CMDOPTIONS& ops)
if (szext == 0)
{
// we assume a default extension of .feb if none is provided
sprintf(ops.szfile, "%s.feb", sz);
snprintf(ops.szfile, 1024, "%s.feb", sz);
}
else strcpy(ops.szfile, sz);
ops.binteractive = false;
Expand Down Expand Up @@ -225,7 +225,7 @@ bool febio::ProcessOptionsString(const std::string& s, CMDOPTIONS& ops)
if (szext == 0)
{
// we assume a default extension of .feb if none is provided
sprintf(ops.szfile, "%s.feb", sz);
snprintf(ops.szfile, sizeof(ops.szfile), "%s.feb", sz);
}
else
{
Expand Down Expand Up @@ -271,9 +271,9 @@ bool febio::ProcessOptionsString(const std::string& s, CMDOPTIONS& ops)
}
else strcpy(szlogbase, szbase);

if (!blog) sprintf(ops.szlog, "%s.log", szlogbase);
if (!bplt) sprintf(ops.szplt, "%s.xplt", szbase);
if (!bdmp) sprintf(ops.szdmp, "%s.dmp", szbase);
if (!blog) snprintf(ops.szlog, sizeof(ops.szlog), "%s.log", szlogbase);
if (!bplt) snprintf(ops.szplt, sizeof(ops.szplt), "%s.xplt", szbase);
if (!bdmp) snprintf(ops.szdmp, sizeof(ops.szdmp), "%s.dmp", szbase);
}
else if (ops.szctrl[0])
{
Expand All @@ -282,9 +282,9 @@ bool febio::ProcessOptionsString(const std::string& s, CMDOPTIONS& ops)
char* ch = strrchr(szbase, '.');
if (ch) *ch = 0;

if (!blog) sprintf(ops.szlog, "%s.log", szbase);
if (!bplt) sprintf(ops.szplt, "%s.xplt", szbase);
if (!bdmp) sprintf(ops.szdmp, "%s.dmp", szbase);
if (!blog) snprintf(ops.szlog, sizeof(ops.szlog), "%s.log", szbase);
if (!bplt) snprintf(ops.szplt, sizeof(ops.szplt), "%s.xplt", szbase);
if (!bdmp) snprintf(ops.szdmp, sizeof(ops.szdmp), "%s.dmp", szbase);
}

return true;
Expand Down
4 changes: 2 additions & 2 deletions FEBioLib/hello.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int febio::Hello(LogStream& log)
{
char szversion[128] = { 0 };
char* szvernum = getVersionString();
sprintf(szversion, " version %s\n", szvernum);
snprintf(szversion, 128, " version %s\n", szvernum);

log.print("===========================================================================\n");
log.print(" ________ _________ _______ __ _________ \n");
Expand All @@ -62,4 +62,4 @@ int febio::Hello(LogStream& log)

return 0;
}


2 changes: 1 addition & 1 deletion FEBioLib/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void FEBioModel::print_parameter(FEParam& p, int level)
{
char sz[512] = {0};
int l = (int)strlen(p.name()) + 2*level;
sprintf(sz, "\t%*s %.*s", l, p.name(), 50-l, "..................................................");
snprintf(sz, 512, "\t%*s %.*s", l, p.name(), 50-l, "..................................................");
if (p.dim() == 1)
{
switch (p.type())
Expand Down
6 changes: 3 additions & 3 deletions FEBioLib/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ char* febio::getVersionString()
static char version[32];

#ifndef DEVCOMMIT
sprintf(version, "%d.%d.%d", VERSION, SUBVERSION, SUBSUBVERSION);
snprintf(version, 32, "%d.%d.%d", VERSION, SUBVERSION, SUBSUBVERSION);
#else
sprintf(version, "%d.%d.%d.%s", VERSION, SUBVERSION, SUBSUBVERSION, DEVCOMMIT);
snprintf(version, 32, "%d.%d.%d.%s", VERSION, SUBVERSION, SUBSUBVERSION, DEVCOMMIT);
#endif

return version;
}
}
7 changes: 5 additions & 2 deletions FEBioMech/FEBioMechModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ SOFTWARE.*/
#include "FETractionLoad.h"
#include "FESurfaceForceUniform.h"
#include "FEBearingLoad.h"
#include "FEIdealGasPressure.h"
#include "FEGenericBodyForce.h"
#include "FECentrifugalBodyForce.h"
#include "FEPointBodyForce.h"
Expand Down Expand Up @@ -634,8 +635,9 @@ void FEBioMech::InitModule()
// classes derived from FESurfaceLoad
REGISTER_FECORE_CLASS(FEPressureLoad, "pressure");
REGISTER_FECORE_CLASS(FETractionLoad, "traction");
REGISTER_FECORE_CLASS(FESurfaceForceUniform, "force");
REGISTER_FECORE_CLASS(FEBearingLoad, "bearing load");
REGISTER_FECORE_CLASS(FESurfaceForceUniform, "force");
REGISTER_FECORE_CLASS(FEBearingLoad, "bearing load");
REGISTER_FECORE_CLASS(FEIdealGasPressure, "ideal gas pressure");

//-----------------------------------------------------------------------------
// classes derived from FEBodyForce
Expand Down Expand Up @@ -863,6 +865,7 @@ void FEBioMech::InitModule()
REGISTER_FECORE_CLASS(FEPlotGrowthRightHencky, "growth right Hencky");
REGISTER_FECORE_CLASS(FEPlotGrowthLeftHencky, "growth left Hencky");
REGISTER_FECORE_CLASS(FEPlotGrowthRelativeVolume, "growth relative volume");
REGISTER_FECORE_CLASS(FEPlotIdealGasPressure, "ideal gas pressure");

// beam variables
REGISTER_FECORE_CLASS(FEPlotBeamStress , "beam stress");
Expand Down
37 changes: 34 additions & 3 deletions FEBioMech/FEBioMechPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ SOFTWARE.*/
#include <FECore/FEElement.h>
#include <FEBioMech/FEElasticBeamDomain.h>
#include <FEBioMech/FEElasticBeamMaterial.h>
#include "FEIdealGasPressure.h"

//=============================================================================
// N O D E D A T A
Expand Down Expand Up @@ -1407,8 +1408,8 @@ bool FEPlotDensity::Save(FEDomain &dom, FEDataStream& a)
if (dom.Class() == FE_DOMAIN_SOLID)
{
FESolidDomain& bd = static_cast<FESolidDomain&>(dom);
FEElasticMaterial* em = dynamic_cast<FEElasticMaterial*>(bd.GetMaterial());
if (em == 0) return false;
FEElasticMaterial* em = bd.GetMaterial()->ExtractProperty<FEElasticMaterial>();
if (em == 0) return false;

FERemodelingElasticMaterial* rm = dynamic_cast<FERemodelingElasticMaterial*>(em);
if (rm)
Expand All @@ -1426,7 +1427,7 @@ bool FEPlotDensity::Save(FEDomain &dom, FEDataStream& a)
}
else if (dom.Class() == FE_DOMAIN_SHELL)
{
FEElasticMaterial* em = dynamic_cast<FEElasticMaterial*>(dom.GetMaterial());
FEElasticMaterial* em = dom.GetMaterial()->ExtractProperty<FEElasticMaterial>();
if (em == 0) return false;
FEDensity dens(em);
writeAverageElementValue<double>(dom, a, dens);
Expand Down Expand Up @@ -4660,3 +4661,33 @@ bool FEPlotGrowthRelativeVolume::Save(FEDomain &dom, FEDataStream& a)
return true;
}


bool FEPlotIdealGasPressure::Init()
{
FEModel* fem = GetFEModel();
if (fem == nullptr) return false;

for (int i = 0; i < fem->ModelLoads(); ++i)
{
m_load = dynamic_cast<FEIdealGasPressure*>(fem->ModelLoad(i));
if (m_load) return true;
}
return (m_load != nullptr);
}

bool FEPlotIdealGasPressure::Save(FESurface& surf, FEDataStream& a)
{
if (m_binit == false)
{
if (!Init()) return false;
m_binit = true;
}
if (m_load == nullptr) return false;

if (m_load->GetSurface().GetFacetSet() == surf.GetFacetSet())
{
a << m_load->GetCurrentPressure();
return true;
}
else return false;
}
14 changes: 14 additions & 0 deletions FEBioMech/FEBioMechPlot.h
Original file line number Diff line number Diff line change
Expand Up @@ -1415,3 +1415,17 @@ class FEPlotBeamCurvature : public FEPlotDomainData
FEPlotBeamCurvature(FEModel* pfem) : FEPlotDomainData(pfem, PLT_VEC3F, FMT_ITEM) {}
bool Save(FEDomain& dom, FEDataStream& a);
};

// plot the current pressure value of the FEIdealGasPressure load
class FEIdealGasPressure;
class FEPlotIdealGasPressure : public FEPlotSurfaceData
{
public:
FEPlotIdealGasPressure(FEModel* fem) : FEPlotSurfaceData(fem, PLT_FLOAT, FMT_REGION) {}
bool Save(FESurface& surf, FEDataStream& a) override;

private:
bool Init() override;
bool m_binit = false;
FEIdealGasPressure* m_load = nullptr;
};
Loading

0 comments on commit 74500da

Please sign in to comment.