Skip to content

Commit

Permalink
Added debug log output and a plot variable for outputting the current…
Browse files Browse the repository at this point in the history
… pressure of an ideal-gas-pressure load.
  • Loading branch information
SteveMaas1978 committed Apr 23, 2024
1 parent 4488ead commit 93672d6
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 1 deletion.
1 change: 1 addition & 0 deletions FEBioMech/FEBioMechModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -865,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
31 changes: 31 additions & 0 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 @@ -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() == &surf)
{
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;
};
9 changes: 8 additions & 1 deletion FEBioMech/FEIdealGasPressure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SOFTWARE.*/
#include "stdafx.h"
#include "FEIdealGasPressure.h"
#include "FEBioMech.h"
#include <FECore/FEFacetSet.h>
#include <FECore/log.h>

BEGIN_FECORE_CLASS(FEIdealGasPressure, FESurfaceLoad)
ADD_PARAMETER(m_initialPressure, "P0")->setUnits(UNIT_PRESSURE);
Expand All @@ -39,6 +39,8 @@ FEIdealGasPressure::FEIdealGasPressure(FEModel* pfem) : FESurfaceLoad(pfem)
m_initialPressure = 0.0;
m_bsymm = true;
m_bshellb = false;
m_currentPressure = 0;
m_currentVolume = 0;
}

bool FEIdealGasPressure::Init()
Expand All @@ -64,6 +66,8 @@ void FEIdealGasPressure::Activate()
m_currentVolume = m_initialVolume;

m_currentPressure = m_initialPressure;

feLogDebug("initial volume: %lg\n", m_initialVolume);

FESurfaceLoad::Activate();
}
Expand All @@ -72,6 +76,9 @@ void FEIdealGasPressure::Update()
{
m_currentVolume = CalculateSurfaceVolume(GetSurface());
m_currentPressure = m_initialPressure * (m_initialVolume / m_currentVolume);

feLogDebug("volume: %lg, pressure: %lg\n", m_currentVolume, m_currentPressure);

FESurfaceLoad::Update();
}

Expand Down
3 changes: 3 additions & 0 deletions FEBioMech/FEIdealGasPressure.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class FEIdealGasPressure : public FESurfaceLoad

void Update() override;

public:
double GetCurrentPressure() const { return m_currentPressure; }

public:
//! calculate residual
void LoadVector(FEGlobalVector& R) override;
Expand Down

0 comments on commit 93672d6

Please sign in to comment.