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