Skip to content

Commit

Permalink
FELinearSystem now takes FEModel as constructor parameter instead of …
Browse files Browse the repository at this point in the history
…FESolver.
  • Loading branch information
SteveMaas1978 committed Oct 15, 2024
1 parent 1306d47 commit 622ca03
Show file tree
Hide file tree
Showing 27 changed files with 49 additions and 49 deletions.
2 changes: 1 addition & 1 deletion FEBioFluid/FEFluidFSISolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ bool FEFluidFSISolver::StiffnessMatrix()
// get the mesh
FEMesh& mesh = fem.GetMesh();

FESolidLinearSystem LS(this, &m_rigidSolver, *m_pK, m_Fd, m_ui, (m_msymm == REAL_SYMMETRIC), m_alphaf, m_nreq);
FESolidLinearSystem LS(&fem, &m_rigidSolver, *m_pK, m_Fd, m_ui, (m_msymm == REAL_SYMMETRIC), m_alphaf, m_nreq);

// calculate the stiffness matrix for each domain
for (int i=0; i<mesh.Domains(); ++i)
Expand Down
2 changes: 1 addition & 1 deletion FEBioFluid/FEMultiphasicFSISolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@ bool FEMultiphasicFSISolver::StiffnessMatrix()
// get the mesh
FEMesh& mesh = fem.GetMesh();

FESolidLinearSystem LS(this, &m_rigidSolver, *m_pK, m_Fd, m_ui, (m_msymm == REAL_SYMMETRIC), m_alphaf, m_nreq);
FESolidLinearSystem LS(&fem, &m_rigidSolver, *m_pK, m_Fd, m_ui, (m_msymm == REAL_SYMMETRIC), m_alphaf, m_nreq);

// calculate the stiffness matrix for each domain
for (int i=0; i<mesh.Domains(); ++i)
Expand Down
2 changes: 1 addition & 1 deletion FEBioMech/FEFacet2FacetSliding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ void FEFacet2FacetSliding::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo&
FEMesh* pm = m_ss.GetMesh();

// see how many reformations we've had to do so far
int nref = LS.GetSolver()->m_nref;
int nref = GetSolver()->m_nref;

// get the "size" of the model
// We need this to scale the insertion distance
Expand Down
2 changes: 1 addition & 1 deletion FEBioMech/FESlidingElasticInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,7 @@ void FESlidingElasticInterface::LoadVector(FEGlobalVector& R, const FETimeInfo&
void FESlidingElasticInterface::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp)
{
// see how many reformations we've had to do so far
int nref = LS.GetSolver()->m_nref;
int nref = GetSolver()->m_nref;

const int MN = FEElement::MAX_NODES;

Expand Down
6 changes: 3 additions & 3 deletions FEBioMech/FESolidLinearSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ SOFTWARE.*/
#include <FECore/FELinearConstraintManager.h>
#include <FECore/FEModel.h>

FESolidLinearSystem::FESolidLinearSystem(FESolver* solver, FERigidSolver* rigidSolver, FEGlobalMatrix& K, std::vector<double>& F, std::vector<double>& u, bool bsymm, double alpha, int nreq) : FELinearSystem(solver, K, F, u, bsymm)
FESolidLinearSystem::FESolidLinearSystem(FEModel* fem, FERigidSolver* rigidSolver, FEGlobalMatrix& K, std::vector<double>& F, std::vector<double>& u, bool bsymm, double alpha, int nreq) : FELinearSystem(fem, K, F, u, bsymm)
{
m_fem = fem;
m_rigidSolver = rigidSolver;
m_alpha = alpha;
m_nreq = nreq;
Expand Down Expand Up @@ -73,8 +74,7 @@ void FESolidLinearSystem::Assemble(const FEElementMatrix& ke)
vector<double>& ui = m_u;

// adjust for linear constraints
FEModel* fem = m_solver->GetFEModel();
FELinearConstraintManager& LCM = fem->GetLinearConstraintManager();
FELinearConstraintManager& LCM = m_fem->GetLinearConstraintManager();
if (LCM.LinearConstraints() > 0)
{
#pragma omp critical (LCM_assemble)
Expand Down
3 changes: 2 additions & 1 deletion FEBioMech/FESolidLinearSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class FERigidSolver;
class FEBIOMECH_API FESolidLinearSystem : public FELinearSystem
{
public:
FESolidLinearSystem(FESolver* solver, FERigidSolver* rigidSolver, FEGlobalMatrix& K, std::vector<double>& F, std::vector<double>& u, bool bsymm, double alpha, int nreq);
FESolidLinearSystem(FEModel* fem, FERigidSolver* rigidSolver, FEGlobalMatrix& K, std::vector<double>& F, std::vector<double>& u, bool bsymm, double alpha, int nreq);

// Assembly routine
// This assembles the element stiffness matrix ke into the global matrix.
Expand All @@ -46,6 +46,7 @@ class FEBIOMECH_API FESolidLinearSystem : public FELinearSystem
void StiffnessAssemblyScaleFactor(double a);

private:
FEModel* fem;
FERigidSolver* m_rigidSolver;
double m_alpha;
int m_nreq;
Expand Down
2 changes: 1 addition & 1 deletion FEBioMech/FESolidSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ bool FESolidSolver::StiffnessMatrix()
const FETimeInfo& tp = fem.GetTime();

// setup the linear syster
FESolidLinearSystem LS(this, &m_rigidSolver, *m_pK, m_Fd, m_ui, (m_msymm == REAL_SYMMETRIC), 1.0, m_nreq);
FESolidLinearSystem LS(&fem, &m_rigidSolver, *m_pK, m_Fd, m_ui, (m_msymm == REAL_SYMMETRIC), 1.0, m_nreq);

// get the mesh
FEMesh& mesh = fem.GetMesh();
Expand Down
4 changes: 2 additions & 2 deletions FEBioMech/FESolidSolver2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ bool FESolidSolver2::InitAccelerations()

// setup the linear system
m_pK->Zero();
FESolidLinearSystem LS(this, &m_rigidSolver, *m_pK, m_Fd, m_ui, (m_msymm == REAL_SYMMETRIC), 1.0, m_nreq);
FESolidLinearSystem LS(&fem, &m_rigidSolver, *m_pK, m_Fd, m_ui, (m_msymm == REAL_SYMMETRIC), 1.0, m_nreq);

// build the global mass matrix
FEMesh& mesh = fem.GetMesh();
Expand Down Expand Up @@ -1324,7 +1324,7 @@ bool FESolidSolver2::StiffnessMatrix()
FEMesh& mesh = fem.GetMesh();

// setup the linear system
FESolidLinearSystem LS(this, &m_rigidSolver, *m_pK, m_Fd, m_ui, (m_msymm == REAL_SYMMETRIC), m_alpha, m_nreq);
FESolidLinearSystem LS(&fem, &m_rigidSolver, *m_pK, m_Fd, m_ui, (m_msymm == REAL_SYMMETRIC), m_alpha, m_nreq);

// calculate the stiffness matrix for each domain
for (int i=0; i<mesh.Domains(); ++i)
Expand Down
2 changes: 1 addition & 1 deletion FEBioMech/FETiedElasticInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ void FETiedElasticInterface::StiffnessMatrix(FELinearSystem& LS, const FETimeInf
FEElementMatrix ke;

// see how many reformations we've had to do so far
int nref = LS.GetSolver()->m_nref;
int nref = GetSolver()->m_nref;

// set higher order stiffness mutliplier
// NOTE: this algrotihm doesn't really need this
Expand Down
2 changes: 1 addition & 1 deletion FEBioMix/FEBiphasicSoluteSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ bool FEBiphasicSoluteSolver::StiffnessMatrix()
FEMesh& mesh = fem.GetMesh();

// setup the linear system
FESolidLinearSystem LS(this, &m_rigidSolver, *m_pK, m_Fd, m_ui, (m_msymm == REAL_SYMMETRIC), m_alpha, m_nreq);
FESolidLinearSystem LS(&fem, &m_rigidSolver, *m_pK, m_Fd, m_ui, (m_msymm == REAL_SYMMETRIC), m_alpha, m_nreq);

// calculate the stiffness matrix for each domain
FEAnalysis* pstep = fem.GetCurrentStep();
Expand Down
2 changes: 1 addition & 1 deletion FEBioMix/FEBiphasicSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ bool FEBiphasicSolver::StiffnessMatrix()
FEMesh& mesh = fem.GetMesh();

// setup the linear system of equations
FESolidLinearSystem LS(this, &m_rigidSolver, *m_pK, m_Fd, m_ui, (m_msymm == REAL_SYMMETRIC), m_alpha, m_nreq);
FESolidLinearSystem LS(&fem, &m_rigidSolver, *m_pK, m_Fd, m_ui, (m_msymm == REAL_SYMMETRIC), m_alpha, m_nreq);

// calculate the stiffness matrix for each domain
FEAnalysis* pstep = fem.GetCurrentStep();
Expand Down
2 changes: 1 addition & 1 deletion FEBioMix/FEMultiphasicSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ bool FEMultiphasicSolver::StiffnessMatrix()
// get the mesh
FEMesh& mesh = fem.GetMesh();

FESolidLinearSystem LS(this, &m_rigidSolver, *m_pK, m_Fd, m_ui, (m_msymm == REAL_SYMMETRIC), m_alpha, m_nreq);
FESolidLinearSystem LS(&fem, &m_rigidSolver, *m_pK, m_Fd, m_ui, (m_msymm == REAL_SYMMETRIC), m_alpha, m_nreq);

// calculate the stiffness matrix for each domain
FEAnalysis* pstep = fem.GetCurrentStep();
Expand Down
2 changes: 1 addition & 1 deletion FEBioMix/FESlidingInterface2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,7 @@ void FESlidingInterface2::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo&
double psf = GetPenaltyScaleFactor();

// see how many reformations we've had to do so far
int nref = LS.GetSolver()->m_nref;
int nref = GetSolver()->m_nref;

// set higher order stiffness mutliplier
// NOTE: this algrotihm doesn't really need this
Expand Down
2 changes: 1 addition & 1 deletion FEBioMix/FESlidingInterface3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1379,7 +1379,7 @@ void FESlidingInterface3::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo&
double psf = GetPenaltyScaleFactor();

// see how many reformations we've had to do so far
int nref = LS.GetSolver()->m_nref;
int nref = GetSolver()->m_nref;

// set higher order stiffness mutliplier
// NOTE: this algrotihm doesn't really need this
Expand Down
2 changes: 1 addition & 1 deletion FEBioMix/FESlidingInterfaceBiphasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1590,7 +1590,7 @@ void FESlidingInterfaceBiphasic::LoadVector(FEGlobalVector& R, const FETimeInfo&
void FESlidingInterfaceBiphasic::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp)
{
// see how many reformations we've had to do so far
int nref = LS.GetSolver()->m_nref;
int nref = GetSolver()->m_nref;

const int MN = FEElement::MAX_NODES;

Expand Down
2 changes: 1 addition & 1 deletion FEBioMix/FESlidingInterfaceBiphasicMixed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1688,7 +1688,7 @@ void FESlidingInterfaceBiphasicMixed::StiffnessMatrix(FESlidingSurfaceBiphasicMi
int degree_p = dofs.GetVariableInterpolationOrder(ss.m_varP);

// see how many reformations we've had to do so far
int nref = LS.GetSolver()->m_nref;
int nref = GetSolver()->m_nref;

const int MN = FEElement::MAX_NODES;

Expand Down
2 changes: 1 addition & 1 deletion FEBioMix/FESlidingInterfaceMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2011,7 +2011,7 @@ void FESlidingInterfaceMP::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo&
double psf = GetPenaltyScaleFactor();

// see how many reformations we've had to do so far
int nref = LS.GetSolver()->m_nref;
int nref = GetSolver()->m_nref;

// set higher order stiffness mutliplier
// NOTE: this algorithm doesn't really need this
Expand Down
2 changes: 1 addition & 1 deletion FEBioMix/FETiedBiphasicInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ void FETiedBiphasicInterface::StiffnessMatrix(FELinearSystem& LS, const FETimeIn
FEMesh* pm = m_ss.GetMesh();

// see how many reformations we've had to do so far
int nref = LS.GetSolver()->m_nref;
int nref = GetSolver()->m_nref;

// set higher order stiffness mutliplier
// NOTE: this algrotihm doesn't really need this
Expand Down
2 changes: 1 addition & 1 deletion FEBioMix/FETiedMultiphasicInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ void FETiedMultiphasicInterface::StiffnessMatrix(FELinearSystem& LS, const FETim
FEModel& fem = *GetFEModel();

// see how many reformations we've had to do so far
int nref = LS.GetSolver()->m_nref;
int nref = GetSolver()->m_nref;

// set higher order stiffness mutliplier
// NOTE: this algorithm doesn't really need this
Expand Down
2 changes: 1 addition & 1 deletion FEBioTest/FEContactDiagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ bool FEContactDiagnostic::Run()
int neq = solver.m_neq;
vector<double> Fd(neq, 0.0);
vector<double> ui(neq, 0.0);
FELinearSystem LS(&solver, K, Fd, ui, true);
FELinearSystem LS(&fem, K, Fd, ui, true);

// build the stiffness matrix
K0.Zero();
Expand Down
2 changes: 1 addition & 1 deletion FEBioTest/FEContactDiagnosticBiphasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ bool FEContactDiagnosticBiphasic::Run()
int neq = solver.m_neq;
vector<double> Fd(neq, 0.0);
vector<double> ui(neq, 0.0);
FELinearSystem LS(&solver, K, Fd, ui, true);
FELinearSystem LS(&fem, K, Fd, ui, true);

// build the stiffness matrix
K.Zero();
Expand Down
2 changes: 1 addition & 1 deletion FECore/FELinearSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ bool FELinearSolver::ReformStiffness()
{
TRACK_TIME(TimerID::Timer_Stiffness);

FELinearSystem K(this, *m_pK, m_R, m_u, (m_msymm == REAL_SYMMETRIC));
FELinearSystem K(GetFEModel(), *m_pK, m_R, m_u, (m_msymm == REAL_SYMMETRIC));
if (!StiffnessMatrix(K)) return false;

// do call back
Expand Down
26 changes: 9 additions & 17 deletions FECore/FELinearSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ SOFTWARE.*/
#include "FEModel.h"

//-----------------------------------------------------------------------------
FELinearSystem::FELinearSystem(FESolver* solver, FEGlobalMatrix& K, vector<double>& F, vector<double>& u, bool bsymm) : m_K(K), m_F(F), m_u(u), m_solver(solver)
FELinearSystem::FELinearSystem(FEModel* fem, FEGlobalMatrix& K, vector<double>& F, vector<double>& u, bool bsymm) : m_K(K), m_F(F), m_u(u), m_fem(fem)
{
m_bsymm = bsymm;
}
Expand All @@ -50,14 +50,6 @@ bool FELinearSystem::IsSymmetric() const
return m_bsymm;
}

//-----------------------------------------------------------------------------
// Get the solver that is using this linear system
FESolver* FELinearSystem::GetSolver()
{
return m_solver;
}

//-----------------------------------------------------------------------------
//! assemble global stiffness matrix
void FELinearSystem::Assemble(const FEElementMatrix& ke)
{
Expand Down Expand Up @@ -98,16 +90,16 @@ void FELinearSystem::Assemble(const FEElementMatrix& ke)
}
}

#pragma omp critical (LC_assemble)
{
FEModel* fem = m_solver->GetFEModel();
FELinearConstraintManager& LCM = fem->GetLinearConstraintManager();
if (LCM.LinearConstraints())
if (m_fem)
{
const vector<int>& en = ke.Nodes();
LCM.AssembleStiffness(m_K, m_F, m_u, en, lmi, lmj, ke);
FELinearConstraintManager& LCM = m_fem->GetLinearConstraintManager();
if (LCM.LinearConstraints())
{
const vector<int>& en = ke.Nodes();
#pragma omp critical (LC_assemble)
LCM.AssembleStiffness(m_K, m_F, m_u, en, lmi, lmj, ke);
}
}
} // omp critical
}

//-----------------------------------------------------------------------------
Expand Down
9 changes: 3 additions & 6 deletions FECore/FELinearSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ SOFTWARE.*/
#include "matrix.h"
#include <vector>

class FESolver;
class FEModel;

//-----------------------------------------------------------------------------
// Experimental class to see if all the assembly operations can be moved to a class
Expand All @@ -44,17 +44,14 @@ class FECORE_API FELinearSystem
// and a vector F which contains the assembled contribution of the prescribed
// degrees of freedom. The F vector must be added to the "force" vector. The u
// vector contains the nodal values of the prescribed degrees of freedom.
FELinearSystem(FESolver* solver, FEGlobalMatrix& K, std::vector<double>& F, std::vector<double>& u, bool bsymm);
FELinearSystem(FEModel* fem, FEGlobalMatrix& K, std::vector<double>& F, std::vector<double>& u, bool bsymm);

// virtual destructor
virtual ~FELinearSystem();

// get symmetry flag
bool IsSymmetric() const;

// Get the solver that is using this linear system
FESolver* GetSolver();

public:
// Assembly routine
// This assembles the element stiffness matrix ke into the global matrix.
Expand All @@ -70,7 +67,7 @@ class FECORE_API FELinearSystem

protected:
bool m_bsymm; //!< symmetry flag
FESolver* m_solver;
FEModel* m_fem;
FEGlobalMatrix& m_K; //!< The global stiffness matrix
std::vector<double>& m_F; //!< Contributions from prescribed degrees of freedom
std::vector<double>& m_u; //!< the array with prescribed values
Expand Down
8 changes: 8 additions & 0 deletions FECore/FEModelComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ SOFTWARE.*/
#include "stdafx.h"
#include "FEModelComponent.h"
#include "FEModel.h"
#include "FEAnalysis.h"
#include "DumpStream.h"
#include <string.h>

Expand Down Expand Up @@ -92,6 +93,13 @@ const FETimeInfo& FEModelComponent::GetTimeInfo() const
return GetFEModel()->GetTime();
}

FESolver* FEModelComponent::GetSolver()
{
FEAnalysis* step = GetFEModel()->GetCurrentStep();
if (step == nullptr) return nullptr;
return step->GetFESolver();
}

//-----------------------------------------------------------------------------
void FEModelComponent::AttachLoadController(const char* szparam, int lc)
{
Expand Down
2 changes: 2 additions & 0 deletions FECore/FEModelComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ SOFTWARE.*/
//! to the constructor.
class FENodeSet;
class FEMesh;
class FESolver;

//-----------------------------------------------------------------------------
//! This class serves as a base class for many of the FECore classes. It defines
Expand Down Expand Up @@ -64,6 +65,7 @@ class FECORE_API FEModelComponent : public FECoreBase
int GetDOFIndex(const char* szvar, int n) const;
int GetDOFIndex(const char* szdof) const;
const FETimeInfo& GetTimeInfo() const;
FESolver* GetSolver();
void AttachLoadController(const char* szparam, int lc);
void AttachLoadController(void* pd, int lc);

Expand Down
2 changes: 1 addition & 1 deletion FECore/FENewtonSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ void FENewtonSolver::UpdateModel()
bool FENewtonSolver::StiffnessMatrix()
{
// setup the linear system
FELinearSystem LS(this, *m_pK, m_Fd, m_ui, (m_msymm == REAL_SYMMETRIC));
FELinearSystem LS(GetFEModel(), *m_pK, m_Fd, m_ui, (m_msymm == REAL_SYMMETRIC));

// build the stiffness matrix
return StiffnessMatrix(LS);
Expand Down

0 comments on commit 622ca03

Please sign in to comment.