MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
dgcartesianbcexact.h
Go to the documentation of this file.
1// Copyright (C) 2024 The m-AIA AUTHORS
2//
3// This file is part of m-AIA (https://git.rwth-aachen.de/aia/m-AIA/m-AIA)
4//
5// SPDX-License-Identifier: LGPL-3.0-only
6
7#ifndef DGBOUNDARYCONDITIONEXACT_H_
8#define DGBOUNDARYCONDITIONEXACT_H_
9
12
25template <MInt nDim, class SysEqn>
26class DgBcExact final : public DgBoundaryCondition<nDim, SysEqn> {
27 // Typedefs
28 public:
30 using Base::begin;
31 using Base::end;
32 using Base::flux;
33 using Base::surfaces;
34 using Base::sysEqn;
35 using typename Base::SolverType;
36
37 // Methods
38 public:
39 DgBcExact(SolverType& solver_, MInt bcId) : Base(solver_, bcId) {}
40 MString name() const override { return "exact"; }
41
42 void apply(const MFloat time) override { maia::dg::bc::loop(&DgBcExact::applyAtSurface, this, begin(), end(), time); }
43
44 void applyAtSurface(const MInt surfaceId, const MFloat NotUsed(time));
45};
46
47
48template <MInt nDim, class SysEqn>
49void DgBcExact<nDim, SysEqn>::applyAtSurface(const MInt surfaceId, const MFloat time) {
50 MFloat* nodeVarsL = &surfaces().nodeVars(surfaceId, 0);
51 MFloat* nodeVarsR = &surfaces().nodeVars(surfaceId, 1);
52 MFloat* stateL = &surfaces().variables(surfaceId, 0);
53 MFloat* stateR = &surfaces().variables(surfaceId, 1);
54
55 // Calculate boundary state from initial condition
56 // The boundary side is marked by an elment id of '-1'
57 MFloat* boundaryState = (surfaces().internalSideId(surfaceId) == 1) ? stateL : stateR;
58 MFloat* boundaryNodeVars = (surfaces().internalSideId(surfaceId) == 1) ? nodeVarsL : nodeVarsR;
59 MFloat* innerNodeVars = (surfaces().internalSideId(surfaceId) == 1) ? nodeVarsR : nodeVarsL;
60
61 // Iterate over all nodes and apply the initial condition at the boundary
62 const MInt noNodes1D = surfaces().noNodes1D(surfaceId);
63 const MInt noNodes1D3 = (nDim == 3) ? noNodes1D : 1;
64 const MInt dirId = surfaces().orientation(surfaceId);
65 MFloatTensor u(boundaryState, noNodes1D, noNodes1D3, SysEqn::noVars());
66 // Set node vars to minimum 1 to avoid errors in Tensor
67 // TODO labels:DG Check if this is really sensible
68 MFloatTensor nodeVars(boundaryNodeVars, noNodes1D, noNodes1D3, std::max(SysEqn::noNodeVars(), 1));
69 MFloatTensor x(&surfaces().nodeCoords(surfaceId), noNodes1D, noNodes1D3, nDim);
70
71 for(MInt i = 0; i < noNodes1D; i++) {
72 for(MInt j = 0; j < noNodes1D3; j++) {
73 sysEqn().calcInitialCondition(time, &x(i, j, 0), &nodeVars(i, j, 0), &u(i, j, 0));
74 }
75 }
76
77 // Calculate Riemann flux
78 // Use inner nodeVars for both sides (depending on the initial condition the
79 // nodeVars are not set in calcInitialCondition)
80 MFloat* f = flux(surfaceId);
81 sysEqn().calcRiemann(innerNodeVars, innerNodeVars, stateL, stateR, noNodes1D, dirId, f);
82}
83
84#endif // DGBOUNDARYCONDITIONEXACT_H_
Boundary condition which imposes initial condition ("exact" boundary conditions) at the domain bounda...
DgBcExact(SolverType &solver_, MInt bcId)
void apply(const MFloat time) override
Apply method to apply boundary condition.
MString name() const override
Returns name of boundary condition.
void applyAtSurface(const MInt surfaceId, const MFloat NotUsed(time))
SurfaceCollector & surfaces()
Return reference to surfaces.
DgCartesianSolver< nDim, SysEqn > SolverType
SysEqn & sysEqn()
Return reference to SysEqn object.
MInt begin() const
Return index of first surface.
MInt end() const
Return index of one-past-last surface.
MFloat * flux(const MInt i)
Return pointer to surface flux.
int32_t MInt
Definition: maiatypes.h:62
std::basic_string< char > MString
Definition: maiatypes.h:55
double MFloat
Definition: maiatypes.h:52
void loop(Functor &&fun, Class *object, const IdType begin, const IdType end, Args... args)