Nektar++
Loading...
Searching...
No Matches
Public Member Functions | List of all members
TestDirichlet< TData > Class Template Reference

#include <TestDirichlet.hpp>

Inheritance diagram for TestDirichlet< TData >:
[legend]

Public Member Functions

 TestDirichlet ()=default
 
void SetTestCase (const double time=0.0)
 
void RunTestCase (const double time=0.0)
 
void ExpectedSolution (const double time=0.0)
 
- Public Member Functions inherited from TestOp< TData, FieldState::Coeff, FieldState::Coeff, MultiRegions::ContField >
 TestOp ()=default
 
virtual ~TestOp ()
 
void Configure (void)
 
void Configure3DH1 (const unsigned int nhomo=1)
 
void Configure3DH2 (const unsigned int nhomoY=1, const unsigned int nhomoZ=1)
 
void SetSession (void)
 
void SetExpList (void)
 
void SetExpList3DH1 (const unsigned int nhomo=1)
 
void SetExpList3DH2 (const unsigned int nhomoY=1, const unsigned int nhomoZ=1)
 
virtual void SetFixture (const unsigned int nhomo)
 
virtual bool Compare (TData tol)
 Compare this field to another field, with absolute tolerance tol. The two must have the same blocks and components; their interleave widths may differ.
 

Additional Inherited Members

- Static Public Member Functions inherited from TestOp< TData, FieldState::Coeff, FieldState::Coeff, MultiRegions::ContField >
static void MixInterleaveWidths (TField &field)
 Put the blocks of field at alternating interleave widths, the execution space's vector width on even blocks and 1 on odd ones, reshaping the data in place: a field whose blocks differ in width, for an operator that must read any mix, such as the trace flux, which addresses each trace at the width of the element block it lies in. On Serial every width is 1 and nothing changes.
 
- Protected Attributes inherited from TestOp< TData, FieldState::Coeff, FieldState::Coeff, MultiRegions::ContField >
std::string meshName
 
Field< TData, stateIn > * fixt_in
 
Field< TData, stateOut > * fixt_out
 
Field< TData, stateIn > * fixt_out_2
 
Field< TData, stateOut > * fixt_expected
 
std::shared_ptr< MultiRegions::ExpList > fixt_explist
 
LibUtilities::SessionReaderSharedPtr session
 

Detailed Description

template<typename TData>
class TestDirichlet< TData >

Definition at line 44 of file TestDirichlet.hpp.

Constructor & Destructor Documentation

◆ TestDirichlet()

template<typename TData >
TestDirichlet< TData >::TestDirichlet ( )
default

Member Function Documentation

◆ ExpectedSolution()

template<typename TData >
void TestDirichlet< TData >::ExpectedSolution ( const double  time = 0.0)
inline

Definition at line 76 of file TestDirichlet.hpp.

77 {
78 // Get variables
79 auto variables = this->fixt_explist->GetSession()->GetVariables();
80 unsigned int nvars = variables.size();
81
82 // Get number of components
83 unsigned int ncomp = this->fixt_in->GetNumComponents();
84 unsigned int ncoeffs = this->fixt_explist->GetNcoeffs();
85 Array<OneD, double> outcoeffs(ncomp * ncoeffs, 0.0);
86
87 ASSERTL0(nvars == ncomp,
88 "Number of components and number fields in "
89 "session file must be equal. Instead they are Ncomp = " +
90 std::to_string(ncomp) + " and Nfields = " +
91 std::to_string(nvars) + ", respectively.")
92
93 // Impose Dirichlet BCs for each component
94 Array<OneD, double> tmp;
95 for (unsigned int nc = 0; nc < ncomp; ++nc)
96 {
97 // Setup dedicated explist for each variable to evaluate correct BCs
98 MultiRegions::ContField bcfield(this->fixt_explist->GetSession(),
99 this->fixt_explist->GetGraph(),
100 variables[nc], true, false,
102
103 // Update BC for this variable and impose
104 bcfield.EvaluateBoundaryConditions(time, variables[nc]);
105 bcfield.ImposeDirichletConditions(tmp = outcoeffs + nc * ncoeffs);
106 }
107 this->fixt_expected->template CopyArray<NektarSpaces::HostSpace>(
108 outcoeffs);
109 }
#define ASSERTL0(condition, msg)
unsigned int GetNumComponents() const
Gets the number of components for a vector field.
This class is the abstraction of a global continuous two- dimensional spectral/hp element expansion w...
Definition ContField.h:60

References ASSERTL0, Nektar::Collections::eNoCollection, Nektar::MultiRegions::ExpList::EvaluateBoundaryConditions(), TestOp< TData, FieldState::Coeff, FieldState::Coeff, MultiRegions::ContField >::fixt_expected, TestOp< TData, FieldState::Coeff, FieldState::Coeff, MultiRegions::ContField >::fixt_explist, TestOp< TData, FieldState::Coeff, FieldState::Coeff, MultiRegions::ContField >::fixt_in, Nektar::LibUtilities::Field< TData, TState >::GetNumComponents(), and Nektar::MultiRegions::ExpList::ImposeDirichletConditions().

Referenced by TestDirichlet< TData >::SetTestCase().

◆ RunTestCase()

template<typename TData >
void TestDirichlet< TData >::RunTestCase ( const double  time = 0.0)
inline

Definition at line 59 of file TestDirichlet.hpp.

60 {
61 std::string execStr = Operator<TData>::GetOpExecSpace(this->session);
62
63 // reshape this->fixt_out
64 if (execStr == "AVX" || execStr == "Device")
65 {
67 NektarSpaces::GetVectorWidth<TData>(execStr));
68 }
69
71 this->session->GetVariables());
72 op->UpdateBndCoeffs(time);
73 op->Apply(*this->fixt_out);
74 }
void SetInterleaveWidth(const unsigned int &interleaveWidth)
static std::shared_ptr< DirBndCondOp< TData > > Create(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components, const std::string &execStr="")
static std::string GetOpExecSpace(std::shared_ptr< LibUtilities::SessionReader > session, const bool warn=true)
Return the execution space name ("opExecSpace") for an operator.
Definition Operator.hpp:190

References Nektar::MultiRegions::DirBndCondOp< TData >::Create(), TestOp< TData, FieldState::Coeff, FieldState::Coeff, MultiRegions::ContField >::fixt_explist, TestOp< TData, FieldState::Coeff, FieldState::Coeff, MultiRegions::ContField >::fixt_out, Nektar::MultiRegions::Operator< TData >::GetOpExecSpace(), TestOp< TData, FieldState::Coeff, FieldState::Coeff, MultiRegions::ContField >::session, and Nektar::LibUtilities::Field< TData, TState >::SetInterleaveWidth().

◆ SetTestCase()

template<typename TData >
void TestDirichlet< TData >::SetTestCase ( const double  time = 0.0)
inline

Definition at line 50 of file TestDirichlet.hpp.

51 {
52 // Set initial conditions.
53 this->fixt_out->template Initialize<NektarSpaces::HostSpace>(0.0);
54
55 // Compute expected solution.
56 ExpectedSolution(time);
57 }
void ExpectedSolution(const double time=0.0)

References TestDirichlet< TData >::ExpectedSolution(), and TestOp< TData, FieldState::Coeff, FieldState::Coeff, MultiRegions::ContField >::fixt_out.