54 _edgeDiscretization->GetNumberOfNodes() !=
55 _surfaceDiscretization->GetNumberOfNodes() ||
56 _surfaceDiscretization->GetNumberOfNodes() !=
57 (_grid.GetDegreesOfFreedomNumberTotal()) ||
58 _surfaceDiscretization->GetNumberOfNodes() !=
59 _materialProperties->GetNumberOfNodes()
62 throw std::invalid_argument(
"The given component dimensions, discretization dimensions or material property dimensions are not matching.");
65 if (_grid.GetDegreesOfFreedomNumberInX() == 0 || _grid.GetDegreesOfFreedomNumberInY() == 0 || _grid.GetDegreesOfFreedomNumberInZ() == 0)
67 throw std::logic_error(
"3D _grid with less then 3 dimensions detected.");
74 T zero =
static_cast<T
>(0.);
75 for (
index_t z = 0; z < _grid.GetDegreesOfFreedomNumberInZ(); z++)
77 for (
index_t y = 0; y < _grid.GetDegreesOfFreedomNumberInY(); y++)
79 for (
index_t x = 0; x < _grid.GetDegreesOfFreedomNumberInX(); x++)
81 index_t index = _grid.GetIndexToCoordinateNotPadded(x, y, z);
82 index_t indexPedded = _grid.GetIndexToCoordinate(x, y, z);
83 if ((*_materialProperties.*GetMaterialInXAtIndex)(index) != 0 && (*_materialProperties.*GetMaterialInYAtIndex)(index) != 0 && (*_materialProperties.*GetMaterialInZAtIndex)(index) != 0)
85 if (_surfaceDiscretization->GetDeltaYZAtIndex(index) != 0)
88 _coefficientComponentXCurlY[indexPedded] = (
static_cast<T
>(timeDiscretization) *
static_cast<T
>(_edgeDiscretization->GetDeltaYAtIndex(index))) /
89 (
static_cast<T
>((*_materialProperties.*GetMaterialInYAtIndex)(index)) *
static_cast<T
>(_surfaceDiscretization->GetDeltaYZAtIndex(index)));
90 _coefficientComponentXCurlZ[indexPedded] = (
static_cast<T
>(timeDiscretization) *
static_cast<T
>(_edgeDiscretization->GetDeltaZAtIndex(index))) /
91 (
static_cast<T
>((*_materialProperties.*GetMaterialInZAtIndex)(index)) *
static_cast<T
>(_surfaceDiscretization->GetDeltaYZAtIndex(index))); }
94 _coefficientComponentXCurlY[indexPedded] = zero;
95 _coefficientComponentXCurlZ[indexPedded] = zero;
98 if (_surfaceDiscretization->GetDeltaXZAtIndex(index) != 0)
100 _coefficientComponentYCurlX[indexPedded] = (
static_cast<T
>(timeDiscretization) *
static_cast<T
>(_edgeDiscretization->GetDeltaXAtIndex(index))) /
101 (
static_cast<T
>((*_materialProperties.*GetMaterialInXAtIndex)(index)) *
static_cast<T
>(_surfaceDiscretization->GetDeltaXZAtIndex(index)));
102 _coefficientComponentYCurlZ[indexPedded] = (
static_cast<T
>(timeDiscretization) *
static_cast<T
>(_edgeDiscretization->GetDeltaZAtIndex(index))) /
103 (
static_cast<T
>((*_materialProperties.*GetMaterialInZAtIndex)(index)) *
static_cast<T
>(_surfaceDiscretization->GetDeltaXZAtIndex(index)));
108 _coefficientComponentYCurlX[indexPedded] = zero;
109 _coefficientComponentYCurlZ[indexPedded] = zero;
112 if (_surfaceDiscretization->GetDeltaXYAtIndex(index) != 0)
114 _coefficientComponentZCurlX[indexPedded] = (
static_cast<T
>(timeDiscretization) *
static_cast<T
>(_edgeDiscretization->GetDeltaXAtIndex(index))) /
115 (
static_cast<T
>((*_materialProperties.*GetMaterialInXAtIndex)(index)) *
static_cast<T
>(_surfaceDiscretization->GetDeltaXYAtIndex(index)));
116 _coefficientComponentZCurlY[indexPedded] = (
static_cast<T
>(timeDiscretization) *
static_cast<T
>(_edgeDiscretization->GetDeltaYAtIndex(index))) /
117 (
static_cast<T
>((*_materialProperties.*GetMaterialInYAtIndex)(index)) *
static_cast<T
>(_surfaceDiscretization->GetDeltaXYAtIndex(index)));
121 _coefficientComponentZCurlX[indexPedded] = zero;
122 _coefficientComponentZCurlY[indexPedded] = zero;
127 _coefficientComponentXCurlY[indexPedded] = zero;
128 _coefficientComponentXCurlZ[indexPedded] = zero;
129 _coefficientComponentYCurlX[indexPedded] = zero;
130 _coefficientComponentYCurlZ[indexPedded] = zero;
131 _coefficientComponentZCurlX[indexPedded] = zero;
132 _coefficientComponentZCurlY[indexPedded] = zero;
144 T one =
static_cast<T
>(1.);
145 T two =
static_cast<T
>(2.);
147 index_t x(0), y(0), z(0), index(0);
149 while (HasZeroValueAtIndex(index) && !(x == _grid.GetDegreesOfFreedomNumberInX() - 1 && y == _grid.GetDegreesOfFreedomNumberInY() - 1 && z == _grid.GetDegreesOfFreedomNumberInZ() - 1))
151 if (x < _grid.GetDegreesOfFreedomNumberInX())
158 if (y < _grid.GetDegreesOfFreedomNumberInY())
168 index = _grid.GetIndexToCoordinateNotPadded(x, y, z);
171 if (HasZeroValueAtIndex(index) && (x == _grid.GetDegreesOfFreedomNumberInX() - 1 && y == _grid.GetDegreesOfFreedomNumberInY() - 1 && z == _grid.GetDegreesOfFreedomNumberInZ() - 1))
173 throw std::logic_error(
"All nodes are either PEC or PMC elements");
177 double permeability(0), permittivity(0);
178 permeability = std::min({
179 _materialProperties->GetPermeabilityInX(index),
180 _materialProperties->GetPermeabilityInY(index),
181 _materialProperties->GetPermeabilityInZ(index)
183 permittivity = std::min({ _materialProperties->GetPermittivityInX(index), _materialProperties->GetPermittivityInY(index), _materialProperties->GetPermittivityInZ(index) });
185 T propagationSpeed = SqrRoot(
186 one / (
static_cast<T
>(permittivity)*
static_cast<T
>(permeability))
188 timeDiscretization = one / SqrRoot(
189 Potenz(one /
static_cast<T
>(_edgeDiscretization->GetDeltaXAtIndex(index)), two) +
190 Potenz(one /
static_cast<T
>(_edgeDiscretization->GetDeltaYAtIndex(index)), two) +
191 Potenz(one /
static_cast<T
>(_edgeDiscretization->GetDeltaZAtIndex(index)), two))
192 * _stabilityFactor / propagationSpeed;
194 for (z = 0; z < _grid.GetDegreesOfFreedomNumberInZ(); z++)
196 for (y = 0; y < _grid.GetDegreesOfFreedomNumberInY(); y++)
198 for (x = 0; x < _grid.GetDegreesOfFreedomNumberInX(); x++)
200 index = _grid.GetIndexToCoordinateNotPadded(x, y, z);
201 if (!HasZeroValueAtIndex(index))
205 propagationSpeed = SqrRoot(
206 one / (
static_cast<T
>(permeability) *
static_cast<T
>(permittivity))
209 T temp = one / SqrRoot(
210 Potenz(
static_cast<T
>(one / _edgeDiscretization->GetDeltaXAtIndex(index)), two) +
211 Potenz(
static_cast<T
>(one / _edgeDiscretization->GetDeltaYAtIndex(index)), two) +
212 Potenz(
static_cast<T
>(one / _edgeDiscretization->GetDeltaZAtIndex(index)), two)
213 * _stabilityFactor / propagationSpeed
216 if (temp < timeDiscretization)
218 timeDiscretization = temp;
230 index_t numberOfDoF = _grid.GetDegreesOfFreedomNumberTotalPadded();
231 _coefficientComponentXCurlY =
static_cast<T*
>(_aligned_malloc(numberOfDoF *
static_cast<index_t>(
sizeof(T)), _grid.GetAlignment()));
232 _coefficientComponentXCurlZ =
static_cast<T*
>(_aligned_malloc(numberOfDoF *
static_cast<index_t>(
sizeof(T)), _grid.GetAlignment()));
233 _coefficientComponentYCurlX =
static_cast<T*
>(_aligned_malloc(numberOfDoF *
static_cast<index_t>(
sizeof(T)), _grid.GetAlignment()));
234 _coefficientComponentYCurlZ =
static_cast<T*
>(_aligned_malloc(numberOfDoF *
static_cast<index_t>(
sizeof(T)), _grid.GetAlignment()));
235 _coefficientComponentZCurlX =
static_cast<T*
>(_aligned_malloc(numberOfDoF *
static_cast<index_t>(
sizeof(T)), _grid.GetAlignment()));
236 _coefficientComponentZCurlY =
static_cast<T*
>(_aligned_malloc(numberOfDoF *
static_cast<index_t>(
sizeof(T)), _grid.GetAlignment()));
238 T zero =
static_cast <T
>(0.);
239 for (
int i = 0; i < numberOfDoF; i++)
241 _coefficientComponentXCurlY[i] = zero;
242 _coefficientComponentXCurlZ[i] = zero;
243 _coefficientComponentYCurlX[i] = zero;
244 _coefficientComponentYCurlZ[i] = zero;
245 _coefficientComponentZCurlX[i] = zero;
246 _coefficientComponentZCurlY[i] = zero;