57template <
typename ExecSpace,
typename TData>
60 using MemSpace =
typename ExecSpace::memory_space;
64 const std::vector<std::string> &components)
70 unsigned int nhomo = 1;
71 session->LoadParameter(
"HomModesZ", nhomo, 1);
90 unsigned int regionOrdinal = 0;
93 for (
auto &it : bregions)
95 const unsigned int thisOrdinal = regionOrdinal++;
97 auto regionId = it.first;
98 auto collectionIter = bconditions.find(regionId);
100 ASSERTL1(collectionIter != bconditions.end(),
101 "Unable to locate collection " + std::to_string(regionId));
104 (*collectionIter).second;
113 std::vector<SpatialDomains::BoundaryConditionType> bndCondType(
115 std::vector<std::string> bndUserDefined(nComp);
116 bool regionTimeDependent =
false;
117 unsigned int numPeriodic = 0;
118 for (
unsigned int nc = 0; nc < nComp; nc++)
120 auto cndMapIter = bndCondMap->find(components[nc]);
122 ASSERTL1(cndMapIter != bndCondMap->end(),
123 "Unable to locate condition map.");
126 (*cndMapIter).second->GetBoundaryConditionType();
127 bndUserDefined[nc] = (*cndMapIter).second->GetUserDefined();
129 regionTimeDependent = regionTimeDependent ||
130 (*cndMapIter).second->IsTimeDependent();
137 if (numPeriodic == nComp)
143 "Boundary region " + std::to_string(regionId) +
144 " is periodic for some components but not others.");
148 auto conditionMapIter = bndCondMap->find(components[0]);
150 ASSERTL1(conditionMapIter != bndCondMap->end(),
151 "Unable to locate condition map.");
154 bc = (*conditionMapIter).second;
158 session, *(it.second),
graph,
true, components[0],
false,
162 bcExpList->SetDataWarehouse();
174 std::vector<std::string> cond(bndUserDefined.size());
175 std::vector<std::map<std::string, std::string>> pars(
176 bndUserDefined.size());
178 for (
size_t c = 0;
c < bndUserDefined.size(); ++
c)
191 for (
size_t e = 0;
e < bcExpList->GetExpSize(); ++
e)
195 const auto tid = bcExpList->GetExp(
e)->GetGeom()->GetGlobalID();
201 std::vector<LibUtilities::EquationSharedPtr> listOfEquations;
202 for (
unsigned int nc = 0; nc < nComp; nc++)
205 auto cndMapIter = bndCondMap->find(components[nc]);
208 bc = (*cndMapIter).second;
209 listOfEquations.push_back(bc->GetEquation());
214 MultiRegions::GetBlockAttributes<TData, FieldState::Phys>(
215 bcExpList, MultiRegions::UnitInterleaveWidths(bcExpList));
218 "Boundary condition phys", blocks_phys, nComp, nhomo));
221 m_wsp_phys.back().template Initialize<MemSpace>(0.0);
225 for (
unsigned int blk = 0; blk < blocks_phys.size(); ++blk)
234 bcExpList, components, ExecSpace::name));
236 std::vector<bool>(nComp,
true));
252 "Boundary condition values",
m_numComp * numPhys));
270 const unsigned int nCompHomo =
271 wsp.GetNumComponents() *
wsp.GetNumHomoModes();
275 "Unexpected boundary phys size.");
277 auto dst =
m_bndPhys[reg].template GetPtr<MemSpace, WriteOnly>(
286 for (
unsigned int blk = 0; blk <
wsp.GetBlocks().size(); ++blk)
288 const unsigned int streamID = blk + 1;
290 auto &block =
wsp.GetBlocks()[blk];
291 ASSERTL1(block.GetInterleaveWidth() == 1,
292 "Boundary condition phys is not interleaved.");
294 auto src = block.template GetPtr<MemSpace, ReadOnly>(streamID);
295 const size_t nSize = block.GetNumElements() * block.GetNumData();
296 for (
unsigned int n = 0; n < nCompHomo; ++n)
298 Math::copyKernel<ExecSpace>(nSize, src + n * block.CompSize(),
299 dst + n * numPhys + offset,
305 ASSERTL1(offset == numPhys,
"Unexpected boundary phys size.");
317 const std::vector<std::string> &components)
319 return std::make_unique<BndCondPhysOpImpl<ExecSpace, TData>>(
320 expansionList, components);
326 std::vector<LibUtilities::Field<TData, FieldState::Phys>>
m_wsp_phys;
333 std::vector<LibUtilities::MemoryRegion<TData>>
m_bndPhys;
343 std::vector<std::vector<SpatialDomains::BoundaryConditionType>>
355 std::vector<std::vector<std::map<std::string, std::string>>>
375 const unsigned blk,
const unsigned comp)
const override
379 "Component index out of range");
385 for (
unsigned int reg = 0; reg <
m_bndPhys.size(); ++reg)
412 std::string &condition,
413 std::map<std::string, std::string> ¶ms)
415 std::vector<std::string> fields;
418 condition = fields.empty() ? std::string() : fields[0];
421 for (
size_t f = 1; f < fields.size(); ++f)
423 const auto eq = fields[f].find(
'=');
426 (eq == std::string::npos) ? fields[f] : fields[f].substr(0, eq);
427 std::string val = (eq == std::string::npos)
429 : fields[f].substr(eq + 1);
439 const std::string &
name,
440 TData &value)
const override
443 "Block index out of range");
445 "Component index out of range");
447 std::string key =
name;
451 const auto it = params.find(key);
453 if (it == params.end())
458 ASSERTL0(!it->second.empty(),
"Boundary tag parameter '" +
name +
459 "' on block " + std::to_string(blk) +
460 " has no value; expected " +
name +
472 auto interp =
m_session->GetInterpreter();
473 value = interp->Evaluate(interp->DefineFunction(
"", it->second));
479 const unsigned comp)
const override
483 "Component index out of range");
488 size_t &compOffset)
override
505 const unsigned int streamID)
override
508 return m_bndPhys[blk].template GetPtr<MemSpace, ReadOnly>(streamID);
512 const unsigned int streamID)
override
515 return m_bndPhys[blk].template GetPtr<MemSpace, ReadWrite>(streamID);
#define ASSERTL0(condition, msg)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Public interface of the Expression operator, which evaluates analytical expressions at the quadrature...
LibUtilities::SessionReaderSharedPtr session
SpatialDomains::MeshGraphSharedPtr graph
A Field represents expansion data to be operated on.
A MemoryRegion represents a memory region.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
Outward normals of one boundary region, in that region's boundary expansion layout.
bool m_hasTimeDependentBndPhys
void UpdateBndPhys(const TData &time=0.0)
Bring the stored values up to date for time time.
bool m_bndPhysInitialised
Set once the constructor's initial evaluation has happened, so that UpdateBndPhys() can skip regions ...
static const std::string name
unsigned int m_opStreamID
Stream the storage is refilled on. See SetStreamID().
Whole-field interface of the Expression operator: evaluates one analytical expression per field compo...
MultiRegions::ExpListSharedPtr m_expansionList
Expansion list the operator acts on.
LibUtilities::NekDataWarehouseSharedPtr m_dataWarehouse
Data warehouse shared with the other operators on the expansion list, used to build and cache shared ...
std::map< size_t, unsigned > m_traceIdToBlk
size_t v_GetBlockCompStride(const unsigned blk) const override
void EvaluateRegion(const unsigned int reg)
Evaluate boundary region reg into its own storage block.
static void SplitBndUserDefined(const std::string &tag, std::string &condition, std::map< std::string, std::string > ¶ms)
Split a boundary tag into its condition and named parameters.
std::vector< std::shared_ptr< ExpressionOp< TData > > > m_expressionOps
std::vector< LibUtilities::MemoryRegion< TData > > m_bndPhys
Boundary values, one storage block per non-periodic boundary region, in that region's own component-m...
std::vector< unsigned int > m_regionOrdinal
Position of each block's region in GetBndCondExpansions(), which the block index does not give once p...
typename ExecSpace::memory_space MemSpace
std::vector< size_t > m_regionNumPhys
Phys points in each region, i.e. the stride between its components.
std::vector< std::vector< SpatialDomains::BoundaryConditionType > > m_bndCondType
Condition type each component of a block carries, indexed as m_bndPhys. The values themselves are sto...
TData * v_UpdateBlockPtr(const unsigned blk, const unsigned int streamID) override
std::vector< std::vector< std::map< std::string, std::string > > > m_bndUserDefinedParams
Parameters carried on each tag, by lower-cased name. Indexed as m_bndUserDefined.
std::vector< std::vector< std::string > > m_bndUserDefined
static std::string className
std::vector< std::vector< unsigned int > > m_regionStreams
Streams the Expression of each region launches on.
size_t v_GetNumBlocks() const override
bool v_GetBndUserDefinedParam(const unsigned blk, const unsigned comp, const std::string &name, TData &value) const override
static std::unique_ptr< Operator< TData > > Instantiate(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components)
std::vector< LibUtilities::Field< TData, FieldState::Phys > > m_wsp_phys
const TData * v_GetBlockPtr(const unsigned blk, const unsigned int streamID) override
bool v_HasTrace(const size_t tid) const override
const TData * v_GetBlockNormals(const unsigned blk) override
SpatialDomains::BoundaryConditionType v_GetBndCondType(const unsigned blk, const unsigned comp) const override
void v_UpdateBndPhys(const TData &time) override
std::map< size_t, size_t > m_traceIdToOffset
BndCondPhysOpImpl(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components)
std::vector< bool > m_regionTimeDependent
Whether any component of a region depends on time, so UpdateBndPhys() re-evaluates only the regions t...
const std::string & v_GetBndUserDefined(const unsigned blk, const unsigned comp) const override
void v_GetTraceLocation(const size_t tid, unsigned &blk, size_t &offset, size_t &compOffset) override
LibUtilities::SessionReaderSharedPtr m_session
USERDEFINEDTYPE of each component, indexed as m_bndCondType. Empty when the session gives none....
const BoundaryRegionCollection & GetBoundaryRegions(void) const
const BoundaryConditionCollection & GetBoundaryConditions(void) const
Predicate matching any of a set of characters.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
NEK_DEVICE_KERNEL void const TData *NEK_RESTRICT const TData *NEK_RESTRICT const size_t const unsigned int const unsigned int const unsigned int const unsigned int const size_t const TData *NEK_RESTRICT const TData *NEK_RESTRICT const TUseSharedWsp TData *NEK_RESTRICT wsp
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::map< int, BoundaryRegionShPtr > BoundaryRegionCollection
std::shared_ptr< BoundaryConditionBase > BoundaryConditionShPtr
std::map< int, BoundaryConditionMapShPtr > BoundaryConditionCollection
std::shared_ptr< BoundaryConditionMap > BoundaryConditionMapShPtr
void Trim(std::string &str)
void ToLower(std::string &str)
Container & Split(Container &result, std::string_view input, Pred pred, TokenCompressMode mode=eTokenCompressOff)
Splits input at characters matching pred into result, which is cleared first. An empty input gives a ...