/home/runner/work/amr-wind/amr-wind/amr-wind/core/ScratchField.H Source File

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/core/ScratchField.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
ScratchField.H
Go to the documentation of this file.
1#ifndef SCRATCHFIELD_H
2#define SCRATCHFIELD_H
3
4#include <string>
5#include <utility>
6
9#include "AMReX_MultiFab.H"
10#include "AMReX_Vector.H"
11#include "AMReX_PhysBCFunct.H"
12
13namespace amr_wind {
14
15class FieldRepo;
16
30{
31public:
32 friend class FieldRepo;
33
34 ScratchField(const ScratchField&) = delete;
36
38 inline const std::string& name() const { return m_name; }
39
41 inline int num_comp() const { return m_ncomp; }
42
44 inline const amrex::IntVect& num_grow() const { return m_ngrow; }
45
47 inline FieldLoc field_location() const { return m_floc; }
48
50 amrex::MultiFab& operator()(int lev) { return m_data[lev]; }
51 const amrex::MultiFab& operator()(int lev) const { return m_data[lev]; }
52
53 amrex::Vector<amrex::MultiFab*> vec_ptrs() noexcept
54 {
55 return amrex::GetVecOfPtrs(m_data);
56 }
57
58 amrex::Vector<const amrex::MultiFab*> vec_const_ptrs() const noexcept
59 {
60 return amrex::GetVecOfConstPtrs(m_data);
61 }
62
64 const FieldRepo& repo() const { return m_repo; }
65
68 ViewField<ScratchField> subview(const int scomp = 0, const int ncomp = 1)
69 {
70 return {*this, scomp, ncomp};
71 }
72
73 void fillpatch(const amrex::Real time) noexcept;
74 void fillpatch(const amrex::Real time, const amrex::IntVect& ng) noexcept;
75
76 void fillpatch(
77 const int lev,
78 const amrex::Real time,
79 amrex::MultiFab& mfab,
80 const amrex::IntVect& nghost) noexcept;
81
82 void fillpatch(
83 const int lev,
84 const amrex::Real time,
85 amrex::MultiFab& mfab,
86 const amrex::IntVect& nghost,
87 amrex::Vector<amrex::BCRec>& bcrec) noexcept;
88
89protected:
91 const FieldRepo& repo,
92 std::string name,
93 const int ncomp = 1,
94 const int ngrow = 1,
95 const FieldLoc floc = FieldLoc::CELL)
96 : m_repo(repo)
97 , m_name(std::move(name))
98 , m_ncomp(ncomp)
99 , m_ngrow(ngrow)
100 , m_floc(floc)
101 {}
102
104 std::string m_name;
106 amrex::IntVect m_ngrow;
108
109 amrex::Vector<amrex::MultiFab> m_data;
110};
111
112} // namespace amr_wind
113
114#endif /* SCRATCHFIELD_H */
Definition FieldRepo.H:86
Definition ScratchField.H:30
FieldLoc field_location() const
Cell, node, face where the field is stored.
Definition ScratchField.H:47
ScratchField & operator=(const ScratchField &)=delete
FieldLoc m_floc
Definition ScratchField.H:107
void fillpatch(const amrex::Real time) noexcept
Definition ScratchField.cpp:50
amrex::Vector< amrex::MultiFab > m_data
Definition ScratchField.H:109
const FieldRepo & repo() const
Return a reference to the field repository that created this field.
Definition ScratchField.H:64
ScratchField(const ScratchField &)=delete
amrex::MultiFab & operator()(int lev)
Return the field data for a given level.
Definition ScratchField.H:50
int num_comp() const
Number of components for this field.
Definition ScratchField.H:41
const amrex::IntVect & num_grow() const
Ghost cells.
Definition ScratchField.H:44
amrex::IntVect m_ngrow
Definition ScratchField.H:106
const amrex::MultiFab & operator()(int lev) const
Definition ScratchField.H:51
const FieldRepo & m_repo
Definition ScratchField.H:103
const std::string & name() const
Name if available for this scratch field.
Definition ScratchField.H:38
std::string m_name
Definition ScratchField.H:104
amrex::Vector< amrex::MultiFab * > vec_ptrs() noexcept
Definition ScratchField.H:53
ScratchField(const FieldRepo &repo, std::string name, const int ncomp=1, const int ngrow=1, const FieldLoc floc=FieldLoc::CELL)
Definition ScratchField.H:90
amrex::Vector< const amrex::MultiFab * > vec_const_ptrs() const noexcept
Definition ScratchField.H:58
ViewField< ScratchField > subview(const int scomp=0, const int ncomp=1)
Definition ScratchField.H:68
int m_ncomp
Definition ScratchField.H:105
Definition ViewField.H:24
FieldLoc
Definition FieldDescTypes.H:27
@ CELL
Cell-centered (default)
Definition BCInterface.cpp:7