keyword
stringclasses
7 values
repo_name
stringlengths
8
98
file_path
stringlengths
4
244
file_extension
stringclasses
29 values
file_size
int64
0
84.1M
line_count
int64
0
1.6M
content
stringlengths
1
84.1M
language
stringclasses
14 values
3D
febiosoftware/FEBio
FEBioFluid/FESolutesDomainFactory.cpp
.cpp
2,006
54
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FESolutesDomainFactory.h" #include "FESolutesMaterial.h" #include "FESolutesDomain.h" //----------------------------------------------------------------------------- FEDomain* FESolutesDomainFactory::CreateDomain(const FE_Element_Spec& spec, FEMesh* pm, FEMaterial* pmat) { FEModel* pfem = pmat->GetFEModel(); FE_Element_Class eclass = spec.eclass; FE_Element_Shape eshape = spec.eshape; const char* sztype = 0; if (dynamic_cast<FESolutesMaterial*>(pmat)) { // fluid elements if (eclass == FE_ELEM_SOLID) sztype = "solutes-3D"; else return 0; } if (sztype) { FEDomain* pd = fecore_new<FESolidDomain>(sztype, pfem); if (pd) pd->SetMaterial(pmat); return pd; } else return 0; }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEFluidSolutesSolver.cpp
.cpp
41,496
1,229
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEBioFluidSolutes.h" #include "FEFluidSolutesSolver.h" #include "FEFluidDomain.h" #include "FEFluidResidualVector.h" #include "FEFluidResistanceBC.h" #include "FEBackFlowStabilization.h" #include "FEFluidNormalVelocity.h" #include "FEFluidVelocity.h" #include "FEFluidRotationalVelocity.h" #include "FETiedFluidInterface.h" #include <FECore/FEModel.h> #include <FECore/log.h> #include <FECore/DOFS.h> #include <assert.h> #include <FECore/FEGlobalMatrix.h> #include <FECore/sys.h> #include <FEBioMech/FEBodyForce.h> #include <FEBioMech/FEResidualVector.h> #include <FECore/FEBoundaryCondition.h> #include <FECore/FENodalLoad.h> #include <FECore/FESurfaceLoad.h> #include <FECore/FEModelLoad.h> #include <FECore/FEAnalysis.h> #include <FECore/FENLConstraint.h> #include <FECore/FELinearConstraintManager.h> #include <FECore/FELinearSystem.h> #include "FEFluidSolutesAnalysis.h" #include <limits> //----------------------------------------------------------------------------- // define the parameter list BEGIN_FECORE_CLASS(FEFluidSolutesSolver, FENewtonSolver) ADD_PARAMETER(m_Vtol , "vtol" ); ADD_PARAMETER(m_Ftol , "ftol" ); ADD_PARAMETER(m_Ctol , "ctol" ); ADD_PARAMETER(m_Etol, FE_RANGE_GREATER_OR_EQUAL(0.0), "etol"); ADD_PARAMETER(m_Rtol, FE_RANGE_GREATER_OR_EQUAL(0.0), "rtol"); ADD_PARAMETER(m_rhoi , "rhoi" ); ADD_PARAMETER(m_pred , "predictor" ); ADD_PARAMETER(m_minJf, "min_volume_ratio"); ADD_PARAMETER(m_forcePositive, "force_positive_concentrations"); ADD_PARAMETER(m_solve_strategy, "solve_strategy")->setEnums("coupled\0sequential\0"); ADD_PARAMETER(m_cmin , "min_C_drop")->SetFlags(FEParamFlag::FE_PARAM_HIDDEN); ADD_PARAMETER(m_cmax , "min_C_rise")->SetFlags(FEParamFlag::FE_PARAM_HIDDEN); ADD_PARAMETER(m_cnum , "min_C_num")->SetFlags(FEParamFlag::FE_PARAM_HIDDEN); END_FECORE_CLASS(); //----------------------------------------------------------------------------- //! FEFluidSolutesSolver Construction // FEFluidSolutesSolver::FEFluidSolutesSolver(FEModel* pfem) : FENewtonSolver(pfem), m_dofW(pfem), m_dofAW(pfem), m_dofEF(pfem), m_dofC(pfem) { // default values m_Rtol = 0.001; m_Etol = 0.01; m_Vtol = 0.001; m_Ftol = 0.001; m_Ctol = 0.01; m_Rmin = 1.0e-20; m_Rmax = 0; // not used if zero m_minJf = 0; // not used if zero m_cmin = 0; // not used if zero m_cmax = 0; // not used if zero m_cnum = 1; m_nveq = 0; m_ndeq = 0; m_niter = 0; // assume non-symmetric stiffness m_msymm = REAL_UNSYMMETRIC; m_forcePositive = true; // force all concentrations to remain positive m_solve_strategy = SOLVE_COUPLED; m_rhoi = 0; m_pred = 0; m_sudden_C_change = false; // Preferred strategy is Broyden's method SetDefaultStrategy(QN_BROYDEN); // turn off checking for a zero diagonal CheckZeroDiagonal(false); } //----------------------------------------------------------------------------- FEFluidSolutesSolver::~FEFluidSolutesSolver() { } //----------------------------------------------------------------------------- //! Allocates and initializes the data structures used by the FEFluidSolutesSolver // bool FEFluidSolutesSolver::Init() { // initialize base class if (FENewtonSolver::Init() == false) return false; // check parameters if (m_Vtol < 0.0) { feLogError("vtol must be nonnegative."); return false; } if (m_Ftol < 0.0) { feLogError("dtol must be nonnegative."); return false; } if (m_Ctol < 0.0) { feLogError("ctol must be nonnegative."); return false; } if (m_Etol < 0.0) { feLogError("etol must be nonnegative."); return false; } if (m_Rtol < 0.0) { feLogError("rtol must be nonnegative."); return false; } if (m_rhoi == -1) { m_alphaf = m_alpham = m_gammaf = 1.0; } else if ((m_rhoi >= 0) && (m_rhoi <= 1)) { m_alphaf = 1.0/(1+m_rhoi); m_alpham = (3-m_rhoi)/(1+m_rhoi)/2; m_gammaf = 0.5 + m_alpham - m_alphaf; } else { feLogError("rhoi must be -1 or between 0 and 1."); return false; } // allocate vectors int neq = m_neq; m_Fr.assign(neq, 0); m_Ui.assign(neq, 0); m_Ut.assign(neq, 0); m_vi.assign(m_nveq,0); m_Vi.assign(m_nveq,0); m_di.assign(m_ndeq,0); m_Di.assign(m_ndeq,0); // get number of DOFS FEModel& fem = *GetFEModel(); DOFS& fedofs = fem.GetDOFS(); int MAX_CDOFS = fedofs.GetVariableSize(FEBioFluidSolutes::GetVariableName(FEBioFluidSolutes::FLUID_CONCENTRATION)); // allocate concentration-vectors m_ci.assign(MAX_CDOFS,vector<double>(0,0)); m_Ci.assign(MAX_CDOFS,vector<double>(0,0)); for (int i=0; i<MAX_CDOFS; ++i) { m_ci[i].assign(m_nceq[i], 0); m_Ci[i].assign(m_nceq[i], 0); } vector<int> dofs; for (int j=0; j<(int)m_nceq.size(); ++j) { if (m_nceq[j]) { dofs.push_back(m_dofC[j]); } } // we need to fill the total DOF vector m_Ut // TODO: I need to find an easier way to do this FEMesh& mesh = fem.GetMesh(); gather(m_Ut, mesh, m_dofW[0]); gather(m_Ut, mesh, m_dofW[1]); gather(m_Ut, mesh, m_dofW[2]); gather(m_Ut, mesh, m_dofEF[0]); gather(m_Ut, mesh, dofs); // set flag for transient or steady-state analyses for (int i = 0; i<mesh.Domains(); ++i) { FEFluidDomain& dom = dynamic_cast<FEFluidDomain&>(mesh.Domain(i)); if (fem.GetCurrentStep()->m_nanalysis == FEFluidSolutesAnalysis::STEADY_STATE) dom.SetSteadyStateAnalysis(); else dom.SetTransientAnalysis(); } return true; } //----------------------------------------------------------------------------- //! Initialize equations bool FEFluidSolutesSolver::InitEquations() { FEModel& fem = *GetFEModel(); FEMesh& mesh = fem.GetMesh(); m_dofW.AddVariable(FEBioFluidSolutes::GetVariableName(FEBioFluidSolutes::RELATIVE_FLUID_VELOCITY)); m_dofAW.AddVariable(FEBioFluidSolutes::GetVariableName(FEBioFluidSolutes::RELATIVE_FLUID_ACCELERATION)); m_dofEF.AddVariable(FEBioFluidSolutes::GetVariableName(FEBioFluidSolutes::FLUID_DILATATION)); m_dofAEF = fem.GetDOFIndex(FEBioFluidSolutes::GetVariableName(FEBioFluidSolutes::FLUID_DILATATION_TDERIV), 0); m_dofC.AddVariable(FEBioFluidSolutes::GetVariableName(FEBioFluidSolutes::FLUID_CONCENTRATION)); m_dofAC = fem.GetDOFIndex(FEBioFluidSolutes::GetVariableName(FEBioFluidSolutes::FLUID_CONCENTRATION_TDERIV), 0); // Add the solution variables AddSolutionVariable(&m_dofW, 1, "velocity", m_Vtol); AddSolutionVariable(&m_dofEF, 1, "dilatation", m_Ftol); AddSolutionVariable(&m_dofC, 1, "concentration", m_Ctol); // base class initialization if (FENewtonSolver::InitEquations() == false) return false; // determined the nr of velocity and dilatation equations m_nveq = m_ndeq = 0; for (int i=0; i<mesh.Nodes(); ++i) { FENode& n = mesh.Node(i); if (n.m_ID[m_dofW[0]] != -1) m_nveq++; if (n.m_ID[m_dofW[1]] != -1) m_nveq++; if (n.m_ID[m_dofW[2]] != -1) m_nveq++; if (n.m_ID[m_dofEF[0]] != -1) m_ndeq++; } // determine the nr of concentration equations DOFS& fedofs = fem.GetDOFS(); int MAX_CDOFS = fedofs.GetVariableSize(FEBioFluidSolutes::GetVariableName(FEBioFluidSolutes::FLUID_CONCENTRATION)); m_nceq.assign(MAX_CDOFS, 0); // get number of DOFS for (int i=0; i<mesh.Nodes(); ++i) { FENode& n = mesh.Node(i); for (int j=0; j<MAX_CDOFS; ++j) { if (n.m_ID[m_dofC[j]] != -1) m_nceq[j]++; } } // get the total concentration equations m_nseq = 0; for (int i = 0; i < MAX_CDOFS; ++i) m_nseq += m_nceq[i]; // check that we are using a block scheme for sequential solves if ((m_solve_strategy == SOLVE_SEQUENTIAL) && (m_eq_scheme != EQUATION_SCHEME::BLOCK)) { feLogWarning("You need a block solver when using the sequential solve strategy."); return false; } // Next, we add any Lagrange Multipliers for (int i = 0; i < fem.NonlinearConstraints(); ++i) { FENLConstraint* lmc = fem.NonlinearConstraint(i); if (lmc->IsActive()) { m_neq += lmc->InitEquations(m_neq); } } for (int i = 0; i < fem.SurfacePairConstraints(); ++i) { FESurfacePairConstraint* spc = fem.SurfacePairConstraint(i); if (spc->IsActive()) { m_neq += spc->InitEquations(m_neq); } } if (m_eq_scheme == EQUATION_SCHEME::BLOCK) { // repartition the equations so that we only have two partitions, // one for the fluid-dilataion, and one for the solutes. // fluid equations is all the rest int nfeq = m_neq - m_nseq; // create the new partitions // Note that this assumes that the solute equations are always last! vector<int> p = { nfeq, m_nseq }; SetPartitions(p); } return true; } //----------------------------------------------------------------------------- void FEFluidSolutesSolver::GetVelocityData(vector<double> &vi, vector<double> &ui) { FEModel& fem = *GetFEModel(); int N = fem.GetMesh().Nodes(), nid, m = 0; zero(vi); for (int i=0; i<N; ++i) { FENode& n = fem.GetMesh().Node(i); nid = n.m_ID[m_dofW[0]]; if (nid != -1) { nid = (nid < -1 ? -nid-2 : nid); vi[m++] = ui[nid]; assert(m <= (int) vi.size()); } nid = n.m_ID[m_dofW[1]]; if (nid != -1) { nid = (nid < -1 ? -nid-2 : nid); vi[m++] = ui[nid]; assert(m <= (int) vi.size()); } nid = n.m_ID[m_dofW[2]]; if (nid != -1) { nid = (nid < -1 ? -nid-2 : nid); vi[m++] = ui[nid]; assert(m <= (int) vi.size()); } } } //----------------------------------------------------------------------------- void FEFluidSolutesSolver::GetDilatationData(vector<double> &ei, vector<double> &ui) { FEModel& fem = *GetFEModel(); int N = fem.GetMesh().Nodes(), nid, m = 0; zero(ei); for (int i=0; i<N; ++i) { FENode& n = fem.GetMesh().Node(i); nid = n.m_ID[m_dofEF[0]]; if (nid != -1) { nid = (nid < -1 ? -nid-2 : nid); ei[m++] = ui[nid]; assert(m <= (int) ei.size()); } } } //----------------------------------------------------------------------------- void FEFluidSolutesSolver::GetConcentrationData(vector<double> &ci, vector<double> &ui, const int sol) { FEModel& fem = *GetFEModel(); int N = fem.GetMesh().Nodes(), nid, m = 0; zero(ci); for (int i=0; i<N; ++i) { FENode& n = fem.GetMesh().Node(i); nid = n.m_ID[m_dofC[sol]]; if (nid != -1) { nid = (nid < -1 ? -nid-2 : nid); ci[m++] = ui[nid]; assert(m <= (int) ci.size()); } } } //----------------------------------------------------------------------------- //! Update the kinematics of the model, such as nodal positions, velocities, //! accelerations, etc. void FEFluidSolutesSolver::UpdateKinematics(vector<double>& ui) { // get the mesh FEModel& fem = *GetFEModel(); FEMesh& mesh = fem.GetMesh(); // update nodes vector<double> U(m_Ut.size()); for (size_t i=0; i<m_Ut.size(); ++i) U[i] = ui[i] + m_Ui[i] + m_Ut[i]; scatter(U, mesh, m_dofW[0]); scatter(U, mesh, m_dofW[1]); scatter(U, mesh, m_dofW[2]); scatter(U, mesh, m_dofEF[0]); // get number of DOFS DOFS& fedofs = fem.GetDOFS(); int MAX_CDOFS = fedofs.GetVariableSize(FEBioFluidSolutes::GetVariableName(FEBioFluidSolutes::FLUID_CONCENTRATION)); // update solute data int nssd = 0, nssr = 0; for (int i=0; i<mesh.Nodes(); ++i) { FENode& node = mesh.Node(i); // update nodal concentration for (int j=0; j<MAX_CDOFS; ++j) { int n = node.m_ID[m_dofC[j]]; // Force the concentrations to remain positive if (n >= 0) { double ct = 0 + m_Ut[n] + m_Ui[n] + ui[n]; if ((ct < 0.0) && m_forcePositive) ct = 0.0; double cp = node.get_prev(m_dofC[j]); if ((m_cmin > 0) && (node.get_bc(m_dofC[j]) == DOF_OPEN) && (cp - ct >= m_cmin)) nssd++; if ((m_cmax > 0) && (node.get_bc(m_dofC[j]) == DOF_OPEN) && (ct - cp >= m_cmax)) nssr++; node.set(m_dofC[j], ct); } } } if (nssd >= m_cnum) m_sudden_C_change = true; if (nssr >= m_cnum) m_sudden_C_change = true; // force dilatations to remain greater than -1 if (m_minJf > 0) { const int NN = mesh.Nodes(); for (int i=0; i<NN; ++i) { FENode& node = mesh.Node(i); if (node.get(m_dofEF[0]) <= -1.0) node.set(m_dofEF[0], m_minJf - 1.0); } } // make sure the prescribed velocities are fulfilled int nvel = fem.BoundaryConditions(); for (int i=0; i<nvel; ++i) { FEBoundaryCondition& bc = *fem.BoundaryCondition(i); if (bc.IsActive() && HasActiveDofs(bc.GetDofList())) bc.Update(); } // prescribe DOFs for specialized surface loads /* int nsl = fem.ModelLoads(); for (int i=0; i<nsl; ++i) { FEModelLoad& pml = *fem.ModelLoad(i); if (pml.IsActive()) pml.Update(); }*/ // enforce the linear constraints // TODO: do we really have to do this? Shouldn't the algorithm // already guarantee that the linear constraints are satisfied? FELinearConstraintManager& LCM = fem.GetLinearConstraintManager(); if (LCM.LinearConstraints() > 0) { LCM.Update(); } // update time derivatives of velocity and dilatation // for dynamic simulations FEAnalysis* pstep = fem.GetCurrentStep(); if (pstep->m_nanalysis == FEFluidSolutesAnalysis::DYNAMIC) { int N = mesh.Nodes(); double dt = fem.GetTime().timeIncrement; double cgi = 1 - 1.0/m_gammaf; for (int i=0; i<N; ++i) { FENode& n = mesh.Node(i); // velocity time derivative vec3d vft = n.get_vec3d(m_dofW[0], m_dofW[1], m_dofW[2]); vec3d vfp = n.get_vec3d_prev(m_dofW[0], m_dofW[1], m_dofW[2]); vec3d aft = n.get_vec3d(m_dofAW[0], m_dofAW[1], m_dofAW[2]); vec3d afp = n.get_vec3d_prev(m_dofAW[0], m_dofAW[1], m_dofAW[2]); aft = afp*cgi + (vft - vfp)/(m_gammaf*dt); n.set_vec3d(m_dofAW[0], m_dofAW[1], m_dofAW[2], aft); // dilatation time derivative double eft = n.get(m_dofEF[0]); double efp = n.get_prev(m_dofEF[0]); double aefp = n.get_prev(m_dofAEF); double aeft = aefp*cgi + (eft - efp)/(m_gammaf*dt); n.set(m_dofAEF, aeft); // concentration time derivative // update nodal concentration for (int j=0; j<MAX_CDOFS; ++j) { int k = n.m_ID[m_dofC[j]]; // Force the concentrations to remain positive if (k >= 0) { double ct = n.get(m_dofC[j]); double cp = n.get_prev(m_dofC[j]); double acp = n.get_prev(m_dofAC+j); double act = acp*cgi + (ct - cp)/(m_gammaf*dt); n.set(m_dofC[j], ct); n.set(m_dofAC + j, act); } } } } } //----------------------------------------------------------------------------- void FEFluidSolutesSolver::Update2(const vector<double>& ui) { // get the mesh FEModel& fem = *GetFEModel(); FEMesh& mesh = fem.GetMesh(); // update nodes vector<double> U(m_Ut.size()); for (size_t i = 0; i<m_Ut.size(); ++i) U[i] = ui[i] + m_Ui[i] + m_Ut[i]; scatter(U, mesh, m_dofW[0]); scatter(U, mesh, m_dofW[1]); scatter(U, mesh, m_dofW[2]); scatter(U, mesh, m_dofEF[0]); // get number of DOFS DOFS& fedofs = fem.GetDOFS(); int MAX_CDOFS = fedofs.GetVariableSize(FEBioFluidSolutes::GetVariableName(FEBioFluidSolutes::FLUID_CONCENTRATION)); // update solute data for (int i=0; i<mesh.Nodes(); ++i) { FENode& node = mesh.Node(i); // update nodal concentration for (int j=0; j<MAX_CDOFS; ++j) { int n = node.m_ID[m_dofC[j]]; // Force the concentrations to remain positive if (n >= 0) { double ct = 0 + m_Ut[n] + m_Ui[n] + ui[n]; if ((ct < 0.0) && m_forcePositive) ct = 0.0; node.set(m_dofC[j], ct); } } } // Update the prescribed nodes for (int i = 0; i<mesh.Nodes(); ++i) { FENode& node = mesh.Node(i); if (node.m_rid == -1) { vec3d dv(0, 0, 0); for (int j = 0; j < node.m_ID.size(); ++j) { int nj = -node.m_ID[j] - 2; if (nj >= 0) node.set(j, node.get(j) + ui[nj]); } } } // update model state GetFEModel()->Update(); } //----------------------------------------------------------------------------- //! Updates the current state of the model void FEFluidSolutesSolver::Update(vector<double>& ui) { FEModel& fem = *GetFEModel(); FETimeInfo& tp = fem.GetTime(); tp.currentIteration = m_niter; // update kinematics UpdateKinematics(ui); // update model state UpdateModel(); } //----------------------------------------------------------------------------- bool FEFluidSolutesSolver::InitStep(double time) { FEModel& fem = *GetFEModel(); // set time integration parameters FETimeInfo& tp = fem.GetTime(); tp.alphaf = m_alphaf; tp.alpham = m_alpham; tp.gamma = m_gammaf; // evaluate load curve values at current (or intermediate) time double t = tp.currentTime; double dt = tp.timeIncrement; double ta = (t > 0) ? t - (1-m_alphaf)*dt : m_alphaf*dt; return FESolver::InitStep(ta); } //----------------------------------------------------------------------------- //! Prepares the data for the first BFGS-iteration. void FEFluidSolutesSolver::PrepStep() { FEModel& fem = *GetFEModel(); // get number of DOFS DOFS& fedofs = fem.GetDOFS(); int MAX_CDOFS = fedofs.GetVariableSize(FEBioFluidSolutes::GetVariableName(FEBioFluidSolutes::FLUID_CONCENTRATION)); FETimeInfo& tp = fem.GetTime(); double dt = tp.timeIncrement; tp.currentIteration = m_niter; // zero total DOFs zero(m_Ui); zero(m_Vi); zero(m_Di); for (int j=0; j<(int)m_nceq.size(); ++j) if (m_nceq[j]) zero(m_Ci[j]); // store previous mesh state // we need them for strain and acceleration calculations FEMesh& mesh = fem.GetMesh(); for (int i=0; i<mesh.Nodes(); ++i) { FENode& ni = mesh.Node(i); ni.m_rp = ni.m_rt = ni.m_r0; ni.m_dp = ni.m_dt = ni.m_d0; ni.UpdateValues(); switch (m_pred) { case 0: { // initial guess at start of new time step (default) vec3d afp = ni.get_vec3d_prev(m_dofAW[0], m_dofAW[1], m_dofAW[2]); ni.set_vec3d(m_dofAW[0], m_dofAW[1], m_dofAW[2], afp*(m_gammaf-1)/m_gammaf); ni.set(m_dofAEF, ni.get_prev(m_dofAEF)*(m_gammaf-1)/m_gammaf); // update nodal concentration for (int j=0; j<MAX_CDOFS; ++j) ni.set(m_dofAC+j, ni.get_prev(m_dofAC+j)*(m_gammaf-1)/m_gammaf); } break; case 1: { // initial guess at start of new time step (Zero Ydot) ni.set_vec3d(m_dofAW[0], m_dofAW[1], m_dofAW[2], vec3d(0,0,0)); ni.set(m_dofAEF, 0); for (int j=0; j<MAX_CDOFS; ++j) ni.set(m_dofAC+j, 0); vec3d vfp = ni.get_vec3d_prev(m_dofW[0], m_dofW[1], m_dofW[2]); vec3d afp = ni.get_vec3d_prev(m_dofAW[0], m_dofAW[1], m_dofAW[2]); ni.set_vec3d(m_dofW[0], m_dofW[1], m_dofW[2], vfp + afp*dt*(1-m_gammaf)*m_alphaf); ni.set(m_dofEF[0], ni.get_prev(m_dofEF[0]) + ni.get_prev(m_dofAEF)*dt*(1-m_gammaf)*m_alphaf); for (int j=0; j<MAX_CDOFS; ++j) ni.set(m_dofC[j], ni.get_prev(m_dofC[j]) + ni.get_prev(m_dofAC+j)*dt*(1-m_gammaf)*m_alphaf); } break; case 2: { // initial guess at start of new time step (Same Ydot) vec3d afp = ni.get_vec3d_prev(m_dofAW[0], m_dofAW[1], m_dofAW[2]); ni.set_vec3d(m_dofAW[0], m_dofAW[1], m_dofAW[2], afp); ni.set(m_dofAEF, ni.get_prev(m_dofAEF)); for (int j=0; j<MAX_CDOFS; ++j) ni.set(m_dofAC+j, ni.get_prev(m_dofAC+j)); vec3d vfp = ni.get_vec3d_prev(m_dofW[0], m_dofW[1], m_dofW[2]); ni.set_vec3d(m_dofW[0], m_dofW[1], m_dofW[2], vfp + afp*dt); ni.set(m_dofEF[0], ni.get_prev(m_dofEF[0]) + ni.get_prev(m_dofAEF)*dt); for (int j=0; j<MAX_CDOFS; ++j) ni.set(m_dofC[j], ni.get_prev(m_dofC[j]) + ni.get_prev(m_dofAC+j)*dt); } break; default: break; } } // apply prescribed velocities // we save the prescribed velocity increments in the ui vector vector<double>& ui = m_ui; zero(ui); int nbc = fem.BoundaryConditions(); for (int i=0; i<nbc; ++i) { FEBoundaryCondition& bc = *fem.BoundaryCondition(i); if (bc.IsActive() && HasActiveDofs(bc.GetDofList())) bc.PrepStep(ui); } // apply prescribed DOFs for specialized surface loads int nsl = fem.ModelLoads(); for (int i = 0; i < nsl; ++i) { FEModelLoad& pml = *fem.ModelLoad(i); if (pml.IsActive()) pml.PrepStep(); } // initialize material point data // NOTE: do this before the stresses are updated // TODO: does it matter if the stresses are updated before // the material point data is initialized // update domain data for (int i=0; i<mesh.Domains(); ++i) mesh.Domain(i).PreSolveUpdate(tp); // update model state UpdateModel(); // see if we need to do contact augmentations m_baugment = false; for (int i = 0; i<fem.SurfacePairConstraints(); ++i) { FEContactInterface& ci = dynamic_cast<FEContactInterface&>(*fem.SurfacePairConstraint(i)); if (ci.IsActive() && (ci.m_laugon == FECore::AUGLAG_METHOD)) m_baugment = true; } // see if we have to do nonlinear constraint augmentations if (fem.NonlinearConstraints() != 0) m_baugment = true; } //----------------------------------------------------------------------------- bool FEFluidSolutesSolver::Quasin() { FEModel& fem = *GetFEModel(); // convergence norms double normR1; // residual norm double normE1; // energy norm double normV; // velocity norm double normv; // velocity increment norm double normRi = 0; // initial residual norm double normVi = 0; // initial velocity norm double normEi = 0; // initial energy norm double normEm = 0; // max energy norm double normDi = 0; // initial dilatation norm double normD; // current dilatation norm double normd; // incremement dilatation norm // get number of DOFS DOFS& fedofs = fem.GetDOFS(); int MAX_CDOFS = fedofs.GetVariableSize(FEBioFluidSolutes::GetVariableName(FEBioFluidSolutes::FLUID_CONCENTRATION)); // solute convergence data vector<double> normCi(MAX_CDOFS); // initial concentration norm vector<double> normC(MAX_CDOFS); // current concentration norm vector<double> normc(MAX_CDOFS); // incremement concentration norm // Get the current step FEAnalysis* pstep = fem.GetCurrentStep(); // prepare for the first iteration const FETimeInfo& tp = fem.GetTime(); PrepStep(); // Init QN method if (QNInit() == false) return false; // this flag indicates whether the velocity has converged for a sequential solve // (This is not used for a coupled solve.) bool vel_converged = false; // loop until converged or when max nr of reformations reached bool bconv = false; // convergence flag do { feLog(" %d\n", m_niter+1); // assume we'll converge. bconv = true; // for sequential solve, we set one of the residual components to zero if (m_solve_strategy == SOLVE_SEQUENTIAL) { int veq = m_neq - m_nseq; if (vel_converged == false) { // zero the solute residual for (int i = veq; i < m_neq; ++i) m_R0[i] = 0.0; } else { // zero the velocity residual for (int i = 0; i < veq; ++i) m_R0[i] = 0.0; } } // solve the equations (returns line search; solution stored in m_ui) double s = QNSolve(); // for sequential solve, we set one of the residual components to zero if (m_solve_strategy == SOLVE_SEQUENTIAL) { int veq = m_neq - m_nseq; if (vel_converged == false) { // zero the solute residual for (int i = veq; i < m_neq; ++i) m_R1[i] = 0.0; // zero the solute solution for (int i = veq; i < m_neq; ++i) m_ui[i] = 0.0; } else { // zero the velocity residual for (int i = 0; i < veq; ++i) m_R1[i] = 0.0; // if solving sequentially with ctol = 0, ignore solute residual if (m_Ctol == 0) { // zero the solute residual for (int i = veq; i < m_neq; ++i) m_R1[i] = 0.0; } } } // extract the velocity and dilatation increments GetVelocityData(m_vi, m_ui); GetDilatationData(m_di, m_ui); // set initial convergence norms if (m_niter == 0) { normRi = fabs(m_R0*m_R0); normEi = fabs(m_ui*m_R0); normVi = fabs(m_vi*m_vi); normDi = fabs(m_di*m_di); normEm = normEi; } // calculate norms // update all degrees of freedom for (int i=0; i<m_neq; ++i) m_Ui[i] += s*m_ui[i]; // update velocities for (int i = 0; i<m_nveq; ++i) m_Vi[i] += s*m_vi[i]; // update dilatations for (int i = 0; i<m_ndeq; ++i) m_Di[i] += s*m_di[i]; // calculate the norms normR1 = m_R1*m_R1; normv = (m_vi*m_vi)*(s*s); normV = m_Vi*m_Vi; normd = (m_di*m_di)*(s*s); normD = m_Di*m_Di; normE1 = s*fabs(m_ui*m_R1); // check for nans if (ISNAN(normR1)) throw NANInResidualDetected(); // check residual norm if ((m_Rtol > 0) && (normR1 > m_Rtol*normRi)) bconv = false; // check velocity norm if ((m_Vtol > 0) && (normv > (m_Vtol*m_Vtol)*normV )) bconv = false; // check dilatation norm if ((m_Ftol > 0) && (normd > (m_Ftol*m_Ftol)*normD )) bconv = false; // check energy norm if ((m_Etol > 0) && (normE1 > m_Etol*normEi)) bconv = false; // check linestep size if ((m_lineSearch->m_LStol > 0) && (s < m_lineSearch->m_LSmin)) bconv = false; // check energy divergence //Changed to be like solid solver /* if (m_bdivreform) { if (normE1 > normEm) bconv = false; }*/ if (normE1 > normEm) bconv = false; // check solute convergence // extract the concentration increments for (int j = 0; j<(int)m_nceq.size(); ++j) { if (m_nceq[j]) { GetConcentrationData(m_ci[j], m_ui,j); // set initial norm if (m_niter == 0) normCi[j] = fabs(m_ci[j]*m_ci[j]); // update total concentration for (int i = 0; i<m_nceq[j]; ++i) m_Ci[j][i] += s*m_ci[j][i]; // calculate norms normC[j] = m_Ci[j]*m_Ci[j]; normc[j] = (m_ci[j]*m_ci[j])*(s*s); } } // check convergence if (m_Ctol > 0) { for (int j = 0; j<(int)m_nceq.size(); ++j) if (m_nceq[j]) bconv = bconv && (normc[j] <= (m_Ctol*m_Ctol)*normC[j]); } // print convergence summary feLog(" Nonlinear solution status: time= %lg\n", tp.currentTime); feLog("\tstiffness updates = %d\n", m_qnstrategy->m_nups); feLog("\tright hand side evaluations = %d\n", m_nrhs); feLog("\tstiffness matrix reformations = %d\n", m_nref); if (m_lineSearch->m_LStol > 0) feLog("\tstep from line search = %lf\n", s); feLog("\tconvergence norms : INITIAL CURRENT REQUIRED\n"); feLog("\t residual %15le %15le %15le \n", normRi, normR1, m_Rtol*normRi); feLog("\t energy %15le %15le %15le \n", normEi, normE1, m_Etol*normEi); feLog("\t velocity %15le %15le %15le \n", normVi, normv ,(m_Vtol*m_Vtol)*normV ); feLog("\t dilatation %15le %15le %15le \n", normDi, normd ,(m_Ftol*m_Ftol)*normD ); for (int j = 0; j<(int)m_nceq.size(); ++j) { if (m_nceq[j]) feLog("\t solute %d concentration %15le %15le %15le\n", j+1, normCi[j], normc[j] ,(m_Ctol*m_Ctol)*normC[j] ); } // see if we may have a small residual if ((bconv == false) && (normR1 < m_Rmin)) { // check for almost zero-residual on the first iteration // this might be an indication that there is no force on the system feLogWarning("No force acting on the system."); bconv = true; } // see if we have exceeded the max residual if ((bconv == false) && (m_Rmax > 0) && (normR1 >= m_Rmax)) { // doesn't look like we're getting anywhere, so let's retry the time step throw MaxResidualError(); } // check if we have converged. // If not, calculate the BFGS update vectors if (bconv == false) { if (s < m_lineSearch->m_LSmin) { // check for zero linestep size feLogWarning("Zero linestep size. Stiffness matrix will now be reformed"); QNForceReform(true); } else if ((normE1 > normEm) && m_bdivreform) { // check for diverging feLogWarning("Problem is diverging. Stiffness matrix will now be reformed"); normEm = normE1; normEi = normE1; normRi = normR1; normVi = normv; normDi = normd; for (int j = 0; j<(int)m_nceq.size(); ++j) if (m_nceq[j]) normCi[j] = normc[j]; QNForceReform(true); } // Do the QN update (This may also do a stiffness reformation if necessary) bool bret = QNUpdate(); // something went wrong with the update, so we'll need to break if (bret == false) break; } else if (m_baugment) { // Do augmentations bconv = DoAugmentations(); } if (bconv && (m_solve_strategy == SOLVE_SEQUENTIAL)) { if (vel_converged == false) { vel_converged = true; bconv = false; m_qnstrategy->m_nups = 0; m_niter = -1; Residual(m_R0); feLog("\n*** Velocity converged. Now solving for solutes.\n"); } } // check for sudden solute concentration change if (bconv && m_sudden_C_change) { m_sudden_C_change = false; throw ConcentrationChangeDetected(); } else m_sudden_C_change = false; // increase iteration number m_niter++; // do minor iterations callbacks fem.DoCallback(CB_MINOR_ITERS); } while (bconv == false); // if converged we update the total velocities if (bconv) { m_Ut += m_Ui; zero(m_Ui); } return bconv; } //----------------------------------------------------------------------------- //! Calculates global stiffness matrix. bool FEFluidSolutesSolver::StiffnessMatrix(FELinearSystem& LS) { FEModel& fem = *GetFEModel(); const FETimeInfo& tp = fem.GetTime(); // get the mesh FEMesh& mesh = fem.GetMesh(); // calculate the stiffness matrix for each domain for (int i=0; i<mesh.Domains(); ++i) { FEFluidDomain& dom = dynamic_cast<FEFluidDomain&>(mesh.Domain(i)); dom.StiffnessMatrix(LS); } // calculate the body force stiffness matrix for each domain int NBL = fem.ModelLoads(); for (int j = 0; j<NBL; ++j) { FEBodyForce* pbf = dynamic_cast<FEBodyForce*>(fem.ModelLoad(j)); if (pbf && pbf->IsActive()) { for (int i = 0; i<pbf->Domains(); ++i) { FEFluidDomain& dom = dynamic_cast<FEFluidDomain&>(*pbf->Domain(i)); dom.BodyForceStiffness(LS, *pbf); } } } // calculate contact stiffness ContactStiffness(LS); // calculate stiffness matrix due to model loads int nsl = fem.ModelLoads(); for (int i=0; i<nsl; ++i) { FEModelLoad* pml = fem.ModelLoad(i); if (pml->IsActive()) pml->StiffnessMatrix(LS); // if (pml->IsActive() && HasActiveDofs(pml->GetDofList())) pml->StiffnessMatrix(LS); } // Add mass matrix // loop over all domains for (int i=0; i<mesh.Domains(); ++i) { FEFluidDomain& dom = dynamic_cast<FEFluidDomain&>(mesh.Domain(i)); dom.MassMatrix(LS); } // calculate nonlinear constraint stiffness // note that this is the contribution of the // constraints enforced with augmented lagrangian NonLinearConstraintStiffness(LS, tp); return true; } //----------------------------------------------------------------------------- //! Calculate the stiffness contribution due to nonlinear constraints void FEFluidSolutesSolver::NonLinearConstraintStiffness(FELinearSystem& LS, const FETimeInfo& tp) { FEModel& fem = *GetFEModel(); int N = fem.NonlinearConstraints(); for (int i=0; i<N; ++i) { FENLConstraint* plc = fem.NonlinearConstraint(i); if (plc->IsActive()) plc->StiffnessMatrix(LS, tp); } } //----------------------------------------------------------------------------- //! This function calculates the contact stiffness matrix void FEFluidSolutesSolver::ContactStiffness(FELinearSystem& LS) { FEModel& fem = *GetFEModel(); const FETimeInfo& tp = fem.GetTime(); for (int i = 0; i<fem.SurfacePairConstraints(); ++i) { FEContactInterface* pci = dynamic_cast<FEContactInterface*>(fem.SurfacePairConstraint(i)); if (pci->IsActive()) pci->StiffnessMatrix(LS, tp); } } //----------------------------------------------------------------------------- //! Calculates the contact forces void FEFluidSolutesSolver::ContactForces(FEGlobalVector& R) { FEModel& fem = *GetFEModel(); const FETimeInfo& tp = fem.GetTime(); for (int i = 0; i<fem.SurfacePairConstraints(); ++i) { FEContactInterface* pci = dynamic_cast<FEContactInterface*>(fem.SurfacePairConstraint(i)); if (pci->IsActive()) pci->LoadVector(R, tp); } } //----------------------------------------------------------------------------- //! calculates the residual vector //! Note that the concentrated nodal forces are not calculated here. //! This is because they do not depend on the geometry //! so we only calculate them once (in Quasin) and then add them here. bool FEFluidSolutesSolver::Residual(vector<double>& R) { FEModel& fem = *GetFEModel(); // get the time information const FETimeInfo& tp = fem.GetTime(); // initialize residual zero(R); // zero nodal reaction forces zero(m_Fr); // setup the global vector FEResidualVector RHS(fem, R, m_Fr); // get the mesh FEMesh& mesh = fem.GetMesh(); // calculate the internal (stress) forces for (int i=0; i<mesh.Domains(); ++i) { FEFluidDomain& dom = dynamic_cast<FEFluidDomain&>(mesh.Domain(i)); dom.InternalForces(RHS); } // calculate the body forces for (int j = 0; j<fem.ModelLoads(); ++j) { FEBodyForce* pbf = dynamic_cast<FEBodyForce*>(fem.ModelLoad(j)); if (pbf && pbf->IsActive()) { for (int i = 0; i<pbf->Domains(); ++i) { FEFluidDomain& dom = dynamic_cast<FEFluidDomain&>(*pbf->Domain(i)); dom.BodyForce(RHS, *pbf); } } } // calculate inertial forces for (int i=0; i<mesh.Domains(); ++i) { FEFluidDomain& dom = dynamic_cast<FEFluidDomain&>(mesh.Domain(i)); dom.InertialForces(RHS); } // calculate contact forces ContactForces(RHS); // calculate nonlinear constraint forces // note that these are the linear constraints // enforced using the augmented lagrangian NonLinearConstraintForces(RHS, tp); // add model loads int NML = fem.ModelLoads(); for (int i=0; i<NML; ++i) { FEModelLoad& mli = *fem.ModelLoad(i); if (mli.IsActive()) { mli.LoadVector(RHS); } } // set the nodal reaction forces // TODO: Is this a good place to do this? for (int i=0; i<mesh.Nodes(); ++i) { FENode& node = mesh.Node(i); node.set_load(m_dofW[0], 0); node.set_load(m_dofW[1], 0); node.set_load(m_dofW[2], 0); int n; if ((n = -node.m_ID[m_dofW[0]] - 2) >= 0) node.set_load(m_dofW[0], -m_Fr[n]); if ((n = -node.m_ID[m_dofW[1]] - 2) >= 0) node.set_load(m_dofW[1], -m_Fr[n]); if ((n = -node.m_ID[m_dofW[2]] - 2) >= 0) node.set_load(m_dofW[2], -m_Fr[n]); } // increase RHS counter m_nrhs++; return true; } //----------------------------------------------------------------------------- //! calculate the nonlinear constraint forces void FEFluidSolutesSolver::NonLinearConstraintForces(FEGlobalVector& R, const FETimeInfo& tp) { FEModel& fem = *GetFEModel(); int N = fem.NonlinearConstraints(); for (int i=0; i<N; ++i) { FENLConstraint* plc = fem.NonlinearConstraint(i); if (plc->IsActive()) plc->LoadVector(R, tp); } } //----------------------------------------------------------------------------- //! Serialization void FEFluidSolutesSolver::Serialize(DumpStream& ar) { FENewtonSolver::Serialize(ar); ar & m_neq & m_nveq & m_ndeq & m_nseq & m_nceq; ar & m_nrhs & m_niter & m_nref & m_ntotref; ar & m_Fr & m_Ui & m_Ut; ar & m_Vi & m_Di & m_Ci; if (ar.IsLoading()) { m_Fr.assign(m_neq, 0); m_Vi.assign(m_nveq,0); m_Di.assign(m_ndeq,0); for (int i=0; i<m_nceq.size(); ++i) { m_ci[i].assign(m_nceq[i], 0); m_Ci[i].assign(m_nceq[i], 0); } } if (ar.IsShallow()) return; ar & m_alphaf & m_alpham; ar & m_gammaf; ar & m_pred; ar & m_dofW & m_dofAW & m_dofEF & m_dofAEF & m_dofC & m_dofAC; }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEInitialFluidTemperature.cpp
.cpp
1,757
42
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2020 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "FEInitialFluidTemperature.h" //============================================================================= BEGIN_FECORE_CLASS(FEInitialFluidTemperature, FEInitialCondition) ADD_PARAMETER(m_data, "value")->setUnits(UNIT_RELATIVE_TEMPERATURE); END_FECORE_CLASS(); FEInitialFluidTemperature::FEInitialFluidTemperature(FEModel* fem) : FEInitialDOF(fem) { } bool FEInitialFluidTemperature::Init() { if (SetDOF("T") == false) return false; return FEInitialDOF::Init(); }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEIdealGas.cpp
.cpp
9,230
276
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "FEIdealGas.h" #include <FECore/log.h> #include "FEFluidMaterialPoint.h" #include "FEThermoFluid.h" #include "FEThermoFluidMaterialPoint.h" //----------------------------------------------------------------------------- BEGIN_FECORE_CLASS(FEIdealGas, FEElasticFluid) // material parameters ADD_PARAMETER(m_M , FE_RANGE_GREATER(0.0), "M")->setUnits(UNIT_MOLAR_MASS)->setLongName("molar mass"); ADD_PARAMETER(m_ar , "ar")->setLongName("normalized referential specific free energy"); // ar normalized by R.Tr/M ADD_PARAMETER(m_sr , "sr")->setLongName("normalized referential specific entropy"); // sr normalized by R/M ADD_PROPERTY (m_ao , "ao")->SetLongName("normalized specific free energy circle"); // a-circle normalized by R.Tr/M ADD_PROPERTY (m_cp , "cp")->SetLongName("normalized isobaric specific heat capacity"); // cp normalized by R/M END_FECORE_CLASS(); FEIdealGas::FEIdealGas(FEModel* pfem) : FEElasticFluid(pfem) { m_R = m_Pr = m_Tr = m_ar = m_sr = 0; m_ao = nullptr; m_cp = nullptr; } //----------------------------------------------------------------------------- //! initialization bool FEIdealGas::Init() { m_R = GetGlobalConstant("R"); m_Tr = GetGlobalConstant("T"); m_Pr = GetGlobalConstant("P"); if (m_R <= 0) { feLogError("A positive universal gas constant R must be defined in Globals section"); return false; } if (m_Tr <= 0) { feLogError("A positive referential absolute temperature T must be defined in Globals section"); return false; } if (m_Pr == 0) { FEThermoFluid* pMat = dynamic_cast<FEThermoFluid*>(GetParent()); double rhor = pMat->ReferentialDensity(); m_Pr = m_R*m_Tr/m_M*rhor; feLogWarning("The referential absolute pressure P is calculated internally as %g\n",m_Pr); } m_ao->Init(); m_cp->Init(); return true; } //----------------------------------------------------------------------------- void FEIdealGas::Serialize(DumpStream& ar) { FEElasticFluid::Serialize(ar); if (ar.IsShallow()) return; ar & m_R & m_Pr & m_Tr; } //----------------------------------------------------------------------------- //! gauge pressure double FEIdealGas::Pressure(FEMaterialPoint& mp) { FEFluidMaterialPoint& fp = *mp.ExtractData<FEFluidMaterialPoint>(); FEThermoFluidMaterialPoint& tf = *mp.ExtractData<FEThermoFluidMaterialPoint>(); double T = m_Tr + tf.m_T; double Jf = 1 + fp.m_ef; double p = m_Pr*(T/(Jf*m_Tr) - 1); return p; } //----------------------------------------------------------------------------- //! tangent of pressure with respect to strain J double FEIdealGas::Tangent_Strain(FEMaterialPoint& mp) { FEFluidMaterialPoint& fp = *mp.ExtractData<FEFluidMaterialPoint>(); FEThermoFluidMaterialPoint& tf = *mp.ExtractData<FEThermoFluidMaterialPoint>(); double T = m_Tr + tf.m_T; double Jf = 1 + fp.m_ef; double dp = -m_Pr*T/(Jf*Jf*m_Tr); return dp; } //----------------------------------------------------------------------------- //! 2nd tangent of pressure with respect to strain J double FEIdealGas::Tangent_Strain_Strain(FEMaterialPoint& mp) { FEFluidMaterialPoint& fp = *mp.ExtractData<FEFluidMaterialPoint>(); FEThermoFluidMaterialPoint& tf = *mp.ExtractData<FEThermoFluidMaterialPoint>(); double T = m_Tr + tf.m_T; double Jf = 1 + fp.m_ef; double d2p = 2*m_Pr*T/(pow(Jf,3)*m_Tr); return d2p; } //----------------------------------------------------------------------------- //! tangent of pressure with respect to temperature T double FEIdealGas::Tangent_Temperature(FEMaterialPoint& mp) { FEFluidMaterialPoint& fp = *mp.ExtractData<FEFluidMaterialPoint>(); double Jf = 1 + fp.m_ef; double dp = m_Pr/(Jf*m_Tr); return dp; } //----------------------------------------------------------------------------- //! 2nd tangent of pressure with respect to temperature T double FEIdealGas::Tangent_Temperature_Temperature(FEMaterialPoint& mp) { return 0; } //----------------------------------------------------------------------------- //! tangent of pressure with respect to strain J and temperature T double FEIdealGas::Tangent_Strain_Temperature(FEMaterialPoint& mp) { FEFluidMaterialPoint& fp = *mp.ExtractData<FEFluidMaterialPoint>(); double Jf = 1 + fp.m_ef; double d2p = -m_Pr/(Jf*Jf*m_Tr); return d2p; } //----------------------------------------------------------------------------- //! specific free energy double FEIdealGas::SpecificFreeEnergy(FEMaterialPoint& mp) { FEFluidMaterialPoint& fp = *mp.ExtractData<FEFluidMaterialPoint>(); FEThermoFluidMaterialPoint& tf = *mp.ExtractData<FEThermoFluidMaterialPoint>(); double J = 1 + fp.m_ef; double T = tf.m_T + m_Tr; double That = T/m_Tr; double scl = m_R*m_Tr/m_M; // referential free energy double a = m_ar - m_sr*(That-1); // add a_circle a += m_ao->value(That); // add strain-dependent contribution a += J+That*(log(That/J)-1); return a*scl; } //----------------------------------------------------------------------------- //! specific entropy double FEIdealGas::SpecificEntropy(FEMaterialPoint& mp) { FEFluidMaterialPoint& fp = *mp.ExtractData<FEFluidMaterialPoint>(); FEThermoFluidMaterialPoint& tf = *mp.ExtractData<FEThermoFluidMaterialPoint>(); double J = 1 + fp.m_ef; double T = tf.m_T + m_Tr; double That = T/m_Tr; double scl = m_R/m_M; // referential entropy double s = m_sr; // add s_circle s -= m_ao->derive(That); // add strain-dependent contribution s += -log(That/J); return s*scl; } //----------------------------------------------------------------------------- //! specific strain energy double FEIdealGas::SpecificStrainEnergy(FEMaterialPoint& mp) { FEFluidMaterialPoint& fp = *mp.ExtractData<FEFluidMaterialPoint>(); FEThermoFluidMaterialPoint& tf = *mp.ExtractData<FEThermoFluidMaterialPoint>(); double J = 1 + fp.m_ef; double T = tf.m_T; double That = T/m_Tr; double scl = m_R*m_Tr/m_M; // strain-dependent contribution double a = J+That*(log(That/J)-1); return a*scl; } //----------------------------------------------------------------------------- //! isobaric specific heat capacity double FEIdealGas::IsobaricSpecificHeatCapacity(FEMaterialPoint& mp) { FEThermoFluidMaterialPoint& tf = *mp.ExtractData<FEThermoFluidMaterialPoint>(); double T = tf.m_T + m_Tr; double That = T/m_Tr; double scl = m_R/m_M; double cp = m_cp->value(That); return cp*scl; } //----------------------------------------------------------------------------- //! isochoric specific heat capacity double FEIdealGas::IsochoricSpecificHeatCapacity(FEMaterialPoint& mp) { double cv = IsobaricSpecificHeatCapacity(mp) - m_R/m_M; return cv; } //----------------------------------------------------------------------------- //! tangent of isochoric specific heat capacity with respect to strain J double FEIdealGas::Tangent_cv_Strain(FEMaterialPoint& mp) { return 0; } //----------------------------------------------------------------------------- //! tangent of isochoric specific heat capacity with respect to temperature T double FEIdealGas::Tangent_cv_Temperature(FEMaterialPoint& mp) { FEThermoFluidMaterialPoint& tf = *mp.ExtractData<FEThermoFluidMaterialPoint>(); double T = tf.m_T + m_Tr; double That = T/m_Tr; double scl = m_R/(m_M*m_Tr); double dcv = m_cp->derive(That); return dcv*scl; } //----------------------------------------------------------------------------- //! dilatation from temperature and pressure bool FEIdealGas::Dilatation(const double T, const double p, double& e) { double J = (T+m_Tr)/m_Tr/(1+p/m_Pr); e = J - 1; return true; }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEFluidSolver.cpp
.cpp
33,851
1,070
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEFluidSolver.h" #include "FEFluidDomain.h" #include "FEFluidResidualVector.h" #include "FECore/FEModel.h" #include "FECore/log.h" #include "FECore/DOFS.h" #include <assert.h> #include "FECore/FEGlobalMatrix.h" #include "FECore/sys.h" #include <FEBioMech/FEBodyForce.h> #include <FECore/FEBoundaryCondition.h> #include <FECore/FENodalLoad.h> #include <FECore/FESurfaceLoad.h> #include "FEFluidResistanceBC.h" #include "FEBackFlowStabilization.h" #include "FEFluidNormalVelocity.h" #include "FEFluidVelocity.h" #include "FEFluidRotationalVelocity.h" #include "FETiedFluidInterface.h" #include <FECore/FEModelLoad.h> #include <FECore/FEAnalysis.h> #include <FECore/FELinearConstraintManager.h> #include <FECore/FENLConstraint.h> #include <FECore/FELinearSystem.h> #include "FEBioFluid.h" #include "FEFluidAnalysis.h" //----------------------------------------------------------------------------- // define the parameter list BEGIN_FECORE_CLASS(FEFluidSolver, FENewtonSolver) ADD_PARAMETER(m_Vtol , "vtol" ); ADD_PARAMETER(m_Ftol , "ftol" ); ADD_PARAMETER(m_rhoi , "rhoi" ); ADD_PARAMETER(m_Etol, FE_RANGE_GREATER_OR_EQUAL(0.0), "etol"); ADD_PARAMETER(m_Rtol, FE_RANGE_GREATER_OR_EQUAL(0.0), "rtol"); ADD_PARAMETER(m_pred , "predictor" ); ADD_PARAMETER(m_minJf, "min_volume_ratio"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- //! FEFluidSolver Construction // FEFluidSolver::FEFluidSolver(FEModel* pfem) : FENewtonSolver(pfem), m_dofW(pfem), m_dofAW(pfem), m_dofEF(pfem) { // default values m_Rtol = 0.001; m_Etol = 0.01; m_Vtol = 0.001; m_Ftol = 0.001; m_Rmin = 1.0e-20; m_Rmax = 0; // not used if zero m_minJf = 0; // not used if zero m_nveq = 0; m_ndeq = 0; m_niter = 0; // assume non-symmetric stiffness m_msymm = REAL_UNSYMMETRIC; m_rhoi = 0; m_pred = 0; // Preferred strategy is Broyden's method SetDefaultStrategy(QN_BROYDEN); // turn off checking for a zero diagonal CheckZeroDiagonal(false); // get the dof indices // TODO: Can this be done in Init, since there is no error checking if (pfem) { m_dofW.AddVariable(FEBioFluid::GetVariableName(FEBioFluid::RELATIVE_FLUID_VELOCITY)); m_dofAW.AddVariable(FEBioFluid::GetVariableName(FEBioFluid::RELATIVE_FLUID_ACCELERATION)); m_dofEF.AddVariable(FEBioFluid::GetVariableName(FEBioFluid::FLUID_DILATATION)); m_dofAEF = pfem->GetDOFIndex(FEBioFluid::GetVariableName(FEBioFluid::FLUID_DILATATION_TDERIV), 0); } } //----------------------------------------------------------------------------- FEFluidSolver::~FEFluidSolver() { } //----------------------------------------------------------------------------- //! Allocates and initializes the data structures used by the FEFluidSolver // bool FEFluidSolver::Init() { // initialize base class if (FENewtonSolver::Init() == false) return false; // check parameters if (m_Vtol < 0.0) { feLogError("vtol must be nonnegative."); return false; } if (m_Ftol < 0.0) { feLogError("dtol must be nonnegative."); return false; } if (m_Etol < 0.0) { feLogError("etol must be nonnegative."); return false; } if (m_Rtol < 0.0) { feLogError("rtol must be nonnegative."); return false; } if (m_rhoi == -1) { m_alphaf = m_alpham = m_gammaf = 1.0; } else if ((m_rhoi >= 0) && (m_rhoi <= 1)) { m_alphaf = 1.0/(1+m_rhoi); m_alpham = (3-m_rhoi)/(1+m_rhoi)/2; m_gammaf = 0.5 + m_alpham - m_alphaf; } else { feLogError("rhoi must be -1 or between 0 and 1."); return false; } // allocate vectors int neq = m_neq; m_Fr.assign(neq, 0); m_Ui.assign(neq, 0); m_Ut.assign(neq, 0); m_vi.assign(m_nveq,0); m_Vi.assign(m_nveq,0); m_di.assign(m_ndeq,0); m_Di.assign(m_ndeq,0); // we need to fill the total DOF vector m_Ut // TODO: I need to find an easier way to do this FEModel& fem = *GetFEModel(); FEMesh& mesh = fem.GetMesh(); gather(m_Ut, mesh, m_dofW[0]); gather(m_Ut, mesh, m_dofW[1]); gather(m_Ut, mesh, m_dofW[2]); gather(m_Ut, mesh, m_dofEF[0]); // set flag for transient or steady-state analyses for (int i = 0; i<mesh.Domains(); ++i) { FEFluidDomain& dom = dynamic_cast<FEFluidDomain&>(mesh.Domain(i)); if (fem.GetCurrentStep()->m_nanalysis == FEFluidAnalysis::STEADY_STATE) dom.SetSteadyStateAnalysis(); else dom.SetTransientAnalysis(); } return true; } //----------------------------------------------------------------------------- //! Initialize equations bool FEFluidSolver::InitEquations() { // Add the solution variables AddSolutionVariable(&m_dofW, 1, "velocity", m_Vtol); AddSolutionVariable(&m_dofEF, 1, "dilatation", m_Ftol); // base class initialization if (FENewtonSolver::InitEquations() == false) return false; // determined the nr of velocity and dilatation equations FEMesh& mesh = GetFEModel()->GetMesh(); m_nveq = m_ndeq = 0; for (int i=0; i<mesh.Nodes(); ++i) { FENode& n = mesh.Node(i); if (n.m_ID[m_dofW[0]] != -1) m_nveq++; if (n.m_ID[m_dofW[1]] != -1) m_nveq++; if (n.m_ID[m_dofW[2]] != -1) m_nveq++; if (n.m_ID[m_dofEF[0]] != -1) m_ndeq++; } // Next, we add any Lagrange Multipliers FEModel& fem = *GetFEModel(); for (int i = 0; i < fem.NonlinearConstraints(); ++i) { FENLConstraint* lmc = fem.NonlinearConstraint(i); if (lmc->IsActive()) { m_neq += lmc->InitEquations(m_neq); } } for (int i = 0; i < fem.SurfacePairConstraints(); ++i) { FESurfacePairConstraint* spc = fem.SurfacePairConstraint(i); if (spc->IsActive()) { m_neq += spc->InitEquations(m_neq); } } return true; } //----------------------------------------------------------------------------- //! Initialize equations bool FEFluidSolver::InitEquations2() { // Add the solution variables AddSolutionVariable(&m_dofW, -1, "velocity", m_Vtol); AddSolutionVariable(&m_dofEF, -1, "dilatation", m_Ftol); // base class initialization FENewtonSolver::InitEquations2(); // determined the nr of velocity and dilatation equations FEMesh& mesh = GetFEModel()->GetMesh(); m_nveq = m_ndeq = 0; for (int i = 0; i<mesh.Nodes(); ++i) { FENode& n = mesh.Node(i); if (n.m_ID[m_dofW[0]] != -1) m_nveq++; if (n.m_ID[m_dofW[1]] != -1) m_nveq++; if (n.m_ID[m_dofW[2]] != -1) m_nveq++; if (n.m_ID[m_dofEF[0]] != -1) m_ndeq++; } // Next, we add any Lagrange Multipliers FEModel& fem = *GetFEModel(); for (int i = 0; i < fem.NonlinearConstraints(); ++i) { FENLConstraint* lmc = fem.NonlinearConstraint(i); if (lmc->IsActive()) { m_neq += lmc->InitEquations(m_neq); } } for (int i = 0; i < fem.SurfacePairConstraints(); ++i) { FESurfacePairConstraint* spc = fem.SurfacePairConstraint(i); if (spc->IsActive()) { m_neq += spc->InitEquations(m_neq); } } return true; } //----------------------------------------------------------------------------- void FEFluidSolver::GetVelocityData(vector<double> &vi, vector<double> &ui) { FEModel& fem = *GetFEModel(); int N = fem.GetMesh().Nodes(), nid, m = 0; zero(vi); for (int i=0; i<N; ++i) { FENode& n = fem.GetMesh().Node(i); nid = n.m_ID[m_dofW[0]]; if (nid != -1) { nid = (nid < -1 ? -nid-2 : nid); vi[m++] = ui[nid]; assert(m <= (int) vi.size()); } nid = n.m_ID[m_dofW[1]]; if (nid != -1) { nid = (nid < -1 ? -nid-2 : nid); vi[m++] = ui[nid]; assert(m <= (int) vi.size()); } nid = n.m_ID[m_dofW[2]]; if (nid != -1) { nid = (nid < -1 ? -nid-2 : nid); vi[m++] = ui[nid]; assert(m <= (int) vi.size()); } } } //----------------------------------------------------------------------------- void FEFluidSolver::GetDilatationData(vector<double> &ei, vector<double> &ui) { FEModel& fem = *GetFEModel(); int N = fem.GetMesh().Nodes(), nid, m = 0; zero(ei); for (int i=0; i<N; ++i) { FENode& n = fem.GetMesh().Node(i); nid = n.m_ID[m_dofEF[0]]; if (nid != -1) { nid = (nid < -1 ? -nid-2 : nid); ei[m++] = ui[nid]; assert(m <= (int) ei.size()); } } } //----------------------------------------------------------------------------- //! Update the kinematics of the model, such as nodal positions, velocities, //! accelerations, etc. void FEFluidSolver::UpdateKinematics(vector<double>& ui) { // get the mesh FEModel& fem = *GetFEModel(); FEMesh& mesh = fem.GetMesh(); // update nodes vector<double> U(m_Ut.size()); for (size_t i=0; i<m_Ut.size(); ++i) U[i] = ui[i] + m_Ui[i] + m_Ut[i]; scatter(U, mesh, m_dofW[0]); scatter(U, mesh, m_dofW[1]); scatter(U, mesh, m_dofW[2]); scatter(U, mesh, m_dofEF[0]); // force dilatations to remain greater than -1 if (m_minJf > 0) { const int NN = mesh.Nodes(); for (int i=0; i<NN; ++i) { FENode& node = mesh.Node(i); if (node.get(m_dofEF[0]) <= -1.0) node.set(m_dofEF[0], m_minJf - 1.0); } } // make sure the prescribed velocities are fulfilled int nvel = fem.BoundaryConditions(); for (int i=0; i<nvel; ++i) { FEBoundaryCondition& bc = *fem.BoundaryCondition(i); if (bc.IsActive() && HasActiveDofs(bc.GetDofList())) bc.Update(); } // enforce the linear constraints // TODO: do we really have to do this? Shouldn't the algorithm // already guarantee that the linear constraints are satisfied? FELinearConstraintManager& LCM = fem.GetLinearConstraintManager(); if (LCM.LinearConstraints() > 0) { LCM.Update(); } // update time derivatives of velocity and dilatation // for dynamic simulations FEAnalysis* pstep = fem.GetCurrentStep(); if (pstep->m_nanalysis == FEFluidAnalysis::DYNAMIC) { int N = mesh.Nodes(); double dt = fem.GetTime().timeIncrement; double cgi = 1 - 1.0/m_gammaf; for (int i=0; i<N; ++i) { FENode& n = mesh.Node(i); // velocity time derivative vec3d vft = n.get_vec3d(m_dofW[0], m_dofW[1], m_dofW[2]); vec3d vfp = n.get_vec3d_prev(m_dofW[0], m_dofW[1], m_dofW[2]); vec3d aft = n.get_vec3d(m_dofAW[0], m_dofAW[1], m_dofAW[2]); vec3d afp = n.get_vec3d_prev(m_dofAW[0], m_dofAW[1], m_dofAW[2]); aft = afp*cgi + (vft - vfp)/(m_gammaf*dt); n.set_vec3d(m_dofAW[0], m_dofAW[1], m_dofAW[2], aft); // dilatation time derivative double eft = n.get(m_dofEF[0]); double efp = n.get_prev(m_dofEF[0]); double aefp = n.get_prev(m_dofAEF); double aeft = aefp*cgi + (eft - efp)/(m_gammaf*dt); n.set(m_dofAEF, aeft); } } // update nonlinear constraints (needed for updating Lagrange Multiplier) for (int i = 0; i < fem.NonlinearConstraints(); ++i) { FENLConstraint* nlc = fem.NonlinearConstraint(i); if (nlc->IsActive()) nlc->Update(m_Ui, ui); } for (int i = 0; i < fem.SurfacePairConstraints(); ++i) { FESurfacePairConstraint* spc = fem.SurfacePairConstraint(i); if (spc->IsActive()) spc->Update(m_Ui, ui); } } //----------------------------------------------------------------------------- //! Update DOF increments void FEFluidSolver::UpdateIncrements(vector<double>& Ui, vector<double>& ui, bool emap) { FEModel& fem = *GetFEModel(); // get the mesh FEMesh& mesh = fem.GetMesh(); // extract the velocity and dilatation increments GetVelocityData(m_vi, ui); GetDilatationData(m_di, ui); // update all degrees of freedom for (int i=0; i<m_neq; ++i) Ui[i] += ui[i]; // update velocities for (int i = 0; i<m_nveq; ++i) m_Vi[i] += m_vi[i]; // update dilatations for (int i = 0; i<m_ndeq; ++i) m_Di[i] += m_di[i]; for (int i = 0; i < fem.NonlinearConstraints(); ++i) { FENLConstraint* plc = fem.NonlinearConstraint(i); if (plc && plc->IsActive()) plc->UpdateIncrements(Ui, ui); } for (int i = 0; i < fem.SurfacePairConstraints(); ++i) { FESurfacePairConstraint* psc = fem.SurfacePairConstraint(i); if (psc && psc->IsActive()) psc->UpdateIncrements(Ui, ui); } // TODO: This is a hack! // The problem is that I only want to call the domain's IncrementalUpdate during // the quasi-Newtoon loop. However, this function is also called after the loop // converges. The emap parameter is used here to detect wether we are inside the // loop (emap == false), or not (emap == true). if (emap == false) { for (int i = 0; i < mesh.Domains(); ++i) { FEDomain& dom = mesh.Domain(i); dom.IncrementalUpdate(ui, true); } } } //----------------------------------------------------------------------------- void FEFluidSolver::Update2(const vector<double>& ui) { // get the mesh FEModel& fem = *GetFEModel(); FEMesh& mesh = fem.GetMesh(); // update nodes vector<double> U(m_Ut.size()); for (size_t i = 0; i<m_Ut.size(); ++i) U[i] = ui[i] + m_Ui[i] + m_Ut[i]; scatter(U, mesh, m_dofW[0]); scatter(U, mesh, m_dofW[1]); scatter(U, mesh, m_dofW[2]); scatter(U, mesh, m_dofEF[0]); // Update the prescribed nodes for (int i = 0; i<mesh.Nodes(); ++i) { FENode& node = mesh.Node(i); if (node.m_rid == -1) { vec3d dv(0, 0, 0); for (int j = 0; j < node.m_ID.size(); ++j) { int nj = -node.m_ID[j] - 2; if (nj >= 0) node.set(j, node.get(j) + ui[nj]); } } } // update model state GetFEModel()->Update(); } //----------------------------------------------------------------------------- //! Updates the current state of the model void FEFluidSolver::Update(vector<double>& ui) { FEModel& fem = *GetFEModel(); FETimeInfo& tp = fem.GetTime(); tp.currentIteration = m_niter; // update kinematics UpdateKinematics(ui); // update model state GetFEModel()->Update(); } //----------------------------------------------------------------------------- //! Update nonlinear constraints void FEFluidSolver::UpdateConstraints() { FEModel& fem = *GetFEModel(); FETimeInfo& tp = fem.GetTime(); tp.currentIteration = m_niter; // Update all nonlinear constraints for (int i = 0; i<fem.NonlinearConstraints(); ++i) { FENLConstraint* pci = fem.NonlinearConstraint(i); if (pci->IsActive()) pci->Update(); } } //----------------------------------------------------------------------------- bool FEFluidSolver::InitStep(double time) { FEModel& fem = *GetFEModel(); // set time integration parameters FETimeInfo& tp = fem.GetTime(); tp.alphaf = m_alphaf; tp.alpham = m_alpham; tp.gamma = m_gammaf; // evaluate load curve values at current (or intermediate) time double t = tp.currentTime; double dt = tp.timeIncrement; double ta = (t > 0) ? t - (1-m_alphaf)*dt : m_alphaf*dt; return FESolver::InitStep(ta); } //----------------------------------------------------------------------------- //! Prepares the data for the first BFGS-iteration. void FEFluidSolver::PrepStep() { FEModel& fem = *GetFEModel(); FETimeInfo& tp = fem.GetTime(); double dt = tp.timeIncrement; tp.currentIteration = m_niter; // zero total DOFs zero(m_Ui); zero(m_Vi); zero(m_Di); // store previous mesh state // we need them for strain and acceleration calculations FEMesh& mesh = fem.GetMesh(); for (int i=0; i<mesh.Nodes(); ++i) { FENode& ni = mesh.Node(i); ni.m_rp = ni.m_rt = ni.m_r0; ni.m_dp = ni.m_dt = ni.m_d0; ni.UpdateValues(); switch (m_pred) { case 0: { // initial guess at start of new time step (default) vec3d afp = ni.get_vec3d_prev(m_dofAW[0], m_dofAW[1], m_dofAW[2]); ni.set_vec3d(m_dofAW[0], m_dofAW[1], m_dofAW[2], afp*(m_gammaf-1)/m_gammaf); ni.set(m_dofAEF, ni.get_prev(m_dofAEF)*(m_gammaf-1)/m_gammaf); } break; case 1: { // initial guess at start of new time step (Zero Ydot) ni.set_vec3d(m_dofAW[0], m_dofAW[1], m_dofAW[2], vec3d(0,0,0)); ni.set(m_dofAEF, 0); vec3d vfp = ni.get_vec3d_prev(m_dofW[0], m_dofW[1], m_dofW[2]); vec3d afp = ni.get_vec3d_prev(m_dofAW[0], m_dofAW[1], m_dofAW[2]); ni.set_vec3d(m_dofW[0], m_dofW[1], m_dofW[2], vfp + afp*dt*(1-m_gammaf)*m_alphaf); ni.set(m_dofEF[0], ni.get_prev(m_dofEF[0]) + ni.get_prev(m_dofAEF)*dt*(1-m_gammaf)*m_alphaf); } break; case 2: { // initial guess at start of new time step (Same Ydot) vec3d afp = ni.get_vec3d_prev(m_dofAW[0], m_dofAW[1], m_dofAW[2]); ni.set_vec3d(m_dofAW[0], m_dofAW[1], m_dofAW[2], afp); ni.set(m_dofAEF, ni.get_prev(m_dofAEF)); vec3d vfp = ni.get_vec3d_prev(m_dofW[0], m_dofW[1], m_dofW[2]); ni.set_vec3d(m_dofW[0], m_dofW[1], m_dofW[2], vfp + afp*dt); ni.set(m_dofEF[0], ni.get_prev(m_dofEF[0]) + ni.get_prev(m_dofAEF)*dt); } break; default: break; } } // apply prescribed velocities // we save the prescribed velocity increments in the ui vector vector<double>& ui = m_ui; zero(ui); int nbc = fem.BoundaryConditions(); for (int i=0; i<nbc; ++i) { FEBoundaryCondition& bc = *fem.BoundaryCondition(i); if (bc.IsActive() && HasActiveDofs(bc.GetDofList())) bc.PrepStep(ui); } // do the linear constraints fem.GetLinearConstraintManager().PrepStep(); // initialize material point data // NOTE: do this before the stresses are updated // TODO: does it matter if the stresses are updated before // the material point data is initialized // update domain data for (int i=0; i<mesh.Domains(); ++i) mesh.Domain(i).PreSolveUpdate(tp); // update model state UpdateModel(); // // update stresses // fem.Update(); for (int i = 0; i < fem.NonlinearConstraints(); ++i) { FENLConstraint* plc = fem.NonlinearConstraint(i); if (plc && plc->IsActive()) plc->PrepStep(); } for (int i = 0; i < fem.SurfacePairConstraints(); ++i) { FESurfacePairConstraint* psc = fem.SurfacePairConstraint(i); if (psc && psc->IsActive()) psc->PrepStep(); } // apply prescribed DOFs for specialized surface loads int nsl = fem.ModelLoads(); for (int i = 0; i < nsl; ++i) { FEModelLoad& pml = *fem.ModelLoad(i); if (pml.IsActive()) pml.PrepStep(); } // see if we need to do contact augmentations m_baugment = false; for (int i = 0; i<fem.SurfacePairConstraints(); ++i) { FEContactInterface& ci = dynamic_cast<FEContactInterface&>(*fem.SurfacePairConstraint(i)); if (ci.IsActive() && (ci.m_laugon == FECore::AUGLAG_METHOD)) m_baugment = true; } // see if we have to do nonlinear constraint augmentations if (fem.NonlinearConstraints() != 0) m_baugment = true; } //----------------------------------------------------------------------------- bool FEFluidSolver::Quasin() { FEModel& fem = *GetFEModel(); // convergence norms double normR1; // residual norm double normE1; // energy norm double normV; // velocity norm double normv; // velocity increment norm double normRi = 0; // initial residual norm double normVi = 0; // initial velocity norm double normEi = 0; // initial energy norm double normEm = 0; // max energy norm double normDi = 0; // initial dilatation norm double normD; // current dilatation norm double normd; // incremement dilatation norm // prepare for the first iteration const FETimeInfo& tp = fem.GetTime(); PrepStep(); // Init QN method if (QNInit() == false) return false; // loop until converged or when max nr of reformations reached bool bconv = false; // convergence flag do { feLog(" %d\n", m_niter+1); // assume we'll converge. bconv = true; // solve the equations SolveEquations(m_ui, m_R0); // do the line search double s = DoLineSearch(); // set initial convergence norms if (m_niter == 0) { normRi = fabs(m_R0*m_R0); normEi = fabs(m_ui*m_R0); normVi = fabs(m_vi*m_vi); normDi = fabs(m_di*m_di); normEm = normEi; } // calculate actual displacement increment // NOTE: We don't apply the line search directly to m_ui since we need the unscaled search direction for the QN update below int neq = (int)m_Ui.size(); vector<double> ui(m_ui); for (int i = 0; i<neq; ++i) ui[i] *= s; // update increments (including Lagrange multipliers) UpdateIncrements(m_Ui, ui, false); // calculate the norms normR1 = m_R1*m_R1; normv = m_vi*m_vi; normV = m_Vi*m_Vi; normd = m_di*m_di; normD = m_Di*m_Di; normE1 = fabs(ui*m_R1); // check for nans if (ISNAN(normR1)) throw NANInResidualDetected(); if (ISNAN(normv)) throw NANInSolutionDetected(); if (ISNAN(normd)) throw NANInSolutionDetected(); // check residual norm if ((m_Rtol > 0) && (normR1 > m_Rtol*normRi)) bconv = false; // check velocity norm if ((m_Vtol > 0) && (normv > (m_Vtol*m_Vtol)*normV )) bconv = false; // check dilatation norm if ((m_Ftol > 0) && (normd > (m_Ftol*m_Ftol)*normD )) bconv = false; // check energy norm if ((m_Etol > 0) && (normE1 > m_Etol*normEi)) bconv = false; // check linestep size if ((m_lineSearch->m_LStol > 0) && (s < m_lineSearch->m_LSmin)) bconv = false; // check energy divergence if (normE1 > normEm) bconv = false; // print convergence summary feLog(" Nonlinear solution status: time= %lg\n", tp.currentTime); feLog("\tstiffness updates = %d\n", m_qnstrategy->m_nups); feLog("\tright hand side evaluations = %d\n", m_nrhs); feLog("\tstiffness matrix reformations = %d\n", m_nref); if (m_lineSearch->m_LStol > 0) feLog("\tstep from line search = %lf\n", s); feLog("\tconvergence norms : INITIAL CURRENT REQUIRED\n"); feLog("\t residual %15le %15le %15le \n", normRi, normR1, m_Rtol*normRi); feLog("\t energy %15le %15le %15le \n", normEi, normE1, m_Etol*normEi); feLog("\t velocity %15le %15le %15le \n", normVi, normv ,(m_Vtol*m_Vtol)*normV ); feLog("\t dilatation %15le %15le %15le \n", normDi, normd ,(m_Ftol*m_Ftol)*normD ); // see if we may have a small residual if ((bconv == false) && (normR1 < m_Rmin)) { // check for almost zero-residual on the first iteration // this might be an indication that there is no force on the system feLogWarning("No force acting on the system."); bconv = true; } // see if we have exceeded the max residual if ((bconv == false) && (m_Rmax > 0) && (normR1 >= m_Rmax)) { // doesn't look like we're getting anywhere, so let's retry the time step throw MaxResidualError(); } // check if we have converged. // If not, calculate the BFGS update vectors if (bconv == false) { if (s < m_lineSearch->m_LSmin) { // check for zero linestep size feLogWarning("Zero linestep size. Stiffness matrix will now be reformed"); QNForceReform(true); } else if ((normE1 > normEm) && m_bdivreform) { // check for diverging feLogWarning("Problem is diverging. Stiffness matrix will now be reformed"); normEm = normE1; normEi = normE1; normRi = normR1; normVi = normv; normDi = normd; QNForceReform(true); } // Do the QN update (This may also do a stiffness reformation if necessary) bool bret = QNUpdate(); // something went wrong with the update, so we'll need to break if (bret == false) break; } else if (m_baugment) { // Do augmentations bconv = DoAugmentations(); } // increase iteration number m_niter++; // do minor iterations callbacks fem.DoCallback(CB_MINOR_ITERS); } while (bconv == false); // if converged we update the total velocities if (bconv) { UpdateIncrements(m_Ut, m_Ui, true); zero(m_Ui); } return bconv; } //----------------------------------------------------------------------------- //! Calculates global stiffness matrix. bool FEFluidSolver::StiffnessMatrix(FELinearSystem& LS) { FEModel& fem = *GetFEModel(); const FETimeInfo& tp = fem.GetTime(); // get the mesh FEMesh& mesh = fem.GetMesh(); // calculate the stiffness matrix for each domain for (int i=0; i<mesh.Domains(); ++i) { FEFluidDomain& dom = dynamic_cast<FEFluidDomain&>(mesh.Domain(i)); dom.StiffnessMatrix(LS); } // calculate the body force stiffness matrix for each domain int NBL = fem.ModelLoads(); for (int j = 0; j<NBL; ++j) { FEBodyForce* pbf = dynamic_cast<FEBodyForce*>(fem.ModelLoad(j)); if (pbf && pbf->IsActive()) { for (int i = 0; i<pbf->Domains(); ++i) { FEFluidDomain& dom = dynamic_cast<FEFluidDomain&>(*pbf->Domain(i)); dom.BodyForceStiffness(LS, *pbf); } } } // calculate contact stiffness ContactStiffness(LS); // calculate stiffness matrix due to model loads int nsl = fem.ModelLoads(); for (int i=0; i<nsl; ++i) { FEModelLoad* pml = fem.ModelLoad(i); if (pml->IsActive()) pml->StiffnessMatrix(LS); // if (pml->IsActive() && HasActiveDofs(pml->GetDofList())) pml->StiffnessMatrix(LS); } // Add mass matrix // loop over all domains for (int i=0; i<mesh.Domains(); ++i) { FEFluidDomain& dom = dynamic_cast<FEFluidDomain&>(mesh.Domain(i)); dom.MassMatrix(LS); } // calculate nonlinear constraint stiffness // note that this is the contribution of the // constraints enforced with augmented lagrangian NonLinearConstraintStiffness(LS, tp); return true; } //----------------------------------------------------------------------------- //! Calculate the stiffness contribution due to nonlinear constraints void FEFluidSolver::NonLinearConstraintStiffness(FELinearSystem& LS, const FETimeInfo& tp) { FEModel& fem = *GetFEModel(); int N = fem.NonlinearConstraints(); for (int i=0; i<N; ++i) { FENLConstraint* plc = fem.NonlinearConstraint(i); if (plc->IsActive()) plc->StiffnessMatrix(LS, tp); } } //----------------------------------------------------------------------------- //! This function calculates the contact stiffness matrix void FEFluidSolver::ContactStiffness(FELinearSystem& LS) { FEModel& fem = *GetFEModel(); const FETimeInfo& tp = fem.GetTime(); for (int i = 0; i<fem.SurfacePairConstraints(); ++i) { FEContactInterface* pci = dynamic_cast<FEContactInterface*>(fem.SurfacePairConstraint(i)); if (pci->IsActive()) pci->StiffnessMatrix(LS, tp); } } //----------------------------------------------------------------------------- //! Calculates the contact forces void FEFluidSolver::ContactForces(FEGlobalVector& R) { FEModel& fem = *GetFEModel(); const FETimeInfo& tp = fem.GetTime(); for (int i = 0; i<fem.SurfacePairConstraints(); ++i) { FEContactInterface* pci = dynamic_cast<FEContactInterface*>(fem.SurfacePairConstraint(i)); if (pci->IsActive()) pci->LoadVector(R, tp); } } //----------------------------------------------------------------------------- //! calculates the residual vector //! Note that the concentrated nodal forces are not calculated here. //! This is because they do not depend on the geometry //! so we only calculate them once (in Quasin) and then add them here. bool FEFluidSolver::Residual(vector<double>& R) { FEModel& fem = *GetFEModel(); // get the time information const FETimeInfo& tp = fem.GetTime(); // initialize residual with concentrated nodal loads zero(R); // zero nodal reaction forces zero(m_Fr); // setup the global vector FEFluidResidualVector RHS(fem, R, m_Fr); // get the mesh FEMesh& mesh = fem.GetMesh(); // calculate the internal (stress) forces for (int i=0; i<mesh.Domains(); ++i) { FEFluidDomain& dom = dynamic_cast<FEFluidDomain&>(mesh.Domain(i)); dom.InternalForces(RHS); } // calculate the body forces for (int j = 0; j<fem.ModelLoads(); ++j) { FEBodyForce* pbf = dynamic_cast<FEBodyForce*>(fem.ModelLoad(j)); if (pbf && pbf->IsActive()) { for (int i = 0; i<pbf->Domains(); ++i) { FEFluidDomain& dom = dynamic_cast<FEFluidDomain&>(*pbf->Domain(i)); dom.BodyForce(RHS, *pbf); } } } // calculate inertial forces for (int i=0; i<mesh.Domains(); ++i) { FEFluidDomain& dom = dynamic_cast<FEFluidDomain&>(mesh.Domain(i)); dom.InertialForces(RHS); } // calculate contact forces ContactForces(RHS); // calculate nonlinear constraint forces // note that these are the linear constraints // enforced using the augmented lagrangian NonLinearConstraintForces(RHS, tp); // add model loads int NML = fem.ModelLoads(); for (int i=0; i<NML; ++i) { FEModelLoad& mli = *fem.ModelLoad(i); if (mli.IsActive()) { mli.LoadVector(RHS); } } // set the nodal reaction forces // TODO: Is this a good place to do this? for (int i=0; i<mesh.Nodes(); ++i) { FENode& node = mesh.Node(i); node.set_load(m_dofW[0], 0); node.set_load(m_dofW[1], 0); node.set_load(m_dofW[2], 0); int n; if ((n = -node.m_ID[m_dofW[0]] - 2) >= 0) node.set_load(m_dofW[0], -m_Fr[n]); if ((n = -node.m_ID[m_dofW[1]] - 2) >= 0) node.set_load(m_dofW[1], -m_Fr[n]); if ((n = -node.m_ID[m_dofW[2]] - 2) >= 0) node.set_load(m_dofW[2], -m_Fr[n]); } // increase RHS counter m_nrhs++; return true; } //----------------------------------------------------------------------------- //! calculate the nonlinear constraint forces void FEFluidSolver::NonLinearConstraintForces(FEGlobalVector& R, const FETimeInfo& tp) { FEModel& fem = *GetFEModel(); int N = fem.NonlinearConstraints(); for (int i=0; i<N; ++i) { FENLConstraint* plc = fem.NonlinearConstraint(i); if (plc->IsActive()) plc->LoadVector(R, tp); } } //----------------------------------------------------------------------------- //! Serialization void FEFluidSolver::Serialize(DumpStream& ar) { FENewtonSolver::Serialize(ar); ar & m_Ut & m_Ui; ar & m_Vi & m_Di; ar & m_nrhs & m_niter & m_nref & m_ntotref; ar & m_neq & m_nveq & m_ndeq; if (ar.IsLoading()) { m_Fr.assign(m_neq, 0); m_Vi.assign(m_nveq,0); m_Di.assign(m_ndeq,0); } if (ar.IsShallow()) return; ar & m_rhoi & m_alphaf & m_alpham; ar & m_gammaf; ar & m_pred; ar & m_dofW & m_dofAW & m_dofEF & m_dofAEF; }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEFluidMixtureTractionLoad.cpp
.cpp
3,217
87
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEFluidMixtureTractionLoad.h" #include <FECore/FESurface.h> #include <FECore/FEFacetSet.h> #include <FECore/FEMesh.h> #include "FEBioFluid.h" //============================================================================= BEGIN_FECORE_CLASS(FEFluidMixtureTractionLoad, FESurfaceLoad) ADD_PARAMETER(m_scale, "scale" ); ADD_PARAMETER(m_TC , "traction"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- //! constructor FEFluidMixtureTractionLoad::FEFluidMixtureTractionLoad(FEModel* pfem) : FESurfaceLoad(pfem) { m_scale = 1.0; m_TC = vec3d(0,0,0); } //----------------------------------------------------------------------------- //! allocate storage void FEFluidMixtureTractionLoad::SetSurface(FESurface* ps) { FESurfaceLoad::SetSurface(ps); m_TC.SetItemList(ps->GetFacetSet()); } //----------------------------------------------------------------------------- bool FEFluidMixtureTractionLoad::Init() { m_dof.Clear(); if (m_dof.AddVariable(FEBioFluid::GetVariableName(FEBioFluid::DISPLACEMENT)) == false) return false; return FESurfaceLoad::Init(); } //----------------------------------------------------------------------------- //! Calculate the residual for the traction load void FEFluidMixtureTractionLoad::LoadVector(FEGlobalVector& R) { m_psurf->LoadVector(R, m_dof, true, [&](FESurfaceMaterialPoint& mp, const FESurfaceDofShape& dof_a, vector<double>& fa) { // fluid traction vec3d t = m_TC(mp)*m_scale; vec3d f = t*((mp.dxr ^ mp.dxs).norm()); double H = dof_a.shape; fa[0] = H * f.x; fa[1] = H * f.y; fa[2] = H * f.z; }); } //----------------------------------------------------------------------------- //! calculate traction stiffness (there is none) void FEFluidMixtureTractionLoad::StiffnessMatrix(FELinearSystem& LS) { }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEFluidResistanceBC.cpp
.cpp
6,269
202
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEFluidResistanceBC.h" #include "FEBioFluid.h" #include <FECore/FEModel.h> //============================================================================= BEGIN_FECORE_CLASS(FEFluidResistanceBC, FEPrescribedSurface) ADD_PARAMETER(m_R , "R")->setUnits("F.t/L^5"); ADD_PARAMETER(m_p0, "pressure_offset")->setUnits(UNIT_PRESSURE); END_FECORE_CLASS(); //----------------------------------------------------------------------------- //! constructor FEFluidResistanceBC::FEFluidResistanceBC(FEModel* pfem) : FEPrescribedSurface(pfem), m_dofW(pfem) { m_R = 0.0; m_pfluid = nullptr; m_p0 = 0; m_e = 0.0; m_psurf = nullptr; } //----------------------------------------------------------------------------- //! initialize bool FEFluidResistanceBC::Init() { m_dofW.AddVariable(FEBioFluid::GetVariableName(FEBioFluid::RELATIVE_FLUID_VELOCITY)); m_dofEF = GetDOFIndex(FEBioFluid::GetVariableName(FEBioFluid::FLUID_DILATATION), 0); SetDOFList(m_dofEF); if (FEPrescribedSurface::Init() == false) return false; m_psurf = GetSurface(); // get fluid from first surface element // assuming the entire surface bounds the same fluid FESurfaceElement& el = m_psurf->Element(0); FEElement* pe = el.m_elem[0].pe; if (pe == nullptr) return false; // get the material FEMaterial* pm = GetFEModel()->GetMaterial(pe->GetMatID()); m_pfluid = pm->ExtractProperty<FEFluidMaterial>(); if (m_pfluid == nullptr) return false; return true; } //----------------------------------------------------------------------------- //! serialization void FEFluidResistanceBC::Serialize(DumpStream& ar) { FEPrescribedSurface::Serialize(ar); ar & m_e; if (ar.IsShallow()) return; ar & m_pfluid; ar & m_dofW & m_dofEF; ar & m_psurf; } //----------------------------------------------------------------------------- void FEFluidResistanceBC::Update() { UpdateDilatation(); FEPrescribedSurface::Update(); // TODO: Is this necessary? GetFEModel()->SetMeshUpdateFlag(true); } //----------------------------------------------------------------------------- void FEFluidResistanceBC::UpdateModel() { Update(); } //----------------------------------------------------------------------------- //! Evaluate and prescribe the resistance pressure void FEFluidResistanceBC::UpdateDilatation() { // evaluate the flow rate double Q = FlowRate(); // calculate the resistance pressure double p = m_R*Q; // calculate the dilatation m_e = 0; bool good = m_pfluid->Dilatation(0,p+m_p0, m_e); assert(good); } //----------------------------------------------------------------------------- //! evaluate the flow rate across this surface at the current time double FEFluidResistanceBC::FlowRate() { double Q = 0; vec3d rt[FEElement::MAX_NODES]; vec3d vt[FEElement::MAX_NODES]; const FETimeInfo& tp = GetTimeInfo(); double alpha = tp.alpha; double alphaf = tp.alphaf; for (int iel=0; iel<m_psurf->Elements(); ++iel) { FESurfaceElement& el = m_psurf->Element(iel); // nr integration points int nint = el.GaussPoints(); // nr of element nodes int neln = el.Nodes(); // nodal coordinates for (int i=0; i<neln; ++i) { FENode& node = m_psurf->Node(el.m_lnode[i]); rt[i] = node.m_rt; vt[i] = node.get_vec3d(m_dofW[0], m_dofW[1], m_dofW[2]); } double* Nr, *Ns; double* N; double* w = el.GaussWeights(); vec3d dxr, dxs, v; // repeat over integration points for (int n=0; n<nint; ++n) { N = el.H(n); Nr = el.Gr(n); Ns = el.Gs(n); // calculate the velocity and tangent vectors at integration point dxr = dxs = v = vec3d(0,0,0); for (int i=0; i<neln; ++i) { v += vt[i]*N[i]; dxr += rt[i]*Nr[i]; dxs += rt[i]*Ns[i]; } vec3d normal = dxr ^ dxs; double q = normal*v; Q += q*w[n]; } } return Q; } //----------------------------------------------------------------------------- void FEFluidResistanceBC::PrepStep(std::vector<double>& ui, bool brel) { UpdateDilatation(); FEPrescribedSurface::PrepStep(ui, brel); } //----------------------------------------------------------------------------- void FEFluidResistanceBC::GetNodalValues(int nodelid, std::vector<double>& val) { val[0] = m_e; FENode& node = GetMesh().Node(m_nodeList[nodelid]); node.set(m_dofEF, m_e); } //----------------------------------------------------------------------------- // copy data from another class void FEFluidResistanceBC::CopyFrom(FEBoundaryCondition* pbc) { // TODO: implement this assert(false); }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEConstFluidBodyMoment.cpp
.cpp
1,757
46
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEConstFluidBodyMoment.h" BEGIN_FECORE_CLASS(FEConstFluidBodyMoment, FEBodyMoment); ADD_PARAMETER(m_moment, "moment")->setUnits(UNIT_SPECIFIC_FORCE); END_FECORE_CLASS(); FEConstFluidBodyMoment::FEConstFluidBodyMoment(FEModel* pfem) : FEBodyMoment(pfem) { } vec3d FEConstFluidBodyMoment::moment(FEMaterialPoint& pt) { return m_moment(pt); } mat3ds FEConstFluidBodyMoment::stiffness(FEMaterialPoint& pt) { return mat3ds(0, 0, 0, 0, 0, 0); }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEBioFluidPlot.cpp
.cpp
54,297
1,604
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEBioFluidPlot.h" #include "FEFluidDomain3D.h" #include "FEFluidMaterial.h" #include "FEPolarFluidMaterial.h" #include "FEFluid.h" #include "FEThermoFluid.h" #include "FEPolarFluid.h" #include "FEFluidDomain.h" #include "FEFluidFSIDomain.h" #include "FEFluidFSI.h" #include "FEBiphasicFSIDomain.h" #include "FEBiphasicFSI.h" #include "FEMultiphasicFSIDomain.h" #include "FEMultiphasicFSI.h" #include "FEThermoFluid.h" #include <FECore/FEModel.h> #include <FECore/FESurface.h> #include <FECore/writeplot.h> #include <FECore/FEDomainParameter.h> //============================================================================= // N O D E D A T A //============================================================================= //----------------------------------------------------------------------------- //! Store the nodal displacements bool FEPlotDisplacement::Save(FEMesh& m, FEDataStream& a) { // loop over all nodes writeNodalValues<vec3d>(m, a, [](const FENode& node) { return node.m_rt - node.m_r0; }); return true; } //----------------------------------------------------------------------------- //! Store the nodal fluid velocity (only for CFD domains) bool FEPlotNodalFluidVelocity::Save(FEMesh& m, FEDataStream& a) { FEModel* fem = GetFEModel(); int dofWX = fem->GetDOFIndex("wx"); int dofWY = fem->GetDOFIndex("wy"); int dofWZ = fem->GetDOFIndex("wz"); int dofVX = fem->GetDOFIndex("vfx"); int dofVY = fem->GetDOFIndex("vfy"); int dofVZ = fem->GetDOFIndex("vfz"); bool bcfd = false; if ((dofVX == -1) && (dofVY == -1) && (dofVZ == -1)) { bcfd = true; } if (bcfd) { writeNodalValues<vec3d>(m, a, [=](const FENode& node) { return node.get_vec3d(dofWX, dofWY, dofWZ); }); return true; } else { writeNodalValues<vec3d>(m, a, [=](const FENode& node) { return node.get_vec3d(dofVX, dofVY, dofVZ); }); return true; } } //----------------------------------------------------------------------------- //! Store the nodal relative fluid velocity bool FEPlotNodalRelativeFluidVelocity::Save(FEMesh& m, FEDataStream& a) { FEModel* fem = GetFEModel(); int dofWX = fem->GetDOFIndex("wx"); int dofWY = fem->GetDOFIndex("wy"); int dofWZ = fem->GetDOFIndex("wz"); writeNodalValues<vec3d>(m, a, [=](const FENode& node) { return node.get_vec3d(dofWX, dofWY, dofWZ); }); return true; } //----------------------------------------------------------------------------- //! Store the nodal dilatations bool FEPlotFluidDilatation::Save(FEMesh& m, FEDataStream& a) { // get the dilatation dof index int dof_e = GetFEModel()->GetDOFIndex("ef"); if (dof_e < 0) return false; // loop over all nodes writeNodalValues<double>(m, a, [=](const FENode& node) { return node.get(dof_e); }); return true; } //----------------------------------------------------------------------------- //! Store the nodal effective fluid pressure bool FEPlotFluidEffectivePressure::Save(FEDomain& dom, FEDataStream& a) { // get the dilatation dof index int dof_e = GetFEModel()->GetDOFIndex("ef"); if (dof_e < 0) return false; FEFluid* pfluid = dom.GetMaterial()->ExtractProperty<FEFluid>(); if (pfluid == 0) return false; // loop over all nodes writeNodalValues<double>(dom, a, [=, &dom](int i) { FENode& node = dom.Node(i); return pfluid->Pressure(node.get(dof_e)); }); return true; } //----------------------------------------------------------------------------- //! Store the nodal polar fluid angular velocity bool FEPlotNodalPolarFluidAngularVelocity::Save(FEMesh& m, FEDataStream& a) { FEModel* fem = GetFEModel(); int dofGX = fem->GetDOFIndex("gx"); int dofGY = fem->GetDOFIndex("gy"); int dofGZ = fem->GetDOFIndex("gz"); writeNodalValues<vec3d>(m, a, [=](const FENode& node) { return node.get_vec3d(dofGX, dofGY, dofGZ); }); return true; } //----------------------------------------------------------------------------- //! Store the nodal temperatures bool FEPlotNodalFluidTemperature::Save(FEMesh& m, FEDataStream& a) { // get the dilatation dof index int dof_T = GetFEModel()->GetDOFIndex("T"); if (dof_T < 0) return false; // loop over all nodes writeNodalValues<double>(m, a, [=](const FENode& node) { return node.get(dof_T); }); return true; } //============================================================================= // S U R F A C E D A T A //============================================================================= //----------------------------------------------------------------------------- bool FEPlotFluidSurfaceForce::Save(FESurface &surf, FEDataStream &a) { FESurface* pcs = &surf; if (pcs == 0) return false; int NF = pcs->Elements(); vec3d fn(0,0,0); // initialize // calculate the vectorial area of each surface element and to identify solid element associated with this surface element m_area.resize(NF); for (int j=0; j<NF; ++j) { FESurfaceElement& el = pcs->Element(j); m_area[j] = pcs->SurfaceNormal(el,0,0)*pcs->FaceArea(el); } // calculate net fluid force for (int j=0; j<NF; ++j) { FESurfaceElement& el = pcs->Element(j); // get the element this surface element belongs to FEElement* pe = el.m_elem[0].pe; if (pe) { // get the material FEMaterial* pm = GetFEModel()->GetMaterial(pe->GetMatID()); FEFluidMaterial* pfluid = pm->ExtractProperty<FEFluidMaterial>(); if (!pfluid) { pe = el.m_elem[1].pe; if (pe) pfluid = GetFEModel()->GetMaterial(pe->GetMatID())->ExtractProperty<FEFluidMaterial>(); } // see if this is a fluid element if (pfluid) { FEPolarFluidMaterial* polar = pfluid->ExtractProperty<FEPolarFluidMaterial>(); // evaluate the average stress in this element int nint = pe->GaussPoints(); mat3d s(mat3dd(0)); for (int n=0; n<nint; ++n) { FEMaterialPoint& mp = *pe->GetMaterialPoint(n); FEFluidMaterialPoint& pt = *(mp.ExtractData<FEFluidMaterialPoint>()); s += pt.m_sf; if (polar) s += polar->GetViscousPolar()->SkewStress(mp); } s /= nint; // Evaluate contribution to net force on surface. // Negate the fluid traction since we want the traction on the surface, // which is the opposite of the traction on the fluid. fn -= s*m_area[j]; } } } // save results a << fn; return true; } //----------------------------------------------------------------------------- bool FEPlotFluidSurfaceMoment::Save(FESurface &surf, FEDataStream &a) { FESurface* pcs = &surf; if (pcs == 0) return false; int NF = pcs->Elements(); vec3d mn(0,0,0); // initialize // initialize on the first pass to calculate the vectorial area of each surface element and to identify solid element associated with this surface element if (m_binit) { m_area.resize(NF); for (int j=0; j<NF; ++j) { FESurfaceElement& el = pcs->Element(j); m_area[j] = pcs->SurfaceNormal(el,0,0)*pcs->FaceArea(el); } m_binit = false; } // calculate net fluid moment for (int j=0; j<NF; ++j) { FESurfaceElement& el = pcs->Element(j); // get the element this surface element belongs to FEElement* pe = el.m_elem[0].pe; if (pe) { // get the material FEMaterial* pm = GetFEModel()->GetMaterial(pe->GetMatID()); FEPolarFluidMaterial* pfluid = pm->ExtractProperty<FEPolarFluidMaterial>(); if (!pfluid) { pe = el.m_elem[1].pe; if (pe) pfluid = GetFEModel()->GetMaterial(pe->GetMatID())->ExtractProperty<FEPolarFluidMaterial>(); } // see if this is a fluid element if (pfluid) { // evaluate the average stress in this element int nint = pe->GaussPoints(); mat3d s(mat3dd(0)); for (int n=0; n<nint; ++n) { FEMaterialPoint& mp = *pe->GetMaterialPoint(n); if (pfluid->GetViscousPolar()) s += pfluid->GetViscousPolar()->CoupleStress(mp); } s /= nint; // Evaluate contribution to net moment on surface. // Negate the fluid couple vector since we want the couple vector on the surface, // which is the opposite of the traction on the fluid. mn -= s*m_area[j]; } } } // save results a << mn; return true; } //----------------------------------------------------------------------------- // Plot contact pressure bool FEPlotFluidSurfacePressure::Save(FESurface &surf, FEDataStream& a) { FESurface* pcs = &surf; if (pcs == 0) return false; const int dof_EF = GetFEModel()->GetDOFIndex("ef"); const int dof_T = GetFEModel()->GetDOFIndex("T"); writeElementValue<double>(surf, a, [=](int nface) { FESurfaceElement& el = pcs->Element(nface); double ef = pcs->Evaluate(nface, dof_EF); double T = pcs->Evaluate(nface, dof_T); FEElement* pe = el.m_elem[0].pe; if (pe) { // get the material FEMaterial* pm = GetFEModel()->GetMaterial(pe->GetMatID()); FEFluidMaterial* fluid = pm->ExtractProperty<FEFluidMaterial>(); if (!fluid) { pe = el.m_elem[1].pe; if (pe) fluid = GetFEModel()->GetMaterial(pe->GetMatID())->ExtractProperty<FEFluidMaterial>(); } if (fluid) return fluid->Pressure(ef, T); else return 0.; } else return 0.; }); return true; } //----------------------------------------------------------------------------- bool FEPlotFluidSurfaceTractionPower::Save(FESurface &surf, FEDataStream &a) { FESurface* pcs = &surf; if (pcs == 0) return false; int NF = pcs->Elements(); double fn = 0; // initialize // initialize on the first pass to calculate the vectorial area of each surface element and to identify solid element associated with this surface element if (m_binit) { m_area.resize(NF); for (int j=0; j<NF; ++j) { FESurfaceElement& el = pcs->Element(j); m_area[j] = pcs->SurfaceNormal(el,0,0)*pcs->FaceArea(el); } m_binit = false; } // calculate net fluid force for (int j=0; j<NF; ++j) { FESurfaceElement& el = pcs->Element(j); // get the element this surface element belongs to FEElement* pe = el.m_elem[0].pe; if (pe) { // get the material FEMaterial* pm = GetFEModel()->GetMaterial(pe->GetMatID()); FEFluidMaterial* pfluid = pm->ExtractProperty<FEFluidMaterial>(); // see if this is a fluid element if (pfluid) { // evaluate the average stress in this element int nint = pe->GaussPoints(); double s = 0; for (int n=0; n<nint; ++n) { FEMaterialPoint& mp = *pe->GetMaterialPoint(n); FEFluidMaterialPoint& pt = *(mp.ExtractData<FEFluidMaterialPoint>()); s += pt.m_vft*(pt.m_sf*m_area[j]); } s /= nint; // Evaluate contribution to net traction power on surface. fn += s; } } } // save results a << fn; return true; } //----------------------------------------------------------------------------- bool FEPlotFluidSurfaceEnergyFlux::Save(FESurface &surf, FEDataStream &a) { FESurface* pcs = &surf; if (pcs == 0) return false; int NF = pcs->Elements(); double fn = 0; // initialize // initialize on the first pass to calculate the vectorial area of each surface element and to identify solid element associated with this surface element if (m_binit) { m_area.resize(NF); for (int j=0; j<NF; ++j) { FESurfaceElement& el = pcs->Element(j); m_area[j] = pcs->SurfaceNormal(el,0,0)*pcs->FaceArea(el); } m_binit = false; } // calculate net fluid force for (int j=0; j<NF; ++j) { FESurfaceElement& el = pcs->Element(j); // get the element this surface element belongs to FEElement* pe = el.m_elem[0].pe; if (pe) { // get the material FEMaterial* pm = GetFEModel()->GetMaterial(pe->GetMatID()); FEFluidMaterial* pfluid = pm->ExtractProperty<FEFluidMaterial>(); // see if this is a fluid element if (pfluid) { // evaluate the average stress in this element int nint = pe->GaussPoints(); double s = 0; for (int n=0; n<nint; ++n) { FEMaterialPoint& mp = *pe->GetMaterialPoint(n); FEFluidMaterialPoint& pt = *(mp.ExtractData<FEFluidMaterialPoint>()); s += pfluid->EnergyDensity(mp)*(pt.m_vft*m_area[j]); } s /= nint; // Evaluate contribution to net energy flux on surface. fn += s; } } } // save results a << fn; return true; } //----------------------------------------------------------------------------- bool FEPlotFluidMassFlowRate::Save(FESurface &surf, FEDataStream &a) { FESurface* pcs = &surf; if (pcs == 0) return false; FEModel* fem = GetFEModel(); int dofWX = fem->GetDOFIndex("wx"); int dofWY = fem->GetDOFIndex("wy"); int dofWZ = fem->GetDOFIndex("wz"); int dofEF = fem->GetDOFIndex("ef"); int NF = pcs->Elements(); double fn = 0; // initialize FEMesh* m_pMesh = pcs->GetMesh(); // calculate net fluid mass flow rate for (int j=0; j<NF; ++j) { FESurfaceElement& el = pcs->Element(j); // get the element this surface element belongs to FEElement* pe = el.m_elem[0].pe; if (pe) { // get the material FEMaterial* pm = fem->GetMaterial(pe->GetMatID()); // see if this is a fluid element FEFluidMaterial* fluid = pm->ExtractProperty<FEFluidMaterial>(); if (fluid) { double rhor = fluid->m_rhor; // get the surface element FESurfaceElement& el = pcs->Element(j); // extract nodal velocities and dilatation int neln = el.Nodes(); vec3d vt[FEElement::MAX_NODES]; double et[FEElement::MAX_NODES]; for (int j=0; j<neln; ++j) { vt[j] = m_pMesh->Node(el.m_node[j]).get_vec3d(dofWX, dofWY, dofWZ); et[j] = m_pMesh->Node(el.m_node[j]).get(dofEF); } // evaluate mass flux across this surface element int nint = el.GaussPoints(); double* gw = el.GaussWeights(); vec3d gcov[2]; for (int n=0; n<nint; ++n) { vec3d v = el.eval(vt, n); double J = 1 + el.eval(et, n); pcs->CoBaseVectors(el, n, gcov); fn += (v*(gcov[0] ^ gcov[1]))*rhor/J*gw[n]; } } } } // save results a << fn; return true; } //----------------------------------------------------------------------------- bool FEPlotFluidFlowRate::Save(FESurface &surf, FEDataStream &a) { FESurface* pcs = &surf; if (pcs == 0) return false; int NF = pcs->Elements(); double fn = 0; // initialize // initialize on the first pass to calculate the vectorial area of each surface element and to identify solid element associated with this surface element if (m_binit) { m_area.resize(NF); for (int j = 0; j<NF; ++j) { FESurfaceElement& el = pcs->Element(j); m_area[j] = pcs->SurfaceNormal(el, 0, 0)*pcs->FaceArea(el); } m_binit = false; } // calculate net flow rate normal to this surface for (int j = 0; j<NF; ++j) { FESurfaceElement& el = pcs->Element(j); // get the element this surface element belongs to FEElement* pe = el.m_elem[0].pe; if (pe) { // evaluate the average fluid flux in this element int nint = pe->GaussPoints(); vec3d w(0, 0, 0); for (int n = 0; n<nint; ++n) { FEMaterialPoint& mp = *pe->GetMaterialPoint(n); FEFluidMaterialPoint* ptf = mp.ExtractData<FEFluidMaterialPoint>(); if (ptf) w += ptf->m_vft / (ptf->m_ef + 1); } w /= nint; // Evaluate contribution to net flow rate across surface. fn += w*m_area[j]; } } // save results a << fn; return true; } //============================================================================= // D O M A I N D A T A //============================================================================= //----------------------------------------------------------------------------- bool FEPlotFluidPressure::Save(FEDomain &dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; writeAverageElementValue<double>(dom, a, [](const FEMaterialPoint& mp) { const FEFluidMaterialPoint* pt = (mp.ExtractData<FEFluidMaterialPoint>()); return (pt ? pt->m_pf : 0.0); }); return true; } //----------------------------------------------------------------------------- // TODO: This plots the exact same value as FEFluidPressure. Delete? bool FEPlotElasticFluidPressure::Save(FEDomain &dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; writeAverageElementValue<double>(dom, a, [](const FEMaterialPoint& mp) { const FEFluidMaterialPoint* pt = (mp.ExtractData<FEFluidMaterialPoint>()); return (pt ? pt->m_pf : 0.0); }); return true; } //----------------------------------------------------------------------------- bool FEPlotFluidTemperature::Save(FEDomain &dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; writeAverageElementValue<double>(dom, a, [=](const FEMaterialPoint& mp) { return pfluid->Temperature(const_cast<FEMaterialPoint&>(mp)); }); return true; } //----------------------------------------------------------------------------- class FEFluidVolumeRatio { public: FEFluidVolumeRatio(FEModel* fem, FESolidDomain& dom) : m_dom(dom) { m_dofEF = fem->GetDOFIndex("ef"); } double operator()(const FEMaterialPoint& mp) { FESolidElement* pel = dynamic_cast<FESolidElement*>(mp.m_elem); if (pel == nullptr) return 0.0; FESolidElement& el = *pel; FEMesh& mesh = *m_dom.GetMesh(); int neln = el.Nodes(); double et[FEElement::MAX_NODES]; for (int j = 0; j<neln; ++j) et[j] = mesh.Node(el.m_node[j]).get(m_dofEF); double Jf = 1.0 + el.Evaluate(et, mp.m_index); return Jf; } private: FESolidDomain& m_dom; int m_dofEF; }; bool FEPlotFluidVolumeRatio::Save(FEDomain &dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; if (dom.Class() == FE_DOMAIN_SOLID) { FESolidDomain& sd = static_cast<FESolidDomain&>(dom); writeAverageElementValue<double>(dom, a, FEFluidVolumeRatio(GetFEModel(), sd)); return true; } return false; } //----------------------------------------------------------------------------- class FEFluidDensity { public: FEFluidDensity(FEModel* fem, FESolidDomain& dom, FEFluidMaterial* pm) : m_dom(dom), m_mat(pm) { m_dofEF = fem->GetDOFIndex("ef"); } double operator()(const FEMaterialPoint& mp) { FESolidElement* pel = dynamic_cast<FESolidElement*>(mp.m_elem); if (pel == nullptr) return 0.0; FESolidElement& el = *pel; FEMesh& mesh = *m_dom.GetMesh(); int neln = el.Nodes(); double et[FEElement::MAX_NODES]; for (int j = 0; j<neln; ++j) et[j] = mesh.Node(el.m_node[j]).get(m_dofEF); double rhor = m_mat->m_rhor; double Jf = 1 + el.Evaluate(et, mp.m_index); return rhor / Jf; } private: FESolidDomain& m_dom; FEFluidMaterial* m_mat; int m_dofEF; }; bool FEPlotFluidDensity::Save(FEDomain &dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; if (dom.Class() == FE_DOMAIN_SOLID) { FESolidDomain& sd = static_cast<FESolidDomain&>(dom); writeAverageElementValue<double>(dom, a, FEFluidDensity(GetFEModel(), sd, pfluid)); return true; } return false; } //----------------------------------------------------------------------------- class FEFluidDensityRate { public: FEFluidDensityRate(FEModel* fem, FESolidDomain& dom, FEFluidMaterial* pm) : m_dom(dom), m_mat(pm) { m_dofVX = fem->GetDOFIndex("vx"); m_dofVY = fem->GetDOFIndex("vy"); m_dofVZ = fem->GetDOFIndex("vz"); m_dofEF = fem->GetDOFIndex("ef"); m_dofAEF = fem->GetDOFIndex("aef"); } double operator()(const FEMaterialPoint& mp) { FESolidElement* pel = dynamic_cast<FESolidElement*>(mp.m_elem); if (pel == nullptr) return 0.0; FESolidElement& el = *pel; FEMesh& mesh = *m_dom.GetMesh(); vec3d vt[FEElement::MAX_NODES]; double et[FEElement::MAX_NODES]; double aet[FEElement::MAX_NODES]; int neln = el.Nodes(); for (int j = 0; j<neln; ++j) { vt[j] = mesh.Node(el.m_node[j]).get_vec3d(m_dofVX, m_dofVY, m_dofVZ); et[j] = mesh.Node(el.m_node[j]).get(m_dofEF); aet[j] = mesh.Node(el.m_node[j]).get(m_dofAEF); } double rhor = m_mat->m_rhor; double Jf = 1.0 + el.Evaluate(et, mp.m_index); double Jfdot = el.Evaluate(aet, mp.m_index); double divvs = m_dom.gradient(el, vt, mp.m_index).trace(); return rhor / Jf*(divvs - Jfdot / Jf); } private: FESolidDomain& m_dom; FEFluidMaterial* m_mat; int m_dofVX, m_dofVY, m_dofVZ; int m_dofEF, m_dofAEF; }; bool FEPlotFluidDensityRate::Save(FEDomain &dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; if (dom.Class() == FE_DOMAIN_SOLID) { FESolidDomain& sd = static_cast<FESolidDomain&>(dom); writeAverageElementValue<double>(sd, a, FEFluidDensityRate(GetFEModel(), sd, pfluid)); return true; } return false; } //----------------------------------------------------------------------------- class FEFluidBodyForce { public: FEFluidBodyForce(FEModel* fem, FESolidDomain& dom) : m_fem(fem), m_dom(dom) {} vec3d operator()(const FEMaterialPoint& mp) { int NBL = m_fem->ModelLoads(); vec3d bf(0,0,0); for (int j = 0; j<NBL; ++j) { FEBodyForce* pbf = dynamic_cast<FEBodyForce*>(m_fem->ModelLoad(j)); FEMaterialPoint& pt = const_cast<FEMaterialPoint&>(mp); if (pbf && pbf->IsActive()) bf += pbf->force(pt); } // FEBio actually applies the negative of the body force return -bf; } private: FESolidDomain& m_dom; FEModel* m_fem; }; bool FEPlotFluidBodyForce::Save(FEDomain &dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; if (dom.Class() == FE_DOMAIN_SOLID) { FESolidDomain& sd = static_cast<FESolidDomain&>(dom); writeAverageElementValue<vec3d>(dom, a, FEFluidBodyForce(GetFEModel(), sd)); return true; } return true; } //----------------------------------------------------------------------------- bool FEPlotFluidVelocity::Save(FEDomain &dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; // write solid element data writeAverageElementValue<vec3d>(dom, a, [](const FEMaterialPoint& mp) { const FEFluidMaterialPoint* ppt = mp.ExtractData<FEFluidMaterialPoint>(); return (ppt ? ppt->m_vft : vec3d(0.)); }); return true; } //----------------------------------------------------------------------------- bool FEPlotRelativeFluidVelocity::Save(FEDomain &dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; writeAverageElementValue<vec3d>(dom, a, [](const FEMaterialPoint& mp) { const FEFluidMaterialPoint* fpt = mp.ExtractData<FEFluidMaterialPoint>(); const FEElasticMaterialPoint* ept = mp.ExtractData<FEElasticMaterialPoint>(); return (fpt ? fpt->m_vft - ept->m_v : vec3d(0.0)); }); return true; } //----------------------------------------------------------------------------- bool FEPlotBFSIPorosity::Save(FEDomain &dom, FEDataStream& a) { FEBiphasicFSI* bp = dom.GetMaterial()->ExtractProperty<FEBiphasicFSI>(); if (bp == 0) return false; // write solid element data writeAverageElementValue<double>(dom, a, [=](const FEMaterialPoint& mp) { return bp->Porosity(const_cast<FEMaterialPoint&>(mp)); }); return true; } //----------------------------------------------------------------------------- bool FEPlotBFSISolidVolumeFraction::Save(FEDomain &dom, FEDataStream& a) { FEBiphasicFSI* bp = dom.GetMaterial()->ExtractProperty<FEBiphasicFSI>(); if (bp == 0) return false; // write solid element data writeAverageElementValue<double>(dom, a, [=](const FEMaterialPoint& mp) { return bp->SolidVolumeFrac(const_cast<FEMaterialPoint&>(mp)); }); return true; } //----------------------------------------------------------------------------- bool FEPlotFSIFluidFlux::Save(FEDomain &dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; writeAverageElementValue<vec3d>(dom, a, [](const FEMaterialPoint& mp) { const FEFSIMaterialPoint* ppt = mp.ExtractData<FEFSIMaterialPoint>(); return (ppt ? ppt->m_w : vec3d(0.0)); }); return true; } //----------------------------------------------------------------------------- bool FEPlotPermeability::Save(FEDomain &dom, FEDataStream& a) { FEBiphasicFSI* bp = dom.GetMaterial()->ExtractProperty<FEBiphasicFSI>(); if (bp == 0) return false; writeAverageElementValue<mat3ds>(dom, a, [=](const FEMaterialPoint& mp) { return bp->Permeability(const_cast<FEMaterialPoint&>(mp)); }); return true; } //----------------------------------------------------------------------------- bool FEPlotGradJ::Save(FEDomain &dom, FEDataStream& a) { FEBiphasicFSI* pbfsi = dom.GetMaterial()->ExtractProperty<FEBiphasicFSI>(); if (pbfsi == 0) return false; writeAverageElementValue<vec3d>(dom, a, [](const FEMaterialPoint& mp) { const FEBiphasicFSIMaterialPoint* bpt = mp.ExtractData<FEBiphasicFSIMaterialPoint>(); return (bpt ? bpt->m_gradJ : vec3d(0.0)); }); return true; } //----------------------------------------------------------------------------- bool FEPlotGradPhiF::Save(FEDomain &dom, FEDataStream& a) { FEBiphasicFSI* bp = dom.GetMaterial()->ExtractProperty<FEBiphasicFSI>(); if (bp == 0) return false; // write solid element data writeAverageElementValue<vec3d>(dom, a, [=](const FEMaterialPoint& mp) { return bp->gradPorosity(const_cast<FEMaterialPoint&>(mp)); }); return true; } //----------------------------------------------------------------------------- bool FEPlotFluidAcceleration::Save(FEDomain &dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; // write solid element data writeAverageElementValue<vec3d>(dom, a, [](const FEMaterialPoint& mp) { const FEFluidMaterialPoint* ppt = mp.ExtractData<FEFluidMaterialPoint>(); return (ppt ? ppt->m_aft : vec3d(0.)); }); return true; } //----------------------------------------------------------------------------- bool FEPlotFluidVorticity::Save(FEDomain &dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; // write solid element data writeAverageElementValue<vec3d>(dom, a, [](const FEMaterialPoint& mp) { const FEFluidMaterialPoint* ppt = mp.ExtractData<FEFluidMaterialPoint>(); return (ppt ? ppt->Vorticity() : vec3d(0.)); }); return true; } //----------------------------------------------------------------------------- bool FEPlotPolarFluidAngularVelocity::Save(FEDomain &dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; // write solid element data writeAverageElementValue<vec3d>(dom, a, [](const FEMaterialPoint& mp) { const FEPolarFluidMaterialPoint* ppt = mp.ExtractData<FEPolarFluidMaterialPoint>(); const FEFluidMaterialPoint* pt = mp.ExtractData<FEFluidMaterialPoint>(); vec3d g(0,0,0); if (ppt) g = ppt->m_gf; else if (pt) g = pt->Vorticity()/2; return g; }); return true; } //----------------------------------------------------------------------------- bool FEPlotPolarFluidRelativeAngularVelocity::Save(FEDomain &dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; // write solid element data writeAverageElementValue<vec3d>(dom, a, [](const FEMaterialPoint& mp) { const FEFluidMaterialPoint* pt = mp.ExtractData<FEFluidMaterialPoint>(); const FEPolarFluidMaterialPoint* ppt = mp.ExtractData<FEPolarFluidMaterialPoint>(); return (ppt ? ppt->m_gf - pt->Vorticity()/2 : vec3d(0.)); }); return true; } //----------------------------------------------------------------------------- bool FEPlotPolarFluidRegionalAngularVelocity::Save(FEDomain &dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; // write solid element data writeAverageElementValue<vec3d>(dom, a, [](const FEMaterialPoint& mp) { const FEFluidMaterialPoint* ppt = mp.ExtractData<FEFluidMaterialPoint>(); return (ppt ? ppt->Vorticity()/2 : vec3d(0.)); }); return true; } //----------------------------------------------------------------------------- bool FEPlotFluidHeatFlux::Save(FEDomain &dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; // write solid element data writeAverageElementValue<vec3d>(dom, a, [](const FEMaterialPoint& mp) { const FEThermoFluidMaterialPoint* ppt = mp.ExtractData<FEThermoFluidMaterialPoint>(); return (ppt ? ppt->m_q : vec3d(0.)); }); return true; } //----------------------------------------------------------------------------- //! Store the average stresses for each element. bool FEPlotFluidStress::Save(FEDomain& dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; // write solid element data writeAverageElementValue<mat3ds>(dom, a, [](const FEMaterialPoint& mp) { const FEFluidMaterialPoint* ppt = mp.ExtractData<FEFluidMaterialPoint>(); return (ppt ? ppt->m_sf : mat3ds(0.)); }); return true; } //----------------------------------------------------------------------------- //! Store the average stresses for each element. bool FEPlotElementFluidRateOfDef::Save(FEDomain& dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; // write solid element data writeAverageElementValue<mat3ds>(dom, a, [](const FEMaterialPoint& mp) { const FEFluidMaterialPoint* ppt = mp.ExtractData<FEFluidMaterialPoint>(); return (ppt ? ppt->RateOfDeformation() : mat3ds(0.)); }); return true; } //----------------------------------------------------------------------------- bool FEPlotFluidStressPowerDensity::Save(FEDomain &dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; // write solid element data writeAverageElementValue<double>(dom, a, [](const FEMaterialPoint& mp) { const FEFluidMaterialPoint* ppt = mp.ExtractData<FEFluidMaterialPoint>(); return (ppt ? (ppt->m_sf*ppt->m_Lf).trace() : 0.0); }); return true; } //----------------------------------------------------------------------------- bool FEPlotFluidHeatSupplyDensity::Save(FEDomain &dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; // write solid element data writeAverageElementValue<double>(dom, a, [=](const FEMaterialPoint& mp) { FEMaterialPoint& mp_noconst = const_cast<FEMaterialPoint&>(mp); FEFluidMaterialPoint* ppt = (mp_noconst.ExtractData<FEFluidMaterialPoint>()); return (ppt ? -(pfluid->GetViscous()->Stress(mp_noconst)*ppt->m_Lf).trace() : 0.0); }); return true; } //----------------------------------------------------------------------------- bool FEPlotFluidShearViscosity::Save(FEDomain &dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; // write solid element data writeAverageElementValue<double>(dom, a, [=](const FEMaterialPoint& mp) { FEMaterialPoint& mp_noconst = const_cast<FEMaterialPoint&>(mp); return pfluid->GetViscous()->ShearViscosity(mp_noconst); }); return true; } //----------------------------------------------------------------------------- bool FEPlotFluidStrainEnergyDensity::Save(FEDomain &dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; // write solid element data writeAverageElementValue<double>(dom, a, [=](const FEMaterialPoint& mp) { FEMaterialPoint& mp_noconst = const_cast<FEMaterialPoint&>(mp); return pfluid->StrainEnergyDensity(mp_noconst); }); return true; } //----------------------------------------------------------------------------- bool FEPlotFluidKineticEnergyDensity::Save(FEDomain &dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; // write solid element data writeAverageElementValue<double>(dom, a, [=](const FEMaterialPoint& mp) { FEMaterialPoint& mp_noconst = const_cast<FEMaterialPoint&>(mp); return pfluid->KineticEnergyDensity(mp_noconst); }); return true; } //----------------------------------------------------------------------------- bool FEPlotFluidEnergyDensity::Save(FEDomain &dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; // write solid element data writeAverageElementValue<double>(dom, a, [=](const FEMaterialPoint& mp) { FEMaterialPoint& mp_noconst = const_cast<FEMaterialPoint&>(mp); return pfluid->EnergyDensity(mp_noconst); }); return true; } //----------------------------------------------------------------------------- bool FEPlotFluidBulkModulus::Save(FEDomain &dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; // write solid element data writeAverageElementValue<double>(dom, a, [=](const FEMaterialPoint& mp) { FEMaterialPoint& mp_noconst = const_cast<FEMaterialPoint&>(mp); return pfluid->BulkModulus(mp_noconst); }); return true; } //----------------------------------------------------------------------------- bool FEPlotFluidElementStrainEnergy::Save(FEDomain &dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; if (dom.Class() == FE_DOMAIN_SOLID) { FESolidDomain& sd = static_cast<FESolidDomain&>(dom); writeIntegratedElementValue<double>(sd, a, [=](const FEMaterialPoint& mp) { FEMaterialPoint& mp_noconst = const_cast<FEMaterialPoint&>(mp); return pfluid->StrainEnergyDensity(mp_noconst); }); return true; } return false; } //----------------------------------------------------------------------------- bool FEPlotFluidElementKineticEnergy::Save(FEDomain &dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; if (dom.Class() == FE_DOMAIN_SOLID) { FESolidDomain& sd = static_cast<FESolidDomain&>(dom); writeIntegratedElementValue<double>(sd, a, [=](const FEMaterialPoint& mp) { FEMaterialPoint& mp_noconst = const_cast<FEMaterialPoint&>(mp); return pfluid->KineticEnergyDensity(mp_noconst); }); return true; } return false; } //----------------------------------------------------------------------------- // NOTE: Can't use helper functions due to division by m. bool FEPlotFluidElementCenterOfMass::Save(FEDomain &dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; double dens = pfluid->m_rhor; if (dom.Class() == FE_DOMAIN_SOLID) { FESolidDomain& bd = static_cast<FESolidDomain&>(dom); for (int i=0; i<bd.Elements(); ++i) { FESolidElement& el = bd.Element(i); double* gw = el.GaussWeights(); // integrate zeroth and first mass moments vec3d ew = vec3d(0,0,0); double m = 0; for (int j=0; j<el.GaussPoints(); ++j) { FEFluidMaterialPoint& pt = *(el.GetMaterialPoint(j)->ExtractData<FEFluidMaterialPoint>()); double detJ = bd.detJ0(el, j)*gw[j]; ew += pt.m_r0*(dens*detJ); m += dens*detJ; } a << ew/m; } return true; } return false; } //----------------------------------------------------------------------------- bool FEPlotFluidElementLinearMomentum::Save(FEDomain &dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; if (dom.Class() == FE_DOMAIN_SOLID) { FESolidDomain& bd = static_cast<FESolidDomain&>(dom); writeIntegratedElementValue<vec3d>(bd, a, [=](const FEMaterialPoint& mp) { double dens = pfluid->m_rhor; const FEFluidMaterialPoint& pt = *(mp.ExtractData<FEFluidMaterialPoint>()); return pt.m_vft*dens; }); return true; } return false; } //----------------------------------------------------------------------------- bool FEPlotFluidElementAngularMomentum::Save(FEDomain &dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; if (dom.Class() == FE_DOMAIN_SOLID) { FESolidDomain& bd = static_cast<FESolidDomain&>(dom); writeIntegratedElementValue<vec3d>(bd, a, [=](const FEMaterialPoint& mp) { double dens = pfluid->m_rhor; const FEFluidMaterialPoint& pt = *(mp.ExtractData<FEFluidMaterialPoint>()); return pt.m_vft*dens; }); return true; } return false; } //----------------------------------------------------------------------------- bool FEPlotFluidSpecificFreeEnergy::Save(FEDomain &dom, FEDataStream& a) { FEElasticFluid* pfluid = dom.GetMaterial()->ExtractProperty<FEElasticFluid>(); if (pfluid == 0) return false; writeAverageElementValue<double>(dom, a, [=](const FEMaterialPoint& mp) { FEMaterialPoint& mp_noconst = const_cast<FEMaterialPoint&>(mp); return pfluid->SpecificFreeEnergy(mp_noconst); }); return true; } //----------------------------------------------------------------------------- bool FEPlotFluidSpecificEntropy::Save(FEDomain &dom, FEDataStream& a) { FEElasticFluid* pfluid = dom.GetMaterial()->ExtractProperty<FEElasticFluid>(); if (pfluid == 0) return false; writeAverageElementValue<double>(dom, a, [=](const FEMaterialPoint& mp) { FEMaterialPoint& mp_noconst = const_cast<FEMaterialPoint&>(mp); return pfluid->SpecificEntropy(mp_noconst); }); return true; } //----------------------------------------------------------------------------- bool FEPlotFluidSpecificInternalEnergy::Save(FEDomain &dom, FEDataStream& a) { FEElasticFluid* pfluid = dom.GetMaterial()->ExtractProperty<FEElasticFluid>(); if (pfluid == 0) return false; writeAverageElementValue<double>(dom, a, [=](const FEMaterialPoint& mp) { FEMaterialPoint& mp_noconst = const_cast<FEMaterialPoint&>(mp); return pfluid->SpecificInternalEnergy(mp_noconst); }); return true; } //----------------------------------------------------------------------------- bool FEPlotFluidSpecificGaugeEnthalpy::Save(FEDomain &dom, FEDataStream& a) { FEElasticFluid* pfluid = dom.GetMaterial()->ExtractProperty<FEElasticFluid>(); if (pfluid == 0) return false; writeAverageElementValue<double>(dom, a, [=](const FEMaterialPoint& mp) { FEMaterialPoint& mp_noconst = const_cast<FEMaterialPoint&>(mp); return pfluid->SpecificGaugeEnthalpy(mp_noconst); }); return true; } //----------------------------------------------------------------------------- bool FEPlotFluidSpecificFreeEnthalpy::Save(FEDomain &dom, FEDataStream& a) { FEElasticFluid* pfluid = dom.GetMaterial()->ExtractProperty<FEElasticFluid>(); if (pfluid == 0) return false; writeAverageElementValue<double>(dom, a, [=](const FEMaterialPoint& mp) { FEMaterialPoint& mp_noconst = const_cast<FEMaterialPoint&>(mp); return pfluid->SpecificFreeEnthalpy(mp_noconst); }); return true; } //----------------------------------------------------------------------------- bool FEPlotFluidSpecificStrainEnergy::Save(FEDomain &dom, FEDataStream& a) { FEElasticFluid* pfluid = dom.GetMaterial()->ExtractProperty<FEElasticFluid>(); if (pfluid == 0) return false; writeAverageElementValue<double>(dom, a, [=](const FEMaterialPoint& mp) { FEMaterialPoint& mp_noconst = const_cast<FEMaterialPoint&>(mp); return pfluid->SpecificStrainEnergy(mp_noconst); }); return true; } //----------------------------------------------------------------------------- bool FEPlotFluidIsochoricSpecificHeatCapacity::Save(FEDomain &dom, FEDataStream& a) { FEElasticFluid* pfluid = dom.GetMaterial()->ExtractProperty<FEElasticFluid>(); if (pfluid == 0) return false; writeAverageElementValue<double>(dom, a, [=](const FEMaterialPoint& mp) { FEMaterialPoint& mp_noconst = const_cast<FEMaterialPoint&>(mp); return pfluid->IsochoricSpecificHeatCapacity(mp_noconst); }); return true; } //----------------------------------------------------------------------------- bool FEPlotFluidIsobaricSpecificHeatCapacity::Save(FEDomain &dom, FEDataStream& a) { FEElasticFluid* pfluid = dom.GetMaterial()->ExtractProperty<FEElasticFluid>(); if (pfluid == 0) return false; writeAverageElementValue<double>(dom, a, [=](const FEMaterialPoint& mp) { FEMaterialPoint& mp_noconst = const_cast<FEMaterialPoint&>(mp); return pfluid->IsobaricSpecificHeatCapacity(mp_noconst); }); return true; } //----------------------------------------------------------------------------- bool FEPlotFluidPressureTangentTemperature::Save(FEDomain &dom, FEDataStream& a) { FEElasticFluid* pfluid = dom.GetMaterial()->ExtractProperty<FEElasticFluid>(); if (pfluid == 0) return false; writeAverageElementValue<double>(dom, a, [=](const FEMaterialPoint& mp) { FEMaterialPoint& mp_noconst = const_cast<FEMaterialPoint&>(mp); return pfluid->Tangent_Temperature(mp_noconst); }); return true; } //----------------------------------------------------------------------------- bool FEPlotFluidPressureTangentStrain::Save(FEDomain &dom, FEDataStream& a) { FEElasticFluid* pfluid = dom.GetMaterial()->ExtractProperty<FEElasticFluid>(); if (pfluid == 0) return false; writeAverageElementValue<double>(dom, a, [=](const FEMaterialPoint& mp) { FEMaterialPoint& mp_noconst = const_cast<FEMaterialPoint&>(mp); return pfluid->Tangent_Strain(mp_noconst); }); return true; } //----------------------------------------------------------------------------- bool FEPlotFluidThermalConductivity::Save(FEDomain &dom, FEDataStream& a) { FEFluidThermalConductivity* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidThermalConductivity>(); if (pfluid == 0) return false; writeAverageElementValue<double>(dom, a, [=](const FEMaterialPoint& mp) { FEMaterialPoint& mp_noconst = const_cast<FEMaterialPoint&>(mp); return pfluid->ThermalConductivity(mp_noconst); }); return true; } //----------------------------------------------------------------------------- //! Store the average stresses for each element. bool FEPlotFSISolidStress::Save(FEDomain& dom, FEDataStream& a) { FEFluid* pfluid = dom.GetMaterial()->ExtractProperty<FEFluid>(); if (pfluid == 0) return false; if (dom.Class() == FE_DOMAIN_SOLID) { FESolidDomain& sd = static_cast<FESolidDomain&>(dom); writeAverageElementValue<mat3ds>(sd, a, [](const FEMaterialPoint& mp) { const FEFSIMaterialPoint* pt = (mp.ExtractData<FEFSIMaterialPoint>()); return (pt ? pt->m_ss : mat3ds(0.0)); }); return true; } return false; } //----------------------------------------------------------------------------- bool FEPlotFluidShearStressError::Save(FEDomain& dom, FEDataStream& a) { FEFluid* pfluid = dom.GetMaterial()->ExtractProperty<FEFluid>(); if (pfluid == 0) return false; if (dom.Class() == FE_DOMAIN_SOLID) { writeRelativeError(dom, a, [](FEMaterialPoint& mp) { FEFluidMaterialPoint& fp = *mp.ExtractData<FEFluidMaterialPoint>(); mat3ds s = fp.m_sf; double v = s.max_shear(); return v; }); return true; } return false; } //----------------------------------------------------------------------------- //! Store the average polar fluid stresses for each element. bool FEPlotPolarFluidStress::Save(FEDomain& dom, FEDataStream& a) { FEViscousPolarFluid* vpfluid = dom.GetMaterial()->ExtractProperty<FEViscousPolarFluid>(); if (vpfluid == 0) return false; FEViscousFluid* vfluid = dom.GetMaterial()->ExtractProperty<FEViscousFluid>(); // write solid element data writeAverageElementValue<mat3d>(dom, a, [&](const FEMaterialPoint& mp) { FEMaterialPoint& mp_noconst = const_cast<FEMaterialPoint&>(mp); return (vpfluid->SkewStress(mp_noconst) + vfluid->Stress(mp_noconst)); }); return true; } //----------------------------------------------------------------------------- //! Store the average polar fluid couple stresses for each element. bool FEPlotPolarFluidCoupleStress::Save(FEDomain& dom, FEDataStream& a) { FEViscousPolarFluid* pfluid = dom.GetMaterial()->ExtractProperty<FEViscousPolarFluid>(); if (pfluid == 0) return false; // write solid element data writeAverageElementValue<mat3d>(dom, a, [&](const FEMaterialPoint& mp) { FEMaterialPoint& mp_noconst = const_cast<FEMaterialPoint&>(mp); return pfluid->CoupleStress(mp_noconst); }); return true; } //----------------------------------------------------------------------------- bool FEPlotFluidRelativeReynoldsNumber::Save(FEDomain &dom, FEDataStream& a) { FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; writeAverageElementValue<double>(dom, a, [&pfluid](const FEMaterialPoint& mp) { const FEFluidMaterialPoint* fpt = mp.ExtractData<FEFluidMaterialPoint>(); const FEElasticMaterialPoint* ept = mp.ExtractData<FEElasticMaterialPoint>(); FEMaterialPoint& mp_noconst = const_cast<FEMaterialPoint&>(mp); double nu = pfluid->KinematicViscosity(mp_noconst); vec3d v(0,0,0); if (ept) v = ept->m_v; return (fpt->m_vft - v).Length()/nu; }); return true; } //----------------------------------------------------------------------------- bool FEPlotFluidRelativeThermalPecletNumber::Save(FEDomain &dom, FEDataStream& a) { FEThermoFluid* pfluid = dom.GetMaterial()->ExtractProperty<FEThermoFluid>(); if (pfluid == 0) return false; writeAverageElementValue<double>(dom, a, [&pfluid](const FEMaterialPoint& mp) { const FEFluidMaterialPoint* fpt = mp.ExtractData<FEFluidMaterialPoint>(); // const FEElasticMaterialPoint* ept = mp.ExtractData<FEElasticMaterialPoint>(); FEMaterialPoint& mp_noconst = const_cast<FEMaterialPoint&>(mp); double cp = pfluid->GetElastic()->IsobaricSpecificHeatCapacity(mp_noconst); double K = pfluid->GetConduct()->ThermalConductivity(mp_noconst); double rho = pfluid->Density(mp_noconst); vec3d v(0,0,0); // if (ept) v = ept->m_v; return (fpt->m_vft - v).Length()*rho*cp/K; }); return true; } //================================================================================================= //----------------------------------------------------------------------------- FEPlotFluidRelativePecletNumber::FEPlotFluidRelativePecletNumber(FEModel* pfem) : FEPlotDomainData(pfem, PLT_ARRAY, FMT_ITEM) { DOFS& dofs = pfem->GetDOFS(); int nsol = dofs.GetVariableSize("concentration"); SetArraySize(nsol); // collect the names int ndata = pfem->GlobalDataItems(); vector<string> s; for (int i = 0; i<ndata; ++i) { FESoluteData* ps = dynamic_cast<FESoluteData*>(pfem->GetGlobalData(i)); if (ps) { s.push_back(ps->GetName()); m_sol.push_back(ps->GetID()); } } assert(nsol == (int)s.size()); SetArrayNames(s); SetUnits(UNIT_RECIPROCAL_LENGTH); } //----------------------------------------------------------------------------- bool FEPlotFluidRelativePecletNumber::Save(FEDomain &dom, FEDataStream& a) { FESoluteInterface* pm = dynamic_cast<FESoluteInterface*>(dom.GetMaterial()); if (pm == 0) return false; FEFluidMaterial* pfluid = dom.GetMaterial()->ExtractProperty<FEFluidMaterial>(); if (pfluid == 0) return false; // figure out the local solute IDs. This depends on the material int nsols = (int)m_sol.size(); vector<int> lid(nsols, -1); int negs = 0; for (int i = 0; i<(int)m_sol.size(); ++i) { lid[i] = pm->FindLocalSoluteID(m_sol[i]); if (lid[i] < 0) negs++; } if (negs == nsols) return false; // loop over all elements int N = dom.Elements(); for (int i = 0; i<N; ++i) { FEElement& el = dom.ElementRef(i); for (int k=0; k<nsols; ++k) { int nsid = lid[k]; if (nsid == -1) a << 0.f; else { // calculate average relative Peclet number double ew = 0; for (int j = 0; j<el.GaussPoints(); ++j) { FEMaterialPoint& mp = *el.GetMaterialPoint(j); const FEFluidMaterialPoint* fpt = mp.ExtractData<FEFluidMaterialPoint>(); const FEElasticMaterialPoint* ept = mp.ExtractData<FEElasticMaterialPoint>(); vec3d v(0,0,0); if (ept) v = ept->m_v; ew += (fpt->m_vft - v).Length()/pm->GetFreeDiffusivity(mp, nsid); } ew /= el.GaussPoints(); a << ew; } } } return true; }
C++
3D
febiosoftware/FEBio
FEBioFluid/FETemperatureBackFlowStabilization.cpp
.cpp
8,631
249
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FETemperatureBackFlowStabilization.h" #include "FEFluid.h" #include "FEBioThermoFluid.h" #include <FECore/FEModel.h> //----------------------------------------------------------------------------- //! constructor FETemperatureBackFlowStabilization::FETemperatureBackFlowStabilization(FEModel* pfem) : FESurfaceLoad(pfem), m_dofW(pfem) { } //----------------------------------------------------------------------------- //! allocate storage void FETemperatureBackFlowStabilization::SetSurface(FESurface* ps) { FESurfaceLoad::SetSurface(ps); } //----------------------------------------------------------------------------- //! initialize bool FETemperatureBackFlowStabilization::Init() { FEModel& fem = *GetFEModel(); // determine the nr of concentration equations m_dofW.Clear(); m_dofW.AddVariable(FEBioThermoFluid::GetVariableName(FEBioThermoFluid::RELATIVE_FLUID_VELOCITY)); m_dofT = fem.GetDOFIndex(FEBioThermoFluid::GetVariableName(FEBioThermoFluid::TEMPERATURE), 0); m_dof.Clear(); m_dof.AddDofs(m_dofW); m_dof.AddDof(m_dofT); FESurface* ps = &GetSurface(); m_nnlist.Create(fem.GetMesh()); return FESurfaceLoad::Init(); } //----------------------------------------------------------------------------- //! Activate the degrees of freedom for this BC void FETemperatureBackFlowStabilization::Activate() { FESurface* ps = &GetSurface(); for (int i=0; i<ps->Nodes(); ++i) { FENode& node = ps->Node(i); // mark node as having open DOF node.set_bc(m_dofT, DOF_OPEN); } FESurfaceLoad::Activate(); } //----------------------------------------------------------------------------- //! Evaluate and prescribe the temperature void FETemperatureBackFlowStabilization::Update() { // determine backflow conditions MarkBackFlow(); // prescribe solute backflow constraint at the nodes FESurface* ps = &GetSurface(); for (int i=0; i<ps->Nodes(); ++i) { FENode& node = ps->Node(i); // set node as having prescribed DOF (concentration at previous time) if (node.m_ID[m_dofT] < -1) node.set(m_dofT, node.get_prev(m_dofT)); else { node.set_bc(m_dofT, DOF_PRESCRIBED); node.m_ID[m_dofT] = -node.m_ID[m_dofT] - 2; int nid = node.GetID()-1; //0 based int val = m_nnlist.Valence(nid); int* nlist = m_nnlist.NodeList(nid); vector<int> connectnidarray; int connectnid=0; //check which connecting nodes are not on surface for (int j = 0; j<val; ++j) { int cnid = *(nlist+j); bool isSurf = false; for (int k=0; k<ps->Nodes(); ++k) { if (cnid==ps->Node(k).GetID()-1) isSurf = true; } if (!isSurf) { connectnidarray.push_back(cnid); } } //find closest connecting node if (connectnidarray.size()>0) { int cnodeIndex = 0; FENode* cnodeArray = GetFEModel()->GetMesh().FindNodeFromID(connectnidarray[cnodeIndex]+1); double smallDist = sqrt(pow((node.m_rt.x-cnodeArray->m_rt.x),2)+pow((node.m_rt.y-cnodeArray->m_rt.y),2)+pow((node.m_rt.z-cnodeArray->m_rt.z),2)); for (int j = 1; j<connectnidarray.size(); ++j) { FENode* tempNode = GetFEModel()->GetMesh().FindNodeFromID(connectnidarray[j]+1); double temp = sqrt(pow((node.m_rt.x-tempNode->m_rt.x),2)+pow((node.m_rt.y-tempNode->m_rt.y),2)+pow((node.m_rt.z-tempNode->m_rt.z),2)); if(temp<smallDist) { cnodeIndex = j; cnodeArray = tempNode; smallDist = temp; } } connectnid = connectnidarray[cnodeIndex]; FENode* cnode = GetFEModel()->GetMesh().FindNodeFromID(connectnid+1); node.set(m_dofT, cnode->get(m_dofT)); } else node.set(m_dofT, node.get_prev(m_dofT)); } } } //----------------------------------------------------------------------------- //! evaluate the flow rate across this surface void FETemperatureBackFlowStabilization::MarkBackFlow() { // Mark all nodes on this surface to have open concentration DOF FESurface* ps = &GetSurface(); for (int i=0; i<ps->Nodes(); ++i) { FENode& node = ps->Node(i); // mark node as having free DOF if (node.m_ID[m_dofT] < -1) { node.set_bc(m_dofT, DOF_OPEN); node.m_ID[m_dofT] = -node.m_ID[m_dofT] - 2; } } // Calculate normal flow velocity on each face to determine // backflow condition vec3d rt[FEElement::MAX_NODES]; vec3d vt[FEElement::MAX_NODES]; const FETimeInfo& tp = GetTimeInfo(); for (int iel=0; iel<m_psurf->Elements(); ++iel) { FESurfaceElement& el = m_psurf->Element(iel); // nr integration points int nint = el.GaussPoints(); // nr of element nodes int neln = el.Nodes(); // nodal coordinates for (int i=0; i<neln; ++i) { FENode& node = m_psurf->GetMesh()->Node(el.m_node[i]); rt[i] = node.m_rt*tp.alpha + node.m_rp*(1-tp.alpha); vt[i] = node.get_vec3d(m_dofW[0], m_dofW[1], m_dofW[2])*tp.alpha + node.get_vec3d_prev(m_dofW[0], m_dofW[1], m_dofW[2])*(1-tp.alpha); } double* Nr, *Ns; double* N; double* w = el.GaussWeights(); vec3d dxr, dxs, v; double vn = 0; // repeat over integration points for (int n=0; n<nint; ++n) { N = el.H(n); Nr = el.Gr(n); Ns = el.Gs(n); // calculate the velocity and tangent vectors at integration point dxr = dxs = v = vec3d(0,0,0); for (int i=0; i<neln; ++i) { v += vt[i]*N[i]; dxr += rt[i]*Nr[i]; dxs += rt[i]*Ns[i]; } vec3d normal = dxr ^ dxs; normal.unit(); vn += (normal*v)*w[n]; } if (vn < 0) { for (int i=0; i<neln; ++i) { FENode& node = m_psurf->GetMesh()->Node(el.m_node[i]); if (node.m_ID[m_dofT] > -1) { node.set_bc(m_dofT, DOF_PRESCRIBED); node.m_ID[m_dofT] = -node.m_ID[m_dofT] - 2; } } } } } //----------------------------------------------------------------------------- //! calculate residual void FETemperatureBackFlowStabilization::LoadVector(FEGlobalVector& R) { } //----------------------------------------------------------------------------- //! serialization void FETemperatureBackFlowStabilization::Serialize(DumpStream& ar) { FESurfaceLoad::Serialize(ar); if (ar.IsShallow()) return; ar & m_dofW; ar & m_dofT; m_nnlist.Create(GetFEModel()->GetMesh()); }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEFixedFluidDilatation.cpp
.cpp
1,589
42
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2020 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEFixedFluidDilatation.h" BEGIN_FECORE_CLASS(FEFixedFluidDilatation, FEFixedBC) END_FECORE_CLASS(); FEFixedFluidDilatation::FEFixedFluidDilatation(FEModel* fem) : FEFixedBC(fem) { } bool FEFixedFluidDilatation::Init() { SetDOFList(GetDOFIndex("ef")); return FEFixedBC::Init(); }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEFixedFluidTemperature.h
.h
1,472
37
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2020 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FEFixedBC.h> class FEFixedFluidTemperature : public FEFixedBC { public: FEFixedFluidTemperature(FEModel* fem); bool Init() override; DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEMultiphasicFSIPressureBC.h
.h
2,357
69
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2020 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FEPrescribedBC.h> #include "FEMultiphasicFSI.h" //----------------------------------------------------------------------------- //! FEFluidResistanceBC is a fluid surface that has a normal //! pressure proportional to the flow rate (resistance). //! class FEBIOFLUID_API FEMultiphasicFSIPressureBC : public FEPrescribedSurface { public: //! constructor FEMultiphasicFSIPressureBC(FEModel* pfem); //! set the dilatation void Update() override; //! initialize bool Init() override; //! serialization void Serialize(DumpStream& ar) override; public: // return the value for node i, dof j void GetNodalValues(int nodelid, std::vector<double>& val) override; // copy data from another class void CopyFrom(FEBoundaryCondition* pbc) override; private: FEParamDouble m_p; //!< prescribed fluid pressure private: std::vector<double> m_e; double m_Rgas; double m_Tabs; int m_dofEF; int m_dofC; DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FENonlinearElasticFluid.cpp
.cpp
5,465
157
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2020 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "FENonlinearElasticFluid.h" #include "FEFluidMaterialPoint.h" //----------------------------------------------------------------------------- FENonlinearElasticFluid::FENonlinearElasticFluid(FEModel* pfem) : FEElasticFluid(pfem) { m_k = 0; m_rhor = 0; } //----------------------------------------------------------------------------- //! initialization bool FENonlinearElasticFluid::Init() { return true; } //----------------------------------------------------------------------------- // serialization void FENonlinearElasticFluid::Serialize(DumpStream& ar) { ar& m_k& m_rhor; } //----------------------------------------------------------------------------- //! gauge pressure double FENonlinearElasticFluid::Pressure(FEMaterialPoint& mp) { FEFluidMaterialPoint& fp = *mp.ExtractData<FEFluidMaterialPoint>(); double p =m_k*(1/(1+fp.m_ef)-1); return p; } //----------------------------------------------------------------------------- //! tangent of pressure with respect to strain J double FENonlinearElasticFluid::Tangent_Strain(FEMaterialPoint& mp) { FEFluidMaterialPoint& fp = *mp.ExtractData<FEFluidMaterialPoint>(); return -m_k/pow(1+fp.m_ef,2); } //----------------------------------------------------------------------------- //! 2nd tangent of pressure with respect to strain J double FENonlinearElasticFluid::Tangent_Strain_Strain(FEMaterialPoint& mp) { FEFluidMaterialPoint& fp = *mp.ExtractData<FEFluidMaterialPoint>(); return 2*m_k/pow(1+fp.m_ef,3); } //----------------------------------------------------------------------------- //! tangent of pressure with respect to temperature T double FENonlinearElasticFluid::Tangent_Temperature(FEMaterialPoint& mp) { return 0; } //----------------------------------------------------------------------------- //! 2nd tangent of pressure with respect to temperature T double FENonlinearElasticFluid::Tangent_Temperature_Temperature(FEMaterialPoint& mp) { return 0; } //----------------------------------------------------------------------------- //! tangent of pressure with respect to strain J and temperature T double FENonlinearElasticFluid::Tangent_Strain_Temperature(FEMaterialPoint& mp) { return 0; } //----------------------------------------------------------------------------- //! specific free energy double FENonlinearElasticFluid::SpecificFreeEnergy(FEMaterialPoint& mp) { FEFluidMaterialPoint& fp = *mp.ExtractData<FEFluidMaterialPoint>(); double a = m_k/m_rhor*(fp.m_ef-log(1+fp.m_ef)); return a; } //----------------------------------------------------------------------------- //! specific entropy double FENonlinearElasticFluid::SpecificEntropy(FEMaterialPoint& mp) { return 0; } //----------------------------------------------------------------------------- //! specific strain energy double FENonlinearElasticFluid::SpecificStrainEnergy(FEMaterialPoint& mp) { return SpecificFreeEnergy(mp); } //----------------------------------------------------------------------------- //! isobaric specific heat capacity double FENonlinearElasticFluid::IsobaricSpecificHeatCapacity(FEMaterialPoint& mp) { return 0; } //----------------------------------------------------------------------------- //! isochoric specific heat capacity double FENonlinearElasticFluid::IsochoricSpecificHeatCapacity(FEMaterialPoint& mp) { return 0; } //----------------------------------------------------------------------------- //! tangent of isochoric specific heat capacity with respect to strain J double FENonlinearElasticFluid::Tangent_cv_Strain(FEMaterialPoint& mp) { return 0; } //----------------------------------------------------------------------------- //! tangent of isochoric specific heat capacity with respect to temperature T double FENonlinearElasticFluid::Tangent_cv_Temperature(FEMaterialPoint& mp) { return 0; } //----------------------------------------------------------------------------- //! dilatation from temperature and pressure bool FENonlinearElasticFluid::Dilatation(const double T, const double p, double& e) { e = 1.0/(1+p/m_k)-1.0; return true; }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEFluidSupplyStarling.cpp
.cpp
3,581
104
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include <sstream> #include <iostream> #include <cstdlib> #include "FEFluidSupplyStarling.h" #include "FEFluidFSI.h" //#include "FESolutesMaterialPoint.h" #include <FECore/FEModel.h> // define the material parameters BEGIN_FECORE_CLASS(FEFluidSupplyStarling, FEFluidSupply) ADD_PARAMETER(m_kp, "kp")->setLongName("filtration coefficient"); ADD_PARAMETER(m_pv, "pv")->setLongName("external pressure")->setUnits(UNIT_PRESSURE); END_FECORE_CLASS(); //----------------------------------------------------------------------------- //! Constructor. FEFluidSupplyStarling::FEFluidSupplyStarling(FEModel* pfem) : FEFluidSupply(pfem) { m_kp = 0; m_pv = 0; } //----------------------------------------------------------------------------- //! Solvent supply double FEFluidSupplyStarling::Supply(FEMaterialPoint& mp) { FEFluidMaterialPoint& pt = *mp.ExtractData<FEFluidMaterialPoint>(); // evaluate solvent supply from pressure drop double kp = m_kp(mp); double pv = m_pv(mp); double phiwhat = kp*(pv - pt.m_pf); /* // evaluate solvent supply from concentration drop if (mpt) { int nsol = mpt->m_nsol; for (int isol=0; isol<nsol; ++isol) { phiwhat += m_qc[isol]*(m_cv[isol] - mpt->m_c[isol]); } } */ return phiwhat; } //----------------------------------------------------------------------------- //! Tangent of solvent supply with respect to strain mat3d FEFluidSupplyStarling::Tangent_Supply_Strain(FEMaterialPoint &mp) { return mat3d(mat3dd(0)); } //----------------------------------------------------------------------------- //! Tangent of solvent supply with respect to pressure double FEFluidSupplyStarling::Tangent_Supply_Dilatation(FEMaterialPoint &mp) { double dpdJ = 0; FEFluidFSI* m_pMat = dynamic_cast<FEFluidFSI*>(GetParent()); if (m_pMat) dpdJ = m_pMat->Fluid()->GetElastic()->Tangent_Strain(mp); double kp = m_kp(mp); return -kp*dpdJ; } /* //----------------------------------------------------------------------------- //! Tangent of solvent supply with respect to concentration double FEFluidSupplyStarling::Tangent_Supply_Concentration(FEMaterialPoint &mp, const int isol) { FESolutesMaterialPoint& mpt = *mp.ExtractData<FESolutesMaterialPoint>(); if (isol < mpt.m_nsol) { return -m_qc[isol]; } return 0; } */
C++
3D
febiosoftware/FEBio
FEBioFluid/FEThermoFluidPressureBC.cpp
.cpp
7,950
209
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEThermoFluidPressureBC.h" #include "FEBioThermoFluid.h" #include <FECore/FEAnalysis.h> #include <FECore/FEModel.h> #include <FECore/FESurface.h> #include "FEThermoFluid.h" #include "FEFluid.h" //============================================================================= BEGIN_FECORE_CLASS(FEThermoFluidPressureBC, FEPrescribedSurface) ADD_PARAMETER(m_p, "pressure")->setUnits("P")->setLongName("fluid pressure"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- //! constructor FEThermoFluidPressureBC::FEThermoFluidPressureBC(FEModel* pfem) : FEPrescribedSurface(pfem) { m_p = 0; m_dofEF = -1; m_dofT = -1; m_Rgas = 0; m_Tabs = 0; m_psurf = nullptr; } //----------------------------------------------------------------------------- //! initialize bool FEThermoFluidPressureBC::Init() { m_dofEF = GetDOFIndex(FEBioThermoFluid::GetVariableName(FEBioThermoFluid::FLUID_DILATATION), 0); m_dofT = GetDOFIndex(FEBioThermoFluid::GetVariableName(FEBioThermoFluid::TEMPERATURE), 0); SetDOFList(m_dofEF); if (FEPrescribedSurface::Init() == false) return false; m_Rgas = GetFEModel()->GetGlobalConstant("R"); m_Tabs = GetFEModel()->GetGlobalConstant("T"); m_psurf = FESurfaceBC::GetSurface(); m_e.assign(GetSurface()->Nodes(), 0.0); return true; } //----------------------------------------------------------------------------- //! Evaluate and prescribe the resistance pressure void FEThermoFluidPressureBC::Update() { // prescribe this dilatation at the nodes FESurface* ps = GetSurface(); FEModel* fem = GetFEModel(); FEMesh& mesh = fem->GetMesh(); FETimeInfo& tp = fem->GetTime(); int N = ps->Nodes(); std::vector<vector<double>> efNodes(N, vector<double>()); //Project sum of all ca and osc values from int points to nodes on surface //All values put into map, including duplicates for (int i=0; i<ps->Elements(); ++i) { FESurfaceElement& el = ps->Element(i); // evaluate average prescribed pressure on this face double p = 0; for (int j=0; j<el.GaussPoints(); ++j) { FEMaterialPoint* pt = el.GetMaterialPoint(j); p += m_p(*pt); } p /= el.GaussPoints(); // get surface underlying material FEElement* e = el.m_elem[0].pe; FESolidElement* se = dynamic_cast<FESolidElement*>(e); if (se) { FEMaterial* pm = GetFEModel()->GetMaterial(e->GetMatID()); FEThermoFluid* ptfl = pm->ExtractProperty<FEThermoFluid>(); FEFluid* pfl = pm->ExtractProperty<FEFluid>(); if (ptfl) { // evaluate average temperature on this face double T = 0; for (int j=0; j<el.Nodes(); ++j) { FENode& node = mesh.Node(el.m_node[j]); T += node.get(m_dofT)*tp.alphaf + node.get_prev(m_dofT)*(1-tp.alphaf); } T /= el.Nodes(); double efi[FEElement::MAX_INTPOINTS] = {0}; double efo[FEElement::MAX_NODES] = {0}; /* bool good = true; for (int j=0; j<se->GaussPoints(); ++j) { FEMaterialPoint* pt = se->GetMaterialPoint(j); good = good && ptfl->Dilatation(T, p, 0, efi[j]); if (!good) break; } // only keep the dilatations at the nodes of the surface face if (good) { // project dilatations from integration points to nodes se->project_to_nodes(efi, efo); for (int j=0; j<el.Nodes(); ++j) efNodes[el.m_lnode[j]].push_back(efo[j]); } else {*/ for (int j=0; j<el.Nodes(); ++j) { FENode& node = mesh.Node(el.m_node[j]); efo[j] = node.get_prev(m_dofEF); ptfl->Dilatation(T, p, efo[j]); efNodes[el.m_lnode[j]].push_back(efo[j]); } // } } else if (pfl) { double efi[FEElement::MAX_INTPOINTS] = {0}; double efo[FEElement::MAX_NODES] = {0}; bool good = true; for (int j=0; j<se->GaussPoints(); ++j) { FEMaterialPoint* pt = se->GetMaterialPoint(j); good = good && pfl->Dilatation(0, p, efi[j]); if (!good) break; } // only keep the dilatations at the nodes of the surface face if (good) { // project dilatations from integration points to nodes se->project_to_nodes(efi, efo); for (int j=0; j<el.Nodes(); ++j) efNodes[el.m_lnode[j]].push_back(efo[j]); } else { for (int j=0; j<el.Nodes(); ++j) { FENode& node = mesh.Node(el.m_node[j]); efo[j] = node.get_prev(m_dofEF); pfl->Dilatation(0, p, efo[j]); efNodes[el.m_lnode[j]].push_back(efo[j]); } } } else break; } //If no solid element, insert all 0s else { for (int j=0; j<el.Nodes(); ++j) efNodes[el.m_lnode[j]].push_back(0); } } //For each node, average the nodal ef for (int i=0; i<ps->Nodes(); ++i) { double ef = 0; for (int j = 0; j < efNodes[i].size(); ++j) ef += efNodes[i][j]; ef /= efNodes[i].size(); // store value for now m_e[i] = ef; } FEPrescribedSurface::Update(); } //----------------------------------------------------------------------------- void FEThermoFluidPressureBC::GetNodalValues(int nodelid, std::vector<double>& val) { val[0] = m_e[nodelid]; } //----------------------------------------------------------------------------- // copy data from another class void FEThermoFluidPressureBC::CopyFrom(FEBoundaryCondition* pbc) { // TODO: implement this assert(false); } //----------------------------------------------------------------------------- //! serialization void FEThermoFluidPressureBC::Serialize(DumpStream& ar) { FEPrescribedSurface::Serialize(ar); ar & m_e; if (ar.IsShallow()) return; ar & m_dofT & m_dofEF; ar & m_Rgas & m_Tabs; ar & m_psurf; }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEInitialFluidDilatation.h
.h
1,483
37
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2020 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FEInitialCondition.h> class FEInitialFluidDilatation : public FEInitialDOF { public: FEInitialFluidDilatation(FEModel* fem); bool Init() override; DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEPrescribedFluidAngularVelocity.cpp
.cpp
2,013
41
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2020 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEPrescribedFluidAngularVelocity.h" //======================================================================================= // NOTE: I'm setting FEBoundaryCondition is the base class since I don't want to pull // in the parameters of FEPrescribedDOF. BEGIN_FECORE_CLASS(FEPrescribedFluidAngularVelocity, FEBoundaryCondition) ADD_PARAMETER(m_dof, "dof", 0, "$(dof_list:fluid angular velocity)"); ADD_PARAMETER(m_scale, "value")->setUnits(UNIT_ANGULAR_VELOCITY)->SetFlags(FE_PARAM_ADDLC | FE_PARAM_VOLATILE); ADD_PARAMETER(m_brelative, "relative"); END_FECORE_CLASS(); FEPrescribedFluidAngularVelocity::FEPrescribedFluidAngularVelocity(FEModel* fem) : FEPrescribedDOF(fem) { }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEInitialFluidPressureTemperature.cpp
.cpp
7,622
216
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2020 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "FEInitialFluidPressureTemperature.h" #include "FEBioThermoFluid.h" #include "FEThermoFluid.h" #include "FEFluid.h" #include <FECore/FEModel.h> #include <FECore/FEAnalysis.h> //============================================================================= BEGIN_FECORE_CLASS(FEInitialFluidPressureTemperature, FEInitialCondition) // material properties ADD_PARAMETER(m_Pdata, "pressure" )->setUnits(UNIT_PRESSURE); ADD_PARAMETER(m_Tdata, "temperature")->setUnits(UNIT_RELATIVE_TEMPERATURE); END_FECORE_CLASS(); //----------------------------------------------------------------------------- FEInitialFluidPressureTemperature::FEInitialFluidPressureTemperature(FEModel* fem) : FENodalIC(fem) { } //----------------------------------------------------------------------------- bool FEInitialFluidPressureTemperature::Init() { if (SetPDOF("ef") == false) return false; if (SetTDOF("T") == false) return false; m_e.assign(m_nodeSet->Size(), 0.0); m_T.assign(m_nodeSet->Size(), 0.0); FEDofList dofs(GetFEModel()); if (dofs.AddVariable(FEBioThermoFluid::GetVariableName(FEBioThermoFluid::FLUID_DILATATION)) == false) return false; if (dofs.AddVariable(FEBioThermoFluid::GetVariableName(FEBioThermoFluid::TEMPERATURE)) == false) return false; SetDOFList(dofs); return FENodalIC::Init(); } //----------------------------------------------------------------------------- void FEInitialFluidPressureTemperature::SetTDOF(int ndof) { m_dofT = ndof; } //----------------------------------------------------------------------------- bool FEInitialFluidPressureTemperature::SetTDOF(const char* szdof) { FEModel* fem = GetFEModel(); int ndof = fem->GetDOFIndex(szdof); assert(ndof >= 0); if (ndof < 0) return false; SetTDOF(ndof); return true; } //----------------------------------------------------------------------------- void FEInitialFluidPressureTemperature::SetPDOF(int ndof) { m_dofEF = ndof; } //----------------------------------------------------------------------------- bool FEInitialFluidPressureTemperature::SetPDOF(const char* szdof) { FEModel* fem = GetFEModel(); int ndof = fem->GetDOFIndex(szdof); assert(ndof >= 0); if (ndof < 0) return false; SetPDOF(ndof); return true; } //----------------------------------------------------------------------------- void FEInitialFluidPressureTemperature::Activate() { // prescribe this dilatation at the nodes FEModel* fem = GetFEModel(); FENodeList nodeList = m_nodeSet->GetNodeList(); int N = nodeList.Size(); std::vector<vector<double>> efNodes(N, vector<double>()); FEMesh& mesh = *m_nodeSet->GetMesh(); // evaluate average prescribed pressure and temperature in each element // project them from int points to nodes for (int i=0; i<mesh.Elements(); ++i) { FEElement& el = *mesh.Element(i); // get material FEMaterial* pm = GetFEModel()->GetMaterial(el.GetMatID()); FEThermoFluid* ptfl = pm->ExtractProperty<FEThermoFluid>(); FEFluid* pfl = pm->ExtractProperty<FEFluid>(); if (ptfl) { double efi[FEElement::MAX_INTPOINTS] = {0}; double efo[FEElement::MAX_NODES] = {0}; bool good = true; for (int j=0; j<el.GaussPoints(); ++j) { FEMaterialPoint* pt = el.GetMaterialPoint(j); good = good && ptfl->Dilatation(m_Tdata(*pt), m_Pdata(*pt), efi[j]); } // project dilatations from integration points to nodes el.project_to_nodes(efi, efo); if (good) { for (int j=0; j<el.Nodes(); ++j) efNodes[el.m_node[j]].push_back(efo[j]); } else { for (int j=0; j<el.Nodes(); ++j) { efo[j] = 0; efNodes[el.m_node[j]].push_back(efo[j]); } } } else if (pfl) { double efi[FEElement::MAX_INTPOINTS] = {0}; double efo[FEElement::MAX_NODES] = {0}; bool good = true; for (int j=0; j<el.GaussPoints(); ++j) { FEMaterialPoint* pt = el.GetMaterialPoint(j); good = good && pfl->Dilatation(0, m_Pdata(*pt), efi[j]); } // project dilatations from integration points to nodes el.project_to_nodes(efi, efo); if (good) { for (int j=0; j<el.Nodes(); ++j) efNodes[el.m_node[j]].push_back(efo[j]); } else { for (int j=0; j<el.Nodes(); ++j) { efo[j] = 0; efNodes[el.m_node[j]].push_back(efo[j]); } } } else break; } //For each node, average the nodal ef for (int i=0; i<nodeList.Size(); ++i) { double ef = 0; for (int j = 0; j < efNodes[i].size(); ++j) ef += efNodes[i][j]; ef /= efNodes[i].size(); // store value for now m_e[i] = ef; // get the nodal temperature FENode& node = *nodeList.Node(i); FEMaterialPoint mp; mp.m_r0 = node.m_r0; mp.m_index = i; m_T[i] = m_Tdata(mp); } FEStepComponent::Activate(); if (m_dofs.IsEmpty()) return; int dofs = (int)m_dofs.Size(); std::vector<double> val(dofs, 0.0); for (int i = 0; i<N; ++i) { FENode& node = *m_nodeSet->Node(i); // get the nodal values GetNodalValues(i, val); for (int j = 0; j < dofs; ++j) { node.set(m_dofs[j], val[j]); } } } //----------------------------------------------------------------------------- void FEInitialFluidPressureTemperature::GetNodalValues(int inode, std::vector<double>& values) { values[0] = m_e[inode]; values[1] = m_T[inode]; } //----------------------------------------------------------------------------- void FEInitialFluidPressureTemperature::Serialize(DumpStream& ar) { FENodalIC::Serialize(ar); if (ar.IsLoading()) { m_e.assign(m_nodeSet->Size(), 0.0); m_T.assign(m_nodeSet->Size(), 0.0); } ar & m_e & m_T; if (ar.IsShallow()) return; ar & m_dofEF & m_dofT; }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEInitialFluidVelocity.h
.h
1,799
50
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2020 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FEInitialCondition.h> #include "febiofluid_api.h" #include <FECore/FEModelParam.h> class FEBIOFLUID_API FEInitialFluidVelocity : public FENodalIC { public: FEInitialFluidVelocity(FEModel* fem); bool Init() override; // set the initial value void SetValue(const vec3d& v0); // return the values for node i void GetNodalValues(int inode, std::vector<double>& values) override; private: FEParamVec3 m_v0; DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEThermoFluidDomainFactory.cpp
.cpp
2,087
56
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEThermoFluidDomainFactory.h" #include "FEThermoFluid.h" #include <FECore/FESolidDomain.h> //----------------------------------------------------------------------------- FEDomain* FEThermoFluidDomainFactory::CreateDomain(const FE_Element_Spec& spec, FEMesh* pm, FEMaterial* pmat) { FEModel* pfem = pmat->GetFEModel(); FE_Element_Class eclass = spec.eclass; FE_Element_Shape eshape = spec.eshape; const char* sztype = 0; if (dynamic_cast<FEThermoFluid*>(pmat)) { // fluid elements if (eclass == FE_ELEM_SOLID) sztype = "thermo-fluid-3D"; else return 0; } if (sztype) { FEDomain* pd = fecore_new<FESolidDomain>(sztype, pfem); if (pd) pd->SetMaterial(pmat); return pd; } else return 0; }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEViscousPolarFluid.h
.h
3,199
76
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2022 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FEMaterial.h> #include <FECore/tens4d.h> #include "febiofluid_api.h" //----------------------------------------------------------------------------- //! Base class for the viscous part of the fluid response. //! These materials provide the viscous stress and its tangents. //! class FEBIOFLUID_API FEViscousPolarFluid : public FEMaterialProperty { public: FEViscousPolarFluid(FEModel* pfem) : FEMaterialProperty(pfem) {} virtual ~FEViscousPolarFluid() {} //! dual vector non-symmetric part of viscous stress in polar fluid virtual vec3d SkewStressDualVector(FEMaterialPoint& pt) = 0; //! non-symmetric part of viscous stress in polar fluid virtual mat3da SkewStress(FEMaterialPoint& pt) { return mat3da(SkewStressDualVector(pt)); } //! tangent of stress with respect to strain J virtual mat3da SkewTangent_Strain(FEMaterialPoint& mp) = 0; //! tangent of stress with respect to relative rate of rotation tensor H virtual mat3d SkewTangent_RateOfRotation(FEMaterialPoint& mp) = 0; //! tangent of stress with respect to temperature virtual mat3da SkewTangent_Temperature(FEMaterialPoint& mp) = 0; //! viscous couple stress in polar fluid virtual mat3d CoupleStress(FEMaterialPoint& pt) = 0; //! tangent of viscous couple stress with respect to strain J virtual mat3d CoupleTangent_Strain(FEMaterialPoint& mp) = 0; //! tangent of viscous couple stress with respect to rate of rotation tensor g virtual tens4d CoupleTangent_RateOfRotation(FEMaterialPoint& mp) = 0; //! tangent of viscous couple stress with respect to temperature virtual mat3d CoupleTangent_Temperature(FEMaterialPoint& mp) = 0; //! dynamic viscosity virtual double RelativeRotationalViscosity(FEMaterialPoint& mp) = 0; FECORE_BASE_CLASS(FEViscousPolarFluid) };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEFluidSolutesSolver.h
.h
6,089
173
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FENewtonSolver.h> #include <FECore/FETimeInfo.h> #include <FECore/FEGlobalVector.h> #include <FECore/FEDofList.h> #include "febiofluid_api.h" //----------------------------------------------------------------------------- class FELinearSystem; //----------------------------------------------------------------------------- //! The FEFluidSolutesSolver class solves fluid mechanics problems //! with mass transport (solutes) //! It can deal with quasi-static and dynamic problems //! class FEBIOFLUID_API FEFluidSolutesSolver : public FENewtonSolver { enum SOLVE_STRATEGY { SOLVE_COUPLED, // monolithic solution approach SOLVE_SEQUENTIAL // first solve velocity, then solutes }; public: //! constructor FEFluidSolutesSolver(FEModel* pfem); //! destructor ~FEFluidSolutesSolver(); //! Initializes data structures bool Init() override; //! initialize the step bool InitStep(double time) override; //! Initialize linear equation system bool InitEquations() override; //! preferred matrix type should be unsymmetric. Matrix_Type PreferredMatrixType() const override { return REAL_UNSYMMETRIC; }; public: //{ --- evaluation and update --- //! Perform an update void Update(vector<double>& ui) override; //! update nodal positions, velocities, accelerations, etc. void UpdateKinematics(vector<double>& ui); //! used by JFNK void Update2(const vector<double>& ui) override; //} //{ --- Solution functions --- //! prepares the data for the first QN iteration void PrepStep() override; //! Performs a Newton-Raphson iteration bool Quasin() override; //{ --- Stiffness matrix routines --- //! calculates the global stiffness matrix bool StiffnessMatrix(FELinearSystem& LS) override; //! contact stiffness void ContactStiffness(FELinearSystem& LS); //! calculates stiffness contributon of nonlinear constraints void NonLinearConstraintStiffness(FELinearSystem& LS, const FETimeInfo& tp); //{ --- Residual routines --- //! Calculate the contact forces void ContactForces(FEGlobalVector& R); //! Calculates residual bool Residual(vector<double>& R) override; //! Calculate nonlinear constraint forces void NonLinearConstraintForces(FEGlobalVector& R, const FETimeInfo& tp); //! Serialization void Serialize(DumpStream& ar) override; protected: void GetVelocityData(vector<double>& vi, vector<double>& ui); void GetDilatationData(vector<double>& ei, vector<double>& ui); void GetConcentrationData(vector<double>& ci, vector<double>& ui, const int sol); public: // convergence tolerances double m_Vtol; //!< velocity tolerance double m_Ftol; //!< dilatation tolerance double m_Ctol; //!< concentration tolerance double m_minJf; //!< minimum allowable compression ratio bool m_forcePositive; //!< force conentrations to remain positive double m_cmin; //!< threshold for detecting sudden drop in concentration double m_cmax; //!< threshold for detecting sudden increase in concentration int m_cnum; //!< minimum number of points at which C drops suddenly public: // equation numbers int m_nveq; //!< number of equations related to velocity dofs int m_ndeq; //!< number of equations related to dilatation dofs int m_nseq; //!< total number of concentration dofs vector<int> m_nceq; //!< number of equations related to concentration dofs public: vector<double> m_Fr; //!< nodal reaction forces vector<double> m_vi; //!< velocity increment vector vector<double> m_Vi; //!< Total velocity vector for iteration vector<double> m_di; //!< dilatation increment vector vector<double> m_Di; //!< Total dilatation vector for iteration // solute data vector< vector<double> > m_ci; //!< concentration increment vector vector< vector<double> > m_Ci; //!< Total concentration vector for iteration // generalized alpha method double m_rhoi; //!< rho infinity double m_alphaf; //!< alpha step for Y={v,e} double m_alpham; //!< alpha step for Ydot={∂v/∂t,∂e/∂t} double m_gammaf; //!< gamma int m_pred; //!< predictor method protected: FEDofList m_dofW; FEDofList m_dofAW; FEDofList m_dofEF; int m_dofAEF; FEDofList m_dofC; int m_dofAC; int m_solve_strategy; private: bool m_sudden_C_change; // declare the parameter list DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEFluidAnalysis.h
.h
1,540
43
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FEAnalysis.h> #include "febiofluid_api.h" class FEBIOFLUID_API FEFluidAnalysis : public FEAnalysis { public: enum FluidAnalysisType { STEADY_STATE, DYNAMIC }; public: FEFluidAnalysis(FEModel* fem); DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEMultiphasicFSISolver.h
.h
7,048
182
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2020 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FENewtonSolver.h> #include <FECore/FETimeInfo.h> #include <FECore/FEGlobalVector.h> #include <FEBioMech/FERigidSolver.h> #include <FECore/FEDofList.h> #include "febiofluid_api.h" //----------------------------------------------------------------------------- //! The FEFluidFSISolver class solves fluid-FSI problems //! It can deal with quasi-static and dynamic problems //! class FEBIOFLUID_API FEMultiphasicFSISolver : public FENewtonSolver { public: //! constructor FEMultiphasicFSISolver(FEModel* pfem); //! destructor ~FEMultiphasicFSISolver(); //! serialize data to/from dump file void Serialize(DumpStream& ar) override; //! Initializes data structures bool Init() override; //! initialize the step bool InitStep(double time) override; //! Initialize linear equation system bool InitEquations() override; //! Generate warnings if needed void SolverWarnings(); //! preferred matrix type should be unsymmetric. Matrix_Type PreferredMatrixType() const override { return REAL_UNSYMMETRIC; }; public: //{ --- evaluation and update --- //! Perform an update void Update(vector<double>& ui) override; //! update nodal positions, velocities, accelerations, etc. void UpdateKinematics(vector<double>& ui); //! Update EAS void UpdateEAS(vector<double>& ui); void UpdateIncrementsEAS(vector<double>& ui, const bool binc); //! update DOF increments virtual void UpdateIncrements(vector<double>& Ui, vector<double>& ui, bool emap); //} //{ --- Solution functions --- //! prepares the data for the first QN iteration void PrepStep() override; //! Performs a Newton-Raphson iteration bool Quasin() override; //{ --- Stiffness matrix routines --- //! calculates the global stiffness matrix bool StiffnessMatrix() override; //! contact stiffness void ContactStiffness(FELinearSystem& LS); //! calculates stiffness contributon of nonlinear constraints void NonLinearConstraintStiffness(FELinearSystem& LS, const FETimeInfo& tp); //{ --- Residual routines --- //! Calculate the contact forces void ContactForces(FEGlobalVector& R); //! Calculates residual bool Residual(vector<double>& R) override; //! Calculate nonlinear constraint forces void NonLinearConstraintForces(FEGlobalVector& R, const FETimeInfo& tp); protected: void GetDisplacementData(vector<double>& xi, vector<double>& ui); void GetVelocityData(vector<double>& vi, vector<double>& ui); void GetDilatationData(vector<double>& ei, vector<double>& ui); void GetConcentrationData(vector<double>& ci, vector<double>& ui, const int sol); public: // convergence tolerances double m_Dtol; //!< displacement tolerance double m_Vtol; //!< velocity tolerance double m_Ftol; //!< dilatation tolerance double m_Ctol; //!< concentration tolerance double m_minJf; //!< minimum allowable compression ratio bool m_forcePositive; //!< force conentrations to remain positive public: // equation numbers int m_nreq; //!< start of rigid body equations int m_ndeq; //!< number of equations related to displacement dofs int m_nveq; //!< number of equations related to velocity dofs int m_nfeq; //!< number of equations related to dilatation dofs int m_nseq; //!< total number of concentration dofs vector<int> m_nceq; //!< number of equations related to concentration dofs public: vector<double> m_Fr; //!< nodal reaction forces vector<double> m_di; //!< displacement increment vector vector<double> m_Di; //!< Total displacement vector for iteration vector<double> m_vi; //!< velocity increment vector vector<double> m_Vi; //!< Total velocity vector for iteration vector<double> m_fi; //!< dilatation increment vector vector<double> m_Fi; //!< Total dilatation vector for iteration // solute data vector< vector<double> > m_ci; //!< concentration increment vector vector< vector<double> > m_Ci; //!< Total concentration vector for iteration // generalized alpha method double m_rhoi; //!< spectral radius (rho infinity) double m_alphaf; //!< alpha step for Y={v,e} double m_alpham; //!< alpha step for Ydot={∂v/∂t,∂e/∂t} double m_beta; //!< beta double m_gamma; //!< gamma int m_pred; //!< predictor method int m_order; //!< generalized-alpha integration order protected: FEDofList m_dofU; // solid displacement FEDofList m_dofV; // solid velocity FEDofList m_dofSU; // shell displacement FEDofList m_dofSV; // shell velocity FEDofList m_dofSA; // shell acceleration FEDofList m_dofR; // rigid body rotations FEDofList m_dofVF; // fluid velocity FEDofList m_dofAF; // material time derivative of fluid velocity FEDofList m_dofW; // fluid velocity relative to solid FEDofList m_dofAW; // material time derivative of fluid velocity relative to solid FEDofList m_dofEF; // fluid dilatation int m_dofAEF; // material time derivative of fluid dilatation int m_dofC; int m_dofAC; protected: FERigidSolverNew m_rigidSolver; // declare the parameter list DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEIdealGasIsentropic.h
.h
3,881
102
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include "FEElasticFluid.h" //----------------------------------------------------------------------------- //! Ideal gas under isentropic conditions. class FEBIOFLUID_API FEIdealGasIsentropic : public FEElasticFluid { public: FEIdealGasIsentropic(FEModel* pfem); public: //! initialization bool Init() override; //! Serialization void Serialize(DumpStream& ar) override; //! elastic pressure double Pressure(FEMaterialPoint& mp) override; //! tangent of pressure with respect to strain J double Tangent_Strain(FEMaterialPoint& mp) override; //! 2nd tangent of pressure with respect to strain J double Tangent_Strain_Strain(FEMaterialPoint& mp) override; //! tangent of pressure with respect to temperature T double Tangent_Temperature(FEMaterialPoint& mp) override; //! 2nd tangent of pressure with respect to temperature T double Tangent_Temperature_Temperature(FEMaterialPoint& mp) override; //! tangent of pressure with respect to strain J and temperature T double Tangent_Strain_Temperature(FEMaterialPoint& mp) override; //! specific free energy double SpecificFreeEnergy(FEMaterialPoint& mp) override; //! specific entropy double SpecificEntropy(FEMaterialPoint& mp) override; //! specific strain energy double SpecificStrainEnergy(FEMaterialPoint& mp) override; //! isochoric specific heat capacity double IsochoricSpecificHeatCapacity(FEMaterialPoint& mp) override; //! tangent of isochoric specific heat capacity with respect to strain J double Tangent_cv_Strain(FEMaterialPoint& mp) override; //! tangent of isochoric specific heat capacity with respect to temperature T double Tangent_cv_Temperature(FEMaterialPoint& mp) override; //! isobaric specific heat capacity double IsobaricSpecificHeatCapacity(FEMaterialPoint& mp) override; //! dilatation from temperature and pressure bool Dilatation(const double T, const double p, double& e) override; public: double m_gamma; //!< ratio of specific heats (constant pressure/constant volume) double m_M; //!< molar mass double m_cv0; //!< isochoric specific heat capacity double m_Pr; //!< ambient pressure double m_Tr; //!< ambient temperature double m_R; //!< universal gas constant double m_k; //!< bulk modulus double m_rhor; //!< true density // declare parameter list DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEInitialFluidPressure.h
.h
1,787
50
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2020 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FEInitialCondition.h> class FEInitialFluidPressure : public FENodalIC { public: FEInitialFluidPressure(FEModel* fem); bool Init() override; void Activate() override; void SetPDOF(int ndof); bool SetPDOF(const char* szdof); void GetNodalValues(int inode, std::vector<double>& values) override; void Serialize(DumpStream& ar) override; protected: int m_dofEF; FEParamDouble m_Pdata; vector<double> m_e; DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEBiphasicFSIDomain3D.h
.h
4,438
131
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FESolidDomain.h> #include "FEBiphasicFSIDomain.h" #include "FEBiphasicFSI.h" //----------------------------------------------------------------------------- //! Biphasic-FSI domain described by 3D volumetric elements //! class FEBIOFLUID_API FEBiphasicFSIDomain3D : public FESolidDomain, public FEBiphasicFSIDomain { public: //! constructor FEBiphasicFSIDomain3D(FEModel* pfem); ~FEBiphasicFSIDomain3D() {} //! assignment operator FEBiphasicFSIDomain3D& operator = (FEBiphasicFSIDomain3D& d); //! activate void Activate() override; //! reset domain data void Reset() override; //! initialize elements void PreSolveUpdate(const FETimeInfo& timeInfo) override; //! Unpack element data void UnpackLM(FEElement& el, vector<int>& lm) override; //! Serialization void Serialize(DumpStream& ar) override; // get the total dof const FEDofList& GetDOFList() const override; public: // overrides from FEDomain //! get the material FEMaterial* GetMaterial() override { return m_pMat; } //! set the material void SetMaterial(FEMaterial* pm) override; public: // overrides from FEElasticDomain // update stresses void Update(const FETimeInfo& tp) override; // update the element stress void UpdateElementStress(int iel, const FETimeInfo& tp); //! internal stress forces void InternalForces(FEGlobalVector& R) override; //! body forces void BodyForce(FEGlobalVector& R, FEBodyForce& BF) override; //! inertial forces for dynamic problems void InertialForces(FEGlobalVector& R) override; //! calculates the global stiffness matrix for this domain void StiffnessMatrix(FELinearSystem& LS) override; //! calculates inertial stiffness void MassMatrix(FELinearSystem& LS) override; //! body force stiffness void BodyForceStiffness(FELinearSystem& LS, FEBodyForce& bf) override; public: // --- S T I F F N E S S --- //! calculates the solid element stiffness matrix void ElementStiffness(FESolidElement& el, matrix& ke); //! calculates the solid element mass matrix void ElementMassMatrix(FESolidElement& el, matrix& ke); //! calculates the stiffness matrix due to body forces void ElementBodyForceStiffness(FEBodyForce& bf, FESolidElement& el, matrix& ke); // --- R E S I D U A L --- //! Calculates the internal stress vector for solid elements void ElementInternalForce(FESolidElement& el, vector<double>& fe); //! Calculates external body forces for solid elements void ElementBodyForce(FEBodyForce& BF, FESolidElement& elem, vector<double>& fe); //! Calculates the inertial force vector for solid elements void ElementInertialForce(FESolidElement& el, vector<double>& fe); protected: FEBiphasicFSI* m_pMat; double m_sseps; protected: FEDofList m_dofU, m_dofV, m_dofW, m_dofAW; FEDofList m_dofSU, m_dofR; FEDofList m_dof; int m_dofEF; int m_dofAEF; };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEFluidMaterial.cpp
.cpp
3,490
98
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "FEFluidMaterial.h" #include "FEFluidMaterialPoint.h" #include <FECore/FECoreKernel.h> #include <FECore/DumpStream.h> // define the material parameters BEGIN_FECORE_CLASS(FEFluidMaterial, FEMaterial) // material parameters ADD_PARAMETER(m_rhor, FE_RANGE_GREATER_OR_EQUAL(0.0), "density")->setUnits(UNIT_DENSITY); // material properties ADD_PROPERTY(m_pViscous, "viscous"); END_FECORE_CLASS(); //============================================================================ // FEFluid //============================================================================ //----------------------------------------------------------------------------- //! FEFluid constructor FEFluidMaterial::FEFluidMaterial(FEModel* pfem) : FEMaterial(pfem) { m_rhor = 0; m_pViscous = nullptr; } //----------------------------------------------------------------------------- //! calculate current fluid density double FEFluidMaterial::Density(FEMaterialPoint& pt) { FEFluidMaterialPoint& vt = *pt.ExtractData<FEFluidMaterialPoint>(); return m_rhor/(vt.m_ef+1); } //----------------------------------------------------------------------------- //! calculate current fluid kinematic viscosity double FEFluidMaterial::KinematicViscosity(FEMaterialPoint& mp) { return m_pViscous->ShearViscosity(mp)/Density(mp); } //----------------------------------------------------------------------------- //! calculate current acoustic speed double FEFluidMaterial::AcousticSpeed(FEMaterialPoint& mp) { double c = sqrt(BulkModulus(mp)/Density(mp)); return c; } //----------------------------------------------------------------------------- //! calculate kinetic energy density (per reference volume) double FEFluidMaterial::KineticEnergyDensity(FEMaterialPoint& mp) { FEFluidMaterialPoint& fp = *mp.ExtractData<FEFluidMaterialPoint>(); double ked = m_rhor*(fp.m_vft*fp.m_vft)/2; return ked; } //----------------------------------------------------------------------------- //! calculate strain + kinetic energy density (per reference volume) double FEFluidMaterial::EnergyDensity(FEMaterialPoint& mp) { return StrainEnergyDensity(mp) + KineticEnergyDensity(mp); }
C++
3D
febiosoftware/FEBio
FEBioFluid/FERealLiquid.h
.h
5,029
118
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2020 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include "FEElasticFluid.h" #include "FEThermoFluid.h" #include <FECore/FEFunction1D.h> //----------------------------------------------------------------------------- //! Base class for the viscous part of the fluid response. //! These materials provide the viscous stress and its tangents. //! class FEBIOFLUID_API FERealLiquid : public FEElasticFluid { public: enum { MAX_NVC = 3 }; public: FERealLiquid(FEModel* pfem); ~FERealLiquid() {} //! initialization bool Init() override; //! Serialization void Serialize(DumpStream& ar) override; //! gauge pressure double Pressure(FEMaterialPoint& pt) override; //! tangent of pressure with respect to strain J double Tangent_Strain(FEMaterialPoint& mp) override; //! 2nd tangent of pressure with respect to strain J double Tangent_Strain_Strain(FEMaterialPoint& mp) override; //! tangent of pressure with respect to temperature T double Tangent_Temperature(FEMaterialPoint& mp) override; //! 2nd tangent of pressure with respect to temperature T double Tangent_Temperature_Temperature(FEMaterialPoint& mp) override; //! tangent of pressure with respect to strain J and temperature T double Tangent_Strain_Temperature(FEMaterialPoint& mp) override; //! specific free energy double SpecificFreeEnergy(FEMaterialPoint& mp) override; //! specific entropy double SpecificEntropy(FEMaterialPoint& mp) override; //! specific strain energy double SpecificStrainEnergy(FEMaterialPoint& mp) override; //! isochoric specific heat capacity double IsochoricSpecificHeatCapacity(FEMaterialPoint& mp) override; //! tangent of isochoric specific heat capacity with respect to strain J double Tangent_cv_Strain(FEMaterialPoint& mp) override; //! tangent of isochoric specific heat capacity with respect to temperature T double Tangent_cv_Temperature(FEMaterialPoint& mp) override; //! isobaric specific heat capacity double IsobaricSpecificHeatCapacity(FEMaterialPoint& mp) override; //! dilatation from temperature and pressure bool Dilatation(const double T, const double p, double& e) override; //! fluid pressure from state variables double Pressure(const double ef, const double T); public: double m_R; //!< universal gas constant double m_Pr; //!< referential absolute pressure double m_Tr; //!< referential absolute temperature double m_rhor; //!< referential mass density FEFunction1D* m_psat; //!< normalized gauge pressure on saturation curve (multiply by m_Pr to get actual value) FEFunction1D* m_asat; //!< normalized specific free energy on saturation curve (multiply by m_Pr/m_rhor to get actual value) FEFunction1D* m_ssat; //!< normalized specific entropy on saturation curve (multiply by m_Pr/m_rhor*m_Tr to get actual value) FEFunction1D* m_esat; //!< dilatation on saturation curve int m_nvc; //!< number of virial coefficients for pressure and cv constitutive relation FEFunction1D* m_B[MAX_NVC]; //!< non-dimensional virial coefficients for pressure constitutive relation FEFunction1D* m_cvsat; //!< normalized isochoric specific heat capacity on saturation curve (multiply by m_Pr/m_rhor*m_Tr to get actual value) FEFunction1D* m_C[MAX_NVC]; //!< non-dimensional virial coefficients for isochoric specific heat capacity FEThermoFluid* m_pMat; //!< parent thermo-fluid material // declare parameter list DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEPolarFluidDomain.cpp
.cpp
1,554
38
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2022 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEPolarFluidDomain.h" #include "FECore/FESolidDomain.h" #include "FECore/FEModel.h" //----------------------------------------------------------------------------- FEPolarFluidDomain::FEPolarFluidDomain(FEModel* pfem) { }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEFluidHeatSupplyConst.cpp
.cpp
1,891
49
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "FEFluidHeatSupplyConst.h" // define the material parameters BEGIN_FECORE_CLASS(FEFluidHeatSupplyConst, FEFluidHeatSupply) ADD_PARAMETER(m_r, FE_RANGE_DONT_CARE(), "r"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- //! Constructor. FEFluidHeatSupplyConst::FEFluidHeatSupplyConst(FEModel* pfem) : FEFluidHeatSupply(pfem) { m_r = 0; } //----------------------------------------------------------------------------- //! calculate the body force at a material point double FEFluidHeatSupplyConst::heat(FEMaterialPoint& pt) { return m_r; }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEInitialFluidAngularVelocity.cpp
.cpp
2,528
75
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2020 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEInitialFluidAngularVelocity.h" #include "FEBioPolarFluid.h" #include <FECore/FEMaterialPoint.h> #include <FECore/FENode.h> BEGIN_FECORE_CLASS(FEInitialFluidAngularVelocity, FENodalIC) ADD_PARAMETER(m_v0, "value")->setUnits(UNIT_ANGULAR_VELOCITY); END_FECORE_CLASS(); FEInitialFluidAngularVelocity::FEInitialFluidAngularVelocity(FEModel* fem) : FENodalIC(fem) { m_v0 = vec3d(0, 0, 0); } // set the initial value void FEInitialFluidAngularVelocity::SetValue(const vec3d& v0) { m_v0 = v0; } // initialization bool FEInitialFluidAngularVelocity::Init() { FEDofList dofs(GetFEModel()); if (dofs.AddVariable(FEBioPolarFluid::GetVariableName(FEBioPolarFluid::FLUID_ANGULAR_VELOCITY)) == false) return false; SetDOFList(dofs); return true; } // return the values for node i void FEInitialFluidAngularVelocity::GetNodalValues(int inode, std::vector<double>& values) { assert(values.size() == 3); const FENodeSet& nset = *GetNodeSet(); const FENode& node = *nset.Node(inode); FEMaterialPoint mp; mp.m_r0 = node.m_r0; mp.m_index = inode; vec3d v0 = m_v0(mp); values[0] = v0.x; values[1] = v0.y; values[2] = v0.z; }
C++
3D
febiosoftware/FEBio
FEBioFluid/FENonlinearElasticFluid.h
.h
3,539
94
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include "FEElasticFluid.h" #include <FECore/FEFunction1D.h> //----------------------------------------------------------------------------- //! Linear elastic fluid //! class FEBIOFLUID_API FENonlinearElasticFluid : public FEElasticFluid { public: FENonlinearElasticFluid(FEModel* pfem); ~FENonlinearElasticFluid() {} //! initialization bool Init() override; // serialization void Serialize(DumpStream& ar) override; //! gauge pressure double Pressure(FEMaterialPoint& pt) override; //! tangent of pressure with respect to strain J double Tangent_Strain(FEMaterialPoint& mp) override; //! 2nd tangent of pressure with respect to strain J double Tangent_Strain_Strain(FEMaterialPoint& mp) override; //! tangent of pressure with respect to temperature T double Tangent_Temperature(FEMaterialPoint& mp) override; //! 2nd tangent of pressure with respect to temperature T double Tangent_Temperature_Temperature(FEMaterialPoint& mp) override; //! tangent of pressure with respect to strain J and temperature T double Tangent_Strain_Temperature(FEMaterialPoint& mp) override; //! specific free energy double SpecificFreeEnergy(FEMaterialPoint& mp) override; //! specific entropy double SpecificEntropy(FEMaterialPoint& mp) override; //! specific strain energy double SpecificStrainEnergy(FEMaterialPoint& mp) override; //! isochoric specific heat capacity double IsochoricSpecificHeatCapacity(FEMaterialPoint& mp) override; //! tangent of isochoric specific heat capacity with respect to strain J double Tangent_cv_Strain(FEMaterialPoint& mp) override; //! tangent of isochoric specific heat capacity with respect to temperature T double Tangent_cv_Temperature(FEMaterialPoint& mp) override; //! isobaric specific heat capacity double IsobaricSpecificHeatCapacity(FEMaterialPoint& mp) override; //! dilatation from temperature and pressure bool Dilatation(const double T, const double p, double& e) override; public: double m_k; //!< bulk modulus double m_rhor; //!< true density };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEConstraintFrictionlessWall.cpp
.cpp
4,426
102
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEConstraintFrictionlessWall.h" #include <FECore/FECoreKernel.h> #include <FECore/FESurface.h> BEGIN_FECORE_CLASS(FEConstraintFrictionlessWall, FESurfaceConstraint) ADD_PARAMETER(m_lc.m_laugon, "laugon"); ADD_PARAMETER(m_lc.m_tol, "tol"); ADD_PARAMETER(m_lc.m_eps, "penalty"); ADD_PARAMETER(m_lc.m_rhs, "rhs"); ADD_PARAMETER(m_lc.m_naugmin, "minaug"); ADD_PARAMETER(m_lc.m_naugmax, "maxaug"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- FEConstraintFrictionlessWall::FEConstraintFrictionlessWall(FEModel* pfem) : FESurfaceConstraint(pfem), m_surf(pfem), m_lc(pfem) { m_binit = false; } //----------------------------------------------------------------------------- //! Initializes data structures. void FEConstraintFrictionlessWall::Activate() { // don't forget to call base class FESurfaceConstraint::Activate(); if (m_binit == false) { // evaluate the nodal normals m_surf.UpdateNodeNormals(); // get the dofs int dof_wx = GetDOFIndex("wx"); int dof_wy = GetDOFIndex("wy"); int dof_wz = GetDOFIndex("wz"); // create linear constraints // for a frictionless wall the constraint on (vx, vy, vz) is // nx*vx + ny*vy + nz*vz = 0 for (int i=0; i<m_surf.Nodes(); ++i) { FEAugLagLinearConstraint* pLC = fecore_alloc(FEAugLagLinearConstraint, GetFEModel()); FENode& node = m_surf.Node(i); vec3d nn = m_surf.NodeNormal(i); pLC->AddDOF(node.GetID(), dof_wx, nn.x); pLC->AddDOF(node.GetID(), dof_wy, nn.y); pLC->AddDOF(node.GetID(), dof_wz, nn.z); // add the linear constraint to the system m_lc.add(pLC); } m_lc.Init(); m_lc.Activate(); m_binit = true; } } //----------------------------------------------------------------------------- bool FEConstraintFrictionlessWall::Init() { // initialize surface return m_surf.Init(); } //----------------------------------------------------------------------------- void FEConstraintFrictionlessWall::Serialize(DumpStream& ar) { m_lc.Serialize(ar); } void FEConstraintFrictionlessWall::LoadVector(FEGlobalVector& R, const FETimeInfo& tp) { m_lc.LoadVector(R, tp); } void FEConstraintFrictionlessWall::StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp) { m_lc.StiffnessMatrix(LS, tp); } bool FEConstraintFrictionlessWall::Augment(int naug, const FETimeInfo& tp) { return m_lc.Augment(naug, tp); } void FEConstraintFrictionlessWall::BuildMatrixProfile(FEGlobalMatrix& M) { m_lc.BuildMatrixProfile(M); } int FEConstraintFrictionlessWall::InitEquations(int neq) { return m_lc.InitEquations(neq); } void FEConstraintFrictionlessWall::Update(const std::vector<double>& Ui, const std::vector<double>& ui) { m_lc.Update(Ui, ui); } void FEConstraintFrictionlessWall::UpdateIncrements(std::vector<double>& Ui, const std::vector<double>& ui) { m_lc.UpdateIncrements(Ui, ui); } void FEConstraintFrictionlessWall::PrepStep() { m_lc.PrepStep(); }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEFluidStressCriterion.cpp
.cpp
1,824
46
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEFluidStressCriterion.h" #include "FEFluid.h" #include <FECore/FEElementList.h> BEGIN_FECORE_CLASS(FEFluidStressCriterion, FEMeshAdaptorCriterion) END_FECORE_CLASS(); FEFluidStressCriterion::FEFluidStressCriterion(FEModel* fem) : FEMeshAdaptorCriterion(fem) { } bool FEFluidStressCriterion::GetMaterialPointValue(FEMaterialPoint& mp, double& value) { FEFluidMaterialPoint* fp = mp.ExtractData<FEFluidMaterialPoint>(); if (fp == nullptr) return false; mat3ds& s = fp->m_sf; value = s.max_shear(); return true; }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEBioFluidData.cpp
.cpp
16,209
523
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEBioFluidData.h" #include "FEFluid.h" #include "FEFluidFSI.h" #include "FECore/FEModel.h" //----------------------------------------------------------------------------- double FENodeFluidXVel::value(const FENode& node) { const int dof_VFX = GetFEModel()->GetDOFIndex("wx"); return node.get(dof_VFX); } //----------------------------------------------------------------------------- double FENodeFluidYVel::value(const FENode& node) { const int dof_VFY = GetFEModel()->GetDOFIndex("wy"); return node.get(dof_VFY); } //----------------------------------------------------------------------------- double FENodeFluidZVel::value(const FENode& node) { const int dof_VFZ = GetFEModel()->GetDOFIndex("wz"); return node.get(dof_VFZ); } //----------------------------------------------------------------------------- double FELogElemFluidPosX::value(FEElement& el) { double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEMaterialPoint& mp = *el.GetMaterialPoint(i); FEFluidMaterialPoint* pt = mp.ExtractData<FEFluidMaterialPoint>(); FEElasticMaterialPoint* ept = mp.ExtractData<FEElasticMaterialPoint>(); if (pt) val += mp.m_r0.x; else if (ept) val += mp.m_rt.x; } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogElemFluidPosY::value(FEElement& el) { double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEMaterialPoint& mp = *el.GetMaterialPoint(i); FEFluidMaterialPoint* pt = mp.ExtractData<FEFluidMaterialPoint>(); FEElasticMaterialPoint* ept = mp.ExtractData<FEElasticMaterialPoint>(); if (pt) val += mp.m_r0.y; else if (ept) val += mp.m_rt.y; } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogElemFluidPosZ::value(FEElement& el) { double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEMaterialPoint& mp = *el.GetMaterialPoint(i); FEFluidMaterialPoint* pt = mp.ExtractData<FEFluidMaterialPoint>(); FEElasticMaterialPoint* ept = mp.ExtractData<FEElasticMaterialPoint>(); if (pt) val += mp.m_r0.z; else if (ept) val += mp.m_rt.z; } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogElasticFluidPressure::value(FEElement& el) { double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEFluidMaterialPoint* ppt = el.GetMaterialPoint(i)->ExtractData<FEFluidMaterialPoint>(); if (ppt) val += ppt->m_pf; } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogFluidVolumeRatio::value(FEElement& el) { double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEFluidMaterialPoint* ppt = el.GetMaterialPoint(i)->ExtractData<FEFluidMaterialPoint>(); if (ppt) val += ppt->m_ef + 1; } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogFluidDensity::value(FEElement& el) { double val = 0.0; int nint = el.GaussPoints(); FEMaterial* pmat = GetFEModel()->GetMaterial(el.GetMatID()); FEFluid* pfmat = dynamic_cast<FEFluid*>(pmat); if (pfmat) { for (int i=0; i<nint; ++i) { FEMaterialPoint* pt = el.GetMaterialPoint(i); val += pfmat->Density(*pt); } return val / (double) nint; } else return 0; } //----------------------------------------------------------------------------- double FELogFluidStressPower::value(FEElement& el) { double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEFluidMaterialPoint* ppt = el.GetMaterialPoint(i)->ExtractData<FEFluidMaterialPoint>(); if (ppt) val += (ppt->m_sf*ppt->m_Lf).trace(); } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogFluidVelocityX::value(FEElement& el) { double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEFluidMaterialPoint* ppt = el.GetMaterialPoint(i)->ExtractData<FEFluidMaterialPoint>(); if (ppt) val += ppt->m_vft.x; } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogFluidVelocityY::value(FEElement& el) { double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEFluidMaterialPoint* ppt = el.GetMaterialPoint(i)->ExtractData<FEFluidMaterialPoint>(); if (ppt) val += ppt->m_vft.y; } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogFluidVelocityZ::value(FEElement& el) { double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEFluidMaterialPoint* ppt = el.GetMaterialPoint(i)->ExtractData<FEFluidMaterialPoint>(); if (ppt) val += ppt->m_vft.z; } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogFluidAccelerationX::value(FEElement& el) { double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEFluidMaterialPoint* ppt = el.GetMaterialPoint(i)->ExtractData<FEFluidMaterialPoint>(); if (ppt) val += ppt->m_aft.x; } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogFluidAccelerationY::value(FEElement& el) { double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEFluidMaterialPoint* ppt = el.GetMaterialPoint(i)->ExtractData<FEFluidMaterialPoint>(); if (ppt) val += ppt->m_aft.y; } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogFluidAccelerationZ::value(FEElement& el) { double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEFluidMaterialPoint* ppt = el.GetMaterialPoint(i)->ExtractData<FEFluidMaterialPoint>(); if (ppt) val += ppt->m_aft.z; } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogFluidVorticityX::value(FEElement& el) { double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEFluidMaterialPoint* ppt = el.GetMaterialPoint(i)->ExtractData<FEFluidMaterialPoint>(); if (ppt) val += ppt->Vorticity().x; } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogFluidVorticityY::value(FEElement& el) { double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEFluidMaterialPoint* ppt = el.GetMaterialPoint(i)->ExtractData<FEFluidMaterialPoint>(); if (ppt) val += ppt->Vorticity().y; } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogFluidVorticityZ::value(FEElement& el) { double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEFluidMaterialPoint* ppt = el.GetMaterialPoint(i)->ExtractData<FEFluidMaterialPoint>(); if (ppt) val += ppt->Vorticity().z; } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogFluidStressXX::value(FEElement& el) { double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEFluidMaterialPoint* ppt = el.GetMaterialPoint(i)->ExtractData<FEFluidMaterialPoint>(); if (ppt) val += ppt->m_sf.xx(); } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogFluidStressYY::value(FEElement& el) { double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEFluidMaterialPoint* ppt = el.GetMaterialPoint(i)->ExtractData<FEFluidMaterialPoint>(); if (ppt) val += ppt->m_sf.yy(); } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogFluidStressZZ::value(FEElement& el) { double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEFluidMaterialPoint* ppt = el.GetMaterialPoint(i)->ExtractData<FEFluidMaterialPoint>(); if (ppt) val += ppt->m_sf.zz(); } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogFluidStressXY::value(FEElement& el) { double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEFluidMaterialPoint* ppt = el.GetMaterialPoint(i)->ExtractData<FEFluidMaterialPoint>(); if (ppt) val += ppt->m_sf.xy(); } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogFluidStressYZ::value(FEElement& el) { double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEFluidMaterialPoint* ppt = el.GetMaterialPoint(i)->ExtractData<FEFluidMaterialPoint>(); if (ppt) val += ppt->m_sf.yz(); } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogFluidStressXZ::value(FEElement& el) { double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEFluidMaterialPoint* ppt = el.GetMaterialPoint(i)->ExtractData<FEFluidMaterialPoint>(); if (ppt) val += ppt->m_sf.xz(); } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogFluidStress1::value(FEElement& el) { double l[3]; double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEFluidMaterialPoint* ppt = el.GetMaterialPoint(i)->ExtractData<FEFluidMaterialPoint>(); if (ppt) { ppt->m_sf.exact_eigen(l); val += l[0]; } } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogFluidStress2::value(FEElement& el) { double l[3]; double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEFluidMaterialPoint* ppt = el.GetMaterialPoint(i)->ExtractData<FEFluidMaterialPoint>(); if (ppt) { ppt->m_sf.exact_eigen(l); val += l[1]; } } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogFluidStress3::value(FEElement& el) { double l[3]; double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEFluidMaterialPoint* ppt = el.GetMaterialPoint(i)->ExtractData<FEFluidMaterialPoint>(); if (ppt) { ppt->m_sf.exact_eigen(l); val += l[2]; } } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogFluidMaxShearStress::value(FEElement& el) { double l[3]; double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEFluidMaterialPoint* ppt = el.GetMaterialPoint(i)->ExtractData<FEFluidMaterialPoint>(); if (ppt) { ppt->m_sf.exact_eigen(l); double mxs = max(fabs(l[1]-l[0])/2,fabs(l[2]-l[1])/2); mxs = max(mxs,fabs(l[0]-l[2])/2); val += mxs; } } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogFluidRateOfDefXX::value(FEElement& el) { double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEFluidMaterialPoint* ppt = el.GetMaterialPoint(i)->ExtractData<FEFluidMaterialPoint>(); if (ppt) { mat3ds D = ppt->RateOfDeformation(); val += D.xx(); } } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogFluidRateOfDefYY::value(FEElement& el) { double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEFluidMaterialPoint* ppt = el.GetMaterialPoint(i)->ExtractData<FEFluidMaterialPoint>(); if (ppt) { mat3ds D = ppt->RateOfDeformation(); val += D.yy(); } } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogFluidRateOfDefZZ::value(FEElement& el) { double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEFluidMaterialPoint* ppt = el.GetMaterialPoint(i)->ExtractData<FEFluidMaterialPoint>(); if (ppt) { mat3ds D = ppt->RateOfDeformation(); val += D.zz(); } } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogFluidRateOfDefXY::value(FEElement& el) { double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEFluidMaterialPoint* ppt = el.GetMaterialPoint(i)->ExtractData<FEFluidMaterialPoint>(); if (ppt) { mat3ds D = ppt->RateOfDeformation(); val += D.xy(); } } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogFluidRateOfDefYZ::value(FEElement& el) { double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEFluidMaterialPoint* ppt = el.GetMaterialPoint(i)->ExtractData<FEFluidMaterialPoint>(); if (ppt) { mat3ds D = ppt->RateOfDeformation(); val += D.yz(); } } return val / (double) nint; } //----------------------------------------------------------------------------- double FELogFluidRateOfDefXZ::value(FEElement& el) { double val = 0.0; int nint = el.GaussPoints(); for (int i=0; i<nint; ++i) { FEFluidMaterialPoint* ppt = el.GetMaterialPoint(i)->ExtractData<FEFluidMaterialPoint>(); if (ppt) { mat3ds D = ppt->RateOfDeformation(); val += D.xz(); } } return val / (double) nint; }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEBodyMoment.h
.h
2,035
55
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FEMaterialPoint.h> #include <FECore/FEBodyLoad.h> #include "febiofluid_api.h" //----------------------------------------------------------------------------- //! This class is the base class for body moments //! Derived classes need to implement the force and stiffness functions. // class FEBIOFLUID_API FEBodyMoment : public FEBodyLoad { public: //! constructor FEBodyMoment(FEModel* pfem); public: //! calculate the specific body moment at a material point virtual vec3d moment(FEMaterialPoint& pt) = 0; //! calculate constribution to stiffness matrix virtual mat3ds stiffness(FEMaterialPoint& pt) = 0; public: void LoadVector(FEGlobalVector& R) override; void StiffnessMatrix(FELinearSystem& LS) override; };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEPolarFluidMaterialPoint.h
.h
2,291
61
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2022 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FEModel.h> #include <FECore/FEMaterial.h> #include "febiofluid_api.h" //----------------------------------------------------------------------------- //! Polar fluid material point class. // class FEBIOFLUID_API FEPolarFluidMaterialPoint : public FEMaterialPointData { public: //! constructor FEPolarFluidMaterialPoint(FEMaterialPointData* pt = 0); //! create a shallow copy FEMaterialPointData* Copy(); //! data serialization void Serialize(DumpStream& ar); //! Data initialization void Init(); public: mat3da RelativeSpin() { return mat3da(m_hf); } public: // polar fluid data vec3d m_gf; //!< fluid angular velocity vec3d m_gfdot; //!< fluid angular acceleration vec3d m_hf; //!< fluid relative angular velocity mat3da m_sfa; //!< antisymmetric part of fluid stress mat3d m_Psi; //!< gradient of fluid angular velocity };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEMultiphasicFSIDomain3D.h
.h
4,762
141
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2020 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FESolidDomain.h> #include "FEMultiphasicFSIDomain.h" #include "FEMultiphasicFSI.h" #include "FEFluidDomain.h" #include <FECore/FEDofList.h> //----------------------------------------------------------------------------- //! Biphasic-FSI domain described by 3D volumetric elements //! class FEBIOFLUID_API FEMultiphasicFSIDomain3D : public FESolidDomain, public FEMultiphasicFSIDomain { public: //! constructor FEMultiphasicFSIDomain3D(FEModel* pfem); ~FEMultiphasicFSIDomain3D() {} //! assignment operator FEMultiphasicFSIDomain3D& operator = (FEMultiphasicFSIDomain3D& d); //! initialize class bool Init() override; //! activate void Activate() override; //! reset domain data void Reset() override; //! initialize material points in the domain void InitMaterialPoints() override; //! initialize elements void PreSolveUpdate(const FETimeInfo& timeInfo) override; //! Unpack element data void UnpackLM(FEElement& el, vector<int>& lm) override; //! Serialization void Serialize(DumpStream& ar) override; // get the total dof const FEDofList& GetDOFList() const override; public: // overrides from FEDomain //! get the material FEMaterial* GetMaterial() override { return m_pMat; } //! set the material void SetMaterial(FEMaterial* pm) override; public: // overrides from FEElasticDomain // update stresses void Update(const FETimeInfo& tp) override; // update the element stress void UpdateElementStress(int iel, const FETimeInfo& tp); //! internal stress forces void InternalForces(FEGlobalVector& R) override; //! body forces void BodyForce(FEGlobalVector& R, FEBodyForce& BF) override; //! inertial forces for dynamic problems void InertialForces(FEGlobalVector& R) override; //! calculates the global stiffness matrix for this domain void StiffnessMatrix(FELinearSystem& LS) override; //! calculates inertial stiffness void MassMatrix(FELinearSystem& LS) override; //! body force stiffness void BodyForceStiffness(FELinearSystem& LS, FEBodyForce& bf) override; public: // --- S T I F F N E S S --- //! calculates the solid element stiffness matrix void ElementStiffness(FESolidElement& el, matrix& ke); //! calculates the solid element mass matrix void ElementMassMatrix(FESolidElement& el, matrix& ke); //! calculates the stiffness matrix due to body forces void ElementBodyForceStiffness(FEBodyForce& bf, FESolidElement& el, matrix& ke); // --- R E S I D U A L --- //! Calculates the internal stress vector for solid elements void ElementInternalForce(FESolidElement& el, vector<double>& fe); //! Calculates external body forces for solid elements void ElementBodyForce(FEBodyForce& BF, FESolidElement& elem, vector<double>& fe); //! Calculates the inertial force vector for solid elements void ElementInertialForce(FESolidElement& el, vector<double>& fe); protected: FEMultiphasicFSI* m_pMat; double m_sseps; protected: FEDofList m_dofU, m_dofV, m_dofW, m_dofAW; FEDofList m_dofSU, m_dofR; FEDofList m_dof; int m_dofEF; int m_dofAEF; int m_dofC; int m_dofAC; };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEThermoFluidAnalysis.h
.h
1,558
43
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FEAnalysis.h> #include "febiofluid_api.h" class FEBIOFLUID_API FEThermoFluidAnalysis : public FEAnalysis { public: enum ThermoFluidAnalysisType { STEADY_STATE, DYNAMIC }; public: FEThermoFluidAnalysis(FEModel* fem); DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEMultiphasicFSIAnalysis.h
.h
1,564
43
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FEAnalysis.h> #include "febiofluid_api.h" class FEBIOFLUID_API FEMultiphasicFSIAnalysis : public FEAnalysis { public: enum FluidSoluteAnalysisType { STEADY_STATE, DYNAMIC }; public: FEMultiphasicFSIAnalysis(FEModel* fem); DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FESolutesSolver.h
.h
3,868
120
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FENewtonSolver.h> class FESolutesSolver : public FENewtonSolver { public: //! constructor FESolutesSolver(FEModel* pfem); //! destructor ~FESolutesSolver(); //! Initializes data structures bool Init() override; //! initialize the step bool InitStep(double time) override; //! Initialize linear equation system bool InitEquations() override; bool InitEquations2() override; //! preferred matrix type should be unsymmetric. Matrix_Type PreferredMatrixType() const override { return REAL_UNSYMMETRIC; }; public: //{ --- evaluation and update --- //! Perform an update void Update(vector<double>& ui) override; //! update nodal positions, velocities, accelerations, etc. void UpdateKinematics(vector<double>& ui); //! used by JFNK void Update2(const vector<double>& ui) override; //} //{ --- Solution functions --- //! prepares the data for the first QN iteration void PrepStep() override; //! Performs a Newton-Raphson iteration bool Quasin() override; //{ --- Stiffness matrix routines --- //! calculates the global stiffness matrix bool StiffnessMatrix(FELinearSystem& LS) override; //{ --- Residual routines --- //! Calculates residual bool Residual(vector<double>& R) override; public: //! Serialization void Serialize(DumpStream& ar) override; protected: void GetConcentrationData(vector<double>& ci, vector<double>& ui, const int sol); public: // convergence tolerances double m_Ctol; //!< concentration tolerance bool m_forcePositive; //!< force conentrations to remain positive public: // equation numbers vector<int> m_nceq; //!< number of equations related to concentration dofs int m_nCeq; //!< total number of concentration dofs public: vector<double> m_Fr; //!< nodal reaction forces // solute data vector< vector<double> > m_ci; //!< concentration increment vector vector< vector<double> > m_Ci; //!< Total concentration vector for iteration // generalized alpha method double m_rhoi; //!< rho infinity double m_alphaf; //!< alpha step for Y={v,e} double m_alpham; //!< alpha step for Ydot={∂v/∂t,∂e/∂t} double m_gammaf; //!< gamma int m_pred; //!< predictor method protected: FEDofList m_dofC; FEDofList m_dofAC; // declare the parameter list DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEBioPolarFluid.h
.h
1,701
48
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2022 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include "febiofluid_api.h" namespace FEBioPolarFluid { FEBIOFLUID_API void InitModule(); enum POLAR_FLUID_VARIABLE { DISPLACEMENT, RELATIVE_FLUID_VELOCITY, RELATIVE_FLUID_ACCELERATION, FLUID_ANGULAR_VELOCITY, FLUID_ANGULAR_ACCELERATION, FLUID_DILATATION, FLUID_DILATATION_TDERIV }; FEBIOFLUID_API const char* GetVariableName(POLAR_FLUID_VARIABLE var); }
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FETangentialFlowPFStabilization.cpp
.cpp
8,241
227
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2022 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FETangentialFlowPFStabilization.h" #include "FEBioPolarFluid.h" #include "FEPolarFluid.h" #include <FECore/FELinearSystem.h> //----------------------------------------------------------------------------- // Parameter block for pressure loads BEGIN_FECORE_CLASS(FETangentialFlowPFStabilization, FESurfaceLoad) ADD_PARAMETER(m_beta, "beta"); END_FECORE_CLASS() //----------------------------------------------------------------------------- //! constructor FETangentialFlowPFStabilization::FETangentialFlowPFStabilization(FEModel* pfem) : FESurfaceLoad(pfem), m_dofW(pfem), m_dofG(pfem) { m_beta = 1.0; // get the degrees of freedom // TODO: Can this be done in Init, since there is no error checking if (pfem) { m_dofW.Clear(); m_dofW.AddVariable(FEBioPolarFluid::GetVariableName(FEBioPolarFluid::RELATIVE_FLUID_VELOCITY)); m_dofG.Clear(); m_dofG.AddVariable(FEBioPolarFluid::GetVariableName(FEBioPolarFluid::FLUID_ANGULAR_VELOCITY)); m_dof.Clear(); m_dof.AddDofs(m_dofW); m_dof.Clear(); m_dof.AddDofs(m_dofW); m_dof.AddDofs(m_dofG); } } //----------------------------------------------------------------------------- //! allocate storage void FETangentialFlowPFStabilization::SetSurface(FESurface* ps) { FESurfaceLoad::SetSurface(ps); } //----------------------------------------------------------------------------- //! initialize bool FETangentialFlowPFStabilization::Init() { if (FESurfaceLoad::Init() == false) return false; return true; } //----------------------------------------------------------------------------- void FETangentialFlowPFStabilization::Serialize(DumpStream& ar) { FESurfaceLoad::Serialize(ar); if (ar.IsShallow()) return; ar & m_dofW & m_dofG; } //----------------------------------------------------------------------------- vec3d FETangentialFlowPFStabilization::FluidVelocity(FESurfaceMaterialPoint& mp, double alpha) { FESurfaceElement& el = *mp.SurfaceElement(); vec3d vt[FEElement::MAX_NODES]; int neln = el.Nodes(); for (int j = 0; j<neln; ++j) { FENode& node = m_psurf->Node(el.m_lnode[j]); vt[j] = node.get_vec3d(m_dofW[0], m_dofW[1], m_dofW[2])*alpha + node.get_vec3d_prev(m_dofW[0], m_dofW[1], m_dofW[2])*(1 - alpha); } return el.eval(vt, mp.m_index); } //----------------------------------------------------------------------------- vec3d FETangentialFlowPFStabilization::FluidAngularVelocity(FESurfaceMaterialPoint& mp, double alpha) { FESurfaceElement& el = *mp.SurfaceElement(); vec3d gt[FEElement::MAX_NODES]; int neln = el.Nodes(); for (int j = 0; j<neln; ++j) { FENode& node = m_psurf->Node(el.m_lnode[j]); gt[j] = node.get_vec3d(m_dofG[0], m_dofG[1], m_dofG[2])*alpha + node.get_vec3d_prev(m_dofG[0], m_dofG[1], m_dofG[2])*(1 - alpha); } return el.eval(gt, mp.m_index); } //----------------------------------------------------------------------------- void FETangentialFlowPFStabilization::LoadVector(FEGlobalVector& R) { const FETimeInfo& tp = GetFEModel()->GetTime(); m_psurf->LoadVector(R, m_dof, false, [=](FESurfaceMaterialPoint& mp, const FESurfaceDofShape& dof_a, vector<double>& fa) { FESurfaceElement& el = *mp.SurfaceElement(); // get the density FEElement* pe = el.m_elem[0].pe; FEMaterial* pm = GetFEModel()->GetMaterial(pe->GetMatID()); FEPolarFluid* pfluid = pm->ExtractProperty<FEPolarFluid>(); FEFluidMaterial* fluid = pm->ExtractProperty<FEFluidMaterial>(); double rho = fluid->ReferentialDensity(); double kg = (pfluid) ? pfluid->m_kg : 0; // tangent vectors vec3d rt[FEElement::MAX_NODES]; m_psurf->GetNodalCoordinates(el, tp.alphaf, rt); vec3d dxr = el.eval_deriv1(rt, mp.m_index); vec3d dxs = el.eval_deriv2(rt, mp.m_index); // normal and area element vec3d n = dxr ^ dxs; double da = n.unit(); // fluid velocity vec3d v = FluidVelocity(mp, tp.alphaf); // fluid angular velocity vec3d g = FluidAngularVelocity(mp, tp.alphaf); // tangential traction = -beta*density*|tangential velocity|*(tangential velocity) mat3dd I(1.0); vec3d vtau = (I - dyad(n))*v; double vmag = vtau.norm(); vec3d gtau = (I - dyad(n))*g; double gmag = gtau.norm(); // force vector (change sign for inflow vs outflow) vec3d fv = vtau*(-m_beta*rho*vmag*da); vec3d fg = gtau*(-m_beta*rho*pow(kg,3)*gmag*da); double H = dof_a.shape; fa[0] = H * fv.x; fa[1] = H * fv.y; fa[2] = H * fv.z; fa[3] = H * fg.x; fa[4] = H * fg.y; fa[5] = H * fg.z; }); } //----------------------------------------------------------------------------- void FETangentialFlowPFStabilization::StiffnessMatrix(FELinearSystem& LS) { const FETimeInfo& tp = GetFEModel()->GetTime(); m_psurf->LoadStiffness(LS, m_dof, m_dof, [=](FESurfaceMaterialPoint& mp, const FESurfaceDofShape& dof_a, const FESurfaceDofShape& dof_b, matrix& Kab) { FESurfaceElement& el = *mp.SurfaceElement(); // fluid velocity vec3d v = FluidVelocity(mp, tp.alphaf); // fluid angular velocity vec3d g = FluidAngularVelocity(mp, tp.alphaf); // get the density FEElement* pe = el.m_elem[0].pe; FEMaterial* pm = GetFEModel()->GetMaterial(pe->GetMatID()); FEPolarFluid* pfluid = pm->ExtractProperty<FEPolarFluid>(); FEFluidMaterial* fluid = pm->ExtractProperty<FEFluidMaterial>(); double rho = fluid->ReferentialDensity(); double kg = (pfluid) ? pfluid->m_kg : 0; // tangent vectors vec3d rt[FEElement::MAX_NODES]; m_psurf->GetNodalCoordinates(el, tp.alphaf, rt); vec3d dxr = el.eval_deriv1(rt, mp.m_index); vec3d dxs = el.eval_deriv2(rt, mp.m_index); vec3d n = dxr ^ dxs; double da = n.unit(); mat3dd I(1.0); vec3d vtau = (I - dyad(n))*v; double vmag = vtau.unit(); mat3d Kv = (I - dyad(n) + dyad(vtau))*(-m_beta*rho*vmag*da); vec3d gtau = (I - dyad(n))*g; double gmag = gtau.unit(); mat3d Kg = (I - dyad(n) + dyad(gtau))*(-m_beta*rho*pow(kg,3)*gmag*da); // shape functions and derivatives double H_i = dof_a.shape; double H_j = dof_b.shape; // calculate stiffness component mat3d Kww = Kv*(H_i*H_j*tp.alphaf); mat3d Kgg = Kg*(H_i*H_j*tp.alphaf); Kab.zero(); // dw/dw Kab.sub(0, 0, Kww); // dg/dg Kab.sub(3, 3, Kgg); }); }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEConstraintFrictionlessWall.h
.h
3,032
88
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FEAugLagLinearConstraint.h> #include <FECore/FESurface.h> #include "febiofluid_api.h" //----------------------------------------------------------------------------- //! The FEConstraintFrictionlessWall class implements a frictionless fluid wall //! as a linear constraint on the components of the fluid velocity. class FEBIOFLUID_API FEConstraintFrictionlessWall : public FESurfaceConstraint { public: //! constructor FEConstraintFrictionlessWall(FEModel* pfem); //! destructor ~FEConstraintFrictionlessWall() {} //! Activation void Activate() override; //! initialization bool Init() override; // allocate equations int InitEquations(int neq) override; protected: void Update(const std::vector<double>& Ui, const std::vector<double>& ui) override; void UpdateIncrements(std::vector<double>& Ui, const std::vector<double>& ui) override; void PrepStep() override; //! Get the surface FESurface* GetSurface() override { return &m_surf; } public: //! serialize data to archive void Serialize(DumpStream& ar) override; //! add the linear constraint contributions to the residual void LoadVector(FEGlobalVector& R, const FETimeInfo& tp) override; //! add the linear constraint contributions to the stiffness matrix void StiffnessMatrix(FELinearSystem& LS, const FETimeInfo& tp) override; //! do the augmentation bool Augment(int naug, const FETimeInfo& tp) override; //! build connectivity for matrix profile void BuildMatrixProfile(FEGlobalMatrix& M) override; protected: FESurface m_surf; FELinearConstraintSet m_lc; bool m_binit; DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FETangentialFlowPFStabilization.h
.h
2,601
71
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2022 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FESurfaceLoad.h> #include "febiofluid_api.h" //----------------------------------------------------------------------------- //! Tangential flow stabilization prescribes a shear traction that opposes //! tangential fluid velocity on a boundary surface, in the presence of normal //! flow. This can help stabilize inflow/outflow conditions. class FEBIOFLUID_API FETangentialFlowPFStabilization : public FESurfaceLoad { public: //! constructor FETangentialFlowPFStabilization(FEModel* pfem); //! Initialization bool Init() override; //! Set the surface to apply the load to void SetSurface(FESurface* ps) override; //! calculate pressure stiffness void StiffnessMatrix(FELinearSystem& LS) override; //! calculate load vector void LoadVector(FEGlobalVector& R) override; //! serialize data void Serialize(DumpStream& ar) override; protected: vec3d FluidVelocity(FESurfaceMaterialPoint& mp, double alpha); vec3d FluidAngularVelocity(FESurfaceMaterialPoint& mp, double alpha); protected: double m_beta; //!< damping coefficient for viscous surface traction and coupld // degrees of freedom FEDofList m_dofW; FEDofList m_dofG; DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEFluidModule.cpp
.cpp
13,525
307
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2020 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "FEFluidModule.h" #include <FECore/FEModel.h> #include "FEBioFluid.h" #include "FEBioFSI.h" #include "FEBioMultiphasicFSI.h" #include "FEBioThermoFluid.h" #include "FEBioFluidSolutes.h" #include "FEBioPolarFluid.h" FEFluidModule::FEFluidModule() {} void FEFluidModule::InitModel(FEModel* fem) { // Allocate degrees of freedom DOFS& dofs = fem->GetDOFS(); int varD = dofs.AddVariable(FEBioFluid::GetVariableName(FEBioFluid::DISPLACEMENT), VAR_VEC3); dofs.SetDOFName(varD, 0, "x"); dofs.SetDOFName(varD, 1, "y"); dofs.SetDOFName(varD, 2, "z"); int nW = dofs.AddVariable(FEBioFluid::GetVariableName(FEBioFluid::RELATIVE_FLUID_VELOCITY), VAR_VEC3); dofs.SetDOFName(nW, 0, "wx"); dofs.SetDOFName(nW, 1, "wy"); dofs.SetDOFName(nW, 2, "wz"); int nE = dofs.AddVariable(FEBioFluid::GetVariableName(FEBioFluid::FLUID_DILATATION), VAR_SCALAR); dofs.SetDOFName(nE, 0, "ef"); int nAW = dofs.AddVariable(FEBioFluid::GetVariableName(FEBioFluid::RELATIVE_FLUID_ACCELERATION), VAR_VEC3); dofs.SetDOFName(nAW, 0, "awx"); dofs.SetDOFName(nAW, 1, "awy"); dofs.SetDOFName(nAW, 2, "awz"); int nAE = dofs.AddVariable(FEBioFluid::GetVariableName(FEBioFluid::FLUID_DILATATION_TDERIV), VAR_SCALAR); dofs.SetDOFName(nAE, 0, "aef"); } //============================================================================= FEFluidFSIModule::FEFluidFSIModule() {} void FEFluidFSIModule::InitModel(FEModel* fem) { // Allocate degrees of freedom DOFS& dofs = fem->GetDOFS(); int varD = dofs.AddVariable(FEBioFSI::GetVariableName(FEBioFSI::DISPLACEMENT), VAR_VEC3); dofs.SetDOFName(varD, 0, "x"); dofs.SetDOFName(varD, 1, "y"); dofs.SetDOFName(varD, 2, "z"); int varV = dofs.AddVariable(FEBioFSI::GetVariableName(FEBioFSI::VELOCITY), VAR_VEC3); dofs.SetDOFName(varV, 0, "vx"); dofs.SetDOFName(varV, 1, "vy"); dofs.SetDOFName(varV, 2, "vz"); int varQ = dofs.AddVariable(FEBioFSI::GetVariableName(FEBioFSI::ROTATION), VAR_VEC3); dofs.SetDOFName(varQ, 0, "u"); dofs.SetDOFName(varQ, 1, "v"); dofs.SetDOFName(varQ, 2, "w"); int varSD = dofs.AddVariable(FEBioFSI::GetVariableName(FEBioFSI::SHELL_DISPLACEMENT), VAR_VEC3); dofs.SetDOFName(varSD, 0, "sx"); dofs.SetDOFName(varSD, 1, "sy"); dofs.SetDOFName(varSD, 2, "sz"); int varQV = dofs.AddVariable(FEBioFSI::GetVariableName(FEBioFSI::SHELL_VELOCITY), VAR_VEC3); dofs.SetDOFName(varQV, 0, "svx"); dofs.SetDOFName(varQV, 1, "svy"); dofs.SetDOFName(varQV, 2, "svz"); int varQA = dofs.AddVariable(FEBioFSI::GetVariableName(FEBioFSI::SHELL_ACCELERATION), VAR_VEC3); dofs.SetDOFName(varQA, 0, "sax"); dofs.SetDOFName(varQA, 1, "say"); dofs.SetDOFName(varQA, 2, "saz"); int varQR = dofs.AddVariable(FEBioFSI::GetVariableName(FEBioFSI::RIGID_ROTATION), VAR_VEC3); dofs.SetDOFName(varQR, 0, "Ru"); dofs.SetDOFName(varQR, 1, "Rv"); dofs.SetDOFName(varQR, 2, "Rw"); int nW = dofs.AddVariable(FEBioFSI::GetVariableName(FEBioFSI::RELATIVE_FLUID_VELOCITY), VAR_VEC3); dofs.SetDOFName(nW, 0, "wx"); dofs.SetDOFName(nW, 1, "wy"); dofs.SetDOFName(nW, 2, "wz"); int nAW = dofs.AddVariable(FEBioFSI::GetVariableName(FEBioFSI::RELATIVE_FLUID_ACCELERATION), VAR_VEC3); dofs.SetDOFName(nAW, 0, "awx"); dofs.SetDOFName(nAW, 1, "awy"); dofs.SetDOFName(nAW, 2, "awz"); int nVF = dofs.AddVariable(FEBioFSI::GetVariableName(FEBioFSI::FLUID_VELOCITY), VAR_VEC3); dofs.SetDOFName(nVF, 0, "vfx"); dofs.SetDOFName(nVF, 1, "vfy"); dofs.SetDOFName(nVF, 2, "vfz"); int nAF = dofs.AddVariable(FEBioFSI::GetVariableName(FEBioFSI::FLUID_ACCELERATION), VAR_VEC3); dofs.SetDOFName(nAF, 0, "afx"); dofs.SetDOFName(nAF, 1, "afy"); dofs.SetDOFName(nAF, 2, "afz"); int nE = dofs.AddVariable(FEBioFSI::GetVariableName(FEBioFSI::FLUID_DILATATION), VAR_SCALAR); dofs.SetDOFName(nE, 0, "ef"); int nAE = dofs.AddVariable(FEBioFSI::GetVariableName(FEBioFSI::FLUID_DILATATION_TDERIV), VAR_SCALAR); dofs.SetDOFName(nAE, 0, "aef"); } //============================================================================= FEMultiphasicFSIModule::FEMultiphasicFSIModule() { SetStatus(EXPERIMENTAL); } void FEMultiphasicFSIModule::InitModel(FEModel* fem) { // Allocate degrees of freedom DOFS& dofs = fem->GetDOFS(); int varD = dofs.AddVariable(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::DISPLACEMENT), VAR_VEC3); dofs.SetDOFName(varD, 0, "x"); dofs.SetDOFName(varD, 1, "y"); dofs.SetDOFName(varD, 2, "z"); int varV = dofs.AddVariable(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::VELOCITY), VAR_VEC3); dofs.SetDOFName(varV, 0, "vx"); dofs.SetDOFName(varV, 1, "vy"); dofs.SetDOFName(varV, 2, "vz"); int varQ = dofs.AddVariable(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::ROTATION), VAR_VEC3); dofs.SetDOFName(varQ, 0, "u"); dofs.SetDOFName(varQ, 1, "v"); dofs.SetDOFName(varQ, 2, "w"); int varSD = dofs.AddVariable(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::SHELL_DISPLACEMENT), VAR_VEC3); dofs.SetDOFName(varSD, 0, "sx"); dofs.SetDOFName(varSD, 1, "sy"); dofs.SetDOFName(varSD, 2, "sz"); int varQV = dofs.AddVariable(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::SHELL_VELOCITY), VAR_VEC3); dofs.SetDOFName(varQV, 0, "svx"); dofs.SetDOFName(varQV, 1, "svy"); dofs.SetDOFName(varQV, 2, "svz"); int varQA = dofs.AddVariable(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::SHELL_ACCELERATION), VAR_VEC3); dofs.SetDOFName(varQA, 0, "sax"); dofs.SetDOFName(varQA, 1, "say"); dofs.SetDOFName(varQA, 2, "saz"); int varQR = dofs.AddVariable(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::RIGID_ROTATION), VAR_VEC3); dofs.SetDOFName(varQR, 0, "Ru"); dofs.SetDOFName(varQR, 1, "Rv"); dofs.SetDOFName(varQR, 2, "Rw"); int nW = dofs.AddVariable(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::RELATIVE_FLUID_VELOCITY), VAR_VEC3); dofs.SetDOFName(nW, 0, "wx"); dofs.SetDOFName(nW, 1, "wy"); dofs.SetDOFName(nW, 2, "wz"); int nAW = dofs.AddVariable(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::RELATIVE_FLUID_ACCELERATION), VAR_VEC3); dofs.SetDOFName(nAW, 0, "awx"); dofs.SetDOFName(nAW, 1, "awy"); dofs.SetDOFName(nAW, 2, "awz"); int nVF = dofs.AddVariable(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::FLUID_VELOCITY), VAR_VEC3); dofs.SetDOFName(nVF, 0, "vfx"); dofs.SetDOFName(nVF, 1, "vfy"); dofs.SetDOFName(nVF, 2, "vfz"); int nAF = dofs.AddVariable(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::FLUID_ACCELERATION), VAR_VEC3); dofs.SetDOFName(nAF, 0, "afx"); dofs.SetDOFName(nAF, 1, "afy"); dofs.SetDOFName(nAF, 2, "afz"); int nE = dofs.AddVariable(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::FLUID_DILATATION), VAR_SCALAR); dofs.SetDOFName(nE, 0, "ef"); int nAE = dofs.AddVariable(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::FLUID_DILATATION_TDERIV), VAR_SCALAR); dofs.SetDOFName(nAE, 0, "aef"); int varC = dofs.AddVariable(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::FLUID_CONCENTRATION), VAR_ARRAY); int varAC = dofs.AddVariable(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::FLUID_CONCENTRATION_TDERIV), VAR_ARRAY); } //============================================================================= FEThermoFluidModule::FEThermoFluidModule() { SetStatus(EXPERIMENTAL); } void FEThermoFluidModule::InitModel(FEModel* fem) { // Allocate degrees of freedom DOFS& dofs = fem->GetDOFS(); int varD = dofs.AddVariable(FEBioThermoFluid::GetVariableName(FEBioThermoFluid::DISPLACEMENT), VAR_VEC3); dofs.SetDOFName(varD, 0, "x"); dofs.SetDOFName(varD, 1, "y"); dofs.SetDOFName(varD, 2, "z"); int nW = dofs.AddVariable(FEBioThermoFluid::GetVariableName(FEBioThermoFluid::RELATIVE_FLUID_VELOCITY), VAR_VEC3); dofs.SetDOFName(nW, 0, "wx"); dofs.SetDOFName(nW, 1, "wy"); dofs.SetDOFName(nW, 2, "wz"); int nE = dofs.AddVariable(FEBioThermoFluid::GetVariableName(FEBioThermoFluid::FLUID_DILATATION), VAR_SCALAR); dofs.SetDOFName(nE, 0, "ef"); int nT = dofs.AddVariable(FEBioThermoFluid::GetVariableName(FEBioThermoFluid::TEMPERATURE), VAR_SCALAR); dofs.SetDOFName(nT, 0, "T"); int nAW = dofs.AddVariable(FEBioThermoFluid::GetVariableName(FEBioThermoFluid::RELATIVE_FLUID_ACCELERATION), VAR_VEC3); dofs.SetDOFName(nAW, 0, "awx"); dofs.SetDOFName(nAW, 1, "awy"); dofs.SetDOFName(nAW, 2, "awz"); int nAE = dofs.AddVariable(FEBioThermoFluid::GetVariableName(FEBioThermoFluid::FLUID_DILATATION_TDERIV), VAR_SCALAR); dofs.SetDOFName(nAE, 0, "aef"); int nAT = dofs.AddVariable(FEBioThermoFluid::GetVariableName(FEBioThermoFluid::TEMPERATURE_TDERIV), VAR_SCALAR); dofs.SetDOFName(nAT, 0, "aT"); } //============================================================================= FEPolarFluidModule::FEPolarFluidModule() { SetStatus(EXPERIMENTAL); } void FEPolarFluidModule::InitModel(FEModel* fem) { // Allocate degrees of freedom DOFS& dofs = fem->GetDOFS(); int varD = dofs.AddVariable(FEBioPolarFluid::GetVariableName(FEBioPolarFluid::DISPLACEMENT), VAR_VEC3); dofs.SetDOFName(varD, 0, "x"); dofs.SetDOFName(varD, 1, "y"); dofs.SetDOFName(varD, 2, "z"); int nW = dofs.AddVariable(FEBioPolarFluid::GetVariableName(FEBioPolarFluid::RELATIVE_FLUID_VELOCITY), VAR_VEC3); dofs.SetDOFName(nW, 0, "wx"); dofs.SetDOFName(nW, 1, "wy"); dofs.SetDOFName(nW, 2, "wz"); int nAW = dofs.AddVariable(FEBioPolarFluid::GetVariableName(FEBioPolarFluid::RELATIVE_FLUID_ACCELERATION), VAR_VEC3); dofs.SetDOFName(nAW, 0, "awx"); dofs.SetDOFName(nAW, 1, "awy"); dofs.SetDOFName(nAW, 2, "awz"); int nG = dofs.AddVariable(FEBioPolarFluid::GetVariableName(FEBioPolarFluid::FLUID_ANGULAR_VELOCITY), VAR_VEC3); dofs.SetDOFName(nG, 0, "gx"); dofs.SetDOFName(nG, 1, "gy"); dofs.SetDOFName(nG, 2, "gz"); int nAG = dofs.AddVariable(FEBioPolarFluid::GetVariableName(FEBioPolarFluid::FLUID_ANGULAR_ACCELERATION), VAR_VEC3); dofs.SetDOFName(nAG, 0, "agx"); dofs.SetDOFName(nAG, 1, "agy"); dofs.SetDOFName(nAG, 2, "agz"); int nE = dofs.AddVariable(FEBioPolarFluid::GetVariableName(FEBioPolarFluid::FLUID_DILATATION), VAR_SCALAR); dofs.SetDOFName(nE, 0, "ef"); int nAE = dofs.AddVariable(FEBioPolarFluid::GetVariableName(FEBioPolarFluid::FLUID_DILATATION_TDERIV), VAR_SCALAR); dofs.SetDOFName(nAE, 0, "aef"); } //============================================================================= FEFluidSolutesModule::FEFluidSolutesModule() { SetStatus(RELEASED); } void FEFluidSolutesModule::InitModel(FEModel* fem) { // Allocate degrees of freedom DOFS& dofs = fem->GetDOFS(); int varD = dofs.AddVariable(FEBioFluidSolutes::GetVariableName(FEBioFluidSolutes::DISPLACEMENT), VAR_VEC3); dofs.SetDOFName(varD, 0, "x"); dofs.SetDOFName(varD, 1, "y"); dofs.SetDOFName(varD, 2, "z"); int nW = dofs.AddVariable(FEBioFluidSolutes::GetVariableName(FEBioFluidSolutes::RELATIVE_FLUID_VELOCITY), VAR_VEC3); dofs.SetDOFName(nW, 0, "wx"); dofs.SetDOFName(nW, 1, "wy"); dofs.SetDOFName(nW, 2, "wz"); int nE = dofs.AddVariable(FEBioFluidSolutes::GetVariableName(FEBioFluidSolutes::FLUID_DILATATION), VAR_SCALAR); dofs.SetDOFName(nE, 0, "ef"); int nAW = dofs.AddVariable(FEBioFluidSolutes::GetVariableName(FEBioFluidSolutes::RELATIVE_FLUID_ACCELERATION), VAR_VEC3); dofs.SetDOFName(nAW, 0, "awx"); dofs.SetDOFName(nAW, 1, "awy"); dofs.SetDOFName(nAW, 2, "awz"); int nAE = dofs.AddVariable(FEBioFluidSolutes::GetVariableName(FEBioFluidSolutes::FLUID_DILATATION_TDERIV), VAR_SCALAR); dofs.SetDOFName(nAE, 0, "aef"); int varC = dofs.AddVariable(FEBioFluidSolutes::GetVariableName(FEBioFluidSolutes::FLUID_CONCENTRATION), VAR_ARRAY); int varAC = dofs.AddVariable(FEBioFluidSolutes::GetVariableName(FEBioFluidSolutes::FLUID_CONCENTRATION_TDERIV), VAR_ARRAY); }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEPrescribedFluidPressure.h
.h
2,374
71
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2020 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FEModelParam.h> #include <FECore/FEPrescribedBC.h> #include "febiofluid_api.h" class FEFluidMaterial; //----------------------------------------------------------------------------- class FEBIOFLUID_API FEPrescribedFluidPressure : public FEPrescribedSurface { public: //! constructor FEPrescribedFluidPressure(FEModel* pfem); //! set the dilatation void Update() override; void UpdateModel() override; //! initialize bool Init() override; //! serialization void Serialize(DumpStream& ar) override; void PrepStep(std::vector<double>& ui, bool brel) override; // return the value for node i, dof j void GetNodalValues(int nodelid, std::vector<double>& val) override; // copy data from another class void CopyFrom(FEBoundaryCondition* pbc) override; private: void UpdateDilatation(); protected: int m_dofEF; FESurface* m_psurf; public: FEParamDouble m_p; //!< prescribed fluid pressure vector<double> m_e; DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEPolarFluidMaterialPoint.cpp
.cpp
2,637
65
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2022 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "FEPolarFluidMaterialPoint.h" //============================================================================ // FEPolarFluidMaterialPoint //============================================================================ //----------------------------------------------------------------------------- FEPolarFluidMaterialPoint::FEPolarFluidMaterialPoint(FEMaterialPointData* pt) : FEMaterialPointData(pt) { m_gf = m_gfdot = m_hf = vec3d(0,0,0); m_sfa = mat3da(0,0,0); m_Psi = mat3d(0,0,0,0,0,0,0,0,0); } //----------------------------------------------------------------------------- FEMaterialPointData* FEPolarFluidMaterialPoint::Copy() { FEPolarFluidMaterialPoint* pt = new FEPolarFluidMaterialPoint(*this); if (m_pNext) pt->m_pNext = m_pNext->Copy(); return pt; } //----------------------------------------------------------------------------- void FEPolarFluidMaterialPoint::Serialize(DumpStream& ar) { FEMaterialPointData::Serialize(ar); ar & m_gf & m_gfdot & m_hf & m_sfa & m_Psi; } //----------------------------------------------------------------------------- void FEPolarFluidMaterialPoint::Init() { m_gf = m_gfdot = m_hf = vec3d(0,0,0); m_sfa = mat3da(0,0,0); m_Psi = mat3d(0,0,0,0,0,0,0,0,0); // don't forget to initialize the base class FEMaterialPointData::Init(); }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEFluidSolutesAnalysis.h
.h
1,561
43
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FEAnalysis.h> #include "febiofluid_api.h" class FEBIOFLUID_API FEFluidSolutesAnalysis : public FEAnalysis { public: enum FluidSolutesAnalysisType { STEADY_STATE, DYNAMIC }; public: FEFluidSolutesAnalysis(FEModel* fem); DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEPolarFluidDomainFactory.h
.h
1,636
39
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2022 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FECoreKernel.h> #include "febiofluid_api.h" //----------------------------------------------------------------------------- class FEBIOFLUID_API FEPolarFluidDomainFactory : public FEDomainFactory { public: virtual FEDomain* CreateDomain(const FE_Element_Spec& spec, FEMesh* pm, FEMaterial* pmat); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FESoluteConvectiveFlow.h
.h
2,568
75
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FESurfaceLoad.h> #include <FECore/FEOctreeSearch.h> #include "FECore/FENormalProjection.h" #include "febiofluid_api.h" //----------------------------------------------------------------------------- //! FESoluteConvectiveFlow is a fluid domain where solute is transported //! purely via convection. The solute concentration can be obtained from //! the fluid velocity and dilatation results. // TODO: This is not a surface load! class FEBIOFLUID_API FESoluteConvectiveFlow : public FESurfaceLoad { public: //! constructor FESoluteConvectiveFlow(FEModel* pfem); //! calculate traction stiffness (there is none) void StiffnessMatrix(FELinearSystem& LS) override {} //! calculate load vector void LoadVector(FEGlobalVector& R) override {}; //! set the dilatation void Update() override; //! initialize bool Init() override; //! activate void Activate() override; //! serialization void Serialize(DumpStream& ar) override; private: int m_sol; //!< solute id FEDofList m_dofW; int m_dofEF; int m_dofC; vector<bool> m_bexclude; FENormalProjection* m_np; FEOctreeSearch* m_octree; DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEFixedFluidVelocity.cpp
.cpp
1,981
52
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2020 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEFixedFluidVelocity.h" BEGIN_FECORE_CLASS(FEFixedFluidVelocity, FEFixedBC) ADD_PARAMETER(m_dof[0], "wx_dof")->setLongName("x-velocity"); ADD_PARAMETER(m_dof[1], "wy_dof")->setLongName("y-velocity"); ADD_PARAMETER(m_dof[2], "wz_dof")->setLongName("z-velocity"); END_FECORE_CLASS(); FEFixedFluidVelocity::FEFixedFluidVelocity(FEModel* fem) : FEFixedBC(fem) { m_dof[0] = false; m_dof[1] = false; m_dof[2] = false; } bool FEFixedFluidVelocity::Init() { vector<int> dofs; if (m_dof[0]) dofs.push_back(GetDOFIndex("wx")); if (m_dof[1]) dofs.push_back(GetDOFIndex("wy")); if (m_dof[2]) dofs.push_back(GetDOFIndex("wz")); SetDOFList(dofs); return FEFixedBC::Init(); }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEFluidHeatSupply.h
.h
2,090
56
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FEMaterialPoint.h> #include <FECore/FEBodyLoad.h> #include "febiofluid_api.h" //----------------------------------------------------------------------------- //! This class is the base class for body forces //! Derived classes need to implement the force and stiffness functions. // class FEBIOFLUID_API FEFluidHeatSupply : public FEBodyLoad { public: //! constructor FEFluidHeatSupply(FEModel* pfem); virtual ~FEFluidHeatSupply() {} public: //! calculate the body force at a material point virtual double heat(FEMaterialPoint& pt) = 0; //! calculate constribution to stiffness matrix virtual double stiffness(FEMaterialPoint& pt) = 0; public: void LoadVector(FEGlobalVector& R) override; void StiffnessMatrix(FELinearSystem& LS) override; };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEFluidRotationalVelocity.h
.h
2,307
63
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FEPrescribedBC.h> #include "febiofluid_api.h" //----------------------------------------------------------------------------- //! FEFluidRotationalVelocity is a fluid surface that has a rotational //! velocity prescribed on it. This routine prescribes nodal velocities class FEBIOFLUID_API FEFluidRotationalVelocity : public FEPrescribedNodeSet { public: //! constructor FEFluidRotationalVelocity(FEModel* pfem); //! initialization bool Init() override; //! serialization void Serialize(DumpStream& ar) override; // copy data from another class void CopyFrom(FEBoundaryCondition* pbc) override; // return nodal value void GetNodalValues(int nodelid, std::vector<double>& val) override; private: double m_w; //!< angular speed vec3d m_n; //!< unit vector along axis of rotation vec3d m_p; //!< point on axis of rotation vector<vec3d> m_r; //!< nodal radial positions DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEThermoFluidMaterialPoint.h
.h
2,712
65
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FEMaterial.h> #include "febiofluid_api.h" //----------------------------------------------------------------------------- //! Fluid material point class. // class FEBIOFLUID_API FEThermoFluidMaterialPoint : public FEMaterialPointData { public: //! constructor FEThermoFluidMaterialPoint(FEMaterialPointData* pt); //! create a shallow copy FEMaterialPointData* Copy(); //! data serialization void Serialize(DumpStream& ar); //! Data initialization void Init(); public: // fluid data double m_T; //!< temperature (relative to reference temperature) double m_Tdot; //!< material time derivative of temperature vec3d m_gradT; //!< temperature gradient double m_k; //!< bulk modulus double m_K; //!< thermal conductivity double m_dKJ; //!< derivative of thermal conductivity with respect to fluid volume ratio double m_dKT; //!< derivative of thermal conductivity with respect to temperature double m_cv; //!< isochoric specific heat capacity double m_dcvJ; //!< derivative of isochoric specific heat capacity w.r.t. fluid volume ratio double m_dcvT; //!< derivative of isochoric specific heat capacity w.r.t. temperature double m_cp; //!< isobaric specific heat capacity vec3d m_q; //!< heat flux };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEMultiphasicFSISoluteFlux.h
.h
2,468
71
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2020 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FESurfaceLoad.h> #include <FECore/FEModelParam.h> #include "febiofluid_api.h" //----------------------------------------------------------------------------- //! The flux surface is a surface domain that sustains a solute flux boundary //! condition for FluidSolutesDomain class FEBIOFLUID_API FEMultiphasicFSISoluteFlux : public FESurfaceLoad { public: //! constructor FEMultiphasicFSISoluteFlux(FEModel* pfem); //! Set the surface to apply the load to void SetSurface(FESurface* ps) override; //! calculate traction stiffness (there is none) void StiffnessMatrix(FELinearSystem& LS) override; //! calculate load vector void LoadVector(FEGlobalVector& R) override; void SetSolute(int isol) { m_isol = isol; } //! initialization bool Init() override; //! serialization void Serialize(DumpStream& ar) override; private: FEParamDouble m_flux; //!< flux scale factor magnitude int m_isol; //!< solute index private: FEDofList m_dofC; FEDofList m_dofU; DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FECarreauFluid.h
.h
2,536
68
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include "FEViscousFluid.h" //----------------------------------------------------------------------------- // This class evaluates the viscous stress in a Carreau power-law fluid class FEBIOFLUID_API FECarreauFluid : public FEViscousFluid { public: //! constructor FECarreauFluid(FEModel* pfem); //! viscous stress mat3ds Stress(FEMaterialPoint& pt) override; //! tangent of stress with respect to strain J mat3ds Tangent_Strain(FEMaterialPoint& mp) override; //! tangent of stress with respect to rate of deformation tensor D tens4ds Tangent_RateOfDeformation(FEMaterialPoint& mp) override; //! tangent of stress with respect to temperature mat3ds Tangent_Temperature(FEMaterialPoint& mp) override { return mat3ds(0); }; //! dynamic viscosity double ShearViscosity(FEMaterialPoint& mp) override; //! bulk viscosity double BulkViscosity(FEMaterialPoint& mp) override; public: double m_mu0; //!< shear viscosity at zero shear rate double m_mui; //!< shear viscosity at infinite shear rate double m_lam; //!< time constant double m_n; //!< power-law index // declare parameter list DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEPolarFluidMaterial.cpp
.cpp
2,004
53
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "FEPolarFluidMaterial.h" #include "FEFluidMaterialPoint.h" #include <FECore/FECoreKernel.h> #include <FECore/DumpStream.h> // define the material parameters BEGIN_FECORE_CLASS(FEPolarFluidMaterial, FEFluidMaterial) // material properties ADD_PROPERTY(m_pViscpol, "polar"); END_FECORE_CLASS(); //============================================================================ // FEPolarFluidMaterial //============================================================================ //----------------------------------------------------------------------------- //! FEPolarFluidMaterial constructor FEPolarFluidMaterial::FEPolarFluidMaterial(FEModel* pfem) : FEFluidMaterial(pfem) { m_pViscpol = nullptr; }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEFluidSolutesResistanceBC.h
.h
2,509
76
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FEPrescribedBC.h> #include "FEFluidSolutes.h" //----------------------------------------------------------------------------- //! FEFluidSolutesResistanceBC is a fluid-solutes surface that has a normal //! pressure proportional to the flow rate (resistance). //! class FEBIOFLUID_API FEFluidSolutesResistanceBC : public FEPrescribedSurface { public: //! constructor FEFluidSolutesResistanceBC(FEModel* pfem); //! evaluate flow rate double FlowRate(); //! initialize bool Init() override; //! serialize data to archive void Serialize(DumpStream& ar) override; void Update() override; public: // return the value for node i, dof j void GetNodalValues(int nodelid, std::vector<double>& val) override; // copy data from another class void CopyFrom(FEBoundaryCondition* pbc) override; private: double m_R; //!< flow resistance double m_p0; //!< fluid pressure offset vector<double> m_e; //!< fluid dilatation private: double m_Rgas; double m_Tabs; FEDofList m_dofW; int m_dofEF; int m_dofC; DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FETangentialDamping.cpp
.cpp
4,381
136
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FETangentialDamping.h" #include <FECore/FEMesh.h> #include "FEBioFluid.h" #include <FECore/FELinearSystem.h> //----------------------------------------------------------------------------- // Parameter block for pressure loads BEGIN_FECORE_CLASS(FETangentialDamping, FESurfaceLoad) ADD_PARAMETER(m_eps, "penalty"); END_FECORE_CLASS() //----------------------------------------------------------------------------- //! constructor FETangentialDamping::FETangentialDamping(FEModel* pfem) : FESurfaceLoad(pfem), m_dofW(pfem) { m_eps = 0.0; } //----------------------------------------------------------------------------- //! initialize bool FETangentialDamping::Init() { m_dofW.Clear(); if (m_dofW.AddVariable(FEBioFluid::GetVariableName(FEBioFluid::RELATIVE_FLUID_VELOCITY)) == false) return false; m_dof.Clear(); m_dof.AddDofs(m_dofW); if (FESurfaceLoad::Init() == false) return false; return true; } //----------------------------------------------------------------------------- void FETangentialDamping::Serialize(DumpStream& ar) { FESurfaceLoad::Serialize(ar); if (ar.IsShallow()) return; ar & m_dofW; } //----------------------------------------------------------------------------- //! allocate storage void FETangentialDamping::SetSurface(FESurface* ps) { FESurfaceLoad::SetSurface(ps); } //----------------------------------------------------------------------------- vec3d FETangentialDamping::FluidVelocity(FESurfaceMaterialPoint& mp, double alpha) { vec3d vt[FEElement::MAX_NODES]; FESurfaceElement& el = *mp.SurfaceElement(); int neln = el.Nodes(); for (int j = 0; j<neln; ++j) { FENode& node = m_psurf->Node(el.m_lnode[j]); vt[j] = node.get_vec3d(m_dofW[0], m_dofW[1], m_dofW[2])*alpha + node.get_vec3d_prev(m_dofW[0], m_dofW[1], m_dofW[2])*(1. - alpha); } return el.eval(vt, mp.m_index); } //----------------------------------------------------------------------------- void FETangentialDamping::LoadVector(FEGlobalVector& R) { const FETimeInfo& tp = GetTimeInfo(); m_psurf->LoadVector(R, m_dofW, false, [=](FESurfaceMaterialPoint& mp, const FESurfaceDofShape& dof_a, vector<double>& fa) { // fluid velocity vec3d v = FluidVelocity(mp, tp.alphaf); vec3d n = mp.dxr ^ mp.dxs; double da = n.unit(); // force vector mat3dd I(1); vec3d f = (I - dyad(n))*v*(-m_eps*da); double H = dof_a.shape; fa[0] = H * f.x; fa[1] = H * f.y; fa[2] = H * f.z; }); } //----------------------------------------------------------------------------- void FETangentialDamping::StiffnessMatrix(FELinearSystem& LS) { m_psurf->LoadStiffness(LS, m_dofW, m_dofW, [=](FESurfaceMaterialPoint& mp, const FESurfaceDofShape& dof_a, const FESurfaceDofShape& dof_b, matrix& Kab) { vec3d n = mp.dxr ^ mp.dxs; double da = n.unit(); mat3dd I(1); mat3ds K = (I - dyad(n))*(-m_eps*da); // shape functions double H_a = dof_a.shape; double H_b = dof_b.shape; // calculate stiffness component mat3ds kab = K*(H_a*H_b); Kab.set(0, 0, kab); }); }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEInitialFluidAngularVelocity.h
.h
1,837
50
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2020 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FEInitialCondition.h> #include "febiofluid_api.h" #include <FECore/FEModelParam.h> class FEBIOFLUID_API FEInitialFluidAngularVelocity : public FENodalIC { public: FEInitialFluidAngularVelocity(FEModel* fem); bool Init() override; // set the initial value void SetValue(const vec3d& v0); // return the values for node i void GetNodalValues(int inode, std::vector<double>& values) override; private: FEParamVec3 m_v0; DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEFluidResidualVector.h
.h
2,004
52
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FEGlobalVector.h> #include <vector> #include "febiofluid_api.h" //----------------------------------------------------------------------------- class FEModel; //----------------------------------------------------------------------------- //! The FEFluidResidualVector implements a global vector that stores the residual. class FEBIOFLUID_API FEFluidResidualVector : public FEGlobalVector { public: //! constructor FEFluidResidualVector(FEModel& fem, std::vector<double>& R, std::vector<double>& Fr); //! destructor ~FEFluidResidualVector(); //! Assemble the element vector into this global vector void Assemble(std::vector<int>& en, std::vector<int>& elm, std::vector<double>& fe); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FECrossFluid.cpp
.cpp
3,934
105
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FECrossFluid.h" #include "FEFluid.h" // define the material parameters BEGIN_FECORE_CLASS(FECrossFluid, FEViscousFluid) ADD_PARAMETER(m_mu0, FE_RANGE_GREATER_OR_EQUAL(0.0), "mu0")->setUnits("P.t")->setLongName("zero shear rate viscosity"); ADD_PARAMETER(m_mui, FE_RANGE_GREATER_OR_EQUAL(0.0), "mui")->setUnits("P.t")->setLongName("infinite shear rate viscosity"); ADD_PARAMETER(m_lam, FE_RANGE_GREATER_OR_EQUAL(0.0), "lambda")->setUnits(UNIT_TIME)->setLongName("relaxation time"); ADD_PARAMETER(m_m , FE_RANGE_GREATER_OR_EQUAL(2.0), "m")->setLongName("power"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- //! Constructor. FECrossFluid::FECrossFluid(FEModel* pfem) : FEViscousFluid(pfem) { m_mu0 = 0; m_mui = 0; m_lam = 0; m_m = 2; } //----------------------------------------------------------------------------- //! viscous stress mat3ds FECrossFluid::Stress(FEMaterialPoint& pt) { FEFluidMaterialPoint& vt = *pt.ExtractData<FEFluidMaterialPoint>(); mat3ds D = vt.RateOfDeformation(); double mu = ShearViscosity(pt); mat3ds s = D*(2*mu); return s; } //----------------------------------------------------------------------------- //! tangent of stress with respect to strain J mat3ds FECrossFluid::Tangent_Strain(FEMaterialPoint& mp) { return mat3ds(0,0,0,0,0,0); } //----------------------------------------------------------------------------- //! tangent of stress with respect to rate of deformation tensor D tens4ds FECrossFluid::Tangent_RateOfDeformation(FEMaterialPoint& pt) { FEFluidMaterialPoint& vt = *pt.ExtractData<FEFluidMaterialPoint>(); mat3ds D = vt.RateOfDeformation(); double gdot = sqrt(2*(D.sqr()).tr()); double lamg = m_lam*gdot; double mu = ShearViscosity(pt); double dmu = -2*(m_mu0 - m_mui)*m_m*pow(m_lam,m_m)*pow(gdot,m_m-2)/pow(1+pow(lamg,m_m),2); mat3dd I(1.0); tens4ds c = dyad1s(D)*(2*dmu) + dyad4s(I)*(2*mu); return c; } //----------------------------------------------------------------------------- //! dynamic viscosity double FECrossFluid::ShearViscosity(FEMaterialPoint& pt) { FEFluidMaterialPoint& vt = *pt.ExtractData<FEFluidMaterialPoint>(); mat3ds D = vt.RateOfDeformation(); double gdot = sqrt(2*(D.sqr()).tr()); double lamg = m_lam*gdot; double mu = m_mui + (m_mu0 - m_mui)/(1+pow(lamg, m_m)); return mu; } //----------------------------------------------------------------------------- //! bulk viscosity double FECrossFluid::BulkViscosity(FEMaterialPoint& pt) { return 2*ShearViscosity(pt)/3.; }
C++
3D
febiosoftware/FEBio
FEBioFluid/FESolutesMaterial.h
.h
6,665
168
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FEMaterial.h> #include <FEBioMix/FESolute.h> #include <FEBioMix/FESoluteInterface.h> #include <FEBioMix/FEOsmoticCoefficient.h> #include <FEBioMix/FEChemicalReaction.h> #include "febiofluid_api.h" #include "FEFluid.h" //----------------------------------------------------------------------------- class FEBIOFLUID_API FESolutesMaterial : public FEMaterial, public FESoluteInterface { public: class Point : public FEMaterialPointData { public: //! constructor Point(FEMaterialPointData* pt); //! create a shallow copy FEMaterialPointData* Copy(); //! data serialization void Serialize(DumpStream& ar); //! Data initialization void Init(); //! Osmolarity double Osmolarity() const; public: vec3d m_vft; // fluid velocity at integration point double m_JfdotoJf; // divergence of fluid velocity // solutes material data int m_nsol; //!< number of solutes vector<double> m_c; //!< solute concentration vector<double> m_ca; //!< effective solute concentration vector<vec3d> m_gradc; //!< spatial gradient of solute concentration vector<vec3d> m_j; //!< solute molar flux vector<double> m_cdot; //!< material time derivative of solute concentration following fluid vector<double> m_k; //!< solute partition coefficient vector<double> m_dkdJ; //!< 1st deriv of m_k with strain (J) vector< vector<double> > m_dkdc; //!< 1st deriv of m_k with effective concentration }; public: FESolutesMaterial(FEModel* pfem); // returns a pointer to a new material point object FEMaterialPointData* CreateMaterialPointData() override; //! performs initialization bool Init() override; //! data serialization void Serialize(DumpStream& ar) override; public: //! calculate solute molar flux vec3d SoluteFlux(FEMaterialPoint& pt, const int sol); //! actual concentration (as opposed to effective concentration) double Concentration(FEMaterialPoint& pt, const int sol); //! actual concentration (as opposed to effective concentration) double ConcentrationActual(FEMaterialPoint& pt, const int sol); //! actual fluid pressure (as opposed to effective pressure) double PressureActual(FEMaterialPoint& pt); //! partition coefficient double PartitionCoefficient(FEMaterialPoint& pt, const int sol); //! partition coefficients and their derivatives void PartitionCoefficientFunctions(FEMaterialPoint& mp, vector<double>& kappa, vector<double>& dkdJ, vector< vector<double> >& dkdc); //! solute density double SoluteDensity(const int sol) { return m_pSolute[sol]->Density(); } //! solute molar mass double SoluteMolarMass(const int sol) { return m_pSolute[sol]->MolarMass(); } //! Add a chemical reaction void AddChemicalReaction(FEChemicalReaction* pcr); // solute interface public: typedef FESolutesMaterial::Point SolutesMaterial_t; int Solutes() override { return (int)m_pSolute.size(); } FESolute* GetSolute(int i) override { return m_pSolute[i]; } double GetEffectiveSoluteConcentration(FEMaterialPoint& mp, int soluteIndex) override { SolutesMaterial_t* spt = (mp.ExtractData<SolutesMaterial_t>()); return spt->m_c[soluteIndex]; }; double GetActualSoluteConcentration(FEMaterialPoint& mp, int soluteIndex) override { SolutesMaterial_t* spt = (mp.ExtractData<SolutesMaterial_t>()); return spt->m_ca[soluteIndex]; }; double GetPartitionCoefficient(FEMaterialPoint& mp, int soluteIndex) override { SolutesMaterial_t* spt = (mp.ExtractData<SolutesMaterial_t>()); return spt->m_k[soluteIndex]; }; vec3d GetSoluteFlux(FEMaterialPoint& mp, int soluteIndex) override { SolutesMaterial_t* spt = (mp.ExtractData<SolutesMaterial_t>()); return spt->m_j[soluteIndex]; }; double GetOsmolarity(const FEMaterialPoint& mp) override { const SolutesMaterial_t* spt = (mp.ExtractData<SolutesMaterial_t>()); return spt->Osmolarity(); } double dkdc(const FEMaterialPoint& mp, int i, int j) override { const SolutesMaterial_t* spt = (mp.ExtractData<SolutesMaterial_t>()); return spt->m_dkdc[i][j]; } double dkdJ(const FEMaterialPoint& mp, int soluteIndex) override { const SolutesMaterial_t* spt = (mp.ExtractData<SolutesMaterial_t>()); return spt->m_dkdJ[soluteIndex]; } FEOsmoticCoefficient* GetOsmoticCoefficient() override { return m_pOsmC; } public: FEChemicalReaction* GetReaction (int i) { return m_pReact[i]; } int Reactions () { return (int) m_pReact.size(); } public: double m_Rgas; //!< universal gas constant double m_Tabs; //!< absolute temperature double m_Fc; //!< Faraday's constant private: // material properties std::vector<FESolute*> m_pSolute; //!< pointer to solute materials FEOsmoticCoefficient* m_pOsmC; //!< pointer to osmotic coefficient material std::vector<FEChemicalReaction*> m_pReact; //!< pointer to chemical reactions DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FETangentialFlowFSIStabilization.h
.h
2,483
70
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FESurfaceLoad.h> #include "febiofluid_api.h" //----------------------------------------------------------------------------- //! Tangential flow stabilization prescribes a shear traction that opposes //! tangential fluid velocity on a boundary surface, in the presence of normal //! flow. This can help stabilize inflow/outflow conditions. class FEBIOFLUID_API FETangentialFlowFSIStabilization : public FESurfaceLoad { public: //! constructor FETangentialFlowFSIStabilization(FEModel* pfem); //! Initialization bool Init() override; //! Set the surface to apply the load to void SetSurface(FESurface* ps) override; //! calculate pressure stiffness void StiffnessMatrix(FELinearSystem& LS) override; //! calculate load vector void LoadVector(FEGlobalVector& R) override; //! serialize data void Serialize(DumpStream& ar) override; protected: vec3d FluidVelocity(FESurfaceMaterialPoint& mp, double alpha); protected: double m_beta; //!< damping coefficient // degrees of freedom FEDofList m_dofU; FEDofList m_dofW; DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FECarreauFluid.cpp
.cpp
3,981
104
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FECarreauFluid.h" #include "FEFluid.h" // define the material parameters BEGIN_FECORE_CLASS(FECarreauFluid, FEViscousFluid) ADD_PARAMETER(m_mu0, FE_RANGE_GREATER_OR_EQUAL(0.0), "mu0")->setUnits("P.t")->setLongName("zero shear rate viscosity"); ADD_PARAMETER(m_mui, FE_RANGE_GREATER_OR_EQUAL(0.0), "mui")->setUnits("P.t")->setLongName("infinite shear rate viscosity"); ADD_PARAMETER(m_lam, FE_RANGE_GREATER_OR_EQUAL(0.0), "lambda")->setUnits(UNIT_TIME)->setLongName("relaxation time"); ADD_PARAMETER(m_n , FE_RANGE_GREATER_OR_EQUAL(0.0), "n")->setLongName("power index"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- //! Constructor. FECarreauFluid::FECarreauFluid(FEModel* pfem) : FEViscousFluid(pfem) { m_mu0 = 0; m_mui = 0; m_lam = 0; m_n = 1; } //----------------------------------------------------------------------------- //! viscous stress mat3ds FECarreauFluid::Stress(FEMaterialPoint& pt) { FEFluidMaterialPoint& vt = *pt.ExtractData<FEFluidMaterialPoint>(); mat3ds D = vt.RateOfDeformation(); double mu = ShearViscosity(pt); mat3ds s = D*(2*mu); return s; } //----------------------------------------------------------------------------- //! tangent of stress with respect to strain J mat3ds FECarreauFluid::Tangent_Strain(FEMaterialPoint& mp) { return mat3ds(0,0,0,0,0,0); } //----------------------------------------------------------------------------- //! tangent of stress with respect to rate of deformation tensor D tens4ds FECarreauFluid::Tangent_RateOfDeformation(FEMaterialPoint& pt) { FEFluidMaterialPoint& vt = *pt.ExtractData<FEFluidMaterialPoint>(); mat3ds D = vt.RateOfDeformation(); double gdot = sqrt(2*(D.sqr()).tr()); double lamg2 = m_lam*m_lam*gdot*gdot; double mu = m_mui + (m_mu0 - m_mui)*pow(1+lamg2, (m_n-1)*0.5); double dmu = 2*(m_mu0 - m_mui)*(m_n-1)*m_lam*m_lam*pow(1+lamg2, (m_n-3)*0.5); mat3dd I(1.0); tens4ds c = dyad1s(D)*(2*dmu) + dyad4s(I)*(2*mu); return c; } //----------------------------------------------------------------------------- //! dynamic viscosity double FECarreauFluid::ShearViscosity(FEMaterialPoint& pt) { FEFluidMaterialPoint& vt = *pt.ExtractData<FEFluidMaterialPoint>(); mat3ds D = vt.RateOfDeformation(); double gdot = sqrt(2*(D.sqr()).tr()); double mu = m_mui + (m_mu0 - m_mui)*pow(1+m_lam*m_lam*gdot*gdot, (m_n-1)*0.5); return mu; } //----------------------------------------------------------------------------- //! bulk viscosity double FECarreauFluid::BulkViscosity(FEMaterialPoint& pt) { return 2*ShearViscosity(pt)/3.; }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEBiphasicFSI.cpp
.cpp
9,433
276
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEBiphasicFSI.h" #include "FEFluidFSI.h" #include <FECore/FECoreKernel.h> #include <FECore/DumpStream.h> //----------------------------------------------------------------------------- BEGIN_FECORE_CLASS(FEBiphasicFSI, FEFluidFSI) ADD_PARAMETER(m_phi0 , FE_RANGE_CLOSED(0.0, 1.0), "phi0"); // material properties ADD_PROPERTY(m_pPerm, "permeability"); ADD_PROPERTY(m_pSupp, "solvent_supply", FEProperty::Optional); END_FECORE_CLASS(); //============================================================================ // FEFSIMaterialPoint //============================================================================ FEBiphasicFSIMaterialPoint::FEBiphasicFSIMaterialPoint(FEMaterialPointData* pt) : FEMaterialPointData(pt) {} //----------------------------------------------------------------------------- FEMaterialPointData* FEBiphasicFSIMaterialPoint::Copy() { FEBiphasicFSIMaterialPoint* pt = new FEBiphasicFSIMaterialPoint(*this); if (m_pNext) pt->m_pNext = m_pNext->Copy(); return pt; } //----------------------------------------------------------------------------- void FEBiphasicFSIMaterialPoint::Serialize(DumpStream& ar) { FEMaterialPointData::Serialize(ar); ar & m_phi0 & m_gradJ & m_Lw & m_ss; } //----------------------------------------------------------------------------- void FEBiphasicFSIMaterialPoint::Init() { m_gradJ = vec3d(0,0,0); m_phi0 = 0; m_Lw = mat3d(0.0); m_ss.zero(); FEMaterialPointData::Init(); } //============================================================================ // FEFluidFSI //============================================================================ //----------------------------------------------------------------------------- //! FEFluidFSI constructor FEBiphasicFSI::FEBiphasicFSI(FEModel* pfem) : FEFluidFSI(pfem) { m_rhoTw = 0; m_phi0 = 0; m_pPerm = nullptr; m_pSupp = nullptr; } //----------------------------------------------------------------------------- // returns a pointer to a new material point object FEMaterialPointData* FEBiphasicFSI::CreateMaterialPointData() { FEFluidMaterialPoint* fpt = new FEFluidMaterialPoint(m_pSolid->CreateMaterialPointData()); FEFSIMaterialPoint* fst = new FEFSIMaterialPoint(fpt); FEBiphasicFSIMaterialPoint* bfpt = new FEBiphasicFSIMaterialPoint(fst); return bfpt; } //----------------------------------------------------------------------------- // initialize bool FEBiphasicFSI::Init() { m_rhoTw = m_pFluid->m_rhor; m_pPerm->Init(); if (m_pSupp) m_pSupp->Init(); return FEMaterial::Init(); } //----------------------------------------------------------------------------- //! Porosity in current configuration double FEBiphasicFSI::Porosity(FEMaterialPoint& pt) { double phiw = 1 - SolidVolumeFrac(pt); // check for pore collapse // TODO: throw an error if pores collapse // phiw cant be 0 phiw = (phiw > 0) ? phiw : 0; return phiw; } //----------------------------------------------------------------------------- //! Solid Volume Frac (1 - porosity) in current configuration double FEBiphasicFSI::SolidVolumeFrac(FEMaterialPoint& pt) { FEElasticMaterialPoint& et = *pt.ExtractData<FEElasticMaterialPoint>(); FEBiphasicFSIMaterialPoint& bt = *pt.ExtractData<FEBiphasicFSIMaterialPoint>(); // relative volume double J = et.m_J; double phis = bt.m_phi0/J; //double phis = m_phi0(pt)/J; // check if phis is negative // TODO: throw an error if pores collapse phis = (phis >= 0) ? phis : 0; return phis; } //----------------------------------------------------------------------------- //! porosity gradient vec3d FEBiphasicFSI::gradPorosity(FEMaterialPoint& pt) { FEElasticMaterialPoint& et = *pt.ExtractData<FEElasticMaterialPoint>(); FEBiphasicFSIMaterialPoint& bt = *pt.ExtractData<FEBiphasicFSIMaterialPoint>(); double J = et.m_J; double phis = SolidVolumeFrac(pt); return bt.m_gradJ*(phis/J); } //----------------------------------------------------------------------------- //! porosity gradient vec3d FEBiphasicFSI::gradPhifPhis(FEMaterialPoint& pt) { FEElasticMaterialPoint& et = *pt.ExtractData<FEElasticMaterialPoint>(); FEBiphasicFSIMaterialPoint& bt = *pt.ExtractData<FEBiphasicFSIMaterialPoint>(); double phisr = SolidReferentialVolumeFraction(pt); vec3d gradphifphis = vec3d(0.0); if (phisr != 0) gradphifphis = bt.m_gradJ/phisr; return gradphifphis; } //----------------------------------------------------------------------------- //! Solid referential apparent density double FEBiphasicFSI::SolidReferentialApparentDensity(FEMaterialPoint& pt) { FEBiphasicFSIMaterialPoint& pet = *pt.ExtractData<FEBiphasicFSIMaterialPoint>(); // evaluate referential apparent density of base solid double density = TrueSolidDensity(pt); double rhosr = pet.m_phi0*density; return rhosr; } //----------------------------------------------------------------------------- //! Solid referential volume fraction double FEBiphasicFSI::SolidReferentialVolumeFraction(FEMaterialPoint& pt) { // get referential apparent density of base solid (assumed constant) double phisr = m_phi0(pt); return phisr; } //----------------------------------------------------------------------------- //! The stress of a poro-elastic material is the sum of the fluid stress //! and the elastic stress. Note that this function is declared in the base class //! so you do not have to reimplement it in a derived class, unless additional //! pressure terms are required. mat3ds FEBiphasicFSI::Stress(FEMaterialPoint& mp) { // calculate solid material stress mat3ds s = m_pSolid->Stress(mp); // add fluid stress s = s + m_pFluid->Stress(mp); return s; } //----------------------------------------------------------------------------- //! Return the permeability tensor as a double array void FEBiphasicFSI::Permeability(double k[3][3], FEMaterialPoint& pt) { mat3ds kt = m_pPerm->Permeability(pt); k[0][0] = kt.xx(); k[1][1] = kt.yy(); k[2][2] = kt.zz(); k[0][1] = k[1][0] = kt.xy(); k[1][2] = k[2][1] = kt.yz(); k[2][0] = k[0][2] = kt.xz(); } //----------------------------------------------------------------------------- mat3ds FEBiphasicFSI::Permeability(FEMaterialPoint& mp) { return m_pPerm->Permeability(mp); } //----------------------------------------------------------------------------- tens4dmm FEBiphasicFSI::Permeability_Tangent(FEMaterialPoint& mp) { //Return 0 if permeability is 0 to avoid NAN if (m_pPerm->Permeability(mp).xx() == 0.0 && m_pPerm->Permeability(mp).xy() == 0.0 && m_pPerm->Permeability(mp).xz() == 0.0 && m_pPerm->Permeability(mp).yy() == 0.0 && m_pPerm->Permeability(mp).yz() == 0.0 && m_pPerm->Permeability(mp).zz() == 0.0) return tens4dmm(0.0); else return m_pPerm->Tangent_Permeability_Strain(mp); } //----------------------------------------------------------------------------- mat3ds FEBiphasicFSI::InvPermeability(FEMaterialPoint& mp) { //Return 0 for inverse permeability when permeability is set to 0. //Acts as if permeability if infinite. if (m_pPerm->Permeability(mp).xx() == 0.0 && m_pPerm->Permeability(mp).xy() == 0.0 && m_pPerm->Permeability(mp).xz() == 0.0 && m_pPerm->Permeability(mp).yy() == 0.0 && m_pPerm->Permeability(mp).yz() == 0.0 && m_pPerm->Permeability(mp).zz() == 0.0) return mat3ds(0.0); else return m_pPerm->Permeability(mp).inverse(); } //----------------------------------------------------------------------------- double FEBiphasicFSI::FluidDensity(FEMaterialPoint& mp) { double rhoTf = TrueFluidDensity(mp); double phif = Porosity(mp); return rhoTf*phif; } //----------------------------------------------------------------------------- double FEBiphasicFSI::SolidDensity(FEMaterialPoint& mp) { double rhoTs = TrueSolidDensity(mp); double phis = SolidVolumeFrac(mp); return rhoTs*phis; }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEBodyMoment.cpp
.cpp
2,567
70
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEBodyMoment.h" #include "FEFluidMaterial.h" #include "FEPolarFluidDomain.h" //----------------------------------------------------------------------------- FEBodyMoment::FEBodyMoment(FEModel* pfem) : FEBodyLoad(pfem) { } //----------------------------------------------------------------------------- // NOTE: Work in progress! Working on integrating body loads as model loads void FEBodyMoment::LoadVector(FEGlobalVector& R) { for (int i = 0; i<Domains(); ++i) { FEDomain* dom = Domain(i); FEFluidMaterial* mat = dynamic_cast<FEFluidMaterial*>(dom->GetMaterial()); if (mat == nullptr) { FEPolarFluidDomain* pfdom = dynamic_cast<FEPolarFluidDomain*>(dom); if (pfdom) pfdom->BodyMoment(R, *this); } } } //----------------------------------------------------------------------------- // NOTE: Work in progress! Working on integrating body loads as model loads void FEBodyMoment::StiffnessMatrix(FELinearSystem& LS) { for (int i = 0; i<Domains(); ++i) { FEDomain* dom = Domain(i); FEFluidMaterial* mat = dynamic_cast<FEFluidMaterial*>(dom->GetMaterial()); if (mat==nullptr) { FEPolarFluidDomain* pfdom = dynamic_cast<FEPolarFluidDomain*>(dom); if (pfdom) pfdom->BodyMomentStiffness(LS, *this); } } }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEMultiphasicFSISolver.cpp
.cpp
57,347
1,560
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2020 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEFluidFSISolver.h" #include "FEMultiphasicFSISolver.h" #include "FEFluidResidualVector.h" #include "FEBioMech/FEElasticDomain.h" #include "FEBioMech/FEPressureLoad.h" #include "FEBioMech/FERigidConnector.h" #include "FEBioMech/FESlidingElasticInterface.h" #include "FEBioMech/FESSIShellDomain.h" #include "FEBioMech/FEResidualVector.h" #include "FEFluidFSIDomain.h" #include "FEFluidDomain.h" #include "FEBiphasicFSIDomain.h" #include "FEMultiphasicFSIDomain.h" #include "FECore/FEModel.h" #include "FECore/log.h" #include "FECore/DOFS.h" #include <assert.h> #include "FECore/FEGlobalMatrix.h" #include "FECore/sys.h" #include "FEBioMech/FE3FieldElasticSolidDomain.h" #include "FEBioMech/FE3FieldElasticShellDomain.h" #include "FEBioMech/FEUncoupledMaterial.h" #include <FEBioMech/FEBodyForce.h> #include <FECore/FEBoundaryCondition.h> #include <FECore/FENodalLoad.h> #include <FECore/FESurfaceLoad.h> #include <FECore/FEModelLoad.h> #include <FECore/FEAnalysis.h> #include <FECore/FELinearConstraintManager.h> #include <FECore/DumpStream.h> #include <FEBioMech/FESolidLinearSystem.h> #include "FEBioFSI.h" #include "FEBioMultiphasicFSI.h" #include "FEMultiphasicFSIAnalysis.h" //----------------------------------------------------------------------------- // define the parameter list BEGIN_FECORE_CLASS(FEMultiphasicFSISolver, FENewtonSolver) ADD_PARAMETER(m_Dtol , "dtol" ); ADD_PARAMETER(m_Vtol , "vtol" ); ADD_PARAMETER(m_Ftol , "ftol" ); ADD_PARAMETER(m_Ctol , "ctol" ); ADD_PARAMETER(m_Etol, FE_RANGE_GREATER_OR_EQUAL(0.0), "etol"); ADD_PARAMETER(m_Rtol, FE_RANGE_GREATER_OR_EQUAL(0.0), "rtol"); ADD_PARAMETER(m_rhoi , "rhoi" ); ADD_PARAMETER(m_pred , "predictor" ); ADD_PARAMETER(m_minJf, "min_volume_ratio"); ADD_PARAMETER(m_order, "order" ); ADD_PARAMETER(m_forcePositive, "force_positive_concentrations"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- //! FEFluidFSISolver Construction // FEMultiphasicFSISolver::FEMultiphasicFSISolver(FEModel* pfem) : FENewtonSolver(pfem), m_rigidSolver(pfem), \ m_dofU(pfem), m_dofV(pfem), m_dofSU(pfem), m_dofSV(pfem), m_dofSA(pfem),m_dofR(pfem), m_dofVF(pfem),m_dofAF(pfem),m_dofW(pfem), m_dofAW(pfem), m_dofEF(pfem) { // default values m_Rtol = 0.001; m_Etol = 0.01; m_Dtol = 0.001; m_Vtol = 0.001; m_Ftol = 0.001; m_Ctol = 0.01; m_Rmin = 1.0e-20; m_Rmax = 0; // not used if zero m_minJf = 0; m_ndeq = 0; m_nveq = 0; m_nfeq = 0; m_niter = 0; m_nreq = 0; // assume non-symmetric m_msymm = REAL_UNSYMMETRIC; // default Newmark parameters for rhoi = 0 m_rhoi = 0; m_alphaf = 1; m_alpham = 1.5; m_beta = 0.5625; m_gamma = 1; m_pred = 0; m_order = 2; m_forcePositive = true; // force all concentrations to remain positive // Preferred strategy is Broyden's method SetDefaultStrategy(QN_BROYDEN); // turn off checking for a zero diagonal CheckZeroDiagonal(false); // get the dof indices // TODO: Can this be done in Init, since there is no error checking if (pfem) { m_dofU.AddVariable(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::DISPLACEMENT)); m_dofV.AddVariable(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::VELOCITY)); m_dofSU.AddVariable(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::SHELL_DISPLACEMENT)); m_dofSV.AddVariable(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::SHELL_VELOCITY)); m_dofSA.AddVariable(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::SHELL_ACCELERATION)); m_dofR.AddVariable(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::RIGID_ROTATION)); m_dofW.AddVariable(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::RELATIVE_FLUID_VELOCITY)); m_dofAW.AddVariable(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::RELATIVE_FLUID_ACCELERATION)); m_dofVF.AddVariable(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::FLUID_VELOCITY)); m_dofAF.AddVariable(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::FLUID_ACCELERATION)); m_dofEF.AddVariable(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::FLUID_DILATATION)); m_dofAEF = pfem->GetDOFIndex(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::FLUID_DILATATION_TDERIV), 0); m_dofC = m_dofAC = -1; } } //----------------------------------------------------------------------------- FEMultiphasicFSISolver::~FEMultiphasicFSISolver() { } //----------------------------------------------------------------------------- //! Generate warnings if needed void FEMultiphasicFSISolver:: SolverWarnings() { FEModel& fem = *GetFEModel(); // Generate warning if rigid connectors are used with symmetric stiffness if (m_msymm == REAL_SYMMETRIC) { for (int i=0; i<fem.NonlinearConstraints(); ++i) { FENLConstraint* plc = fem.NonlinearConstraint(i); FERigidConnector* prc = dynamic_cast<FERigidConnector*>(plc); if (prc) { feLogWarning("Rigid connectors require non-symmetric stiffness matrix.\nSet symmetric_stiffness flag to 0 in Control section."); break; } } // Generate warning if sliding-elastic contact is used with symmetric stiffness if (fem.SurfacePairConstraints() > 0) { // loop over all contact interfaces for (int i = 0; i<fem.SurfacePairConstraints(); ++i) { FEContactInterface* pci = dynamic_cast<FEContactInterface*>(fem.SurfacePairConstraint(i)); FESlidingElasticInterface* pbw = dynamic_cast<FESlidingElasticInterface*>(pci); if (pbw) { feLogWarning("The sliding-elastic contact algorithm runs better with a non-symmetric stiffness matrix.\nYou may set symmetric_stiffness 0 to false in Control section."); break; } } } } } //----------------------------------------------------------------------------- //! Allocates and initializes the data structures used by the FEFluidFSISolver // bool FEMultiphasicFSISolver::Init() { // initialize base class if (FENewtonSolver::Init() == false) return false; // check parameters if (m_Dtol < 0.0) { feLogError("dtol must be nonnegative."); return false; } if (m_Vtol < 0.0) { feLogError("vtol must be nonnegative."); return false; } if (m_Ftol < 0.0) { feLogError("ftol must be nonnegative."); return false; } if (m_Ctol < 0.0) { feLogError("ctol must be nonnegative."); return false; } if (m_Etol < 0.0) { feLogError("etol must be nonnegative."); return false; } if (m_Rtol < 0.0) { feLogError("rtol must be nonnegative."); return false; } if (m_rhoi == -1) { m_alphaf = m_alpham = m_beta = m_gamma = 1.0; } else if ((m_rhoi >= 0) && (m_rhoi <= 1)) { m_alphaf = 1.0/(1+m_rhoi); if (m_order == 1) m_alpham = (3-m_rhoi)/(1+m_rhoi)/2; // 1st-order system else m_alpham = (2-m_rhoi)/(1+m_rhoi); // 2nd-order system m_beta = pow(1 + m_alpham - m_alphaf,2)/4; m_gamma = 0.5 + m_alpham - m_alphaf; } else { feLogError("rhoi must be -1 or between 0 and 1.\n"); return false; } // allocate vectors int neq = m_neq; m_Fr.assign(neq, 0); m_Ui.assign(neq, 0); m_Ut.assign(neq, 0); m_di.assign(m_ndeq,0); m_Di.assign(m_ndeq,0); m_vi.assign(m_nveq,0); m_Vi.assign(m_nveq,0); m_fi.assign(m_nfeq,0); m_Fi.assign(m_nfeq,0); // get number of DOFS FEModel& fem = *GetFEModel(); DOFS& fedofs = fem.GetDOFS(); int MAX_CDOFS = fedofs.GetVariableSize(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::FLUID_CONCENTRATION)); // allocate concentration-vectors m_ci.assign(MAX_CDOFS,vector<double>(0,0)); m_Ci.assign(MAX_CDOFS,vector<double>(0,0)); for (int i=0; i<MAX_CDOFS; ++i) { m_ci[i].assign(m_nceq[i], 0); m_Ci[i].assign(m_nceq[i], 0); } vector<int> dofs; for (int j=0; j<(int)m_nceq.size(); ++j) { if (m_nceq[j]) { dofs.push_back(m_dofC + j); } } // we need to fill the total DOF vector m_Ut // TODO: I need to find an easier way to do this FEMesh& mesh = fem.GetMesh(); gather(m_Ut, mesh, m_dofU[0]); gather(m_Ut, mesh, m_dofU[1]); gather(m_Ut, mesh, m_dofU[2]); gather(m_Ut, mesh, m_dofSU[0]); gather(m_Ut, mesh, m_dofSU[1]); gather(m_Ut, mesh, m_dofSU[2]); gather(m_Ut, mesh, m_dofW[0]); gather(m_Ut, mesh, m_dofW[1]); gather(m_Ut, mesh, m_dofW[2]); gather(m_Ut, mesh, m_dofEF[0]); gather(m_Ut, mesh, dofs); // set flag for transient or steady-state analyses FEAnalysis* pstep = fem.GetCurrentStep(); for (int i=0; i<mesh.Domains(); ++i) { FEDomain& dom = mesh.Domain(i); if (dom.IsActive()) { FEFluidDomain* fdom = dynamic_cast<FEFluidDomain*>(&dom); FEFluidFSIDomain* fsidom = dynamic_cast<FEFluidFSIDomain*>(&dom); FEBiphasicFSIDomain* bfsidom = dynamic_cast<FEBiphasicFSIDomain*>(&dom); FEMultiphasicFSIDomain* mfsidom = dynamic_cast<FEMultiphasicFSIDomain*>(&dom); if (fdom) { if (pstep->m_nanalysis == FEMultiphasicFSIAnalysis::STEADY_STATE) fdom->SetSteadyStateAnalysis(); else fdom->SetTransientAnalysis(); } else if (fsidom) { if (pstep->m_nanalysis == FEMultiphasicFSIAnalysis::STEADY_STATE) fsidom->SetSteadyStateAnalysis(); else fsidom->SetTransientAnalysis(); } else if (bfsidom) { if (pstep->m_nanalysis == FEMultiphasicFSIAnalysis::STEADY_STATE) bfsidom->SetSteadyStateAnalysis(); else bfsidom->SetTransientAnalysis(); } else if (mfsidom) { if (pstep->m_nanalysis == FEMultiphasicFSIAnalysis::STEADY_STATE) mfsidom->SetSteadyStateAnalysis(); else mfsidom->SetTransientAnalysis(); } } } SolverWarnings(); return true; } //----------------------------------------------------------------------------- //! Initialize equations bool FEMultiphasicFSISolver::InitEquations() { // base class initialization if (FENewtonSolver::InitEquations() == false) return false; if (m_eq_scheme == EQUATION_SCHEME::BLOCK) { // merge the second and third partition if (m_part.size() == 3) { vector<int> newPart(2); newPart[0] = m_part[0]; newPart[1] = m_part[1] + m_part[2]; m_part = newPart; } } // store the number of equations we currently have m_nreq = m_neq; // Next, we assign equation numbers to the rigid body degrees of freedom int neq = m_rigidSolver.InitEquations(m_neq); if (neq == -1) return false; else m_neq = neq; // determine the number of velocity and dilatation equations FEModel& fem = *GetFEModel(); m_dofC = fem.GetDOFIndex(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::FLUID_CONCENTRATION), 0); m_dofAC = fem.GetDOFIndex(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::FLUID_CONCENTRATION_TDERIV), 0); FEMesh& mesh = fem.GetMesh(); m_ndeq = m_nveq = m_nfeq = 0; for (int i=0; i<mesh.Nodes(); ++i) { FENode& n = mesh.Node(i); if (n.m_ID[m_dofU[0] ] != -1) m_ndeq++; if (n.m_ID[m_dofU[1] ] != -1) m_ndeq++; if (n.m_ID[m_dofU[2] ] != -1) m_ndeq++; if (n.m_ID[m_dofSU[0]] != -1) m_ndeq++; if (n.m_ID[m_dofSU[1]] != -1) m_ndeq++; if (n.m_ID[m_dofSU[2]] != -1) m_ndeq++; if (n.m_ID[m_dofW[0] ] != -1) m_nveq++; if (n.m_ID[m_dofW[1] ] != -1) m_nveq++; if (n.m_ID[m_dofW[2] ] != -1) m_nveq++; if (n.m_ID[m_dofEF[0]] != -1) m_nfeq++; } // determine the nr of concentration equations DOFS& fedofs = fem.GetDOFS(); int MAX_CDOFS = fedofs.GetVariableSize(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::FLUID_CONCENTRATION)); m_nceq.assign(MAX_CDOFS, 0); // get number of DOFS for (int i=0; i<mesh.Nodes(); ++i) { FENode& n = mesh.Node(i); for (int j=0; j<MAX_CDOFS; ++j) { if (n.m_ID[m_dofC+j] != -1) m_nceq[j]++; } } // get the total concentration equations m_nseq = 0; for (int i = 0; i < MAX_CDOFS; ++i) m_nseq += m_nceq[i]; // Next, we add any Lagrange Multipliers for (int i = 0; i < fem.NonlinearConstraints(); ++i) { FENLConstraint* lmc = fem.NonlinearConstraint(i); if (lmc->IsActive()) { m_neq += lmc->InitEquations(m_neq); } } for (int i = 0; i < fem.SurfacePairConstraints(); ++i) { FESurfacePairConstraint* spc = fem.SurfacePairConstraint(i); if (spc->IsActive()) { m_neq += spc->InitEquations(m_neq); } } // All initialization is done return true; } //----------------------------------------------------------------------------- void FEMultiphasicFSISolver::GetDisplacementData(vector<double> &xi, vector<double> &ui) { FEModel& fem = *GetFEModel(); int N = fem.GetMesh().Nodes(), nid, m = 0; zero(xi); for (int i=0; i<N; ++i) { FENode& n = fem.GetMesh().Node(i); nid = n.m_ID[m_dofU[0]]; if (nid != -1) { nid = (nid < -1 ? -nid-2 : nid); xi[m++] = ui[nid]; assert(m <= (int) xi.size()); } nid = n.m_ID[m_dofU[1]]; if (nid != -1) { nid = (nid < -1 ? -nid-2 : nid); xi[m++] = ui[nid]; assert(m <= (int) xi.size()); } nid = n.m_ID[m_dofU[2]]; if (nid != -1) { nid = (nid < -1 ? -nid-2 : nid); xi[m++] = ui[nid]; assert(m <= (int) xi.size()); } nid = n.m_ID[m_dofSU[0]]; if (nid != -1) { nid = (nid < -1 ? -nid-2 : nid); xi[m++] = ui[nid]; assert(m <= (int) xi.size()); } nid = n.m_ID[m_dofSU[1]]; if (nid != -1) { nid = (nid < -1 ? -nid-2 : nid); xi[m++] = ui[nid]; assert(m <= (int) xi.size()); } nid = n.m_ID[m_dofSU[2]]; if (nid != -1) { nid = (nid < -1 ? -nid-2 : nid); xi[m++] = ui[nid]; assert(m <= (int) xi.size()); } } } //----------------------------------------------------------------------------- void FEMultiphasicFSISolver::GetVelocityData(vector<double> &vi, vector<double> &ui) { FEModel& fem = *GetFEModel(); int N = fem.GetMesh().Nodes(), nid, m = 0; zero(vi); for (int i=0; i<N; ++i) { FENode& n = fem.GetMesh().Node(i); nid = n.m_ID[m_dofW[0]]; if (nid != -1) { nid = (nid < -1 ? -nid-2 : nid); vi[m++] = ui[nid]; assert(m <= (int) vi.size()); } nid = n.m_ID[m_dofW[1]]; if (nid != -1) { nid = (nid < -1 ? -nid-2 : nid); vi[m++] = ui[nid]; assert(m <= (int) vi.size()); } nid = n.m_ID[m_dofW[2]]; if (nid != -1) { nid = (nid < -1 ? -nid-2 : nid); vi[m++] = ui[nid]; assert(m <= (int) vi.size()); } } } //----------------------------------------------------------------------------- void FEMultiphasicFSISolver::GetDilatationData(vector<double> &ei, vector<double> &ui) { FEModel& fem = *GetFEModel(); int N = fem.GetMesh().Nodes(), nid, m = 0; zero(ei); for (int i=0; i<N; ++i) { FENode& n = fem.GetMesh().Node(i); nid = n.m_ID[m_dofEF[0]]; if (nid != -1) { nid = (nid < -1 ? -nid-2 : nid); ei[m++] = ui[nid]; assert(m <= (int) ei.size()); } } } //----------------------------------------------------------------------------- void FEMultiphasicFSISolver::GetConcentrationData(vector<double> &ci, vector<double> &ui, const int sol) { FEModel& fem = *GetFEModel(); int N = fem.GetMesh().Nodes(), nid, m = 0; zero(ci); for (int i=0; i<N; ++i) { FENode& n = fem.GetMesh().Node(i); nid = n.m_ID[m_dofC+sol]; if (nid != -1) { nid = (nid < -1 ? -nid-2 : nid); ci[m++] = ui[nid]; assert(m <= (int) ci.size()); } } } //----------------------------------------------------------------------------- //! Save data to dump file void FEMultiphasicFSISolver::Serialize(DumpStream& ar) { // Serialize parameters FENewtonSolver::Serialize(ar); // serialize rigid solver m_rigidSolver.Serialize(ar); ar & m_nreq & m_ndeq & m_nfeq & m_nveq & m_nseq & m_nceq; ar & m_nrhs & m_niter & m_nref & m_ntotref; if (ar.IsLoading()) { m_Fr.assign(m_neq, 0); m_Vi.assign(m_nveq,0); m_Di.assign(m_ndeq,0); for (int i=0; i<m_nceq.size(); ++i) { m_ci[i].assign(m_nceq[i], 0); m_Ci[i].assign(m_nceq[i], 0); } } ar & m_Ui & m_Ut & m_Fr; ar & m_Di & m_Vi & m_Fi & m_Ci; if (ar.IsShallow()) return; ar & m_rhoi & m_alphaf & m_alpham; ar & m_beta & m_gamma; ar & m_pred; } //----------------------------------------------------------------------------- //! Update the kinematics of the model, such as nodal positions, velocities, //! accelerations, etc. void FEMultiphasicFSISolver::UpdateKinematics(vector<double>& ui) { FEModel& fem = *GetFEModel(); // get the mesh FEMesh& mesh = fem.GetMesh(); // update rigid bodies m_rigidSolver.UpdateRigidBodies(m_Ui, ui); // update nodes vector<double> U(m_Ut.size()); for (size_t i=0; i<m_Ut.size(); ++i) U[i] = ui[i] + m_Ui[i] + m_Ut[i]; scatter(U, mesh, m_dofU[0]); scatter(U, mesh, m_dofU[1]); scatter(U, mesh, m_dofU[2]); scatter(U, mesh, m_dofSU[0]); scatter(U, mesh, m_dofSU[1]); scatter(U, mesh, m_dofSU[2]); scatter(U, mesh, m_dofW[0]); scatter(U, mesh, m_dofW[1]); scatter(U, mesh, m_dofW[2]); scatter(U, mesh, m_dofEF[0]); // get number of DOFS DOFS& fedofs = fem.GetDOFS(); int MAX_CDOFS = fedofs.GetVariableSize(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::FLUID_CONCENTRATION)); // update solute data for (int i=0; i<mesh.Nodes(); ++i) { FENode& node = mesh.Node(i); // update nodal concentration for (int j=0; j<MAX_CDOFS; ++j) { int n = node.m_ID[m_dofC+j]; // Force the concentrations to remain positive if (n >= 0) { double ct = 0 + m_Ut[n] + m_Ui[n] + ui[n]; if ((ct < 0.0) && m_forcePositive) ct = 0.0; node.set(m_dofC + j, ct); } } } // force dilatations to remain greater than -1 if (m_minJf > 0) { const int NN = mesh.Nodes(); for (int i=0; i<NN; ++i) { FENode& node = mesh.Node(i); if (node.get(m_dofEF[0]) <= -1.0) node.set(m_dofEF[0], m_minJf - 1.0); } } // make sure the prescribed BCs are fulfilled int nvel = fem.BoundaryConditions(); for (int i=0; i<nvel; ++i) { FEBoundaryCondition& bc = *fem.BoundaryCondition(i); if (bc.IsActive()) bc.Update(); } // apply prescribed DOFs for specialized surface loads int nsl = fem.ModelLoads(); for (int i=0; i<nsl; ++i) { FEModelLoad& pml = *fem.ModelLoad(i); if (pml.IsActive()) pml.Update(); } // enforce the linear constraints // TODO: do we really have to do this? Shouldn't the algorithm // already guarantee that the linear constraints are satisfied? FELinearConstraintManager& LCM = fem.GetLinearConstraintManager(); if (LCM.LinearConstraints() > 0) { LCM.Update(); } // Update the spatial nodal positions // Don't update rigid nodes since they are already updated for (int i = 0; i<mesh.Nodes(); ++i) { FENode& node = mesh.Node(i); if (node.m_rid == -1) { node.m_rt = node.m_r0 + node.get_vec3d(m_dofU[0], m_dofU[1], m_dofU[2]); node.m_dt = node.m_d0 + node.get_vec3d(m_dofU[0], m_dofU[1], m_dofU[2]) - node.get_vec3d(m_dofSU[0], m_dofSU[1], m_dofSU[2]); } } // update time derivatives of velocity and dilatation // for dynamic simulations FEAnalysis* pstep = fem.GetCurrentStep(); if (pstep->m_nanalysis == FEMultiphasicFSIAnalysis::DYNAMIC) { int N = mesh.Nodes(); double dt = fem.GetTime().timeIncrement; double a = 1.0 / (m_beta*dt); double b = a / dt; double c = 1.0 - 0.5/m_beta; double cgi = 1 - 1.0/m_gamma; for (int i=0; i<N; ++i) { FENode& n = mesh.Node(i); // solid acceleration n.m_at = (n.m_rt - n.m_rp)*b - n.m_vp*a + n.m_ap*c; // solid velocity vec3d vt = n.m_vp + (n.m_ap*(1.0 - m_gamma) + n.m_at*m_gamma)*dt; n.set_vec3d(m_dofV[0], m_dofV[1], m_dofV[2], vt); // shell kinematics vec3d qt = n.get_vec3d(m_dofSU[0], m_dofSU[1], m_dofSU[2]); vec3d qp = n.get_vec3d_prev(m_dofSU[0], m_dofSU[1], m_dofSU[2]); vec3d vqp = n.get_vec3d_prev(m_dofSV[0], m_dofSV[1], m_dofSV[2]); vec3d aqp = n.get_vec3d_prev(m_dofSA[0], m_dofSA[1], m_dofSA[2]); vec3d aqt = (qt - qp)*b - vqp*a + aqp*c; vec3d vqt = vqp + (aqp*(1.0 - m_gamma) + aqt*m_gamma)*dt; n.set_vec3d(m_dofSA[0], m_dofSA[1], m_dofSA[2], aqt); n.set_vec3d(m_dofSV[0], m_dofSV[1], m_dofSV[2], vqt); // relative fluid velocity material time derivative (in solid frame) vec3d wt = n.get_vec3d(m_dofW[0], m_dofW[1], m_dofW[2]); vec3d wp = n.get_vec3d_prev(m_dofW[0], m_dofW[1], m_dofW[2]); vec3d awt = n.get_vec3d(m_dofAW[0], m_dofAW[1], m_dofAW[2]); vec3d awp = n.get_vec3d_prev(m_dofAW[0], m_dofAW[1], m_dofAW[2]); awt = awp*cgi + (wt - wp)/(m_gamma*dt); n.set_vec3d(m_dofAW[0], m_dofAW[1], m_dofAW[2], awt); // fluid velocity vec3d vft = vt + wt; n.set_vec3d(m_dofVF[0], m_dofVF[1], m_dofVF[2], vft); // material time derivative of fluid velocity (in solid frame) vec3d aft = n.m_at + awt; n.set_vec3d(m_dofAF[0], m_dofAF[1], m_dofAF[2], aft); // dilatation time derivative double eft = n.get(m_dofEF[0]); double efp = n.get_prev(m_dofEF[0]); double aefp = n.get_prev(m_dofAEF); double aeft = aefp*cgi + (eft - efp)/(m_gamma*dt); n.set(m_dofAEF, aeft); // concentration time derivative // update nodal concentration for (int j=0; j<MAX_CDOFS; ++j) { int k = n.m_ID[m_dofC+j]; // Force the concentrations to remain positive if (k >= 0) { double ct = n.get(m_dofC+j); double cp = n.get_prev(m_dofC+j); double acp = n.get_prev(m_dofAC+j); double act = acp*cgi + (ct - cp)/(m_gamma*dt); n.set(m_dofAC + j, act); } } } } } //----------------------------------------------------------------------------- //! Update DOF increments void FEMultiphasicFSISolver::UpdateIncrements(vector<double>& Ui, vector<double>& ui, bool emap) { FEModel& fem = *GetFEModel(); // get the mesh FEMesh& mesh = fem.GetMesh(); // update rigid bodies m_rigidSolver.UpdateIncrements(Ui, ui, emap); DOFS& fedofs = fem.GetDOFS(); int MAX_CDOFS = fedofs.GetVariableSize(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::FLUID_CONCENTRATION)); // update flexible nodes int n; for (int i=0; i<mesh.Nodes(); ++i) { FENode& node = mesh.Node(i); // displacement dofs // current position = initial + total at prev conv step + total increment so far + current increment if ((n = node.m_ID[m_dofU[0]]) >= 0) Ui[n] += ui[n]; if ((n = node.m_ID[m_dofU[1]]) >= 0) Ui[n] += ui[n]; if ((n = node.m_ID[m_dofU[2]]) >= 0) Ui[n] += ui[n]; // rotational dofs if ((n = node.m_ID[m_dofSU[0]]) >= 0) Ui[n] += ui[n]; if ((n = node.m_ID[m_dofSU[1]]) >= 0) Ui[n] += ui[n]; if ((n = node.m_ID[m_dofSU[2]]) >= 0) Ui[n] += ui[n]; // fluid relative velocity if ((n = node.m_ID[m_dofW[0]]) >= 0) Ui[n] += ui[n]; if ((n = node.m_ID[m_dofW[1]]) >= 0) Ui[n] += ui[n]; if ((n = node.m_ID[m_dofW[2]]) >= 0) Ui[n] += ui[n]; // fluid dilatation if ((n = node.m_ID[m_dofEF[0]]) >= 0) Ui[n] += ui[n]; // update nodal concentration for (int j=0; j<MAX_CDOFS; ++j) { if((n = node.m_ID[m_dofC+j]) >= 0) { Ui[n] += ui[n]; } } } } //----------------------------------------------------------------------------- //! Updates the current state of the model void FEMultiphasicFSISolver::Update(vector<double>& ui) { FEModel& fem = *GetFEModel(); FETimeInfo& tp = fem.GetTime(); tp.currentIteration = m_niter; // update EAS UpdateEAS(ui); UpdateIncrementsEAS(ui, true); // update kinematics UpdateKinematics(ui); // update element stresses UpdateModel(); } //----------------------------------------------------------------------------- //! Update EAS void FEMultiphasicFSISolver::UpdateEAS(vector<double>& ui) { FEModel& fem = *GetFEModel(); FEMesh& mesh = fem.GetMesh(); // update EAS on shell domains for (int i=0; i<mesh.Domains(); ++i) { FESSIShellDomain* sdom = dynamic_cast<FESSIShellDomain*>(&mesh.Domain(i)); if (sdom && sdom->IsActive()) sdom->UpdateEAS(ui); } } //----------------------------------------------------------------------------- //! Update EAS void FEMultiphasicFSISolver::UpdateIncrementsEAS(vector<double>& ui, const bool binc) { FEModel& fem = *GetFEModel(); FEMesh& mesh = fem.GetMesh(); // update EAS on shell domains for (int i=0; i<mesh.Domains(); ++i) { FESSIShellDomain* sdom = dynamic_cast<FESSIShellDomain*>(&mesh.Domain(i)); if (sdom && sdom->IsActive()) sdom->UpdateIncrementsEAS(ui, binc); } } //----------------------------------------------------------------------------- bool FEMultiphasicFSISolver::InitStep(double time) { FEModel& fem = *GetFEModel(); // get time integration parameters FETimeInfo& tp = fem.GetTime(); tp.alpha = m_alphaf; tp.beta = m_beta; tp.gamma = m_gamma; tp.alphaf = m_alphaf; tp.alpham = m_alpham; // evaluate load curve values at current (or intermediate) time double t = tp.currentTime; // double dt = tp.timeIncrement; // double ta = (t > 0) ? t - (1-m_alpha)*dt : m_alpha*dt; // return FESolver::InitStep(ta); return FESolver::InitStep(t); } //----------------------------------------------------------------------------- //! Prepares the data for the first BFGS-iteration. void FEMultiphasicFSISolver::PrepStep() { FEModel& fem = *GetFEModel(); DOFS& fedofs = fem.GetDOFS(); int MAX_CDOFS = fedofs.GetVariableSize(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::FLUID_CONCENTRATION)); FETimeInfo& tp = fem.GetTime(); double dt = tp.timeIncrement; tp.currentIteration = m_niter; // zero total DOFs zero(m_Ui); zero(m_Vi); zero(m_Di); zero(m_Fi); for (int j=0; j<(int)m_nceq.size(); ++j) if (m_nceq[j]) zero(m_Ci[j]); // store previous mesh state // we need them for strain and acceleration calculations FEMesh& mesh = fem.GetMesh(); for (int i=0; i<mesh.Nodes(); ++i) { FENode& ni = mesh.Node(i); ni.m_rp = ni.m_rt; ni.m_vp = ni.get_vec3d(m_dofV[0], m_dofV[1], m_dofV[2]); ni.m_ap = ni.m_at; ni.m_dp = ni.m_dt = ni.m_d0; ni.UpdateValues(); switch (m_pred) { case 0: { // initial guess at start of new time step (default) // solid ni.m_at = ni.m_ap*(1-0.5/m_beta) - ni.m_vp/(m_beta*dt); vec3d vs = ni.m_vp + (ni.m_at*m_gamma + ni.m_ap*(1-m_gamma))*dt; ni.set_vec3d(m_dofV[0], m_dofV[1], m_dofV[2], vs); // solid shell vec3d aqp = ni.get_vec3d_prev(m_dofSA[0], m_dofSA[1], m_dofSA[2]); vec3d vqp = ni.get_vec3d_prev(m_dofSV[0], m_dofSV[1], m_dofSV[2]); vec3d aqt = aqp*(1-0.5/m_beta) - vqp/(m_beta*dt); ni.set_vec3d(m_dofSA[0], m_dofSA[1], m_dofSA[2], aqt); vec3d vqt = vqp + (aqt*m_gamma + aqp*(1-m_gamma))*dt; ni.set_vec3d(m_dofSV[0], m_dofSV[1], m_dofSV[2], vqt); // fluid vec3d awp = ni.get_vec3d_prev(m_dofAW[0], m_dofAW[1], m_dofAW[2]); ni.set_vec3d(m_dofAW[0], m_dofAW[1], m_dofAW[2], awp*(m_gamma-1)/m_gamma); ni.set(m_dofAEF, ni.get_prev(m_dofAEF)*(m_gamma-1)/m_gamma); // update nodal concentration for (int j=0; j<MAX_CDOFS; ++j) ni.set(m_dofAC+j, ni.get_prev(m_dofAC+j)*(m_gamma-1)/m_gamma); } break; case 1: { // initial guess at start of new time step (Zero Ydot) ni.m_at = vec3d(0,0,0); ni.set_vec3d(m_dofAW[0], m_dofAW[1], m_dofAW[2],vec3d(0,0,0)); ni.set(m_dofAEF, 0); for (int j=0; j<MAX_CDOFS; ++j) ni.set(m_dofAC+j, 0); ni.set_vec3d(m_dofV[0], m_dofV[1], m_dofV[2], ni.m_vp + ni.m_ap*dt*(1-m_gamma)*m_alphaf); vec3d wp = ni.get_vec3d_prev(m_dofW[0], m_dofW[1], m_dofW[2]); vec3d awp = ni.get_vec3d_prev(m_dofAW[0], m_dofAW[1], m_dofAW[2]); ni.set_vec3d(m_dofW[0], m_dofW[1], m_dofW[2], wp + awp*dt*(1-m_gamma)*m_alphaf); ni.set(m_dofEF[0], ni.get_prev(m_dofEF[0]) + ni.get_prev(m_dofAEF)*dt*(1-m_gamma)*m_alphaf); for (int j=0; j<MAX_CDOFS; ++j) ni.set(m_dofC+j, ni.get_prev(m_dofC+j) + ni.get_prev(m_dofAC+j)*dt*(1-m_gamma)*m_alphaf); } break; case 2: { // initial guess at start of new time step (Same Ydot) vec3d awp = ni.get_vec3d_prev(m_dofAW[0], m_dofAW[1], m_dofAW[2]); ni.set_vec3d(m_dofAW[0], m_dofAW[1], m_dofAW[2], awp); ni.set(m_dofAEF, ni.get_prev(m_dofAEF)); for (int j=0; j<MAX_CDOFS; ++j) ni.set(m_dofAC+j, ni.get_prev(m_dofAC+j)); ni.set_vec3d(m_dofV[0], m_dofV[1], m_dofV[2], ni.m_vp + ni.m_ap*dt); vec3d wp = ni.get_vec3d_prev(m_dofW[0], m_dofW[1], m_dofW[2]); ni.set_vec3d(m_dofW[0], m_dofW[1], m_dofW[2], wp + awp*dt); ni.set(m_dofEF[0], ni.get_prev(m_dofEF[0]) + ni.get_prev(m_dofAEF)*dt); for (int j=0; j<MAX_CDOFS; ++j) ni.set(m_dofC+j, ni.get_prev(m_dofC+j) + ni.get_prev(m_dofAC+j)*dt); } break; default: break; } } // apply prescribed velocities // we save the prescribed velocity increments in the ui vector vector<double>& ui = m_ui; zero(ui); int nbc = fem.BoundaryConditions(); for (int i=0; i<nbc; ++i) { FEBoundaryCondition& bc = *fem.BoundaryCondition(i); if (bc.IsActive()) bc.PrepStep(ui); } // apply prescribed DOFs for specialized surface loads int nsl = fem.ModelLoads(); for (int i = 0; i < nsl; ++i) { FEModelLoad& pml = *fem.ModelLoad(i); if (pml.IsActive()) pml.PrepStep(); } // do the linear constraints fem.GetLinearConstraintManager().PrepStep(); // initialize rigid bodies m_rigidSolver.PrepStep(tp, ui); // initialize material point data // NOTE: do this before the stresses are updated // TODO: does it matter if the stresses are updated before // the material point data is initialized // update domain data for (int i=0; i<mesh.Domains(); ++i) { FEDomain& dom = mesh.Domain(i); if (dom.IsActive()) dom.PreSolveUpdate(tp); } // update model state UpdateModel(); // see if we need to do contact augmentations m_baugment = false; for (int i = 0; i<fem.SurfacePairConstraints(); ++i) { FEContactInterface& ci = dynamic_cast<FEContactInterface&>(*fem.SurfacePairConstraint(i)); if (ci.IsActive() && (ci.m_laugon == FECore::AUGLAG_METHOD)) m_baugment = true; } // see if we need to do incompressible augmentations // TODO: Should I do these augmentations in a nlconstraint class instead? int ndom = mesh.Domains(); for (int i = 0; i < ndom; ++i) { FEDomain* dom = &mesh.Domain(i); FE3FieldElasticSolidDomain* dom3f = dynamic_cast<FE3FieldElasticSolidDomain*>(dom); if (dom3f && dom3f->DoAugmentations()) m_baugment = true; FE3FieldElasticShellDomain* dom3fs = dynamic_cast<FE3FieldElasticShellDomain*>(dom); if (dom3fs && dom3fs->DoAugmentations()) m_baugment = true; } // see if we have to do nonlinear constraint augmentations if (fem.NonlinearConstraints() != 0) m_baugment = true; } //----------------------------------------------------------------------------- bool FEMultiphasicFSISolver::Quasin() { FEModel& fem = *GetFEModel(); vector<double> u0(m_neq); vector<double> Rold(m_neq); // convergence norms double normR1; // residual norm double normE1; // energy norm double normD; // displacement norm double normd; // displacement increment norm double normV; // velocity norm double normv; // velocity increment norm double normRi = 0; // initial residual norm double normDi = 0; // initial displacement norm double normVi = 0; // initial velocity norm double normEi = 0; // initial energy norm double normEm = 0; // max energy norm double normFi = 0; // initial dilatation norm double normF; // current dilatation norm double normf; // incremement dilatation norm // get number of DOFS DOFS& fedofs = fem.GetDOFS(); int MAX_CDOFS = fedofs.GetVariableSize(FEBioMultiphasicFSI::GetVariableName(FEBioMultiphasicFSI::FLUID_CONCENTRATION)); // solute convergence data vector<double> normCi(MAX_CDOFS); // initial concentration norm vector<double> normC(MAX_CDOFS); // current concentration norm vector<double> normc(MAX_CDOFS); // incremement concentration norm // prepare for the first iteration const FETimeInfo& tp = fem.GetTime(); PrepStep(); // init QN method if (QNInit() == false) return false; // loop until converged or when max nr of reformations reached bool bconv = false; // convergence flag do { feLog(" %d\n", m_niter+1); // assume we'll converge. bconv = true; // solve the equations (returns line search; solution stored in m_ui) double s = QNSolve(); // extract the velocity and dilatation increments GetDisplacementData(m_di, m_ui); GetVelocityData(m_vi, m_ui); GetDilatationData(m_fi, m_ui); // set initial convergence norms if (m_niter == 0) { normRi = fabs(m_R0*m_R0); normEi = fabs(m_ui*m_R0); normDi = fabs(m_di*m_di); normVi = fabs(m_vi*m_vi); normFi = fabs(m_fi*m_fi); normEm = normEi; } // calculate norms // update all degrees of freedom for (int i=0; i<m_neq; ++i) m_Ui[i] += s*m_ui[i]; // update displacements for (int i = 0; i<m_ndeq; ++i) m_Di[i] += s*m_di[i]; // update velocities for (int i = 0; i<m_nveq; ++i) m_Vi[i] += s*m_vi[i]; // update dilatations for (int i = 0; i<m_nfeq; ++i) m_Fi[i] += s*m_fi[i]; // calculate the norms normR1 = m_R1*m_R1; normd = (m_di*m_di)*(s*s); normD = m_Di*m_Di; normv = (m_vi*m_vi)*(s*s); normV = m_Vi*m_Vi; normf = (m_fi*m_fi)*(s*s); normF = m_Fi*m_Fi; normE1 = s*fabs(m_ui*m_R1); // check for nans if (ISNAN(normR1)) throw NANInResidualDetected(); // check residual norm if ((m_Rtol > 0) && (normR1 > m_Rtol*normRi)) bconv = false; // check displacement norm if ((m_Dtol > 0) && (normd > (m_Dtol*m_Dtol)*normD )) bconv = false; // check velocity norm if ((m_Vtol > 0) && (normv > (m_Vtol*m_Vtol)*normV )) bconv = false; // check dilatation norm if ((m_Ftol > 0) && (normf > (m_Ftol*m_Ftol)*normF )) bconv = false; // check energy norm if ((m_Etol > 0) && (normE1 > m_Etol*normEi)) bconv = false; // check linestep size if ((m_lineSearch->m_LStol > 0) && (s < m_lineSearch->m_LSmin)) bconv = false; // check energy divergence if (normE1 > normEm) bconv = false; // check solute convergence // extract the concentration increments for (int j = 0; j<(int)m_nceq.size(); ++j) { if (m_nceq[j]) { GetConcentrationData(m_ci[j], m_ui,j); // set initial norm if (m_niter == 0) normCi[j] = fabs(m_ci[j]*m_ci[j]); // update total concentration for (int i = 0; i<m_nceq[j]; ++i) m_Ci[j][i] += s*m_ci[j][i]; // calculate norms normC[j] = m_Ci[j]*m_Ci[j]; normc[j] = (m_ci[j]*m_ci[j])*(s*s); } } // check convergence if (m_Ctol > 0) { for (int j = 0; j<(int)m_nceq.size(); ++j) if (m_nceq[j]) bconv = bconv && (normc[j] <= (m_Ctol*m_Ctol)*normC[j]); } // print convergence summary feLog(" Nonlinear solution status: time= %lg\n", tp.currentTime); feLog("\tstiffness updates = %d\n", m_qnstrategy->m_nups); feLog("\tright hand side evaluations = %d\n", m_nrhs); feLog("\tstiffness matrix reformations = %d\n", m_nref); if (m_lineSearch->m_LStol > 0) feLog("\tstep from line search = %lf\n", s); feLog("\tconvergence norms : INITIAL CURRENT REQUIRED\n"); feLog("\t residual %15le %15le %15le \n", normRi, normR1, m_Rtol*normRi); feLog("\t energy %15le %15le %15le \n", normEi, normE1, m_Etol*normEi); feLog("\t displacement %15le %15le %15le \n", normDi, normd ,(m_Dtol*m_Dtol)*normD ); feLog("\t velocity %15le %15le %15le \n", normVi, normv ,(m_Vtol*m_Vtol)*normV ); feLog("\t dilatation %15le %15le %15le \n", normFi, normf ,(m_Ftol*m_Ftol)*normF ); for (int j = 0; j<(int)m_nceq.size(); ++j) { if (m_nceq[j]) feLog("\t solute %d concentration %15le %15le %15le\n", j+1, normCi[j], normc[j] ,(m_Ctol*m_Ctol)*normC[j] ); } // see if we may have a small residual if ((bconv == false) && (normR1 < m_Rmin)) { // check for almost zero-residual on the first iteration // this might be an indication that there is no force on the system feLogWarning("No force acting on the system."); bconv = true; } // see if we have exceeded the max residual if ((bconv == false) && (m_Rmax > 0) && (normR1 >= m_Rmax)) { // doesn't look like we're getting anywhere, so let's retry the time step throw MaxResidualError(); } // check if we have converged. // If not, calculate the BFGS update vectors if (bconv == false) { if (s < m_lineSearch->m_LSmin) { // check for zero linestep size feLogWarning("Zero linestep size. Stiffness matrix will now be reformed"); QNForceReform(true); } else if ((normE1 > normEm) && m_bdivreform) { // check for diverging feLogWarning("Problem is diverging. Stiffness matrix will now be reformed"); normEm = normE1; normEi = normE1; normRi = normR1; normDi = normd; normVi = normv; normFi = normf; for (int j = 0; j<(int)m_nceq.size(); ++j) if (m_nceq[j]) normCi[j] = normc[j]; QNForceReform(true); } // Do the QN update (This may also do a stiffness reformation if necessary) bool bret = QNUpdate(); // something went wrong with the update, so we'll need to break if (bret == false) break; } else if (m_baugment) { // Do augmentations bconv = DoAugmentations(); } // increase iteration number m_niter++; // do minor iterations callbacks fem.DoCallback(CB_MINOR_ITERS); } while (bconv == false); // if converged we update the total velocities if (bconv) { UpdateIncrementsEAS(m_Ui, false); UpdateIncrements(m_Ut, m_Ui, true); } return bconv; } //----------------------------------------------------------------------------- //! Calculates global stiffness matrix. bool FEMultiphasicFSISolver::StiffnessMatrix() { FEModel& fem = *GetFEModel(); const FETimeInfo& tp = fem.GetTime(); // get the mesh FEMesh& mesh = fem.GetMesh(); 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) { FEDomain& dom = mesh.Domain(i); if (dom.IsActive()) { FEFluidDomain* fdom = dynamic_cast<FEFluidDomain*>(&dom); FEFluidFSIDomain* fsidom = dynamic_cast<FEFluidFSIDomain*>(&dom); FEBiphasicFSIDomain* bfsidom = dynamic_cast<FEBiphasicFSIDomain*>(&dom); FEMultiphasicFSIDomain* mfsidom = dynamic_cast<FEMultiphasicFSIDomain*>(&dom); FEElasticDomain* edom = dynamic_cast<FEElasticDomain*>(&dom); if (fdom) fdom->StiffnessMatrix(LS); else if (fsidom) fsidom->StiffnessMatrix(LS); else if (bfsidom) bfsidom->StiffnessMatrix(LS); else if (mfsidom) mfsidom->StiffnessMatrix(LS); else if (edom) edom->StiffnessMatrix(LS); } } // calculate the body force stiffness matrix for each domain // but not for solid domains (since they have no mass in FSI) int NBL = fem.ModelLoads(); for (int j = 0; j<NBL; ++j) { FEBodyForce* pbf = dynamic_cast<FEBodyForce*>(fem.ModelLoad(j)); if (pbf && pbf->IsActive()) { for (int i = 0; i<pbf->Domains(); ++i) { FEDomain* dom = pbf->Domain(i); if (dom->IsActive()) { FEFluidDomain* fdom = dynamic_cast<FEFluidDomain*>(dom); FEFluidFSIDomain* fsidom = dynamic_cast<FEFluidFSIDomain*>(dom); FEBiphasicFSIDomain* bfsidom = dynamic_cast<FEBiphasicFSIDomain*>(dom); FEMultiphasicFSIDomain* mfsidom = dynamic_cast<FEMultiphasicFSIDomain*>(dom); FEElasticDomain* edom = dynamic_cast<FEElasticDomain*>(dom); if (fdom) fdom->BodyForceStiffness(LS, *pbf); else if (fsidom) fsidom->BodyForceStiffness(LS, *pbf); else if (bfsidom) bfsidom->BodyForceStiffness(LS, *pbf); else if (mfsidom) mfsidom->BodyForceStiffness(LS, *pbf); else if (edom) { FESolidMaterial* mat = dynamic_cast<FESolidMaterial*>(dom->GetMaterial()); if (mat && (mat->IsRigid()==false)) edom->BodyForceStiffness(LS, *pbf); } } } } } // TODO: add body force stiffness for rigid bodies // Add mass matrix // FEAnalysis* pstep = fem.GetCurrentStep(); // if (pstep->m_nanalysis == FEMultiphasicFSIAnalysis::DYNAMIC) { // scale factor double dt = tp.timeIncrement; double a = tp.alpham / (m_beta*dt*dt); // loop over all domains (except rigid) for (int i = 0; i<mesh.Domains(); ++i) { FEDomain& dom = mesh.Domain(i); if (dom.IsActive()) { FEFluidDomain* fdom = dynamic_cast<FEFluidDomain*>(&dom); FEFluidFSIDomain* fsidom = dynamic_cast<FEFluidFSIDomain*>(&dom); FEBiphasicFSIDomain* bfsidom = dynamic_cast<FEBiphasicFSIDomain*>(&dom); FEMultiphasicFSIDomain* mfsidom = dynamic_cast<FEMultiphasicFSIDomain*>(&dom); FEElasticDomain* edom = dynamic_cast<FEElasticDomain*>(&dom); if (fdom) fdom->MassMatrix(LS); else if (fsidom) fsidom->MassMatrix(LS); else if (bfsidom) bfsidom->MassMatrix(LS); else if (mfsidom) mfsidom->MassMatrix(LS); else if (edom) { FESolidMaterial* mat = dynamic_cast<FESolidMaterial*>(dom.GetMaterial()); if (mat && (mat->IsRigid() == false)) edom->MassMatrix(LS, a); } } } m_rigidSolver.RigidMassMatrix(LS, tp); } // calculate contact stiffness ContactStiffness(LS); // calculate nonlinear constraint stiffness // note that this is the contribution of the // constraints enforced with augmented lagrangian NonLinearConstraintStiffness(LS, tp); // calculate the stiffness contributions for the rigid forces for (int i = 0; i<fem.ModelLoads(); ++i) fem.ModelLoad(i)->StiffnessMatrix(LS); // add contributions from rigid bodies m_rigidSolver.StiffnessMatrix(*m_pK, tp); return true; } //----------------------------------------------------------------------------- //! Calculate the stiffness contribution due to nonlinear constraints void FEMultiphasicFSISolver::NonLinearConstraintStiffness(FELinearSystem& LS, const FETimeInfo& tp) { FEModel& fem = *GetFEModel(); int N = fem.NonlinearConstraints(); for (int i=0; i<N; ++i) { FENLConstraint* plc = fem.NonlinearConstraint(i); if (plc->IsActive()) plc->StiffnessMatrix(LS, tp); } } //----------------------------------------------------------------------------- //! This function calculates the contact stiffness matrix void FEMultiphasicFSISolver::ContactStiffness(FELinearSystem& LS) { FEModel& fem = *GetFEModel(); const FETimeInfo& tp = fem.GetTime(); for (int i = 0; i<fem.SurfacePairConstraints(); ++i) { FEContactInterface* pci = dynamic_cast<FEContactInterface*>(fem.SurfacePairConstraint(i)); if (pci->IsActive()) pci->StiffnessMatrix(LS, tp); } } //----------------------------------------------------------------------------- //! Calculates the contact forces void FEMultiphasicFSISolver::ContactForces(FEGlobalVector& R) { FEModel& fem = *GetFEModel(); const FETimeInfo& tp = fem.GetTime(); for (int i = 0; i<fem.SurfacePairConstraints(); ++i) { FEContactInterface* pci = dynamic_cast<FEContactInterface*>(fem.SurfacePairConstraint(i)); if (pci->IsActive()) pci->LoadVector(R, tp); } } //----------------------------------------------------------------------------- //! calculates the residual vector //! Note that the concentrated nodal forces are not calculated here. //! This is because they do not depend on the geometry //! so we only calculate them once (in Quasin) and then add them here. bool FEMultiphasicFSISolver::Residual(vector<double>& R) { FEModel& fem = *GetFEModel(); // get the time information const FETimeInfo& tp = fem.GetTime(); // initialize residual with concentrated nodal loads zero(R); // zero nodal reaction forces zero(m_Fr); // setup the global vector FEResidualVector RHS(fem, R, m_Fr); // zero rigid body reaction forces m_rigidSolver.Residual(); // get the mesh FEMesh& mesh = fem.GetMesh(); // calculate the internal (stress) forces for (int i=0; i<mesh.Domains(); ++i) { FEDomain& dom = mesh.Domain(i); if (dom.IsActive()) { FEFluidDomain* fdom = dynamic_cast<FEFluidDomain*>(&dom); FEFluidFSIDomain* fsidom = dynamic_cast<FEFluidFSIDomain*>(&dom); FEBiphasicFSIDomain* bfsidom = dynamic_cast<FEBiphasicFSIDomain*>(&dom); FEMultiphasicFSIDomain* mfsidom = dynamic_cast<FEMultiphasicFSIDomain*>(&dom); FEElasticDomain* edom = dynamic_cast<FEElasticDomain*>(&dom); if (fdom) fdom->InternalForces(RHS); else if (fsidom) fsidom->InternalForces(RHS); else if (bfsidom) bfsidom->InternalForces(RHS); else if (mfsidom) mfsidom->InternalForces(RHS); else if (edom) { FESolidMaterial* mat = dynamic_cast<FESolidMaterial*>(dom.GetMaterial()); if (mat && (mat->IsRigid() == false)) edom->InternalForces(RHS); } } } // calculate the body forces for (int j = 0; j<fem.ModelLoads(); ++j) { FEBodyForce* pbf = dynamic_cast<FEBodyForce*>(fem.ModelLoad(j)); if (pbf && pbf->IsActive()) { for (int i = 0; i<pbf->Domains(); ++i) { FEDomain* dom = pbf->Domain(i); if (dom->IsActive()) { FEFluidDomain* fdom = dynamic_cast<FEFluidDomain*>(dom); FEFluidFSIDomain* fsidom = dynamic_cast<FEFluidFSIDomain*>(dom); FEBiphasicFSIDomain* bfsidom = dynamic_cast<FEBiphasicFSIDomain*>(dom); FEMultiphasicFSIDomain* mfsidom = dynamic_cast<FEMultiphasicFSIDomain*>(dom); FEElasticDomain* edom = dynamic_cast<FEElasticDomain*>(dom); if (fdom) fdom->BodyForce(RHS, *pbf); else if (fsidom) fsidom->BodyForce(RHS, *pbf); else if (bfsidom) bfsidom->BodyForce(RHS, *pbf); else if (mfsidom) mfsidom->BodyForce(RHS, *pbf); else if (edom) { FESolidMaterial* mat = dynamic_cast<FESolidMaterial*>(dom->GetMaterial()); if (mat && (mat->IsRigid()==false)) edom->BodyForce(RHS, *pbf); } } } } } // allocate F vector<double> F; FEAnalysis* pstep = fem.GetCurrentStep(); // calculate inertial forces for (int i=0; i<mesh.Domains(); ++i) { FEDomain& dom = mesh.Domain(i); if (dom.IsActive()) { FEFluidDomain* fdom = dynamic_cast<FEFluidDomain*>(&dom); FEFluidFSIDomain* fsidom = dynamic_cast<FEFluidFSIDomain*>(&dom); FEBiphasicFSIDomain* bfsidom = dynamic_cast<FEBiphasicFSIDomain*>(&dom); FEMultiphasicFSIDomain* mfsidom = dynamic_cast<FEMultiphasicFSIDomain*>(&dom); FEElasticDomain* edom = dynamic_cast<FEElasticDomain*>(&dom); if (fdom) fdom->InertialForces(RHS); else if (fsidom) fsidom->InertialForces(RHS); else if (bfsidom) bfsidom->InertialForces(RHS); else if (mfsidom) mfsidom->InertialForces(RHS); else if (edom && (pstep->m_nanalysis == FEMultiphasicFSIAnalysis::DYNAMIC)) { FESolidMaterial* mat = dynamic_cast<FESolidMaterial*>(dom.GetMaterial()); if (mat && (mat->IsRigid()==false)) edom->InertialForces(RHS, F); } } } // update rigid bodies if (pstep->m_nanalysis == FEMultiphasicFSIAnalysis::DYNAMIC) m_rigidSolver.InertialForces(RHS, tp); // calculate contact forces ContactForces(RHS); // calculate nonlinear constraint forces // note that these are the linear constraints // enforced using the augmented lagrangian NonLinearConstraintForces(RHS, tp); // add model loads int NML = fem.ModelLoads(); for (int i=0; i<NML; ++i) { FEModelLoad& mli = *fem.ModelLoad(i); if (mli.IsActive()) mli.LoadVector(RHS); } // set the nodal reaction forces // TODO: Is this a good place to do this? for (int i=0; i<mesh.Nodes(); ++i) { FENode& node = mesh.Node(i); node.set_load(m_dofU[0], 0); node.set_load(m_dofU[1], 0); node.set_load(m_dofU[2], 0); int n; if ((n = -node.m_ID[m_dofU[0]] - 2) >= 0) node.set_load(m_dofU[0], -m_Fr[n]); if ((n = -node.m_ID[m_dofU[1]] - 2) >= 0) node.set_load(m_dofU[1], -m_Fr[n]); if ((n = -node.m_ID[m_dofU[2]] - 2) >= 0) node.set_load(m_dofU[2], -m_Fr[n]); } // increase RHS counter m_nrhs++; return true; } //----------------------------------------------------------------------------- //! calculate the nonlinear constraint forces void FEMultiphasicFSISolver::NonLinearConstraintForces(FEGlobalVector& R, const FETimeInfo& tp) { FEModel& fem = *GetFEModel(); int N = fem.NonlinearConstraints(); for (int i=0; i<N; ++i) { FENLConstraint* plc = fem.NonlinearConstraint(i); if (plc->IsActive()) plc->LoadVector(R, tp); } }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEViscousPolarLinear.h
.h
3,264
80
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2022 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include "FEViscousPolarFluid.h" //----------------------------------------------------------------------------- // This class evaluates the viscous stress in a linear polar fluid class FEBIOFLUID_API FEViscousPolarLinear : public FEViscousPolarFluid { public: //! constructor FEViscousPolarLinear(FEModel* pfem); //! dual vector non-symmetric part of viscous stress in polar fluid vec3d SkewStressDualVector(FEMaterialPoint& pt) override; //! non-symmetric part of viscous stress in polar fluid mat3da SkewStress(FEMaterialPoint& pt) override; //! tangent of stress with respect to strain J mat3da SkewTangent_Strain(FEMaterialPoint& mp) override; //! tangent of stress with respect to relative rate of rotation tensor H mat3d SkewTangent_RateOfRotation(FEMaterialPoint& mp) override; //! tangent of stress with respect to temperature mat3da SkewTangent_Temperature(FEMaterialPoint& mp) override { return mat3da(0,0,0); } //! viscous couple stress in polar fluid mat3d CoupleStress(FEMaterialPoint& pt) override; //! tangent of viscous couple stress with respect to strain J mat3d CoupleTangent_Strain(FEMaterialPoint& mp) override; //! tangent of viscous couple stress with respect to rate of rotation tensor g tens4d CoupleTangent_RateOfRotation(FEMaterialPoint& mp) override; //! tangent of viscous couple stress with respect to temperature mat3d CoupleTangent_Temperature(FEMaterialPoint& mp) override { return mat3d(0.); } //! dynamic viscosity double RelativeRotationalViscosity(FEMaterialPoint& mp) override; public: double m_tau; //!< relative rotational viscosity double m_alpha; //!< couple stress viscosity double m_beta; //!< couple stress viscosity double m_gamma; //!< couple stress viscosity // declare parameter list DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEFluidDomainFactory.cpp
.cpp
2,097
55
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEFluidDomainFactory.h" #include "FEFluid.h" #include "FEFluidDomain.h" #include <FECore/FESolidDomain.h> #include <FECore/FEDomain2D.h> //----------------------------------------------------------------------------- FEDomain* FEFluidDomainFactory::CreateDomain(const FE_Element_Spec& spec, FEMesh* pm, FEMaterial* pmat) { FEModel* pfem = pmat->GetFEModel(); FE_Element_Class eclass = spec.eclass; FE_Element_Shape eshape = spec.eshape; const char* sztype = 0; FEDomain* pd = nullptr; if (dynamic_cast<FEFluid*>(pmat)) { // fluid elements if (eclass==FE_ELEM_SOLID) pd = fecore_new<FESolidDomain>("fluid-3D", pfem); else if (eclass==FE_ELEM_2D ) pd = fecore_new<FEDomain2D >("fluid-2D", pfem); else return 0; } if (pd) pd->SetMaterial(pmat); return pd; }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEBioThermoFluid.h
.h
1,892
53
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include "febiofluid_api.h" //----------------------------------------------------------------------------- //! The FEBioThermoFluid module //! The FEBioThermoFluid module adds thermofluid capabilities to FEBio. //! namespace FEBioThermoFluid { FEBIOFLUID_API void InitModule(); enum THERMOFLUID_VARIABLE { DISPLACEMENT, RELATIVE_FLUID_VELOCITY, FLUID_DILATATION, RELATIVE_FLUID_ACCELERATION, FLUID_DILATATION_TDERIV, TEMPERATURE, TEMPERATURE_TDERIV }; FEBIOFLUID_API const char* GetVariableName(THERMOFLUID_VARIABLE var); }
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEFluidSolutesFlux.cpp
.cpp
3,666
108
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2020 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEFluidSolutesFlux.h" #include "FEBioFluidSolutes.h" #include <FEBioMix/FESoluteInterface.h> #include <FECore/FEMaterial.h> #include <FECore/FEModel.h> #include <FECore/log.h> #include <FECore/FEAnalysis.h> //============================================================================= BEGIN_FECORE_CLASS(FEFluidSolutesFlux, FESurfaceLoad) ADD_PARAMETER(m_flux , "flux")->setUnits("n/L^2.t")->setLongName("effective solute molar flux"); ADD_PARAMETER(m_isol , "solute_id")->setEnums("$(solutes)"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- //! constructor FEFluidSolutesFlux::FEFluidSolutesFlux(FEModel* pfem) : FESurfaceLoad(pfem), m_dofC(pfem) { m_flux = 1.0; m_isol = -1; } //----------------------------------------------------------------------------- //! allocate storage void FEFluidSolutesFlux::SetSurface(FESurface* ps) { FESurfaceLoad::SetSurface(ps); m_flux.SetItemList(ps->GetFacetSet()); } //----------------------------------------------------------------------------- //! Calculate the residual for the prescribed normal component of velocity void FEFluidSolutesFlux::LoadVector(FEGlobalVector& R) { FEFluidSolutesFlux* flux = this; m_psurf->LoadVector(R, m_dofC, true, [=](FESurfaceMaterialPoint& mp, const FESurfaceDofShape& dof_a, vector<double>& fa) { double wr = flux->m_flux(mp); vec3d dxt = mp.dxr ^ mp.dxs; // volumetric flow rate double f = dxt.norm()*wr; double H_i = dof_a.shape; fa[0] = H_i * f; }); } //----------------------------------------------------------------------------- //! initialize bool FEFluidSolutesFlux::Init() { if (m_isol == -1) return false; // set up the dof lists FEModel* fem = GetFEModel(); m_dofC.Clear(); m_dofC.AddDof(fem->GetDOFIndex(FEBioFluidSolutes::GetVariableName(FEBioFluidSolutes::FLUID_CONCENTRATION), m_isol-1)); m_dof.Clear(); m_dof.AddDofs(m_dofC); return FESurfaceLoad::Init(); } //----------------------------------------------------------------------------- //! serialization void FEFluidSolutesFlux::Serialize(DumpStream& ar) { FESurfaceLoad::Serialize(ar); if (ar.IsShallow() == false) { ar & m_dofC; } }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEPolarFluid.h
.h
3,923
105
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2022 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include "FEPolarFluidMaterial.h" #include "FEFluidMaterialPoint.h" #include "FEElasticFluid.h" #include "FEPolarFluidMaterialPoint.h" #include <FEBioMix/FEBiphasic.h> //----------------------------------------------------------------------------- //! Base class for polar fluid materials. //! NOTE: This inherits from FEBiphasicInterface in order to override the GetActualFluidPressure, //! which is used in FEReactionRateExpSED and FEReactionRateHuiskes. //! Note sure yet if there is a better alternative. class FEBIOFLUID_API FEPolarFluid : public FEPolarFluidMaterial, public FEBiphasicInterface { public: FEPolarFluid(FEModel* pfem); // returns a pointer to a new material point object FEMaterialPointData* CreateMaterialPointData() override; public: //! performs initialization bool Init() override; //! Serialization void Serialize(DumpStream& ar) override; //! calculate stress at material point mat3ds Stress(FEMaterialPoint& pt) override; //! tangent of stress with respect to strain J mat3ds Tangent_Strain(FEMaterialPoint& mp) override; //! elastic pressure double Pressure(FEMaterialPoint& mp) override; double Pressure(const double e, const double T = 0) override; //! tangent of elastic pressure with respect to strain J double Tangent_Pressure_Strain(FEMaterialPoint& mp) override; //! 2nd tangent of elastic pressure with respect to strain J double Tangent_Pressure_Strain_Strain(FEMaterialPoint& mp) override; //! bulk modulus double BulkModulus(FEMaterialPoint& mp) override; //! strain energy density double StrainEnergyDensity(FEMaterialPoint& mp) override; //! evaluate temperature double Temperature(FEMaterialPoint& mp) override { return m_Tr; } //! evaluate dilatation from pressure bool Dilatation(const double T, const double p, double& e) override; //! return elastic fluid FEElasticFluid* GetElastic() { return m_pElastic; } private: // material properties FEElasticFluid* m_pElastic; //!< pointer to elastic part of fluid material public: // from FEBiphasicInterface double GetActualFluidPressure(const FEMaterialPoint& mp) override { const FEFluidMaterialPoint* pt = (mp.ExtractData<FEFluidMaterialPoint>()); return pt->m_pf; } public: double m_kg; //!< radius of gyration double m_k; //!< bulk modulus at J=1 double m_Tr; //!< ambient temperature DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEMultiphasicFSI.cpp
.cpp
21,829
590
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2020 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEBiphasicFSI.h" #include "FEMultiphasicFSI.h" #include "FEFluidFSI.h" #include <FECore/FECoreKernel.h> #include <FECore/DumpStream.h> #include "FECore/FEModel.h" #include <FECore/log.h> #include <FECore/tools.h> #include <complex> using namespace std; #ifndef SQR #define SQR(x) ((x)*(x)) #endif //----------------------------------------------------------------------------- BEGIN_FECORE_CLASS(FEMultiphasicFSI, FEBiphasicFSI) ADD_PARAMETER(m_penalty, FE_RANGE_GREATER_OR_EQUAL(0.0), "penalty" ); ADD_PARAMETER(m_diffMtmSupp , "dms"); ADD_PARAMETER(m_cFr , "fixed_charge_density"); // material properties ADD_PROPERTY(m_pOsmC , "osmotic_coefficient"); ADD_PROPERTY(m_pSolute, "solute" , FEProperty::Optional); ADD_PROPERTY(m_pReact , "reaction" , FEProperty::Optional); END_FECORE_CLASS(); //============================================================================ // FEFSIMaterialPoint //============================================================================ FEMultiphasicFSIMaterialPoint::FEMultiphasicFSIMaterialPoint(FEMaterialPointData* pt) : FEMaterialPointData(pt) {} //----------------------------------------------------------------------------- FEMaterialPointData* FEMultiphasicFSIMaterialPoint::Copy() { FEMultiphasicFSIMaterialPoint* pt = new FEMultiphasicFSIMaterialPoint(*this); if (m_pNext) pt->m_pNext = m_pNext->Copy(); return pt; } //----------------------------------------------------------------------------- void FEMultiphasicFSIMaterialPoint::Serialize(DumpStream& ar) { FEMaterialPointData::Serialize(ar); ar & m_nsol & m_psi & m_Ie & m_cF & m_pe; ar & m_c & m_ca & m_gradc & m_j & m_cdot & m_k & m_dkdJ; ar & m_dkdc; } //----------------------------------------------------------------------------- void FEMultiphasicFSIMaterialPoint::Init() { m_nsol = 0; m_psi = m_cF = 0; m_pe = 0; m_Ie = vec3d(0,0,0); m_c.clear(); m_ca.clear(); m_gradc.clear(); m_j.clear(); m_cdot.clear(); m_k.clear(); m_dkdJ.clear(); m_dkdJJ.clear(); m_dkdc.clear(); m_dkdJc.clear(); m_dkdcc.clear(); FEMaterialPointData::Init(); } //----------------------------------------------------------------------------- double FEMultiphasicFSIMaterialPoint::Osmolarity() const { double ew = 0.0; for (int isol = 0; isol < (int)m_ca.size(); ++isol) { ew += m_ca[isol]; } return ew; } //============================================================================ // FEFluidFSI //============================================================================ //----------------------------------------------------------------------------- //! FEFluidFSI constructor FEMultiphasicFSI::FEMultiphasicFSI(FEModel* pfem) : FEBiphasicFSI(pfem) { m_Rgas = 0; m_Tabs = 0; m_Fc = 0; m_cFr = 0.0; m_diffMtmSupp = 1.0; m_penalty = 1; m_pOsmC = 0; } //----------------------------------------------------------------------------- // returns a pointer to a new material point object FEMaterialPointData* FEMultiphasicFSI::CreateMaterialPointData() { FEFluidMaterialPoint* fpt = new FEFluidMaterialPoint(m_pSolid->CreateMaterialPointData()); FEFSIMaterialPoint* fst = new FEFSIMaterialPoint(fpt); FEBiphasicFSIMaterialPoint* bfpt = new FEBiphasicFSIMaterialPoint(fst); FEMultiphasicFSIMaterialPoint* mfpt = new FEMultiphasicFSIMaterialPoint(bfpt); return mfpt; } //----------------------------------------------------------------------------- // initialize bool FEMultiphasicFSI::Init() { // set the solute IDs first, since they are referenced in FESolute::Init() for (int i = 0; i<Solutes(); ++i) { m_pSolute[i]->SetSoluteLocalID(i); } // call the base class. // This also initializes all properties if (FEBiphasicFSI::Init() == false) return false; // Determine how to solve for the electric potential psi int isol; int zmin = 0, zmax = 0, z; for (isol=0; isol<(int)m_pSolute.size(); ++isol) { z = m_pSolute[isol]->ChargeNumber(); if (z < zmin) zmin = z; if (z > zmax) zmax = z; } m_zmin = zmin; m_ndeg = zmax - zmin; // polynomial degree m_Rgas = GetFEModel()->GetGlobalConstant("R"); m_Tabs = GetFEModel()->GetGlobalConstant("T"); m_Fc = GetFEModel()->GetGlobalConstant("Fc"); if (m_Rgas <= 0) { feLogError("A positive universal gas constant R must be defined in Globals section"); return false; } if (m_Tabs <= 0) { feLogError("A positive absolute temperature T must be defined in Globals section"); return false; } if ((zmin || zmax) && (m_Fc <= 0)) { feLogError("A positive Faraday constant Fc must be defined in Globals section"); return false; } return true; } //----------------------------------------------------------------------------- void FEMultiphasicFSI::Serialize(DumpStream& ar) { FEMaterial::Serialize(ar); if (ar.IsShallow()) return; ar & m_Rgas & m_Tabs & m_Fc; ar & m_zmin & m_ndeg; } //----------------------------------------------------------------------------- //! The stress of a poro-elastic material is the sum of the fluid stress //! and the elastic stress. Note that this function is declared in the base class //! so you do not have to reimplement it in a derived class, unless additional //! pressure terms are required. mat3ds FEMultiphasicFSI::Stress(FEMaterialPoint& mp) { // calculate solid material stress mat3ds s = m_pSolid->Stress(mp); // add fluid stress s += m_pFluid->GetViscous()->Stress(mp); //add actual pressure s += -mat3dd(1.0)*PressureActual(mp); return s; } //----------------------------------------------------------------------------- //! Return the permeability tensor as a double array void FEMultiphasicFSI::Diffusivity(double d[3][3], FEMaterialPoint& pt, int sol) { mat3ds dt = m_pSolute[sol]->m_pDiff->Diffusivity(pt); d[0][0] = dt.xx(); d[1][1] = dt.yy(); d[2][2] = dt.zz(); d[0][1] = d[1][0] = dt.xy(); d[1][2] = d[2][1] = dt.yz(); d[2][0] = d[0][2] = dt.xz(); } //----------------------------------------------------------------------------- mat3ds FEMultiphasicFSI::Diffusivity(FEMaterialPoint& mp, int sol) { return m_pSolute[sol]->m_pDiff->Diffusivity(mp); } //----------------------------------------------------------------------------- tens4dmm FEMultiphasicFSI::Diffusivity_Tangent_Strain(FEMaterialPoint& mp, int isol) { //Return 0 if diffusivity is 0 to avoid NAN if (m_pSolute[isol]->m_pDiff->Diffusivity(mp).xx() == 0.0 && m_pSolute[isol]->m_pDiff->Diffusivity(mp).xy() == 0.0 && m_pSolute[isol]->m_pDiff->Diffusivity(mp).xz() == 0.0 && m_pSolute[isol]->m_pDiff->Diffusivity(mp).yy() == 0.0 && m_pSolute[isol]->m_pDiff->Diffusivity(mp).yz() == 0.0 && m_pSolute[isol]->m_pDiff->Diffusivity(mp).zz() == 0.0) return tens4dmm(0.0); else return m_pSolute[isol]->m_pDiff->Tangent_Diffusivity_Strain(mp); } //----------------------------------------------------------------------------- mat3ds FEMultiphasicFSI::Diffusivity_Tangent_Concentration(FEMaterialPoint& mp, int isol, int jsol) { //Return 0 if diffusivity is 0 to avoid NAN if (m_pSolute[isol]->m_pDiff->Diffusivity(mp).xx() == 0.0 && m_pSolute[isol]->m_pDiff->Diffusivity(mp).xy() == 0.0 && m_pSolute[isol]->m_pDiff->Diffusivity(mp).xz() == 0.0 && m_pSolute[isol]->m_pDiff->Diffusivity(mp).yy() == 0.0 && m_pSolute[isol]->m_pDiff->Diffusivity(mp).yz() == 0.0 && m_pSolute[isol]->m_pDiff->Diffusivity(mp).zz() == 0.0) return mat3ds(0.0); else return m_pSolute[isol]->m_pDiff->Tangent_Diffusivity_Concentration(mp, jsol); } //----------------------------------------------------------------------------- mat3ds FEMultiphasicFSI::InvDiffusivity(FEMaterialPoint& mp, int sol) { //Return 0 for inverse diffusivity when diffusivity is set to 0. //Acts as if diffusivity if infinite. if (m_pSolute[sol]->m_pDiff->Diffusivity(mp).xx() == 0.0 && m_pSolute[sol]->m_pDiff->Diffusivity(mp).xy() == 0.0 && m_pSolute[sol]->m_pDiff->Diffusivity(mp).xz() == 0.0 && m_pSolute[sol]->m_pDiff->Diffusivity(mp).yy() == 0.0 && m_pSolute[sol]->m_pDiff->Diffusivity(mp).yz() == 0.0 && m_pSolute[sol]->m_pDiff->Diffusivity(mp).zz() == 0.0) return mat3ds(0.0); else return m_pSolute[sol]->m_pDiff->Diffusivity(mp).inverse(); } //----------------------------------------------------------------------------- //! Electric potential double FEMultiphasicFSI::ElectricPotential(FEMaterialPoint& pt, const bool eform) { // check if solution is neutral if (m_ndeg == 0) { if (eform) return 1.0; else return 0.0; } int i, j; // if not neutral, solve electroneutrality polynomial for zeta FEMultiphasicFSIMaterialPoint& set = *pt.ExtractData<FEMultiphasicFSIMaterialPoint>(); const int nsol = (int)m_pSolute.size(); double cF = FixedChargeDensity(pt); vector<double> c(nsol); // effective concentration vector<double> khat(nsol); // solubility vector<int> z(nsol); // charge number for (i=0; i<nsol; ++i) { c[i] = set.m_c[i]; khat[i] = m_pSolute[i]->m_pSolub->Solubility(pt); z[i] = m_pSolute[i]->ChargeNumber(); } // evaluate polynomial coefficients const int n = m_ndeg; vector<double> a(n+1,0); if (m_zmin < 0) { for (i=0; i<nsol; ++i) { j = z[i] - m_zmin; a[j] += z[i]*khat[i]*c[i]; } a[-m_zmin] = cF; } else { for (i=0; i<nsol; ++i) { j = z[i]; a[j] += z[i]*khat[i]*c[i]; } a[0] = cF; } // solve polynomial double psi = set.m_psi; // use previous solution as initial guess double zeta = exp(-m_Fc*psi/m_Rgas/m_Tabs); if (!solvepoly(n, a, zeta)) { zeta = 1.0; } // Return exponential (non-dimensional) form if desired if (eform) return zeta; // Otherwise return dimensional value of electric potential psi = -m_Rgas*m_Tabs/m_Fc*log(zeta); return psi; } //----------------------------------------------------------------------------- //! partition coefficient double FEMultiphasicFSI::PartitionCoefficient(FEMaterialPoint& pt, const int sol) { // solubility double khat = m_pSolute[sol]->m_pSolub->Solubility(pt); // charge number int z = m_pSolute[sol]->ChargeNumber(); // electric potential double zeta = ElectricPotential(pt, true); double zz = pow(zeta, z); // partition coefficient double kappa = zz*khat; return kappa; } //----------------------------------------------------------------------------- //! partition coefficients and their derivatives void FEMultiphasicFSI::PartitionCoefficientFunctions(FEMaterialPoint& mp, vector<double>& kappa, vector<double>& dkdJ, vector< vector<double> >& dkdc) { //TODO: Include dkdcc and dkdJc int isol, jsol, ksol; FEElasticMaterialPoint& ept = *(mp.ExtractData<FEElasticMaterialPoint>()); FEFluidMaterialPoint& fpt = *(mp.ExtractData<FEFluidMaterialPoint>()); FEBiphasicFSIMaterialPoint& ppt = *(mp.ExtractData<FEBiphasicFSIMaterialPoint>()); FEMultiphasicFSIMaterialPoint& spt = *(mp.ExtractData<FEMultiphasicFSIMaterialPoint>()); const int nsol = (int)m_pSolute.size(); vector<double> c(nsol); vector<int> z(nsol); vector<double> khat(nsol); vector<double> dkhdJ(nsol); vector<double> dkhdJJ(nsol); vector< vector<double> > dkhdc(nsol, vector<double>(nsol)); vector< vector<double> > dkhdJc(nsol, vector<double>(nsol)); vector< vector< vector<double> > > dkhdcc(nsol, dkhdc); // use dkhdc to initialize only vector<double> zz(nsol); kappa.resize(nsol); double den = 0; double num = 0; double zeta = ElectricPotential(mp, true); for (isol=0; isol<nsol; ++isol) { // get the effective concentration, its gradient and its time derivative c[isol] = spt.m_c[isol]; // get the charge number z[isol] = m_pSolute[isol]->ChargeNumber(); // evaluate the solubility and its derivatives w.r.t. J and c khat[isol] = m_pSolute[isol]->m_pSolub->Solubility(mp); dkhdJ[isol] = m_pSolute[isol]->m_pSolub->Tangent_Solubility_Strain(mp); dkhdJJ[isol] = m_pSolute[isol]->m_pSolub->Tangent_Solubility_Strain_Strain(mp); for (jsol=0; jsol<nsol; ++jsol) { dkhdc[isol][jsol] = m_pSolute[isol]->m_pSolub->Tangent_Solubility_Concentration(mp,jsol); dkhdJc[isol][jsol] = m_pSolute[isol]->m_pSolub->Tangent_Solubility_Strain_Concentration(mp,jsol); for (ksol=0; ksol<nsol; ++ksol) { dkhdcc[isol][jsol][ksol] = m_pSolute[isol]->m_pSolub->Tangent_Solubility_Concentration_Concentration(mp,jsol,ksol); } } zz[isol] = pow(zeta, z[isol]); kappa[isol] = zz[isol]*khat[isol]; den += SQR(z[isol])*kappa[isol]*c[isol]; num += pow((double)z[isol],3)*kappa[isol]*c[isol]; } // get the charge density and its derivatives double J = ept.m_J; double phi0 = ppt.m_phi0; double cF = FixedChargeDensity(mp); double dcFdJ = -cF/(J - phi0); double dcFdJJ = 2*cF/SQR(J-phi0); // evaluate electric potential (nondimensional exponential form) and its derivatives // also evaluate partition coefficients and their derivatives double zidzdJ = 0; double zidzdJJ = 0, zidzdJJ1 = 0, zidzdJJ2 = 0; vector<double> zidzdc(nsol,0); vector<double> zidzdJc(nsol,0), zidzdJc1(nsol,0), zidzdJc2(nsol,0); vector< vector<double> > zidzdcc(nsol, vector<double>(nsol,0)); vector< vector<double> > zidzdcc1(nsol, vector<double>(nsol,0)); vector<double> zidzdcc2(nsol,0); double zidzdcc3 = 0; if (den > 0) { for (isol=0; isol<nsol; ++isol) zidzdJ += z[isol]*zz[isol]*dkhdJ[isol]*c[isol]; zidzdJ = -(dcFdJ+zidzdJ)/den; for (isol=0; isol<nsol; ++isol) { for (jsol=0; jsol<nsol; ++jsol) { zidzdJJ1 += SQR(z[jsol])*c[jsol]*(z[jsol]*zidzdJ*kappa[jsol]+zz[jsol]*dkhdJ[jsol]); zidzdJJ2 += z[jsol]*zz[jsol]*c[jsol]*(zidzdJ*z[jsol]*dkhdJ[jsol]+dkhdJJ[jsol]); zidzdc[isol] += z[jsol]*zz[jsol]*dkhdc[jsol][isol]*c[jsol]; } zidzdc[isol] = -(z[isol]*kappa[isol]+zidzdc[isol])/den; zidzdcc3 += pow(double(z[isol]),3)*kappa[isol]*c[isol]; } zidzdJJ = zidzdJ*(zidzdJ-zidzdJJ1/den)-(dcFdJJ+zidzdJJ2)/den; for (isol=0; isol<nsol; ++isol) { for (jsol=0; jsol<nsol; ++jsol) { zidzdJc1[isol] += SQR(z[jsol])*c[jsol]*(zidzdc[isol]*z[jsol]*kappa[jsol]+zz[jsol]*dkhdc[jsol][isol]); zidzdJc2[isol] += z[jsol]*zz[jsol]*c[jsol]*(zidzdc[isol]*z[jsol]*dkhdJ[jsol]+dkhdJc[jsol][isol]); zidzdcc2[isol] += SQR(z[jsol])*zz[jsol]*c[jsol]*dkhdc[jsol][isol]; for (ksol=0; ksol<nsol; ++ksol) zidzdcc1[isol][jsol] += z[ksol]*zz[ksol]*c[ksol]*dkhdcc[ksol][isol][jsol]; } zidzdJc[isol] = zidzdJ*(zidzdc[isol]-(SQR(z[isol])*kappa[isol] + zidzdJc1[isol])/den) -(z[isol]*zz[isol]*dkhdJ[isol] + zidzdJc2[isol])/den; } for (isol=0; isol<nsol; ++isol) { for (jsol=0; jsol<nsol; ++jsol) { zidzdcc[isol][jsol] = zidzdc[isol]*zidzdc[jsol]*(1 - zidzdcc3/den) - zidzdcc1[isol][jsol]/den - z[isol]*(z[isol]*kappa[isol]*zidzdc[jsol]+zz[isol]*dkhdc[isol][jsol])/den - z[jsol]*(z[jsol]*kappa[jsol]*zidzdc[isol]+zz[jsol]*dkhdc[jsol][isol])/den - zidzdc[jsol]*zidzdcc2[isol]/den - zidzdc[isol]*zidzdcc2[jsol]/den; } } } dkdJ.resize(nsol); dkdc.resize(nsol, vector<double>(nsol,0)); for (isol=0; isol<nsol; ++isol) { dkdJ[isol] = zz[isol]*dkhdJ[isol]+z[isol]*kappa[isol]*zidzdJ; for (jsol=0; jsol<nsol; ++jsol) { dkdc[isol][jsol] = zz[isol]*dkhdc[isol][jsol]+z[isol]*kappa[isol]*zidzdc[jsol]; } } } //----------------------------------------------------------------------------- //! Current density vec3d FEMultiphasicFSI::CurrentDensity(FEMaterialPoint& pt) { int i; const int nsol = (int)m_pSolute.size(); vector<vec3d> j(nsol); vector<int> z(nsol); vec3d Ie(0,0,0); for (i=0; i<nsol; ++i) { j[i] = SoluteFlux(pt, i); z[i] = m_pSolute[i]->ChargeNumber(); Ie += j[i]*z[i]; } Ie *= m_Fc; return Ie; } //----------------------------------------------------------------------------- //! actual concentration double FEMultiphasicFSI::ConcentrationActual(FEMaterialPoint& pt, const int sol) { FEMultiphasicFSIMaterialPoint& spt = *pt.ExtractData<FEMultiphasicFSIMaterialPoint>(); // effective concentration double c = spt.m_c[sol]; // partition coefficient double kappa = PartitionCoefficient(pt, sol); double ca = kappa*c; return ca; } //----------------------------------------------------------------------------- //! actual fluid pressure double FEMultiphasicFSI::PressureActual(FEMaterialPoint& pt) { int i; FEFluidMaterialPoint& fpt = *pt.ExtractData<FEFluidMaterialPoint>(); const int nsol = (int)m_pSolute.size(); // effective pressure double p = Fluid()->Pressure(pt); // actual concentration vector<double> c(nsol); for (i=0; i<nsol; ++i) c[i] = ConcentrationActual(pt, i); // osmotic coefficient double osmc = m_pOsmC->OsmoticCoefficient(pt); // actual pressure double ca = 0; for (i=0; i<nsol; ++i) ca += c[i]; double pa = p + m_Rgas*m_Tabs*osmc*ca; return pa; } //----------------------------------------------------------------------------- //! Fixed charge density in current configuration double FEMultiphasicFSI::FixedChargeDensity(FEMaterialPoint& pt) { FEElasticMaterialPoint& et = *pt.ExtractData<FEElasticMaterialPoint>(); FEBiphasicFSIMaterialPoint& bt = *pt.ExtractData<FEBiphasicFSIMaterialPoint>(); FEMultiphasicFSIMaterialPoint& spt = *pt.ExtractData<FEMultiphasicFSIMaterialPoint>(); // relative volume double J = et.m_J; double phi0 = bt.m_phi0; double phif = Porosity(pt); double cFr = m_cFr(pt); double cF = cFr*(1-phi0)/(J - phi0); return cF; } //----------------------------------------------------------------------------- //! Calculate solute molar flux vec3d FEMultiphasicFSI::SoluteFlux(FEMaterialPoint& pt, const int sol) { FEMultiphasicFSIMaterialPoint& spt = *pt.ExtractData<FEMultiphasicFSIMaterialPoint>(); FEFSIMaterialPoint& fpt = *pt.ExtractData<FEFSIMaterialPoint>(); // concentration gradient vec3d gradc = spt.m_gradc[sol]; // solute properties mat3ds D = Diffusivity(pt, sol); double khat = m_pSolute[sol]->m_pSolub->Solubility(pt); int z = m_pSolute[sol]->ChargeNumber(); double zeta = ElectricPotential(pt, true); double zz = pow(zeta, z); double kappa = zz*khat; double d0 = GetSolute(sol)->m_pDiff->Free_Diffusivity(pt); double c = spt.m_c[sol]; vec3d w = fpt.m_w; double phif = Porosity(pt); // solute flux j vec3d j = D*(-gradc*phif + w*c/d0)*kappa; return j; } //----------------------------------------------------------------------------- void FEMultiphasicFSI::AddChemicalReaction(FEChemicalReaction* pcr) { m_pReact.push_back(pcr); } //----------------------------------------------------------------------------- double FEMultiphasicFSI::GetReferentialFixedChargeDensity(const FEMaterialPoint& mp) { const FEElasticMaterialPoint* ept = (mp.ExtractData<FEElasticMaterialPoint >()); const FEMultiphasicFSIMaterialPoint* mfspt = mp.ExtractData<FEMultiphasicFSIMaterialPoint>(); const FEBiphasicFSIMaterialPoint* bfspt = mp.ExtractData<FEBiphasicFSIMaterialPoint>(); double cf = (ept->m_J - bfspt->m_phi0) * mfspt->m_cF / (1 - bfspt->m_phi0); return cf; }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEBinghamFluid.h
.h
2,515
67
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include "FEViscousFluid.h" //----------------------------------------------------------------------------- // This class evaluates the viscous stress in a Bingham plastic fluid class FEBIOFLUID_API FEBinghamFluid : public FEViscousFluid { public: //! constructor FEBinghamFluid(FEModel* pfem); //! viscous stress mat3ds Stress(FEMaterialPoint& pt) override; //! tangent of stress with respect to strain J mat3ds Tangent_Strain(FEMaterialPoint& mp) override; //! tangent of stress with respect to rate of deformation tensor D tens4ds Tangent_RateOfDeformation(FEMaterialPoint& mp) override; //! tangent of stress with respect to temperature mat3ds Tangent_Temperature(FEMaterialPoint& mp) override { return mat3ds(0); }; //! dynamic viscosity double ShearViscosity(FEMaterialPoint& mp) override; //! bulk viscosity double BulkViscosity(FEMaterialPoint& mp) override; public: double m_mu; //!< shear viscosity at infinite shear rate double m_tauy; //!< yield stress double m_n; //!< exponential-law coefficient // declare parameter list DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEPrescribedFluidTemperature.cpp
.cpp
2,018
47
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2020 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEPrescribedFluidTemperature.h" //======================================================================================= // NOTE: I'm setting FEBoundaryCondition is the base class since I don't want to pull // in the parameters of FEPrescribedDOF. BEGIN_FECORE_CLASS(FEPrescribedFluidTemperature, FEBoundaryCondition) ADD_PARAMETER(m_scale, "value")->setUnits(UNIT_RELATIVE_TEMPERATURE)->SetFlags(FE_PARAM_ADDLC | FE_PARAM_VOLATILE); ADD_PARAMETER(m_brelative, "relative"); END_FECORE_CLASS(); FEPrescribedFluidTemperature::FEPrescribedFluidTemperature(FEModel* fem) : FEPrescribedDOF(fem) { } bool FEPrescribedFluidTemperature::Init() { SetDOF(GetDOFIndex("T")); return FEPrescribedDOF::Init(); }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEFluidAnalysis.cpp
.cpp
1,668
38
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "FEFluidAnalysis.h" BEGIN_FECORE_CLASS(FEFluidAnalysis, FEAnalysis) // The analysis parameter is already defined in the FEAnalysis base class. // Here, we just need to set the enum values for the analysis parameter. FindParameterFromData(&m_nanalysis)->setEnums("STEADY-STATE\0DYNAMIC\0"); END_FECORE_CLASS() FEFluidAnalysis::FEFluidAnalysis(FEModel* fem) : FEAnalysis(fem) { }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEFluidFSIDomain3D.h
.h
4,308
130
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FESolidDomain.h> #include "FEFluidFSIDomain.h" #include "FEFluidFSI.h" //----------------------------------------------------------------------------- //! Fluid-FSI domain described by 3D volumetric elements //! class FEBIOFLUID_API FEFluidFSIDomain3D : public FESolidDomain, public FEFluidFSIDomain { public: //! constructor FEFluidFSIDomain3D(FEModel* pfem); ~FEFluidFSIDomain3D() {} //! assignment operator FEFluidFSIDomain3D& operator = (FEFluidFSIDomain3D& d); //! activate void Activate() override; //! initialize elements void PreSolveUpdate(const FETimeInfo& timeInfo) override; //! Unpack element data void UnpackLM(FEElement& el, vector<int>& lm) override; //! Serialization void Serialize(DumpStream& ar) override; // get the total dof const FEDofList& GetDOFList() const override; public: // overrides from FEDomain //! get the material FEMaterial* GetMaterial() override { return m_pMat; } //! set the material void SetMaterial(FEMaterial* pm) override; public: // overrides from FEElasticDomain // update stresses void Update(const FETimeInfo& tp) override; // update the element stress void UpdateElementStress(int iel, const FETimeInfo& tp); //! internal stress forces void InternalForces(FEGlobalVector& R) override; //! body forces void BodyForce(FEGlobalVector& R, FEBodyForce& BF) override; //! inertial forces for dynamic problems void InertialForces(FEGlobalVector& R) override; //! calculates the global stiffness matrix for this domain void StiffnessMatrix(FELinearSystem& LS) override; //! calculates inertial stiffness void MassMatrix(FELinearSystem& LS) override; //! body force stiffness void BodyForceStiffness(FELinearSystem& LS, FEBodyForce& bf) override; public: // --- S T I F F N E S S --- //! calculates the solid element stiffness matrix void ElementStiffness(FESolidElement& el, matrix& ke); //! calculates the solid element mass matrix void ElementMassMatrix(FESolidElement& el, matrix& ke); //! calculates the stiffness matrix due to body forces void ElementBodyForceStiffness(FEBodyForce& bf, FESolidElement& el, matrix& ke); // --- R E S I D U A L --- //! Calculates the internal stress vector for solid elements void ElementInternalForce(FESolidElement& el, vector<double>& fe); //! Calculates external body forces for solid elements void ElementBodyForce(FEBodyForce& BF, FESolidElement& elem, vector<double>& fe); //! Calculates the inertial force vector for solid elements void ElementInertialForce(FESolidElement& el, vector<double>& fe); protected: FEFluidFSI* m_pMat; double m_sseps; protected: FEDofList m_dofU, m_dofV, m_dofW, m_dofAW; FEDofList m_dofSU, m_dofR; FEDofList m_dof; int m_dofEF; int m_dofAEF; };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEPowellEyringFluid.cpp
.cpp
4,002
105
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEPowellEyringFluid.h" #include "FEFluid.h" #include <math.h> // define the material parameters BEGIN_FECORE_CLASS(FEPowellEyringFluid, FEViscousFluid) ADD_PARAMETER(m_mu0, FE_RANGE_GREATER_OR_EQUAL(0.0), "mu0")->setUnits("P.t")->setLongName("zero shear rate viscosity"); ADD_PARAMETER(m_mui, FE_RANGE_GREATER_OR_EQUAL(0.0), "mui")->setUnits("P.t")->setLongName("infinite shear rate viscosity"); ADD_PARAMETER(m_lam, FE_RANGE_GREATER_OR_EQUAL(0.0), "lambda")->setUnits(UNIT_TIME)->setLongName("relaxation time"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- //! Constructor. FEPowellEyringFluid::FEPowellEyringFluid(FEModel* pfem) : FEViscousFluid(pfem) { m_mu0 = 0; m_mui = 0; m_lam = 0; } //----------------------------------------------------------------------------- //! viscous stress mat3ds FEPowellEyringFluid::Stress(FEMaterialPoint& pt) { FEFluidMaterialPoint& vt = *pt.ExtractData<FEFluidMaterialPoint>(); mat3ds D = vt.RateOfDeformation(); double mu = ShearViscosity(pt); mat3ds s = D*(2*mu); return s; } //----------------------------------------------------------------------------- //! tangent of stress with respect to strain J mat3ds FEPowellEyringFluid::Tangent_Strain(FEMaterialPoint& mp) { return mat3ds(0,0,0,0,0,0); } //----------------------------------------------------------------------------- //! tangent of stress with respect to rate of deformation tensor D tens4ds FEPowellEyringFluid::Tangent_RateOfDeformation(FEMaterialPoint& pt) { FEFluidMaterialPoint& vt = *pt.ExtractData<FEFluidMaterialPoint>(); mat3ds D = vt.RateOfDeformation(); double gdot = sqrt(2*(D.sqr()).tr()); double lamg = m_lam*gdot; double mu = ShearViscosity(pt); double dmu = (lamg < 1e-3) ? -2*(m_mu0 - m_mui)*m_lam*m_lam/3. : (2*(m_mu0 - m_mui)*(gdot/sqrt(1 + pow(lamg,2)) - asinh(lamg)/m_lam))/pow(gdot,3); mat3dd I(1.0); tens4ds c = dyad1s(D)*(2*dmu) + dyad4s(I)*(2*mu); return c; } //----------------------------------------------------------------------------- //! dynamic viscosity double FEPowellEyringFluid::ShearViscosity(FEMaterialPoint& pt) { FEFluidMaterialPoint& vt = *pt.ExtractData<FEFluidMaterialPoint>(); mat3ds D = vt.RateOfDeformation(); double gdot = sqrt(2*(D.sqr()).tr()); double lamg = m_lam*gdot; double mu = (lamg < 1e-3) ? m_mu0 : m_mui + (m_mu0 - m_mui)*asinh(lamg)/lamg; return mu; } //----------------------------------------------------------------------------- //! bulk viscosity double FEPowellEyringFluid::BulkViscosity(FEMaterialPoint& pt) { return 2*ShearViscosity(pt)/3.; }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEFluidRCBC.cpp
.cpp
7,046
226
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEFluidRCBC.h" #include "FEFluid.h" #include "FEBioFluid.h" #include <FECore/FEAnalysis.h> #include <FECore/FEModel.h> //============================================================================= BEGIN_FECORE_CLASS(FEFluidRCBC, FEPrescribedSurface) ADD_PARAMETER(m_R , "R")->setUnits("F.t/L^5"); ADD_PARAMETER(m_p0, "initial_pressure")->setUnits(UNIT_PRESSURE); ADD_PARAMETER(m_C , "capacitance")->setUnits("L^5/F"); ADD_PARAMETER(m_Bern, "Bernoulli"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- //! constructor FEFluidRCBC::FEFluidRCBC(FEModel* pfem) : FEPrescribedSurface(pfem), m_dofW(pfem) { m_R = 0.0; m_pfluid = nullptr; m_psurf = nullptr; m_p0 = 0; m_C = 0.0; m_Bern = false; m_e = 0.0; m_pt = m_dpt = 0; m_qt = m_dqt = 0; m_pp = m_dpp = 0; m_qp = m_dqp = 0; } //----------------------------------------------------------------------------- //! initialize //! TODO: Generalize to include the initial conditions bool FEFluidRCBC::Init() { m_dofW.AddVariable(FEBioFluid::GetVariableName(FEBioFluid::RELATIVE_FLUID_VELOCITY)); m_dofEF = GetDOFIndex(FEBioFluid::GetVariableName(FEBioFluid::FLUID_DILATATION), 0); if (FEPrescribedSurface::Init() == false) return false; m_psurf = GetSurface(); SetDOFList(m_dofEF); // get fluid from first surface element // assuming the entire surface bounds the same fluid FESurfaceElement& el = m_psurf->Element(0); FEElement* pe = el.m_elem[0].pe; if (pe == nullptr) return false; // get the material FEMaterial* pm = GetFEModel()->GetMaterial(pe->GetMatID()); m_pfluid = pm->ExtractProperty<FEFluidMaterial>(); if (m_pfluid == nullptr) return false; return true; } //----------------------------------------------------------------------------- //! Evaluate and prescribe the resistance pressure void FEFluidRCBC::UpdateDilatation() { const FETimeInfo& tp = GetTimeInfo(); double dt = tp.timeIncrement; double gamma = tp.gamma; double omoog = 1.0 - 1.0/gamma; int niter = GetFEModel()->GetCurrentStep()->GetFESolver()->m_niter; // if this is the start of a new time step, update the flow/pressure parameters if (niter == 0) { m_qp = m_qt; m_dqp = m_dqt*omoog; m_pp = m_pt; m_dpp = m_dpt*omoog; } // evaluate the flow rate m_qt = FlowRate(); // evaluate the outflow pressure double qt = m_Bern ? m_qt*fabs(m_qt) : m_qt; double qp = m_Bern ? m_qp*fabs(m_qp) : m_qp; m_dqt = m_dqp*omoog + (qt-qp)/gamma/dt; m_dpt = m_dpp*omoog + (m_pt-m_pp)/gamma/dt; m_pt = m_pp + (m_R*m_dqt + m_qt/m_C - m_dpp*omoog)*gamma*dt; // calculate the dilatation m_e = 0.0; bool good = m_pfluid->Dilatation(0,m_pt + m_p0, m_e); assert(good); } //----------------------------------------------------------------------------- void FEFluidRCBC::PrepStep(std::vector<double>& ui, bool brel) { UpdateDilatation(); FEPrescribedSurface::PrepStep(ui, brel); } //----------------------------------------------------------------------------- void FEFluidRCBC::Update() { UpdateDilatation(); FEPrescribedSurface::Update(); // TODO: Is this necessary? GetFEModel()->SetMeshUpdateFlag(true); } void FEFluidRCBC::UpdateModel() { Update(); } //----------------------------------------------------------------------------- // return the value for node i, dof j void FEFluidRCBC::GetNodalValues(int nodelid, std::vector<double>& val) { val[0] = m_e; FENode& node = GetMesh().Node(m_nodeList[nodelid]); node.set(m_dofEF, m_e); } //----------------------------------------------------------------------------- // copy data from another class void FEFluidRCBC::CopyFrom(FEBoundaryCondition* pbc) { // TODO: implement this assert(false); } //----------------------------------------------------------------------------- //! evaluate the flow rate across this surface double FEFluidRCBC::FlowRate() { double Q = 0; vec3d rt[FEElement::MAX_NODES]; vec3d vt[FEElement::MAX_NODES]; for (int iel=0; iel<m_psurf->Elements(); ++iel) { FESurfaceElement& el = m_psurf->Element(iel); // nr integration points int nint = el.GaussPoints(); // nr of element nodes int neln = el.Nodes(); // nodal coordinates for (int i=0; i<neln; ++i) { FENode& node = m_psurf->GetMesh()->Node(el.m_node[i]); rt[i] = node.m_rt; vt[i] = node.get_vec3d(m_dofW[0], m_dofW[1], m_dofW[2]); } double* Nr, *Ns; double* N; double* w = el.GaussWeights(); vec3d dxr, dxs, v; // repeat over integration points for (int n=0; n<nint; ++n) { N = el.H(n); Nr = el.Gr(n); Ns = el.Gs(n); // calculate the velocity and tangent vectors at integration point dxr = dxs = v = vec3d(0,0,0); for (int i=0; i<neln; ++i) { v += vt[i]*N[i]; dxr += rt[i]*Nr[i]; dxs += rt[i]*Ns[i]; } vec3d normal = dxr ^ dxs; double q = normal*v; Q += q*w[n]; } } return Q; } //----------------------------------------------------------------------------- //! serialization void FEFluidRCBC::Serialize(DumpStream& ar) { FEPrescribedSurface::Serialize(ar); ar & m_pt & m_dpt & m_qt & m_dqt & m_e; if (ar.IsShallow()) return; ar & m_pfluid; ar & m_dofW & m_dofEF; ar & m_psurf; }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEBioFluidPlot.h
.h
26,001
676
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include "FECore/FEPlotData.h" #include <FECore/units.h> //============================================================================= // N O D E D A T A //============================================================================= //----------------------------------------------------------------------------- //! Nodal displacement class FEPlotDisplacement : public FEPlotNodeData { public: FEPlotDisplacement(FEModel* pfem) : FEPlotNodeData(pfem, PLT_VEC3F, FMT_NODE) { SetUnits(UNIT_LENGTH); } bool Save(FEMesh& m, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Nodal fluid velocity class FEPlotNodalFluidVelocity : public FEPlotNodeData { public: FEPlotNodalFluidVelocity(FEModel* pfem) : FEPlotNodeData(pfem, PLT_VEC3F, FMT_NODE) { SetUnits(UNIT_VELOCITY); } bool Save(FEMesh& m, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Nodal relative fluid velocity class FEPlotNodalRelativeFluidVelocity : public FEPlotNodeData { public: FEPlotNodalRelativeFluidVelocity(FEModel* pfem) : FEPlotNodeData(pfem, PLT_VEC3F, FMT_NODE) { SetUnits(UNIT_VELOCITY); } bool Save(FEMesh& m, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Nodal fluid dilatation class FEPlotFluidDilatation : public FEPlotNodeData { public: FEPlotFluidDilatation(FEModel* pfem) : FEPlotNodeData(pfem, PLT_FLOAT, FMT_NODE){} bool Save(FEMesh& m, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Nodal effective fluid pressures class FEPlotFluidEffectivePressure : public FEPlotDomainData { public: FEPlotFluidEffectivePressure(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_NODE) { SetUnits(UNIT_PRESSURE); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Nodal polar fluid angular velocity class FEPlotNodalPolarFluidAngularVelocity : public FEPlotNodeData { public: FEPlotNodalPolarFluidAngularVelocity(FEModel* pfem) : FEPlotNodeData(pfem, PLT_VEC3F, FMT_NODE) { SetUnits(UNIT_ANGULAR_VELOCITY); } bool Save(FEMesh& m, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Nodal fluid temperature class FEPlotNodalFluidTemperature : public FEPlotNodeData { public: FEPlotNodalFluidTemperature(FEModel* pfem) : FEPlotNodeData(pfem, PLT_FLOAT, FMT_NODE) { SetUnits(UNIT_RELATIVE_TEMPERATURE); } bool Save(FEMesh& m, FEDataStream& a); }; //============================================================================= // S U R F A C E D A T A //============================================================================= //----------------------------------------------------------------------------- //! Fluid surface force //! class FEPlotFluidSurfaceForce : public FEPlotSurfaceData { private: vector<vec3d> m_area; public: FEPlotFluidSurfaceForce(FEModel* pfem) : FEPlotSurfaceData(pfem, PLT_VEC3F, FMT_REGION){ SetUnits(UNIT_FORCE); } bool Save(FESurface& surf, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Fluid surface moment (polar fluids) //! class FEPlotFluidSurfaceMoment : public FEPlotSurfaceData { private: bool m_binit; vector<vec3d> m_area; public: FEPlotFluidSurfaceMoment(FEModel* pfem) : FEPlotSurfaceData(pfem, PLT_VEC3F, FMT_REGION){ m_binit = true; SetUnits(UNIT_MOMENT); } bool Save(FESurface& surf, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Fluid surface pressure //! class FEPlotFluidSurfacePressure : public FEPlotSurfaceData { public: FEPlotFluidSurfacePressure(FEModel* pfem) : FEPlotSurfaceData(pfem, PLT_FLOAT, FMT_ITEM) { SetUnits(UNIT_PRESSURE); } bool Save(FESurface& surf, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Fluid surface traction power //! class FEPlotFluidSurfaceTractionPower : public FEPlotSurfaceData { private: bool m_binit; vector<vec3d> m_area; public: FEPlotFluidSurfaceTractionPower(FEModel* pfem) : FEPlotSurfaceData(pfem, PLT_FLOAT, FMT_REGION){ m_binit = true; SetUnits(UNIT_POWER); } bool Save(FESurface& surf, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Fluid surface energy flux //! class FEPlotFluidSurfaceEnergyFlux : public FEPlotSurfaceData { private: bool m_binit; vector<vec3d> m_area; public: FEPlotFluidSurfaceEnergyFlux(FEModel* pfem) : FEPlotSurfaceData(pfem, PLT_FLOAT, FMT_REGION){ m_binit = true; SetUnits(UNIT_POWER); } bool Save(FESurface& surf, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Fluid mass flow rate //! class FEPlotFluidMassFlowRate : public FEPlotSurfaceData { public: FEPlotFluidMassFlowRate(FEModel* pfem) : FEPlotSurfaceData(pfem, PLT_FLOAT, FMT_REGION) { SetUnits(UNIT_MASS_FLOW_RATE); } bool Save(FESurface& surf, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Fluid flow rate //! class FEPlotFluidFlowRate : public FEPlotSurfaceData { private: bool m_binit; vector<vec3d> m_area; public: FEPlotFluidFlowRate(FEModel* pfem) : FEPlotSurfaceData(pfem, PLT_FLOAT, FMT_REGION){ m_binit = true; SetUnits(UNIT_FLOW_RATE); } bool Save(FESurface& surf, FEDataStream& a); }; //============================================================================= // D O M A I N D A T A //============================================================================= //----------------------------------------------------------------------------- //! Actual fluid pressure class FEPlotFluidPressure : public FEPlotDomainData { public: FEPlotFluidPressure(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM) { SetUnits(UNIT_PRESSURE); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element elastic fluid pressure class FEPlotElasticFluidPressure : public FEPlotDomainData { public: FEPlotElasticFluidPressure(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM) { SetUnits(UNIT_PRESSURE); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element fluid temperature class FEPlotFluidTemperature : public FEPlotDomainData { public: FEPlotFluidTemperature(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM) { SetUnits(UNIT_RELATIVE_TEMPERATURE); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element fluid volume ratio class FEPlotFluidVolumeRatio : public FEPlotDomainData { public: FEPlotFluidVolumeRatio(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM){} bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element fluid density class FEPlotFluidDensity : public FEPlotDomainData { public: FEPlotFluidDensity(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM) { SetUnits(UNIT_DENSITY); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element fluid density rate class FEPlotFluidDensityRate : public FEPlotDomainData { public: FEPlotFluidDensityRate(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM) { SetUnits(UNIT_DENSITY_RATE); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element fluid body force class FEPlotFluidBodyForce : public FEPlotDomainData { public: FEPlotFluidBodyForce(FEModel* pfem) : FEPlotDomainData(pfem, PLT_VEC3F, FMT_ITEM) { SetUnits(UNIT_SPECIFIC_FORCE); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element fluid velocity class FEPlotFluidVelocity : public FEPlotDomainData { public: FEPlotFluidVelocity(FEModel* pfem) : FEPlotDomainData(pfem, PLT_VEC3F, FMT_ITEM) { SetUnits(UNIT_VELOCITY); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element relative fluid velocity class FEPlotRelativeFluidVelocity : public FEPlotDomainData { public: FEPlotRelativeFluidVelocity(FEModel* pfem) : FEPlotDomainData(pfem, PLT_VEC3F, FMT_ITEM) { SetUnits(UNIT_VELOCITY); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element relative fluid flux class FEPlotFSIFluidFlux : public FEPlotDomainData { public: FEPlotFSIFluidFlux(FEModel* pfem) : FEPlotDomainData(pfem, PLT_VEC3F, FMT_ITEM) { SetUnits(UNIT_VELOCITY); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Permeability class FEPlotPermeability : public FEPlotDomainData { public: FEPlotPermeability(FEModel* pfem) : FEPlotDomainData(pfem, PLT_MAT3FS, FMT_ITEM) { SetUnits(UNIT_PERMEABILITY); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element GradJ class FEPlotGradJ : public FEPlotDomainData { public: FEPlotGradJ(FEModel* pfem) : FEPlotDomainData(pfem, PLT_VEC3F, FMT_ITEM){} bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element gradphif class FEPlotGradPhiF : public FEPlotDomainData { public: FEPlotGradPhiF(FEModel* pfem) : FEPlotDomainData(pfem, PLT_VEC3F, FMT_ITEM){} bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element porosity class FEPlotBFSIPorosity : public FEPlotDomainData { public: FEPlotBFSIPorosity(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM){} bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element solid volume fraction class FEPlotBFSISolidVolumeFraction : public FEPlotDomainData { public: FEPlotBFSISolidVolumeFraction(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM){} bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element fluid acceleration class FEPlotFluidAcceleration : public FEPlotDomainData { public: FEPlotFluidAcceleration(FEModel* pfem) : FEPlotDomainData(pfem, PLT_VEC3F, FMT_ITEM) { SetUnits(UNIT_ACCELERATION); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element fluid vorticity class FEPlotFluidVorticity : public FEPlotDomainData { public: FEPlotFluidVorticity(FEModel* pfem) : FEPlotDomainData(pfem, PLT_VEC3F, FMT_ITEM) { SetUnits(UNIT_ANGULAR_VELOCITY); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element polar fluid angular velocity class FEPlotPolarFluidAngularVelocity : public FEPlotDomainData { public: FEPlotPolarFluidAngularVelocity(FEModel* pfem) : FEPlotDomainData(pfem, PLT_VEC3F, FMT_ITEM) { SetUnits(UNIT_ANGULAR_VELOCITY); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element polar fluid relative angular velocity class FEPlotPolarFluidRelativeAngularVelocity : public FEPlotDomainData { public: FEPlotPolarFluidRelativeAngularVelocity(FEModel* pfem) : FEPlotDomainData(pfem, PLT_VEC3F, FMT_ITEM) { SetUnits(UNIT_ANGULAR_VELOCITY); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element polar fluid rregional angular velocity class FEPlotPolarFluidRegionalAngularVelocity : public FEPlotDomainData { public: FEPlotPolarFluidRegionalAngularVelocity(FEModel* pfem) : FEPlotDomainData(pfem, PLT_VEC3F, FMT_ITEM) { SetUnits(UNIT_ANGULAR_VELOCITY); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element fluid heat flux class FEPlotFluidHeatFlux : public FEPlotDomainData { public: FEPlotFluidHeatFlux(FEModel* pfem) : FEPlotDomainData(pfem, PLT_VEC3F, FMT_ITEM) { SetUnits(UNIT_ENERGY_FLUX); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element fluid stresses class FEPlotFluidStress : public FEPlotDomainData { public: FEPlotFluidStress(FEModel* pfem) : FEPlotDomainData(pfem, PLT_MAT3FS, FMT_ITEM) { SetUnits(UNIT_PRESSURE); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element fluid rate of deformation class FEPlotElementFluidRateOfDef : public FEPlotDomainData { public: FEPlotElementFluidRateOfDef(FEModel* pfem) : FEPlotDomainData(pfem, PLT_MAT3FS, FMT_ITEM) { SetUnits(UNIT_RECIPROCAL_TIME); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element fluid stress power density class FEPlotFluidStressPowerDensity : public FEPlotDomainData { public: FEPlotFluidStressPowerDensity(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM) { SetUnits(UNIT_POWER_DENSITY); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element fluid heat supply density class FEPlotFluidHeatSupplyDensity : public FEPlotDomainData { public: FEPlotFluidHeatSupplyDensity(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM) { SetUnits(UNIT_POWER_DENSITY); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element fluid shear viscosity class FEPlotFluidShearViscosity : public FEPlotDomainData { public: FEPlotFluidShearViscosity(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM) { SetUnits(UNIT_VISCOSITY); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element strain energy density class FEPlotFluidStrainEnergyDensity : public FEPlotDomainData { public: FEPlotFluidStrainEnergyDensity(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM) { SetUnits(UNIT_ENERGY_DENSITY); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element kinetic energy density class FEPlotFluidKineticEnergyDensity : public FEPlotDomainData { public: FEPlotFluidKineticEnergyDensity(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM) { SetUnits(UNIT_ENERGY_DENSITY); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element energy density class FEPlotFluidEnergyDensity : public FEPlotDomainData { public: FEPlotFluidEnergyDensity(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM) { SetUnits(UNIT_ENERGY_DENSITY); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element fluid bulk modulus class FEPlotFluidBulkModulus : public FEPlotDomainData { public: FEPlotFluidBulkModulus(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM) { SetUnits(UNIT_PRESSURE); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Strain energy class FEPlotFluidElementStrainEnergy : public FEPlotDomainData { public: FEPlotFluidElementStrainEnergy(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM) { SetUnits(UNIT_ENERGY); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Kinetic energy class FEPlotFluidElementKineticEnergy : public FEPlotDomainData { public: FEPlotFluidElementKineticEnergy(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM) { SetUnits(UNIT_ENERGY); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Center of mass class FEPlotFluidElementCenterOfMass : public FEPlotDomainData { public: FEPlotFluidElementCenterOfMass(FEModel* pfem) : FEPlotDomainData(pfem, PLT_VEC3F, FMT_ITEM) { SetUnits(UNIT_LENGTH); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Linear momentum class FEPlotFluidElementLinearMomentum : public FEPlotDomainData { public: FEPlotFluidElementLinearMomentum(FEModel* pfem) : FEPlotDomainData(pfem, PLT_VEC3F, FMT_ITEM) { SetUnits(UNIT_LINEAR_MOMENTUM); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Angular momentum class FEPlotFluidElementAngularMomentum : public FEPlotDomainData { public: FEPlotFluidElementAngularMomentum(FEModel* pfem) : FEPlotDomainData(pfem, PLT_VEC3F, FMT_ITEM) { SetUnits(UNIT_ANGULAR_MOMENTUM); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Specific free energy class FEPlotFluidSpecificFreeEnergy : public FEPlotDomainData { public: FEPlotFluidSpecificFreeEnergy(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM) { SetUnits(UNIT_SPECIFIC_ENERGY); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Specific entropy class FEPlotFluidSpecificEntropy : public FEPlotDomainData { public: FEPlotFluidSpecificEntropy(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM) { SetUnits(UNIT_SPECIFIC_ENTROPY); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Specific internal energy class FEPlotFluidSpecificInternalEnergy : public FEPlotDomainData { public: FEPlotFluidSpecificInternalEnergy(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM) { SetUnits(UNIT_SPECIFIC_ENERGY); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Specific gauge enthalpy class FEPlotFluidSpecificGaugeEnthalpy : public FEPlotDomainData { public: FEPlotFluidSpecificGaugeEnthalpy(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM) { SetUnits(UNIT_SPECIFIC_ENERGY); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Specific free enthalpy class FEPlotFluidSpecificFreeEnthalpy : public FEPlotDomainData { public: FEPlotFluidSpecificFreeEnthalpy(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM) { SetUnits(UNIT_SPECIFIC_ENERGY); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Specific strain energy class FEPlotFluidSpecificStrainEnergy : public FEPlotDomainData { public: FEPlotFluidSpecificStrainEnergy(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM) { SetUnits(UNIT_SPECIFIC_ENERGY); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Specific isochoric heat capacity class FEPlotFluidIsochoricSpecificHeatCapacity : public FEPlotDomainData { public: FEPlotFluidIsochoricSpecificHeatCapacity(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM) { SetUnits(UNIT_SPECIFIC_ENTROPY); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Specific isobaric heat capacity class FEPlotFluidIsobaricSpecificHeatCapacity : public FEPlotDomainData { public: FEPlotFluidIsobaricSpecificHeatCapacity(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM) { SetUnits(UNIT_SPECIFIC_ENTROPY); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Fluid pressure tangent temperature class FEPlotFluidPressureTangentTemperature : public FEPlotDomainData { public: FEPlotFluidPressureTangentTemperature(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM) { SetUnits(UNIT_SPECIFIC_ENTROPY); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Fluid pressure tangent strain class FEPlotFluidPressureTangentStrain : public FEPlotDomainData { public: FEPlotFluidPressureTangentStrain(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM) { SetUnits(UNIT_SPECIFIC_ENTROPY); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Thermal conductivity class FEPlotFluidThermalConductivity : public FEPlotDomainData { public: FEPlotFluidThermalConductivity(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM) { SetUnits(UNIT_THERMAL_CONDUCTIVITY); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element solid stresses class FEPlotFSISolidStress : public FEPlotDomainData { public: FEPlotFSISolidStress(FEModel* pfem) : FEPlotDomainData(pfem, PLT_MAT3FS, FMT_ITEM) { SetUnits(UNIT_PRESSURE); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! fluid shear stress error class FEPlotFluidShearStressError : public FEPlotDomainData { public: FEPlotFluidShearStressError(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM) {} bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element polar fluid stresses class FEPlotPolarFluidStress : public FEPlotDomainData { public: FEPlotPolarFluidStress(FEModel* pfem) : FEPlotDomainData(pfem, PLT_MAT3F, FMT_ITEM) { SetUnits(UNIT_PRESSURE); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element polar fluid couple stresses class FEPlotPolarFluidCoupleStress : public FEPlotDomainData { public: FEPlotPolarFluidCoupleStress(FEModel* pfem) : FEPlotDomainData(pfem, PLT_MAT3F, FMT_ITEM) { SetUnits(UNIT_ENERGY_AREAL_DENSITY); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element relative Reynolds number class FEPlotFluidRelativeReynoldsNumber : public FEPlotDomainData { public: FEPlotFluidRelativeReynoldsNumber(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM) { SetUnits(UNIT_RECIPROCAL_LENGTH); } bool Save(FEDomain& dom, FEDataStream& a); }; //----------------------------------------------------------------------------- //! Element relative Peclet number class FEPlotFluidRelativePecletNumber : public FEPlotDomainData { public: FEPlotFluidRelativePecletNumber(FEModel* pfem); bool Save(FEDomain& dom, FEDataStream& a); protected: vector<int> m_sol; }; //----------------------------------------------------------------------------- //! Element relative thermal Peclet number class FEPlotFluidRelativeThermalPecletNumber : public FEPlotDomainData { public: FEPlotFluidRelativeThermalPecletNumber(FEModel* pfem) : FEPlotDomainData(pfem, PLT_FLOAT, FMT_ITEM) { SetUnits(UNIT_RECIPROCAL_LENGTH); } bool Save(FEDomain& dom, FEDataStream& a); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEFluidNaturalHeatFlux.cpp
.cpp
3,853
107
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEFluidNaturalHeatFlux.h" #include <FECore/FEGlobalMatrix.h> #include <FECore/FEGlobalVector.h> #include <FECore/log.h> #include <FECore/LinearSolver.h> #include <FECore/FEModel.h> #include "FEBioThermoFluid.h" #include "FEFluidMaterialPoint.h" #include "FEThermoFluidMaterialPoint.h" //----------------------------------------------------------------------------- //! constructor FEFluidNaturalHeatFlux::FEFluidNaturalHeatFlux(FEModel* pfem) : FESurfaceLoad(pfem) { } //----------------------------------------------------------------------------- //! allocate storage void FEFluidNaturalHeatFlux::SetSurface(FESurface* ps) { FESurfaceLoad::SetSurface(ps); } //----------------------------------------------------------------------------- //! initialize bool FEFluidNaturalHeatFlux::Init() { // get the degrees of freedom m_dof.Clear(); m_dof.AddVariable(FEBioThermoFluid::GetVariableName(FEBioThermoFluid::TEMPERATURE)); if (m_dof.IsEmpty()) return false; return FESurfaceLoad::Init(); } //----------------------------------------------------------------------------- //! Calculate the residual for the prescribed normal velocity void FEFluidNaturalHeatFlux::LoadVector(FEGlobalVector& R) { m_psurf->LoadVector(R, m_dof, true, [=](FESurfaceMaterialPoint& mp, const FESurfaceDofShape& dof_a, std::vector<double>& fa) { const FETimeInfo& tp = GetTimeInfo(); // get surface element FESurfaceElement& el = *mp.SurfaceElement(); // get underlying solid element FEElement* pe = el.m_elem[0].pe; FEMaterial* pm = GetFEModel()->GetMaterial(pe->GetMatID()); vec3d dxt = mp.dxr ^ mp.dxs; // get element-averaged heat flux vec3d q(0,0,0); int nint = pe->GaussPoints(); for (int n=0; n<nint; ++n) { FEMaterialPoint& pt = *pe->GetMaterialPoint(n); FEFluidMaterialPoint* pf = pt.ExtractData<FEFluidMaterialPoint>(); if (pf == nullptr) break; FEThermoFluidMaterialPoint* ps = pt.ExtractData<FEThermoFluidMaterialPoint>(); if (ps == nullptr) break; // if (ps->m_q*pf->m_vft > 0) q += ps->m_q; q += ps->m_q; } q /= nint; double qn = dxt*q; double H = dof_a.shape; fa[0] = qn*H; }); } //----------------------------------------------------------------------------- //! serialization void FEFluidNaturalHeatFlux::Serialize(DumpStream& ar) { FESurfaceLoad::Serialize(ar); }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEFluidNormalHeatFlux.h
.h
2,059
57
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FESurfaceLoad.h> #include <FECore/FEModelParam.h> #include "febiofluid_api.h" //----------------------------------------------------------------------------- //! FEFluidNormalHeatFlux is a thermo-fluid surface that has a normal //! heat flux prescribed on it. class FEBIOFLUID_API FEFluidNormalHeatFlux : public FESurfaceLoad { public: //! constructor FEFluidNormalHeatFlux(FEModel* pfem); //! initialization bool Init() override; //! calculate load vector void LoadVector(FEGlobalVector& R) override; //! calculate heat flux stiffness (there is none) void StiffnessMatrix(FELinearSystem& LS) override {} protected: FEParamDouble m_flux; //!< heat flux DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEViscousFluid.cpp
.cpp
1,325
31
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEViscousFluid.h"
C++
3D
febiosoftware/FEBio
FEBioFluid/FEFluidNormalVelocity.h
.h
3,027
92
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FESurfaceLoad.h> #include <FECore/FESurfaceMap.h> #include <FECore/FEModelParam.h> #include "febiofluid_api.h" //----------------------------------------------------------------------------- //! FEFluidNormalVelocity is a fluid surface that has a normal //! velocity prescribed on it. This routine simultaneously prescribes a //! surface load and nodal prescribed velocities class FEBIOFLUID_API FEFluidNormalVelocity : public FESurfaceLoad { public: //! constructor FEFluidNormalVelocity(FEModel* pfem); //! calculate traction stiffness (there is none) void StiffnessMatrix(FELinearSystem& LS) override {} //! calculate load vector void LoadVector(FEGlobalVector& R) override; //! serializatsion void Serialize(DumpStream& ar) override; //! set the velocity void Update() override; //! initialization bool Init() override; //! activate void Activate() override; //! parabolic velocity profile bool SetParabolicVelocity(); //! rim pressure bool SetRimPressure(); double ScalarLoad(FESurfaceMaterialPoint& mp) override; private: double NormalVelocity(FESurfaceMaterialPoint& mp); private: FEParamDouble m_velocity; //!< average velocity bool m_brim; //!< flag for setting rim pressure // obsolete parameters bool m_bpv; //!< flag for prescribing nodal values bool m_bpar; private: vector<vec3d> m_nu; //!< nodal normals vector<double> m_VN; //!< nodal values for velocity vector<int> m_rim; //!< list of nodes on the rim FEDofList m_dofW; FEDofList m_dofEF; DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEFluidMaterialPoint.cpp
.cpp
2,631
71
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "FEFluidMaterialPoint.h" //============================================================================ // FEFluidMaterialPoint //============================================================================ //----------------------------------------------------------------------------- FEFluidMaterialPoint::FEFluidMaterialPoint(FEMaterialPointData* pt) : FEMaterialPointData(pt) { m_pf = 0; m_Lf.zero(); m_ef = 0; m_efdot = 0; m_vft = m_aft = m_gradef = vec3d(0,0,0); m_sf.zero(); } //----------------------------------------------------------------------------- FEMaterialPointData* FEFluidMaterialPoint::Copy() { FEFluidMaterialPoint* pt = new FEFluidMaterialPoint(*this); if (m_pNext) pt->m_pNext = m_pNext->Copy(); return pt; } //----------------------------------------------------------------------------- void FEFluidMaterialPoint::Serialize(DumpStream& ar) { FEMaterialPointData::Serialize(ar); ar & m_pf & m_Lf & m_ef & m_efdot & m_gradef & m_vft & m_aft & m_sf; } //----------------------------------------------------------------------------- void FEFluidMaterialPoint::Init() { m_pf = 0; m_Lf.zero(); m_ef = 0; m_efdot = 0; m_vft = m_aft = m_gradef = vec3d(0,0,0); m_sf.zero(); // don't forget to initialize the base class FEMaterialPointData::Init(); }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEFluidSoluteAnalysis.cpp
.cpp
1,696
38
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "FEFluidSolutesAnalysis.h" BEGIN_FECORE_CLASS(FEFluidSolutesAnalysis, FEAnalysis) // The analysis parameter is already defined in the FEAnalysis base class. // Here, we just need to set the enum values for the analysis parameter. FindParameterFromData(&m_nanalysis)->setEnums("STEADY-STATE\0DYNAMIC\0"); END_FECORE_CLASS() FEFluidSolutesAnalysis::FEFluidSolutesAnalysis(FEModel* fem) : FEAnalysis(fem) { }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEFluidSupply.h
.h
2,445
64
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2023 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FEMaterial.h> #include "febiofluid_api.h" //----------------------------------------------------------------------------- //! Base class for solvent supply. //! These materials need to define the supply and tangent supply functions. //! class FEBIOFLUID_API FEFluidSupply : public FEMaterialProperty { public: FEFluidSupply(FEModel* pfem) : FEMaterialProperty(pfem) {} virtual ~FEFluidSupply(){} //! fluid supply virtual double Supply(FEMaterialPoint& pt) = 0; //! tangent of fluid supply with respect to strain virtual mat3d Tangent_Supply_Strain(FEMaterialPoint& mp) = 0; //! tangent of fluid supply with respect to pressure virtual double Tangent_Supply_Dilatation(FEMaterialPoint& mp) = 0; //! tangent of fluid supply with respect to rate of deformation virtual mat3ds Tangent_Supply_RateOfDeformation(FEMaterialPoint& mp) = 0; //! tangent of fluid supply with respect to concentration virtual double Tangent_Supply_Concentration(FEMaterialPoint& mp, const int isol); //! initialization bool Init() override { return FEMaterialProperty::Init(); } FECORE_BASE_CLASS(FEFluidSupply) };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEIdealGas.h
.h
4,024
104
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include "FEElasticFluid.h" #include <FECore/FEFunction1D.h> //----------------------------------------------------------------------------- //! Base class for the viscous part of the fluid response. //! These materials provide the viscous stress and its tangents. //! class FEBIOFLUID_API FEIdealGas : public FEElasticFluid { public: FEIdealGas(FEModel* pfem); ~FEIdealGas() {} //! initialization bool Init() override; //! Serialization void Serialize(DumpStream& ar) override; //! gauge pressure double Pressure(FEMaterialPoint& pt) override; //! tangent of pressure with respect to strain J double Tangent_Strain(FEMaterialPoint& mp) override; //! 2nd tangent of pressure with respect to strain J double Tangent_Strain_Strain(FEMaterialPoint& mp) override; //! tangent of pressure with respect to temperature T double Tangent_Temperature(FEMaterialPoint& mp) override; //! 2nd tangent of pressure with respect to temperature T double Tangent_Temperature_Temperature(FEMaterialPoint& mp) override; //! tangent of pressure with respect to strain J and temperature T double Tangent_Strain_Temperature(FEMaterialPoint& mp) override; //! specific free energy double SpecificFreeEnergy(FEMaterialPoint& mp) override; //! specific entropy double SpecificEntropy(FEMaterialPoint& mp) override; //! specific strain energy double SpecificStrainEnergy(FEMaterialPoint& mp) override; //! isochoric specific heat capacity double IsochoricSpecificHeatCapacity(FEMaterialPoint& mp) override; //! tangent of isochoric specific heat capacity with respect to strain J double Tangent_cv_Strain(FEMaterialPoint& mp) override; //! tangent of isochoric specific heat capacity with respect to temperature T double Tangent_cv_Temperature(FEMaterialPoint& mp) override; //! isobaric specific heat capacity double IsobaricSpecificHeatCapacity(FEMaterialPoint& mp) override; //! dilatation from temperature and pressure bool Dilatation(const double T, const double p, double& e) override; public: double m_R; //!< universal gas constant double m_Pr; //!< referential absolute pressure double m_Tr; //!< referential absolute temperature double m_M; //!< molar mass double m_ar; //!< referential specific free energy double m_sr; //!< referential specific entropy FEFunction1D* m_cp; //!< isobaric specific heat capacity FEFunction1D* m_ao; //!< specific free energy a-circle // declare parameter list DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEIdealGasIsentropic.cpp
.cpp
7,160
193
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "FEIdealGasIsentropic.h" #include "FEFluidMaterialPoint.h" #include <FECore/log.h> // define the material parameters BEGIN_FECORE_CLASS(FEIdealGasIsentropic, FEElasticFluid) ADD_PARAMETER(m_gamma, FE_RANGE_GREATER(0.0), "gamma")->setLongName("specific heat capacity ratio"); ADD_PARAMETER(m_M , FE_RANGE_GREATER(0.0), "M" )->setLongName("molar mass")->setUnits(UNIT_MOLAR_MASS); ADD_PARAMETER(m_cv0 , FE_RANGE_GREATER(0.0), "cv0" )->setLongName("isochoric specific heat capacity")->setUnits(UNIT_SPECIFIC_ENTROPY); END_FECORE_CLASS(); //============================================================================ // FEIdealGasIsentropic //============================================================================ //----------------------------------------------------------------------------- //! FEIdealGasIsentropic constructor FEIdealGasIsentropic::FEIdealGasIsentropic(FEModel* pfem) : FEElasticFluid(pfem) { m_rhor = 0; m_k = 0; m_gamma = 0; m_M = 0; m_cv0 = 0; } //----------------------------------------------------------------------------- //! initialization bool FEIdealGasIsentropic::Init() { m_R = GetGlobalConstant("R"); m_Tr = GetGlobalConstant("T"); m_Pr = GetGlobalConstant("P"); if (m_R <= 0) { feLogError("A positive universal gas constant R must be defined in Globals section"); return false; } if (m_Tr <= 0) { feLogError("A positive ambient absolute temperature T must be defined in Globals section"); return false; } if (m_Pr <= 0) { feLogError("A positive ambient absolute pressure P must be defined in Globals section"); return false; } if (m_rhor == 0) m_rhor = m_M*m_Pr/(m_R*m_Tr); if (m_k == 0) m_k = m_Pr; return true; } //----------------------------------------------------------------------------- void FEIdealGasIsentropic::Serialize(DumpStream& ar) { FEElasticFluid::Serialize(ar); if (ar.IsShallow()) return; ar & m_R & m_Pr & m_Tr & m_rhor; } //----------------------------------------------------------------------------- //! elastic pressure double FEIdealGasIsentropic::Pressure(FEMaterialPoint& mp) { FEFluidMaterialPoint& fp = *mp.ExtractData<FEFluidMaterialPoint>(); double p =m_k*(pow(1+fp.m_ef,-m_gamma)-1); return p; } //----------------------------------------------------------------------------- //! tangent of pressure with respect to strain J double FEIdealGasIsentropic::Tangent_Strain(FEMaterialPoint& mp) { FEFluidMaterialPoint& fp = *mp.ExtractData<FEFluidMaterialPoint>(); double dpJ = -m_k*m_gamma*pow(1+fp.m_ef,-1-m_gamma); return dpJ; } //----------------------------------------------------------------------------- //! 2nd tangent of pressure with respect to strain J double FEIdealGasIsentropic::Tangent_Strain_Strain(FEMaterialPoint& mp) { FEFluidMaterialPoint& fp = *mp.ExtractData<FEFluidMaterialPoint>(); double d2pJ = m_k*m_gamma*(1+m_gamma)*pow(1+fp.m_ef,-2-m_gamma); return d2pJ; } //----------------------------------------------------------------------------- //! tangent of pressure with respect to temperature T double FEIdealGasIsentropic::Tangent_Temperature(FEMaterialPoint& mp) { FEFluidMaterialPoint& fp = *mp.ExtractData<FEFluidMaterialPoint>(); double dpT = m_k/(1+fp.m_ef)/m_Tr; return dpT; } //----------------------------------------------------------------------------- //! 2nd tangent of pressure with respect to temperature T double FEIdealGasIsentropic::Tangent_Temperature_Temperature(FEMaterialPoint& mp) { return 0; } //----------------------------------------------------------------------------- //! tangent of pressure with respect to strain J and temperature T double FEIdealGasIsentropic::Tangent_Strain_Temperature(FEMaterialPoint& mp) { FEFluidMaterialPoint& fp = *mp.ExtractData<FEFluidMaterialPoint>(); double dpTJ = -m_k/pow(1+fp.m_ef,2)/m_Tr; return 0; } //----------------------------------------------------------------------------- //! specific free energy double FEIdealGasIsentropic::SpecificFreeEnergy(FEMaterialPoint& mp) { FEFluidMaterialPoint& fp = *mp.ExtractData<FEFluidMaterialPoint>(); double a = m_Tr*(m_R/m_M*fp.m_ef + m_cv0*(pow(1+fp.m_ef,1-m_gamma)-1)); return a; } //----------------------------------------------------------------------------- //! specific entropy double FEIdealGasIsentropic::SpecificEntropy(FEMaterialPoint& mp) { return 0; } //----------------------------------------------------------------------------- //! specific strain energy double FEIdealGasIsentropic::SpecificStrainEnergy(FEMaterialPoint& mp) { return SpecificFreeEnergy(mp); } //----------------------------------------------------------------------------- //! isobaric specific heat capacity double FEIdealGasIsentropic::IsobaricSpecificHeatCapacity(FEMaterialPoint& mp) { return m_cv0 + m_R/m_M; } //----------------------------------------------------------------------------- //! isochoric specific heat capacity double FEIdealGasIsentropic::IsochoricSpecificHeatCapacity(FEMaterialPoint& mp) { return m_cv0; } //----------------------------------------------------------------------------- //! tangent of isochoric specific heat capacity with respect to strain J double FEIdealGasIsentropic::Tangent_cv_Strain(FEMaterialPoint& mp) { return 0; } //----------------------------------------------------------------------------- //! tangent of isochoric specific heat capacity with respect to temperature T double FEIdealGasIsentropic::Tangent_cv_Temperature(FEMaterialPoint& mp) { return 0; } //----------------------------------------------------------------------------- //! dilatation from temperature and pressure bool FEIdealGasIsentropic::Dilatation(const double T, const double p, double& e) { e = pow(1+p/m_k,-1/m_gamma)-1.0; return true; }
C++
3D
febiosoftware/FEBio
FEBioFluid/FEMultiphasicFSISoluteBackflowStabilization.h
.h
2,581
75
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2020 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FESurfaceLoad.h> #include "FEFluidSolutes.h" #include <FECore/FENodeNodeList.h> //----------------------------------------------------------------------------- //! FESoluteBackflowStabilization is a fluid surface where solute concentration //! is maintained constant when the fluid velocity normal to the surface is //! inward. //! class FEBIOFLUID_API FEMultiphasicFSISoluteBackflowStabilization : public FESurfaceLoad { public: //! constructor FEMultiphasicFSISoluteBackflowStabilization(FEModel* pfem); //! calculate traction stiffness (there is none) void StiffnessMatrix(FELinearSystem& LS) override {} //! calculate load vector void LoadVector(FEGlobalVector& R) override; //! set the dilatation void Update() override; //! evaluate flow rate void MarkBackFlow(); //! initialize bool Init() override; //! activate void Activate() override; //! serialization void Serialize(DumpStream& ar) override; private: int m_sol; //!< solute id FEDofList m_dofW; int m_dofC; vector<bool> m_backflow; //!< flag for nodes that have backflow FENodeNodeList m_nnlist; DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEFSIErosionVolumeRatio.h
.h
1,627
47
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FEMeshAdaptor.h> class FEFSIErosionVolumeRatio : public FEMeshAdaptor { public: FEFSIErosionVolumeRatio(FEModel* fem); bool Apply(int iteration) override; private: double m_minJ; int m_maxElems; int m_maxIters; int m_metric; DECLARE_FECORE_CLASS() };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEMultiphasicFSIDomainFactory.h
.h
1,640
39
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2020 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FECoreKernel.h> #include "febiofluid_api.h" //----------------------------------------------------------------------------- class FEBIOFLUID_API FEMultiphasicFSIDomainFactory : public FEDomainFactory { public: virtual FEDomain* CreateDomain(const FE_Element_Spec& spec, FEMesh* pm, FEMaterial* pmat); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEFluid.h
.h
3,847
107
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FEBioMech/FEBodyForce.h> #include "FEFluidMaterial.h" #include "FEFluidMaterialPoint.h" #include "FEViscousFluid.h" #include <FEBioMix/FEBiphasic.h> #include "FEElasticFluid.h" //----------------------------------------------------------------------------- //! Base class for fluid materials. //! NOTE: This inherits from FEBiphasicInterface in order to override the GetActualFluidPressure, //! which is used in FEReactionRateExpSED and FEReactionRateHuiskes. //! Note sure yet if there is a better alternative. class FEBIOFLUID_API FEFluid : public FEFluidMaterial, public FEBiphasicInterface { public: FEFluid(FEModel* pfem); // returns a pointer to a new material point object FEMaterialPointData* CreateMaterialPointData() override; public: //! initialization bool Init() override; //! Serialization void Serialize(DumpStream& ar) override; //! calculate stress at material point mat3ds Stress(FEMaterialPoint& pt) override; //! tangent of stress with respect to strain J mat3ds Tangent_Strain(FEMaterialPoint& mp) override; //! elastic pressure double Pressure(FEMaterialPoint& mp) override; double Pressure(const double e, const double T = 0) override; //! tangent of elastic pressure with respect to strain J double Tangent_Pressure_Strain(FEMaterialPoint& mp) override; //! 2nd tangent of elastic pressure with respect to strain J double Tangent_Pressure_Strain_Strain(FEMaterialPoint& mp) override; //! bulk modulus double BulkModulus(FEMaterialPoint& mp) override; //! strain energy density double StrainEnergyDensity(FEMaterialPoint& mp) override; //! evaluate temperature double Temperature(FEMaterialPoint& mp) override { return m_Tr; } //! evaluate dilatation from effective pressure bool Dilatation(const double T, const double p, double& e) override; //! return elastic fluid FEElasticFluid* GetElastic() { return m_pElastic; } private: // material properties FEElasticFluid* m_pElastic; //!< pointer to elastic part of fluid material public: // from FEBiphasicInterface double GetActualFluidPressure(const FEMaterialPoint& mp) override { const FEFluidMaterialPoint* pt = (mp.ExtractData<FEFluidMaterialPoint>()); return pt->m_pf; } public: double m_k; //!< bulk modulus at J=1 double m_Tr; //!< ambient temperature // declare parameter list DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEFluidDomain3D.h
.h
4,095
123
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FESolidDomain.h> #include "FEFluidDomain.h" #include "FEFluid.h" //----------------------------------------------------------------------------- //! domain described by 3D volumetric elements //! class FEBIOFLUID_API FEFluidDomain3D : public virtual FESolidDomain, public FEFluidDomain { public: //! constructor FEFluidDomain3D(FEModel* pfem); ~FEFluidDomain3D() {} //! assignment operator FEFluidDomain3D& operator = (FEFluidDomain3D& d); //! serialize data to archive void Serialize(DumpStream& ar) override; //! initialize elements void PreSolveUpdate(const FETimeInfo& timeInfo) override; public: // overrides from FEDomain //! get the material FEMaterial* GetMaterial() override { return m_pMat; } //! set the material void SetMaterial(FEMaterial* pm) override; // get total dof list const FEDofList& GetDOFList() const override; public: // overrides from FEElasticDomain // update stresses void Update(const FETimeInfo& tp) override; // update the element stress void UpdateElementStress(int iel, const FETimeInfo& tp); //! internal stress forces void InternalForces(FEGlobalVector& R) override; //! body forces void BodyForce(FEGlobalVector& R, FEBodyForce& BF) override; //! inertial forces for dynamic problems void InertialForces(FEGlobalVector& R) override; //! calculates the global stiffness matrix for this domain void StiffnessMatrix(FELinearSystem& LS) override; //! calculates inertial stiffness void MassMatrix(FELinearSystem& LS) override; //! body force stiffness void BodyForceStiffness(FELinearSystem& LS, FEBodyForce& bf) override; public: // --- S T I F F N E S S --- //! calculates the solid element stiffness matrix void ElementStiffness(FESolidElement& el, matrix& ke); //! calculates the solid element mass matrix void ElementMassMatrix(FESolidElement& el, matrix& ke); //! calculates the stiffness matrix due to body forces void ElementBodyForceStiffness(FEBodyForce& bf, FESolidElement& el, matrix& ke); // --- R E S I D U A L --- //! Calculates the internal stress vector for solid elements void ElementInternalForce(FESolidElement& el, vector<double>& fe); //! Calculates external body forces for solid elements void ElementBodyForce(FEBodyForce& BF, FESolidElement& elem, vector<double>& fe); //! Calculates the inertial force vector for solid elements void ElementInertialForce(FESolidElement& el, vector<double>& fe); protected: FEFluid* m_pMat; protected: FEDofList m_dofW; FEDofList m_dofAW; FEDofList m_dof; int m_dofEF; int m_dofAEF; };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEFluidRCLoad.h
.h
3,102
84
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #pragma once #include <FECore/FESurfaceLoad.h> #include "FEFluidMaterial.h" //----------------------------------------------------------------------------- //! FEFluidRCLoad is a fluid surface that has an RC-equivalent circuit for outflow conditions //! class FEBIOFLUID_API FEFluidRCLoad : public FESurfaceLoad { public: //! constructor FEFluidRCLoad(FEModel* pfem); //! calculate traction stiffness (there is none) void StiffnessMatrix(FELinearSystem& LS) override {} //! calculate load vector void LoadVector(FEGlobalVector& R) override; //! set the dilatation void Update() override; //! evaluate flow rate double FlowRate(); //! initialize bool Init() override; //! activate void Activate() override; //! serialization void Serialize(DumpStream& ar) override; private: double m_R; //!< flow resistance double m_p0; //!< initial fluid pressure double m_C; //!< capacitance bool m_Bern; //!< Use Bernoulli's Relation (Q*|Q|) double m_qt; //!< flow rate at current time step double m_dqt; //!< flow rate time derivative at current time step double m_pt; //!< pressure at current time step double m_dpt; //!< pressure derivative at current time step double m_qp; //!< flow rate at previous time step double m_dqp; //!< flow rate time derivative at previous time step double m_pp; //!< pressure at previoust time step double m_dpp; //!< pressure derivative at previoust time step private: FEFluidMaterial* m_pfluid; //!< pointer to fluid FEDofList m_dofW; int m_dofEF; DECLARE_FECORE_CLASS(); };
Unknown
3D
febiosoftware/FEBio
FEBioFluid/FEFluidSolutesRCRBC.cpp
.cpp
9,725
277
/*This file is part of the FEBio source code and is licensed under the MIT license listed below. See Copyright-FEBio.txt for details. Copyright (c) 2021 University of Utah, The Trustees of Columbia University in the City of New York, and others. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #include "stdafx.h" #include "FEFluidSolutesRCRBC.h" #include "FEBioFluidSolutes.h" #include <FECore/FEAnalysis.h> #include <FECore/log.h> #include <FECore/FEModel.h> //============================================================================= BEGIN_FECORE_CLASS(FEFluidSolutesRCRBC, FEPrescribedSurface) ADD_PARAMETER(m_R , "R")->setUnits("F.t/L^5"); ADD_PARAMETER(m_Rd, "Rd")->setUnits("F.t/L^5"); ADD_PARAMETER(m_p0, "initial_pressure")->setUnits(UNIT_PRESSURE); ADD_PARAMETER(m_pd, "pressure_offset")->setUnits(UNIT_PRESSURE); ADD_PARAMETER(m_C , "capacitance")->setUnits("L^5/F"); END_FECORE_CLASS(); //----------------------------------------------------------------------------- //! constructor FEFluidSolutesRCRBC::FEFluidSolutesRCRBC(FEModel* pfem) : FEPrescribedSurface(pfem), m_dofW(pfem) { m_R = 0.0; m_p0 = 0; m_Rd = 0.0; m_pd = 0.0; m_C = 0.0; m_dofEF = -1; m_dofC = -1; m_Rgas = 0; m_Tabs = 0; } //----------------------------------------------------------------------------- //! initialize //! TODO: Generalize to include the initial conditions bool FEFluidSolutesRCRBC::Init() { m_dofW.AddVariable(FEBioFluidSolutes::GetVariableName(FEBioFluidSolutes::RELATIVE_FLUID_VELOCITY)); m_dofEF = GetDOFIndex(FEBioFluidSolutes::GetVariableName(FEBioFluidSolutes::FLUID_DILATATION), 0); m_dofC = GetDOFIndex(FEBioFluidSolutes::GetVariableName(FEBioFluidSolutes::FLUID_CONCENTRATION), 0); SetDOFList(m_dofEF); if (FEPrescribedSurface::Init() == false) return false; m_Rgas = GetFEModel()->GetGlobalConstant("R"); m_Tabs = GetFEModel()->GetGlobalConstant("T"); m_e.assign(GetSurface()->Nodes(), 0.0); m_pn = m_pp = m_p0; m_pdn = m_pdp = m_pd; m_qn = m_qp = 0; m_tp = 0; return true; } //----------------------------------------------------------------------------- void FEFluidSolutesRCRBC::Update() { // Check if we started a new time, if so, update variables FETimeInfo& timeInfo = GetFEModel()->GetTime(); double time = timeInfo.currentTime; int iter = timeInfo.currentIteration; double dt = timeInfo.timeIncrement; if ((time > m_tp) && (iter == 0)) { m_pp = m_pn; m_qp = m_qn; m_pdp = m_pdn; m_tp = time; } // evaluate the flow rate at the current time m_qn = FlowRate(); m_pdn = m_pd; double tau = m_Rd * m_C; // calculate the RCR pressure m_pn = m_pdn + (m_Rd / (1 + tau / dt) + m_R) * m_qn + tau / (dt + tau) * (m_pp - m_pdp - m_R * m_qp); // prescribe this dilatation at the nodes FESurface* ps = GetSurface(); int N = ps->Nodes(); std::vector<vector<double>> efNodes(N, vector<double>()); std::vector<vector<double>> caNodes(N, vector<double>()); // Project mean of osmotic coefficient and partition coefficient from int points to nodes on surface // Use these to evaluate osmolarity at each node on surface for (int i=0; i<ps->Elements(); ++i) { FESurfaceElement& el = ps->Element(i); FEElement* e = el.m_elem[0].pe; FEMaterial* pm = GetFEModel()->GetMaterial(e->GetMatID()); FEFluid* pfl = pm->ExtractProperty<FEFluid>(); FESoluteInterface* psi = pm->ExtractProperty<FESoluteInterface>(); FESolidElement* se = dynamic_cast<FESolidElement*>(e); if (se) { double efo[FEElement::MAX_NODES] = {0}; if (psi) { const int nsol = psi->Solutes(); std::vector<double> kappa(nsol,0); double osc = 0; const int nint = se->GaussPoints(); // get the average osmotic coefficient and partition coefficients in the solid element for (int j=0; j<nint; ++j) { FEMaterialPoint* pt = se->GetMaterialPoint(j); osc += psi->GetOsmoticCoefficient()->OsmoticCoefficient(*pt); for (int k=0; k<nsol; ++k) kappa[k] += psi->GetPartitionCoefficient(*pt, k); } osc /= nint; for (int k=0; k<nsol; ++k) kappa[k] /= nint; // loop over face nodes for (int j=0; j<el.Nodes(); ++j) { double osm = 0; FENode& node = ps->Node(el.m_lnode[j]); // calculate osmolarity at this node, using nodal effective solute concentrations for (int k=0; k<nsol; ++k) osm += node.get(m_dofC+psi->GetSolute(k)->GetSoluteID()-1)*kappa[k]; // evaluate dilatation at this node double c = m_Rgas*osc*osm; bool good = pfl->Dilatation(0, m_pn - m_Rgas*m_Tabs*osc*osm, efo[j]); assert(good); } } else { // loop over face nodes for (int j=0; j<el.Nodes(); ++j) { FENode& node = ps->Node(el.m_lnode[j]); // evaluate dilatation at this node bool good = pfl->Dilatation(0, m_pn, efo[j]); assert(good); } } // only keep the dilatations at the nodes of the surface face for (int j=0; j<el.Nodes(); ++j) efNodes[el.m_lnode[j]].push_back(efo[j]); } //If no solid element, insert all 0s else { for (int j=0; j<el.Nodes(); ++j) efNodes[el.m_lnode[j]].push_back(0); } } //For each node, average the nodal ef for (int i=0; i<ps->Nodes(); ++i) { double ef = 0; for (int j = 0; j < efNodes[i].size(); ++j) ef += efNodes[i][j]; ef /= efNodes[i].size(); // store value for now m_e[i] = ef; } FEPrescribedSurface::Update(); } //----------------------------------------------------------------------------- //! evaluate the flow rate across this surface at current time double FEFluidSolutesRCRBC::FlowRate() { double Q = 0; vec3d rt[FEElement::MAX_NODES]; vec3d vt[FEElement::MAX_NODES]; const FETimeInfo& tp = GetTimeInfo(); double alpha = tp.alpha; double alphaf = tp.alphaf; // prescribe this dilatation at the nodes FESurface* ps = GetSurface(); for (int iel=0; iel<ps->Elements(); ++iel) { FESurfaceElement& el = ps->Element(iel); // nr integration points int nint = el.GaussPoints(); // nr of element nodes int neln = el.Nodes(); // nodal coordinates for (int i=0; i<neln; ++i) { FENode& node = ps->Node(el.m_lnode[i]); rt[i] = node.m_rt; vt[i] = node.get_vec3d(m_dofW[0], m_dofW[1], m_dofW[2]); } double* Nr, *Ns; double* N; double* w = el.GaussWeights(); vec3d dxr, dxs, v; // repeat over integration points for (int n=0; n<nint; ++n) { N = el.H(n); Nr = el.Gr(n); Ns = el.Gs(n); // calculate the velocity and tangent vectors at integration point dxr = dxs = v = vec3d(0,0,0); for (int i=0; i<neln; ++i) { v += vt[i]*N[i]; dxr += rt[i]*Nr[i]; dxs += rt[i]*Ns[i]; } vec3d normal = dxr ^ dxs; double q = normal*v; Q += q*w[n]; } } return Q; } //----------------------------------------------------------------------------- void FEFluidSolutesRCRBC::GetNodalValues(int nodelid, std::vector<double>& val) { val[0] = m_e[nodelid]; } //----------------------------------------------------------------------------- // copy data from another class void FEFluidSolutesRCRBC::CopyFrom(FEBoundaryCondition* pbc) { // TODO: implement this assert(false); } //----------------------------------------------------------------------------- //! serialization void FEFluidSolutesRCRBC::Serialize(DumpStream& ar) { FEPrescribedSurface::Serialize(ar); ar & m_e; ar & m_pn & m_pp & m_qn & m_qp & m_pdn & m_pdp & m_tp & m_e; if (ar.IsShallow()) return; ar & m_dofW & m_dofEF & m_dofC; ar & m_Rgas & m_Tabs; }
C++