52 #ifdef NEKTAR_USE_PETSC
62 RegisterCreatorFunction(
"LinearElasticSystem",
63 LinearElasticSystem::create);
77 int n = geom->GetNumVerts(), i, j;
83 for (i = 0; i < n; ++i)
85 for (j = 0; j < n-1; ++j)
87 map(j,i) = (*geom->GetVertex(i))[j];
94 mapref(0,0) = -1.0; mapref(1,0) = -1.0;
95 mapref(0,1) = 1.0; mapref(1,1) = -1.0;
96 mapref(0,2) = -1.0; mapref(1,2) = 1.0;
100 mapref(0,0) = -1.0; mapref(1,0) = -1.0; mapref(2,0) = -1.0;
101 mapref(0,1) = 1.0; mapref(1,1) = -1.0; mapref(2,1) = -1.0;
102 mapref(0,2) = -1.0; mapref(1,2) = 1.0; mapref(2,2) = -1.0;
103 mapref(0,3) = -1.0; mapref(1,3) = -1.0; mapref(2,3) = 1.0;
111 for (i = 0; i < n-1; ++i)
113 for (j = 0; j < n-1; ++j)
115 mapred(i,j) = newmap(i,j);
126 LinearElasticSystem::LinearElasticSystem(
144 const int nVel =
m_fields[0]->GetCoordim(0);
147 ASSERTL0(nVel > 1,
"Linear elastic solver not set up for"
148 " this dimension (only 2D/3D supported).");
162 u->GetLocalToGlobalMap(),
168 const int nEl =
m_fields[0]->GetExpSize();
181 for (n = 0; n < nEl; ++n)
184 sizeBnd[n] = nVel * exp->NumBndryCoeffs();
185 sizeInt[n] = nVel * exp->GetNcoeffs() - sizeBnd[n];
186 exp->GetBoundaryMap(
m_bmap[n]);
187 exp->GetInteriorMap(
m_imap[n]);
193 sizeBnd, sizeBnd, blkmatStorage);
195 sizeBnd, sizeInt, blkmatStorage);
197 sizeInt, sizeBnd, blkmatStorage);
199 sizeInt, sizeInt, blkmatStorage);
225 const int nEl =
m_fields[0]->GetExpSize();
226 const int nVel =
m_fields[0]->GetCoordim(0);
238 bool verbose =
m_session->DefinesCmdLineArgument(
"verbose");
239 bool root =
m_session->GetComm()->GetRank() == 0;
244 for (n = 0; n < nEl; ++n)
247 const int nPhys = exp->GetTotPoints();
259 *exp, factors, varcoeffA);
262 *exp, factors, varcoeffD);
269 mat[0][0] = exp->GenMatrix(matkeyA);
271 mat[1][0] = mat[0][1];
272 mat[1][1] = exp->GenMatrix(matkeyD);
279 cout <<
"\rBuilding matrix system: "
280 << (int)(100.0 * n / nEl) <<
"%" << flush;
286 for (n = 0; n < nEl; ++n)
289 const int nPhys = exp->GetTotPoints();
306 *exp, factors, varcoeffA);
309 *exp, factors, varcoeffE);
312 *exp, factors, varcoeffI);
320 mat[0][0] = exp->GenMatrix(matkeyA);
324 mat[1][0] = mat[0][1];
325 mat[1][1] = exp->GenMatrix(matkeyE);
328 mat[2][0] = mat[0][2];
329 mat[2][1] = mat[1][2];
330 mat[2][2] = exp->GenMatrix(matkeyI);
337 cout <<
"\rBuilding matrix system: "
338 << (int)(100.0 * n / nEl) <<
"%" << flush;
345 cout <<
"\rBuilding matrix system: done." << endl;
377 const int nVel =
m_fields[0]->GetCoordim(0);
406 #ifdef NEKTAR_USE_PETSC
416 #ifdef NEKTAR_USE_MPI
429 const int nCoeffs =
m_fields[0]->GetNcoeffs();
441 m_session->LoadSolverInfo(
"Temperature", tempEval,
"None");
443 if (tempEval ==
"Jacobian")
448 for (nv = 0; nv < nVel; ++nv)
454 for (i = 0; i <
m_fields[0]->GetExpSize(); ++i)
460 exp->GetPointsKeys();
462 exp->GetMetricInfo()->GetJac(pkey);
464 int offset =
m_fields[0]->GetPhys_Offset(i);
466 if (exp->GetMetricInfo()->GetGtype() ==
481 else if (tempEval ==
"Metric")
484 m_graph->GetAllQuadGeoms().size() == 0) ||
486 m_graph->GetAllPrismGeoms().size() == 0 &&
487 m_graph->GetAllPyrGeoms ().size() == 0 &&
488 m_graph->GetAllHexGeoms ().size() == 0),
489 "LinearIdealMetric temperature only implemented for "
490 "two-dimensional triangular meshes or three-dimensional "
491 "tetrahedral meshes.");
496 for (nv = 0; nv < nVel; ++nv)
502 for (i = 0; i < nVel; ++i)
509 for (i = 0; i <
m_fields[0]->GetExpSize(); ++i)
516 exp->GetMetricInfo()->GetDeriv(pkey);
517 int offset =
m_fields[0]->GetPhys_Offset(i);
526 for (j = 0; j < deriv[0][0].size(); ++j)
528 for (k = 0; k < nVel; ++k)
530 for (l = 0; l < nVel; ++l)
532 jac(l,k) = deriv[k][l][j];
536 jacIdeal = jac * i2rm;
541 char jobvl =
'N', jobvr =
'V';
542 int worklen = 8*nVel, info;
552 &(eval.GetPtr())[0], &wi[0], &vl[0], nVel,
553 &(evec.GetPtr())[0], nVel,
554 &work[0], worklen, info);
560 for (nv = 0; nv < nVel; ++nv)
562 eval(nv,nv) =
m_beta * (
sqrt(eval(nv,nv)) - 1.0);
565 DNekMat beta = evec * eval * evecinv;
567 for (k = 0; k < nVel; ++k)
569 for (l = 0; l < nVel; ++l)
571 m_stress[k][l][offset+j] = beta(k,l);
576 if (deriv[0][0].size() != exp->GetTotPoints())
579 for (k = 0; k < nVel; ++k)
581 for (l = 0; l < nVel; ++l)
584 exp->GetTotPoints(),
m_stress[k][l][offset],
593 for (i = 0; i < nVel; ++i)
595 for (j = 0; j < nVel; ++j)
606 else if (tempEval !=
"None")
608 ASSERTL0(
false,
"Unknown temperature form: " + tempEval);
624 for (nv = 0; nv < nVel; ++nv)
627 m_fields[nv]->IProductWRTBase_IterPerExp(forcing[nv], tmp);
631 m_fields[nv]->ImposeDirichletConditions(loc_inout);
635 for (i = 0; i <
m_fields[nv]->GetExpSize(); ++i)
637 int nBnd =
m_bmap[i].size();
638 int nInt =
m_imap[i].size();
639 int offset =
m_fields[nv]->GetCoeff_Offset(i);
641 for (j = 0; j < nBnd; ++j)
643 forCoeffs[nVel*offset + nv*nBnd + j] =
644 -1.0*tmp[offset+
m_bmap[i][j]];
645 inout[nVel*offset + nv*nBnd + j] =
646 loc_inout[offset+
m_bmap[i][j]];
648 for (j = 0; j < nInt; ++j)
650 forCoeffs[nVel*(offset + nBnd) + nv*nInt + j] =
651 -1.0*tmp[offset+
m_imap[i][j]];
667 for (nv = 0; nv < nVel; ++nv)
669 for (i = 0; i <
m_fields[nv]->GetExpSize(); ++i)
671 int nBnd =
m_bmap[i].size();
672 int nInt =
m_imap[i].size();
673 int offset =
m_fields[nv]->GetCoeff_Offset(i);
675 for (j = 0; j < nBnd; ++j)
678 inout[nVel*offset + nv*nBnd + j];
680 for (j = 0; j < nInt; ++j)
683 inout[nVel*(offset + nBnd) + nv*nInt + j];
709 const int nVel = mat.GetRows();
710 const int nB = exp->NumBndryCoeffs();
711 const int nI = exp->GetNcoeffs() - nB;
712 const int nBnd = exp->NumBndryCoeffs() * nVel;
713 const int nInt = exp->GetNcoeffs() * nVel - nBnd;
726 for (i = 0; i < nVel; ++i)
728 for (j = 0; j < nVel; ++j)
731 for (k = 0; k < nB; ++k)
733 for (l = 0; l < nB; ++l)
735 (*A)(k + i*nB, l + j*nB) =
739 for (l = 0; l < nI; ++l)
741 (*B)(k + i*nB, l + j*nI) =
747 for (k = 0; k < nI; ++k)
749 for (l = 0; l < nB; ++l)
751 (*C)(k + i*nI, l + j*nB) =
755 for (l = 0; l < nI; ++l)
757 (*D)(k + i*nI, l + j*nI) =
767 (*A) = (*A) - (*B)*(*C);
797 const int nCoeffs = exp->GetNcoeffs();
798 const int nPhys = exp->GetTotPoints();
802 nCoeffs, nCoeffs, 0.0,
eFULL);
807 for (i = 0; i < nCoeffs; ++i)
812 exp->BwdTrans ( tmp1, tmp2);
813 exp->PhysDeriv (k1, tmp2, tmp3);
814 exp->IProductWRTDerivBase(k2, tmp3, tmp1);
817 nCoeffs, scale, &tmp1[0], 1, &(ret->GetPtr())[0]+i*nCoeffs, 1);
825 std::vector<std::string> &variables)
827 const int nVel =
m_fields[0]->GetCoordim(0);
828 const int nCoeffs =
m_fields[0]->GetNcoeffs();
835 for (
int i = 0; i < nVel; ++i)
839 fieldcoeffs.push_back(tFwd);
841 "ThermStressDiv" + boost::lexical_cast<std::string>(i));
849 for (
int i = 0; i < nVel; ++i)
851 for (
int j = 0; j < nVel; ++j)
855 fieldcoeffs.push_back(tFwd);
858 + boost::lexical_cast<std::string>(i)
859 + boost::lexical_cast<std::string>(j));
#define ASSERTL0(condition, msg)
Array< OneD, Array< OneD, unsigned int > > m_imap
Interior maps for each of the fields.
DNekScalBlkMatSharedPtr m_Dinv
Matrix of elemental components.
NekDouble m_nu
Poisson ratio.
void BuildMatrixSystem()
Build matrix system for linear elasticity equations.
void SetStaticCondBlock(const int n, const LocalRegions::ExpansionSharedPtr exp, Array< TwoD, DNekMatSharedPtr > &mat)
Given a block matrix for an element, construct its static condensation matrices.
Array< OneD, Array< OneD, NekDouble > > m_temperature
Storage for the temperature terms.
CoupledAssemblyMapSharedPtr m_assemblyMap
Assembly map for the coupled (u,v,w) system.
virtual void v_InitObject()
Set up the linear elasticity system.
DNekScalBlkMatSharedPtr m_BinvD
Matrix of elemental components.
virtual void v_GenerateSummary(SolverUtils::SummaryList &s)
Generate summary at runtime.
NekDouble m_beta
Parameter dictating amount of thermal stress to add.
DNekScalBlkMatSharedPtr m_schurCompl
Schur complement boundary-boundary matrix.
virtual void v_ExtraFldOutput(std::vector< Array< OneD, NekDouble > > &fieldcoeffs, std::vector< std::string > &variables)
NekDouble m_E
Young's modulus.
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_stress
Storage for the thermal stress terms.
virtual void v_DoSolve()
Solve elliptic linear elastic system.
Array< OneD, Array< OneD, unsigned int > > m_bmap
Boundary maps for each of the fields.
DNekMatSharedPtr BuildLaplacianIJMatrix(const int k1, const int k2, const NekDouble scale, LocalRegions::ExpansionSharedPtr exp)
Construct a LaplacianIJ matrix for a given expansion.
DNekScalBlkMatSharedPtr m_C
Matrix of elemental components.
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
This class is the abstraction of a global continuous two- dimensional spectral/hp element expansion w...
Describe a linear system.
A base class for describing how to solve specific equations.
SOLVER_UTILS_EXPORT void SessionSummary(SummaryList &vSummary)
Write out a session summary.
SpatialDomains::MeshGraphSharedPtr m_graph
Pointer to graph defining mesh.
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
SOLVER_UTILS_EXPORT int GetNpoints()
virtual SOLVER_UTILS_EXPORT void v_InitObject()
Initialisation object for EquationSystem.
SOLVER_UTILS_EXPORT SessionFunctionSharedPtr GetFunction(std::string name, const MultiRegions::ExpListSharedPtr &field=MultiRegions::NullExpListSharedPtr, bool cache=false)
Get a SessionFunction by name.
static void Dgeev(const char &uplo, const char &lrev, const int &n, const double *a, const int &lda, double *wr, double *wi, double *rev, const int &ldr, double *lev, const int &ldv, double *work, const int &lwork, int &info)
Solve general real matrix eigenproblem.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::vector< PointsKey > PointsKeyVector
std::shared_ptr< Expansion > ExpansionSharedPtr
static PreconditionerSharedPtr NullPreconditionerSharedPtr
std::shared_ptr< GlobalLinSys > GlobalLinSysSharedPtr
Pointer to a GlobalLinSys object.
std::shared_ptr< ContField > ContFieldSharedPtr
std::vector< std::pair< std::string, std::string > > SummaryList
EquationSystemFactory & GetEquationSystemFactory()
void AddSummaryItem(SummaryList &l, const std::string &name, const std::string &value)
Adds a summary item to the summary info list.
@ eDeformed
Geometry is curved or has non-constant factors.
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
std::shared_ptr< Geometry > GeometrySharedPtr
std::map< StdRegions::VarCoeffType, Array< OneD, NekDouble > > VarCoeffMap
@ eLinearAdvectionReaction
std::map< ConstFactorType, NekDouble > ConstFactorMap
The above copyright notice and this permission notice shall be included.
std::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
NekMatrix< InnerMatrixType, BlockMatrixTag > Transpose(NekMatrix< InnerMatrixType, BlockMatrixTag > &rhs)
std::shared_ptr< DNekMat > DNekMatSharedPtr
DNekMat MappingIdealToRef(SpatialDomains::GeometrySharedPtr geom)
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
scalarT< T > sqrt(scalarT< T > in)