52#ifdef NEKTAR_USE_PETSC
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];
122 for (i = 0; i < n - 1; ++i)
124 for (j = 0; j < n - 1; ++j)
126 mapred(i, j) = newmap(i, j);
154 const int nVel =
m_fields[0]->GetCoordim(0);
157 ASSERTL0(nVel > 1,
"Linear elastic solver not set up for"
158 " this dimension (only 2D/3D supported).");
168 std::dynamic_pointer_cast<MultiRegions::ContField>(
m_fields[0]);
175 const int nEl =
m_fields[0]->GetExpSize();
188 for (n = 0; n < nEl; ++n)
191 sizeBnd[n] = nVel * exp->NumBndryCoeffs();
192 sizeInt[n] = nVel * exp->GetNcoeffs() - sizeBnd[n];
193 exp->GetBoundaryMap(
m_bmap[n]);
194 exp->GetInteriorMap(
m_imap[n]);
200 sizeBnd, sizeBnd, blkmatStorage);
232 const int nEl =
m_fields[0]->GetExpSize();
233 const int nVel =
m_fields[0]->GetCoordim(0);
245 bool verbose =
m_session->DefinesCmdLineArgument(
"verbose");
246 bool root =
m_session->GetComm()->GetRank() == 0;
251 for (n = 0; n < nEl; ++n)
254 const int nPhys = exp->GetTotPoints();
265 exp->DetShapeType(), *exp,
factors,
268 exp->DetShapeType(), *exp,
factors,
276 mat[0][0] = exp->GenMatrix(matkeyA);
278 mat[1][0] = mat[0][1];
279 mat[1][1] = exp->GenMatrix(matkeyD);
286 cout <<
"\rBuilding matrix system: " << (int)(100.0 * n / nEl)
293 for (n = 0; n < nEl; ++n)
296 const int nPhys = exp->GetTotPoints();
312 exp->DetShapeType(), *exp,
factors,
315 exp->DetShapeType(), *exp,
factors,
318 exp->DetShapeType(), *exp,
factors,
327 mat[0][0] = exp->GenMatrix(matkeyA);
331 mat[1][0] = mat[0][1];
332 mat[1][1] = exp->GenMatrix(matkeyE);
335 mat[2][0] = mat[0][2];
336 mat[2][1] = mat[1][2];
337 mat[2][2] = exp->GenMatrix(matkeyI);
344 cout <<
"\rBuilding matrix system: " << (int)(100.0 * n / nEl)
352 cout <<
"\rBuilding matrix system: done." << endl;
384 const int nVel =
m_fields[0]->GetCoordim(0);
413#ifdef NEKTAR_USE_PETSC
434 const int nCoeffs =
m_fields[0]->GetNcoeffs();
446 m_session->LoadSolverInfo(
"Temperature", tempEval,
"None");
448 if (tempEval ==
"Jacobian")
453 for (nv = 0; nv < nVel; ++nv)
459 for (i = 0; i <
m_fields[0]->GetExpSize(); ++i)
466 int offset =
m_fields[0]->GetPhys_Offset(i);
468 if (exp->GetMetricInfo()->GetGtype() ==
483 else if (tempEval ==
"Metric")
486 m_graph->GetAllQuadGeoms().size() == 0) ||
488 m_graph->GetAllPrismGeoms().size() == 0 &&
489 m_graph->GetAllPyrGeoms().size() == 0 &&
490 m_graph->GetAllHexGeoms().size() == 0),
491 "LinearIdealMetric temperature only implemented for "
492 "two-dimensional triangular meshes or three-dimensional "
493 "tetrahedral meshes.");
498 for (nv = 0; nv < nVel; ++nv)
504 for (i = 0; i < nVel; ++i)
511 for (i = 0; i <
m_fields[0]->GetExpSize(); ++i)
517 exp->GetMetricInfo()->GetDeriv(pkey);
518 int offset =
m_fields[0]->GetPhys_Offset(i);
527 for (j = 0; j < deriv[0][0].size(); ++j)
529 for (k = 0; k < nVel; ++k)
531 for (l = 0; l < nVel; ++l)
533 jac(l, k) = deriv[k][l][j];
537 jacIdeal = jac * i2rm;
542 char jobvl =
'N', jobvr =
'V';
543 int worklen = 8 * nVel, info;
553 &(eval.GetPtr())[0], &wi[0], &vl[0], nVel,
554 &(evec.GetPtr())[0], nVel, &work[0], worklen,
561 for (nv = 0; nv < nVel; ++nv)
563 eval(nv, nv) =
m_beta * (
sqrt(eval(nv, nv)) - 1.0);
568 for (k = 0; k < nVel; ++k)
570 for (l = 0; l < nVel; ++l)
577 if (deriv[0][0].size() != exp->GetTotPoints())
580 for (k = 0; k < nVel; ++k)
582 for (l = 0; l < nVel; ++l)
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(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];
708 const int nVel = mat.GetRows();
709 const int nB = exp->NumBndryCoeffs();
710 const int nI = exp->GetNcoeffs() - nB;
711 const int nBnd = exp->NumBndryCoeffs() * nVel;
712 const int nInt = exp->GetNcoeffs() * nVel - nBnd;
725 for (i = 0; i < nVel; ++i)
727 for (j = 0; j < nVel; ++j)
730 for (k = 0; k < nB; ++k)
732 for (l = 0; l < nB; ++l)
734 (*A)(k + i * nB, l + j * nB) =
738 for (l = 0; l < nI; ++l)
740 (*B)(k + i * nB, l + j * nI) =
746 for (k = 0; k < nI; ++k)
748 for (l = 0; l < nB; ++l)
750 (*C)(k + i * nI, l + j * nB) =
754 for (l = 0; l < nI; ++l)
756 (*D)(k + i * nI, l + j * nI) =
766 (*A) = (*A) - (*B) * (*C);
787 const int k1,
const int k2,
const NekDouble scale,
790 const int nCoeffs = exp->GetNcoeffs();
791 const int nPhys = exp->GetTotPoints();
800 for (i = 0; i < nCoeffs; ++i)
805 exp->BwdTrans(tmp1, tmp2);
806 exp->PhysDeriv(k1, tmp2, tmp3);
807 exp->IProductWRTDerivBase(k2, tmp3, tmp1);
810 &(ret->GetPtr())[0] + i * nCoeffs, 1);
818 std::vector<std::string> &variables)
820 const int nVel =
m_fields[0]->GetCoordim(0);
821 const int nCoeffs =
m_fields[0]->GetNcoeffs();
828 for (
int i = 0; i < nVel; ++i)
832 fieldcoeffs.push_back(tFwd);
833 variables.push_back(
"ThermStressDiv" + std::to_string(i));
841 for (
int i = 0; i < nVel; ++i)
843 for (
int j = 0; j < nVel; ++j)
847 fieldcoeffs.push_back(tFwd);
848 variables.push_back(
"ThermStress" + std::to_string(i) +
#define ASSERTL0(condition, msg)
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Array< OneD, Array< OneD, unsigned int > > m_imap
Interior maps for each of the fields.
static EquationSystemSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Creates an instance of this class.
DNekScalBlkMatSharedPtr m_Dinv
Matrix of elemental components.
NekDouble m_nu
Poisson ratio.
static std::string className
Name of class.
void v_InitObject(bool DeclareFields=true) override
Set up the linear elasticity system.
void BuildMatrixSystem()
Build matrix system for linear elasticity equations.
LinearElasticSystem(const LibUtilities::SessionReaderSharedPtr &pSession, const SpatialDomains::MeshGraphSharedPtr &pGraph)
Default constructor.
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.
void v_DoSolve() override
Solve elliptic linear elastic system.
DNekScalBlkMatSharedPtr m_BinvD
Matrix of elemental components.
NekDouble m_beta
Parameter dictating amount of thermal stress to add.
DNekScalBlkMatSharedPtr m_schurCompl
Schur complement boundary-boundary matrix.
void v_ExtraFldOutput(std::vector< Array< OneD, NekDouble > > &fieldcoeffs, std::vector< std::string > &variables) override
NekDouble m_E
Young's modulus.
Array< OneD, Array< OneD, Array< OneD, NekDouble > > > m_stress
Storage for the thermal stress terms.
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.
void v_GenerateSummary(SolverUtils::SummaryList &s) override
Generate summary at runtime.
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.
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.
virtual SOLVER_UTILS_EXPORT void v_InitObject(bool DeclareFeld=true)
Initialisation object for EquationSystem.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
SOLVER_UTILS_EXPORT int GetNpoints()
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
@ beta
Gauss Radau pinned at x=-1,.
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
@ eLinearAdvectionReaction
std::map< ConstFactorType, NekDouble > ConstFactorMap
std::map< StdRegions::VarCoeffType, VarCoeffEntry > VarCoeffMap
StdRegions::ConstFactorMap factors
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)