39 #include <boost/version.hpp> 40 #if BOOST_VERSION >= 106900 && BOOST_VERSION < 107000 41 #define BOOST_ALLOW_DEPRECATED_HEADERS 44 #include <boost/core/ignore_unused.hpp> 45 #include <boost/random/normal_distribution.hpp> 46 #include <boost/random/variate_generator.hpp> 57 AcousticSystem::AcousticSystem(
61 m_ip(-1), m_irho(-1), m_iu(1), m_conservative(false)
74 "Only Projection=DisContinuous supported by the AcousticSystem class.");
97 m_vecLocs[0][i] =
m_iu + i;
100 if (
m_session->DefinesElement(
"Nektar/Coupling"))
102 TiXmlElement *vCoupling =
m_session->GetElement(
"Nektar/Coupling");
104 ASSERTL0(vCoupling->Attribute(
"TYPE"),
105 "Missing TYPE attribute in Coupling");
106 string vType = vCoupling->Attribute(
"TYPE");
108 "TYPE attribute must be non-empty in Coupling");
134 int numForceFields = 0;
137 numForceFields += x->GetForces().num_elements();
139 vector<string> varNames;
142 for (
int i = 0; i <
m_fields.num_elements(); ++i)
144 varNames.push_back(
m_session->GetVariable(i));
145 phys[i] =
m_fields[i]->UpdatePhys();
147 for (
int i = 0; i <
m_bfNames.size(); ++i)
154 for (
auto &x : m_forcing)
156 for (
int i = 0; i < x->GetForces().num_elements(); ++i)
160 varNames.push_back(
"F_" + boost::lexical_cast<string>(f) +
"_" +
190 int nVariables = inarray.num_elements();
198 for (
int i = 0; i < nVariables; ++i)
219 int nvariables = inarray.num_elements();
223 for (
int i = 0; i < nvariables; ++i)
240 int nvariables =
m_fields.num_elements();
247 for (
int i = 0; i < nvariables; ++i)
250 m_fields[i]->ExtractTracePhys(inarray[i], Fwd[i]);
255 for (
int n = 0; n <
m_fields[0]->GetBndConditions().num_elements(); ++n)
257 std::string userDefStr =
258 m_fields[0]->GetBndConditions()[n]->GetUserDefined();
260 if (!userDefStr.empty())
263 if (boost::iequals(userDefStr,
"Wall"))
267 else if (boost::iequals(userDefStr,
"WhiteNoise"))
271 else if (boost::iequals(userDefStr,
"RiemannInvariantBC"))
275 else if (boost::iequals(userDefStr,
"TimeDependent"))
277 for (
int i = 0; i < nvariables; ++i)
280 m_fields[i]->EvaluateBoundaryConditions(time, varName);
285 string errmsg =
"Unrecognised boundary condition: ";
286 errmsg += userDefStr;
292 for (
int i = 0; i < nvariables; ++i)
295 m_fields[i]->EvaluateBoundaryConditions(time, varName);
299 cnt +=
m_fields[0]->GetBndCondExpansions()[n]->GetExpSize();
310 int nVariables = physarray.num_elements();
316 int id1, id2, nBCEdgePts;
317 int eMax =
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExpSize();
319 for (
int e = 0; e < eMax; ++e)
322 ->GetBndCondExpansions()[bcRegion]
325 id1 =
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetPhys_Offset(e);
326 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(traceBndMap[cnt + e]);
339 Vmath::Smul(nBCEdgePts, -2.0, &tmp[0], 1, &tmp[0], 1);
345 &Fwd[
m_iu + i][id2], 1, &Fwd[
m_iu + i][id2], 1);
349 for (
int i = 0; i < nVariables; ++i)
353 ->GetBndCondExpansions()[bcRegion]
354 ->UpdatePhys())[id1],
368 boost::ignore_unused(Fwd);
370 int id1, id2, nBCEdgePts;
371 int nVariables = physarray.num_elements();
375 if (
m_rng.count(bcRegion) == 0)
377 m_rng[bcRegion] = boost::mt19937(bcRegion);
381 m_fields[0]->GetBndConditions()[bcRegion]->GetBoundaryConditionType() ==
383 "WhiteNoise BCs must be Dirichlet type BCs");
387 m_fields[0]->GetBndConditions()[bcRegion])
388 ->m_dirichletCondition;
392 "sigma must be greater than zero");
399 boost::normal_distribution<> dist(0, sigma);
403 int eMax =
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExpSize();
404 for (
int e = 0; e < eMax; ++e)
407 ->GetBndCondExpansions()[bcRegion]
410 id1 =
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetPhys_Offset(e);
411 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(traceBndMap[cnt + e]);
414 for (
int i = 0; i < nVariables; ++i)
424 for (
int i = 0; i < nBCEdgePts; ++i)
441 for (
int i = 0; i < nBCEdgePts; ++i)
445 (sqrt(BfFwd[0][id2 + i]) * BfFwd[1][id2 + i]);
455 for (
int i = 0; i < nVariables; ++i)
459 ->GetBndCondExpansions()[bcRegion]
460 ->UpdatePhys())[id1],
474 int nElm =
m_fields[0]->GetExpSize();
484 for (
int el = 0; el < nElm; ++el)
486 ptsKeys =
m_fields[0]->GetExp(el)->GetPointsKeys();
490 m_fields[0]->GetExp(el)->GetGeom()->GetMetricInfo();
496 ->GetDerivFactors(ptsKeys);
498 int nq =
m_fields[0]->GetExp(el)->GetTotPoints();
505 for (
int j = 0; j < nq; ++j)
510 velocity[i][j] =
m_bf[i + 2][cnt + j] + c;
520 Vmath::Vmul(nq, gmat[i], 1, velocity[0], 1, stdVelocity[i], 1);
523 Vmath::Vvtvp(nq, gmat[m_spacedim * j + i], 1, velocity[j],
524 1, stdVelocity[i], 1, stdVelocity[i], 1);
532 Vmath::Smul(nq, gmat[i][0], velocity[0], 1, stdVelocity[i], 1);
535 Vmath::Svtvp(nq, gmat[m_spacedim * j + i][0], velocity[j],
536 1, stdVelocity[i], 1, stdVelocity[i], 1);
542 for (
int i = 0; i < nq; ++i)
547 pntVelocity += stdVelocity[j][i] * stdVelocity[j][i];
549 pntVelocity = sqrt(pntVelocity);
551 if (pntVelocity > stdV[el])
553 stdV[el] = pntVelocity;
565 std::vector<std::string> &variables)
567 for (
int i = 0; i <
m_bfNames.size(); i++)
572 fieldcoeffs.push_back(tmpC);
578 for (
int i = 0; i < x->GetForces().num_elements(); ++i)
580 variables.push_back(
"F_" + boost::lexical_cast<string>(f) +
"_" +
583 m_fields[0]->FwdTrans(x->GetForces()[i], tmpC);
584 fieldcoeffs.push_back(tmpC);
618 for (
int i = 0; i <
m_bfNames.size(); i++)
631 for (
int bcRegion = 0;
632 bcRegion <
m_fields[0]->GetBndConditions().num_elements(); ++bcRegion)
639 e <
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExpSize();
643 ->GetBndCondExpansions()[bcRegion]
646 id2 =
m_fields[0]->GetTrace()->GetPhys_Offset(
647 m_fields[0]->GetTraceMap()->GetBndCondCoeffsToGlobalCoeffsMap(
653 cnt +=
m_fields[0]->GetBndCondExpansions()[bcRegion]->GetExpSize();
Array< OneD, Array< OneD, NekDouble > > m_bf
#define ASSERTL0(condition, msg)
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
virtual SOLVER_UTILS_EXPORT bool v_PreIntegrate(int step)
std::vector< std::string > m_bfNames
virtual void v_WhiteNoiseBC(int bcRegion, int cnt, Array< OneD, Array< OneD, NekDouble >> &Fwd, Array< OneD, Array< OneD, NekDouble >> &BfFwd, Array< OneD, Array< OneD, NekDouble >> &physarray)
Wall boundary conditions for the AcousticSystem equations.
std::vector< PointsKey > PointsKeyVector
bool m_homoInitialFwd
Flag to determine if simulation should start in homogeneous forward transformed state.
NekDouble m_time
Current time of simulation.
std::shared_ptr< GeomFactors > GeomFactorsSharedPtr
Pointer to a GeomFactors object.
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
void CopyBoundaryTrace(const Array< OneD, NekDouble > &Fwd, Array< OneD, NekDouble > &Bwd)
void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
svtvp (scalar times vector plus vector): z = alpha*x + y
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
enum MultiRegions::ProjectionType m_projectionType
Type of projection; e.g continuous or discontinuous.
bool m_conservative
we are dealing with a conservative formualtion
const Array< OneD, const Array< OneD, NekDouble > > & GetVecLocs()
Get the locations of the components of the directed fields within the fields array.
SOLVER_UTILS_EXPORT int GetTotPoints()
Array< OneD, Array< OneD, NekDouble > > m_traceNormals
Array holding trace normals for DG simulations in the forwards direction.
void DoOdeProjection(const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const NekDouble time)
Compute the projection and call the method for imposing the boundary conditions in case of discontinu...
const Array< OneD, const Array< OneD, NekDouble > > & GetBasefieldFwdBwd()
Get the baseflow field.
static const NekDouble kNekZeroTol
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
virtual bool v_PreIntegrate(int step)
v_PreIntegrate
std::vector< SolverUtils::ForcingSharedPtr > m_forcing
static SOLVER_UTILS_EXPORT std::vector< ForcingSharedPtr > Load(const LibUtilities::SessionReaderSharedPtr &pSession, const std::weak_ptr< EquationSystem > &pEquation, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const unsigned int &pNumForcingFields=0)
Base class for unsteady solvers.
virtual SOLVER_UTILS_EXPORT void v_Output(void)
void UpdateBasefieldFwdBwd()
int m_spacedim
Spatial dimension (>= expansion dim).
virtual ~AcousticSystem()
Destructor.
void Neg(int n, T *x, const int incx)
Negate x = -x.
NekDouble Evaluate() const
virtual void v_InitObject()
Initialization object for the AcousticSystem class.
NekDouble m_whiteNoiseBC_p
void SetBoundaryConditions(Array< OneD, Array< OneD, NekDouble >> &physarray, NekDouble time)
Apply the Boundary Conditions to the AcousticSystem equations.
virtual void v_WallBC(int bcRegion, int cnt, Array< OneD, Array< OneD, NekDouble >> &Fwd, Array< OneD, Array< OneD, NekDouble >> &physarray)
Wall boundary conditions for the AcousticSystem equations.
SOLVER_UTILS_EXPORT int GetTraceTotPoints()
SOLVER_UTILS_EXPORT SessionFunctionSharedPtr GetFunction(std::string name, const MultiRegions::ExpListSharedPtr &field=MultiRegions::NullExpListSharedPtr, bool cache=false)
Get a SessionFunction by name.
int m_ip
indices of the fields
Array< OneD, Array< OneD, NekDouble > > m_bfFwdBwd
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
const Array< OneD, const Array< OneD, NekDouble > > & GetNormals()
Get the normal vectors.
SolverUtils::CouplingSharedPtr m_coupling
std::map< int, boost::mt19937 > m_rng
SOLVER_UTILS_EXPORT int GetNcoeffs()
virtual void v_ExtraFldOutput(std::vector< Array< OneD, NekDouble >> &fieldcoeffs, std::vector< std::string > &variables)
CouplingFactory & GetCouplingFactory()
Declaration of the Coupling factory singleton.
virtual void v_AddLinTerm(const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray)
virtual Array< OneD, NekDouble > v_GetMaxStdVelocity()
Compute the advection velocity in the standard space for each element of the expansion.
virtual SOLVER_UTILS_EXPORT void v_InitObject()
Init object for UnsteadySystem class.
NekDouble m_whiteNoiseBC_lastUpdate
A base class for PDEs which include an advection component.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Geometry is curved or has non-constant factors.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
Array< OneD, Array< OneD, NekDouble > > m_vecLocs
void DoOdeRhs(const Array< OneD, const Array< OneD, NekDouble >> &inarray, Array< OneD, Array< OneD, NekDouble >> &outarray, const NekDouble time)
Compute the right-hand side.
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
virtual void v_RiemannInvariantBC(int bcRegion, int cnt, Array< OneD, Array< OneD, NekDouble >> &Fwd, Array< OneD, Array< OneD, NekDouble >> &BfFwd, Array< OneD, Array< OneD, NekDouble >> &physarray)=0
SolverUtils::AdvectionSharedPtr m_advection