/home/runner/work/amr-wind/amr-wind/amr-wind/equation_systems/sdr/sdr_ops.H Source File

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/equation_systems/sdr/sdr_ops.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
sdr_ops.H
Go to the documentation of this file.
1#ifndef SDR_OPS_H
2#define SDR_OPS_H
3
6
7namespace amr_wind::pde {
8
12template <>
14{
16 : m_tmodel(tmodel), m_fields(fields)
17 {}
18
20 {
21 auto& mueff = m_fields.mueff;
23 }
24
27};
28
32template <>
34{
35 PostSolveOp(CFDSim& /*unused*/, PDEFields& fields) : m_fields(fields) {}
36
37 void operator()(const amrex::Real time)
38 {
41 }
42
44 amrex::Real clip_value{1.0e-8};
45};
46
47template <typename Scheme>
48struct FieldRegOp<SDR, Scheme>
49{
50 explicit FieldRegOp(CFDSim& sim_in) : sim(sim_in) {}
51
53 {
54 auto& repo = sim.repo();
55 auto fields = create_fields_instance<SDR, Scheme>(time, repo);
56
57 repo.declare_cc_field(
58 SDR::var_name() + "_lhs_src_term", SDR::ndim, 1, 1);
59
60 sim.io_manager().register_io_var(fields.field.name());
61
62 return fields;
63 }
64
66};
67
71template <typename Scheme>
72struct DiffusionOp<SDR, Scheme> : public DiffSolverIface<typename SDR::MLDiffOp>
73{
74 static_assert(
75 SDR::ndim == 1, "DiffusionOp invoked for non-scalar SDR type");
76 static_assert(
77 std::is_same_v<typename SDR::MLDiffOp, amrex::MLABecLaplacian>,
78 "Invalid linear operator for scalar diffusion operator");
79
81 PDEFields& fields, const bool has_overset, const bool mesh_mapping)
82 : DiffSolverIface<typename SDR::MLDiffOp>(
83 fields, has_overset, mesh_mapping)
84 , m_lhs_src_term(
85 fields.repo.get_field(SDR::var_name() + "_lhs_src_term"))
86 {
87 this->m_solver->setDomainBC(
89 this->m_pdefields.field, amrex::Orientation::low),
91 this->m_pdefields.field, amrex::Orientation::high));
92 this->m_applier->setDomainBC(
94 this->m_pdefields.field, amrex::Orientation::low),
96 this->m_pdefields.field, amrex::Orientation::high));
97
98 m_lhs_src_term.setVal(0.0);
99 }
100
102 void compute_diff_term(const FieldState fstate)
103 {
104 this->setup_operator(*this->m_applier, 0.0, -1.0, fstate);
105
106 auto tau_state =
107 std::is_same_v<Scheme, fvm::Godunov> ? FieldState::New : fstate;
108 amrex::MLMG mlmg(*this->m_applier);
109 mlmg.apply(
110 this->m_pdefields.diff_term.state(tau_state).vec_ptrs(),
111 this->m_pdefields.field.vec_ptrs());
112 }
113
114 void
115 set_acoeffs(typename SDR::MLDiffOp& linop, const FieldState fstate) override
116 {
117 BL_PROFILE("amr-wind::pde::set_acoeffs");
118 auto& repo = m_pdefields.repo;
119
120 const int nlevels = repo.num_active_levels();
121 auto& density = m_density.state(fstate);
122 auto lhs_total = repo.create_scratch_field(1, 1);
124 *lhs_total, 1.0, m_lhs_src_term, 0, 1.0, density, 0, 0, 1, 1);
125
126 for (int lev = 0; lev < nlevels; ++lev) {
127 linop.setACoeffs(lev, (*lhs_total)(lev));
128 }
129 }
130
132};
133
134} // namespace amr_wind::pde
135
136#endif /* SDR_OPS_H */
Definition CFDSim.H:51
FieldRepo & repo()
Return the field repository.
Definition CFDSim.H:66
IOManager & io_manager()
Definition CFDSim.H:93
Definition Field.H:116
void fillpatch(const amrex::Real time) noexcept
Definition Field.cpp:206
void register_io_var(const std::string &fname)
Convenience function to register a variable for both output and restart.
Definition IOManager.H:76
Definition SimTime.H:30
Definition DiffusionOps.H:30
Definition TurbulenceModel.H:32
virtual void update_scalar_diff(Field &deff, const std::string &name)=0
Interface to update scalar diffusivity based on Schmidt number.
void lower_bound(FType &field, const amrex::Real min_value, const int icomp=0)
Definition field_ops.H:380
void lincomb(T1 &dst, const amrex::Real a, const T2 &x, const int xcomp, const amrex::Real b, const T3 &y, const int ycomp, const int dstcomp, const int numcomp, const amrex::IntVect &nghost)
Definition field_ops.H:317
FieldState
Definition FieldDescTypes.H:14
@ New
Same as FieldState::NP1.
Definition AdvOp_Godunov.H:16
PDEFields create_fields_instance(const SimTime &time, FieldRepo &repo, const FieldInterpolator itype=FieldInterpolator::CellConsLinear)
Definition PDEHelpers.H:49
amrex::Array< amrex::LinOpBCType, AMREX_SPACEDIM > get_diffuse_scalar_bc(amr_wind::Field &scalar, amrex::Orientation::Side side) noexcept
void set_acoeffs(typename SDR::MLDiffOp &linop, const FieldState fstate) override
Definition sdr_ops.H:115
Field & m_lhs_src_term
Definition sdr_ops.H:131
void compute_diff_term(const FieldState fstate)
Computes the diffusion term that goes in the RHS.
Definition sdr_ops.H:102
DiffusionOp(PDEFields &fields, const bool has_overset, const bool mesh_mapping)
Definition sdr_ops.H:80
Definition PDEOps.H:172
CFDSim & sim
Definition sdr_ops.H:65
FieldRegOp(CFDSim &sim_in)
Definition sdr_ops.H:50
PDEFields operator()(const SimTime &time)
Definition sdr_ops.H:52
Definition PDEOps.H:35
CFDSim & sim
Definition PDEOps.H:53
Definition PDEFields.H:27
Field & mueff
Effective visocity field (e.g., velocity_mueff)
Definition PDEFields.H:36
Field & field
Solution variable (e.g., velocity, temperature)
Definition PDEFields.H:34
PDEFields & m_fields
Definition sdr_ops.H:43
PostSolveOp(CFDSim &, PDEFields &fields)
Definition sdr_ops.H:35
void operator()(const amrex::Real time)
Definition sdr_ops.H:37
Definition PDEOps.H:205
PDEFields & m_fields
Definition PDEOps.H:213
Definition SDR.H:32
amrex::MLABecLaplacian MLDiffOp
Definition SDR.H:33
static constexpr int ndim
Definition SDR.H:41
static std::string var_name()
Definition SDR.H:37
void operator()()
Definition sdr_ops.H:19
turbulence::TurbulenceModel & m_tmodel
Definition sdr_ops.H:25
PDEFields & m_fields
Definition sdr_ops.H:26
TurbulenceOp(turbulence::TurbulenceModel &tmodel, PDEFields &fields)
Definition sdr_ops.H:15
Definition PDEOps.H:179
turbulence::TurbulenceModel & m_tmodel
Definition PDEOps.H:190
PDEFields & m_fields
Definition PDEOps.H:191