chombo-discharge
Loading...
Searching...
No Matches
CD_MFHelmholtzElectrostaticEBBCImplem.H
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2021-2026 SINTEF Energy Research
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
13#ifndef CD_MFHELMHOLTZELECTROSTATICEBBCIMPLEM_H
14#define CD_MFHELMHOLTZELECTROSTATICEBBCIMPLEM_H
15
16// Std includes
17#include <limits>
18
19// Our includes
21#include <CD_NamespaceHeader.H>
22
23Real
25 const RealVect& a_pos) const // NOLINT(readability-convert-member-functions-to-static)
26{
27 CH_TIME("MFHelmholtzElectrostaticEBBC::getElectrodePotential(RealVect)");
28
29 // Find closest electrode
30 int closestElectrode = 0;
31 Real minDist = std::numeric_limits<Real>::infinity();
32
33 const std::vector<std::pair<Electrode, ElectrostaticEbBc::BcFunction>>& electrodeBCs = m_electrostaticBCs.getBcs();
34
35 for (int i = 0; i < electrodeBCs.size(); i++) {
36 const RefCountedPtr<BaseIF>& impFunc = electrodeBCs[i].first.getImplicitFunction();
37
38 const Real curDist = std::abs(impFunc->value(a_pos));
39
40 if (curDist < minDist) {
41 closestElectrode = i;
42 minDist = curDist;
43 }
44 }
45
46 // Return potential of closest electrode. Again, following the (perhaps odd) convention that the FieldSolver is "time
47 // dependent" but the operator factory is not, we've passed the time in by reference to the functions in
48 // m_electrostaticBCs. Calling those functions simply ignore the time-argument and uses FieldSolver::m_dt instead. So,
49 // we can just use a dummy dt here.
50 constexpr Real dummyDt = 0.0;
51
52 return electrodeBCs[closestElectrode].second(a_pos, dummyDt);
53}
54
55#include <CD_NamespaceFooter.H>
56
57#endif
Declaration of a Electrostatic boundary condition class for MFHelmholtzOp.
Real getElectrodePotential(const RealVect &a_pos) const
Get electrode potential.
Definition CD_MFHelmholtzElectrostaticEBBCImplem.H:24