2 #ifndef __ELECTROSTATICS_HPP__
3 #define __ELECTROSTATICS_HPP__
63 blockPermittivity = 0.0;
65 PetscInt ghosts[2] = {0, 1};
76 boost::shared_ptr<DataAtIntegrationPts> common_data_ptr,
77 boost::shared_ptr<std::map<int, BlockData>> int_block_sets_ptr,
80 commonDataPtr(common_data_ptr), intBlockSetsPtr(int_block_sets_ptr) {
81 std::fill(&doEntities[MBVERTEX], &doEntities[MBMAXTYPE],
false);
82 doEntities[MBVERTEX] =
true;
86 EntityType col_type,
EntData &row_data,
89 for (
const auto &
m : *intBlockSetsPtr) {
90 if (
m.second.interfaceEnts.find(getFEEntityHandle()) !=
91 m.second.interfaceEnts.end()) {
92 commonDataPtr->blockChrgDens =
m.second.chargeDensity;
106 boost::shared_ptr<DataAtIntegrationPts> common_data_ptr,
107 boost::shared_ptr<map<int, BlockData>> perm_block_sets_ptr,
110 commonDataPtr(common_data_ptr), permBlockSetsPtr(perm_block_sets_ptr) {
111 std::fill(&doEntities[MBVERTEX], &doEntities[MBMAXTYPE],
false);
112 doEntities[MBVERTEX] =
true;
120 for (
auto &
m : (*permBlockSetsPtr)) {
121 if (
m.second.domainEnts.find(getFEEntityHandle()) !=
122 m.second.domainEnts.end()) {
123 commonDataPtr->blockPermittivity =
m.second.epsPermit;
138 boost::shared_ptr<MatrixDouble> grad_u_negative,
139 boost::shared_ptr<std::map<int, BlockData>> perm_block_sets_ptr,
140 boost::shared_ptr<std::map<int, BlockData>> int_domain_block_sets_ptr,
141 boost::shared_ptr<DataAtIntegrationPts> common_data_ptr,
144 gradUNegative(grad_u_negative), permBlockSetsPtr(perm_block_sets_ptr),
145 intDomainBlocksetsPtr(int_domain_block_sets_ptr),
146 commonDataPtr(common_data_ptr), petscTotalEnergy(petsc_vec_energy) {
147 std::fill(&doEntities[MBVERTEX], &doEntities[MBMAXTYPE],
false);
148 doEntities[MBVERTEX] =
true;
153 auto t_negative_grad_u = getFTensor1FromMat<SPACE_DIM>(*gradUNegative);
155 double area = getMeasure();
156 auto t_w = getFTensor0IntegrationWeight();
157 auto nb_gauss_pts = getGaussPts().size2();
158 double totalEnergy = 0.0;
161 for (
const auto &
m : *intDomainBlocksetsPtr) {
163 double blockPermittivity = 0.0;
165 if (
m.second.internalDomainEnts.find(getFEEntityHandle()) !=
166 m.second.internalDomainEnts.end()) {
167 for (
const auto &
n : *permBlockSetsPtr) {
168 if (
n.second.domainEnts.find(getFEEntityHandle()) !=
169 n.second.domainEnts.end()) {
170 blockPermittivity =
n.second.epsPermit;
174 for (
int gg = 0; gg != nb_gauss_pts; gg++) {
175 totalEnergy += 0.5 * t_negative_grad_u(
I) * t_negative_grad_u(
I) *
176 blockPermittivity * t_w * area;
199 boost::shared_ptr<MatrixDouble> grad_u_negative,
200 boost::shared_ptr<VectorDouble> energy_densiity_ptr,
201 boost::shared_ptr<std::map<int, BlockData>> perm_block_sets_ptr,
202 boost::shared_ptr<DataAtIntegrationPts> common_data_ptr)
204 energyDensity(energy_densiity_ptr), gradUNegative(grad_u_negative),
205 permBlockSetsPtr(perm_block_sets_ptr), commonDataPtr(common_data_ptr) {
206 std::fill(&doEntities[MBVERTEX], &doEntities[MBMAXTYPE],
false);
207 doEntities[MBVERTEX] =
true;
216 size_t nb_gauss_pts = getGaussPts().size2();
217 energyDensity->resize(nb_gauss_pts,
false);
218 energyDensity->clear();
220 auto t_negative_grad_u = getFTensor1FromMat<SPACE_DIM>(*gradUNegative);
222 double blockPermittivity = 0.0;
223 for (
const auto &
n : *permBlockSetsPtr) {
224 if (
n.second.domainEnts.find(getFEEntityHandle()) !=
225 n.second.domainEnts.end()) {
226 blockPermittivity =
n.second.epsPermit;
230 for (
int gg = 0; gg != nb_gauss_pts; gg++) {
232 0.5 * t_negative_grad_u(
I) * t_negative_grad_u(
I) * blockPermittivity;
251 boost::shared_ptr<MatrixDouble> grad_u_negative,
252 boost::shared_ptr<MatrixDouble> grad_times_perm,
253 boost::shared_ptr<std::map<int, BlockData>> perm_block_sets_ptr,
254 boost::shared_ptr<DataAtIntegrationPts> common_data_ptr)
256 gradTimesPerm(grad_times_perm), gradUNegative(grad_u_negative),
257 permBlockSetsPtr(perm_block_sets_ptr), commonDataPtr(common_data_ptr) {
258 std::fill(&doEntities[MBVERTEX], &doEntities[MBMAXTYPE],
false);
259 doEntities[MBVERTEX] =
true;
268 size_t nb_gauss_pts = getGaussPts().size2();
269 gradTimesPerm->resize(
SPACE_DIM, nb_gauss_pts,
false);
270 gradTimesPerm->clear();
271 auto t_grad_times_perm = getFTensor1FromMat<SPACE_DIM>(*gradTimesPerm);
272 auto t_negative_grad_u = getFTensor1FromMat<SPACE_DIM>(*gradUNegative);
274 double blockPermittivity = 0.0;
275 for (
const auto &
n : *permBlockSetsPtr) {
276 if (
n.second.domainEnts.find(getFEEntityHandle()) !=
277 n.second.domainEnts.end()) {
278 blockPermittivity =
n.second.epsPermit;
281 for (
int gg = 0; gg != nb_gauss_pts; gg++) {
282 t_grad_times_perm(
I) = t_negative_grad_u(
I) * blockPermittivity;
302 const std::string
field_name, boost::shared_ptr<MatrixDouble> grad_ptr,
303 boost::shared_ptr<MatrixDouble> d_jump,
304 boost::shared_ptr<DataAtIntegrationPts> common_data_ptr,
305 boost::shared_ptr<std::map<int, BlockData>> perm_block_sets_ptr)
307 djump(d_jump), commonDataPtr(common_data_ptr),
308 permBlockSetsPtr(perm_block_sets_ptr)
311 std::fill(&doEntities[MBVERTEX], &doEntities[MBMAXTYPE],
false);
312 doEntities[MBVERTEX] =
true;
319 auto t_field_grad = getFTensor1FromMat<SPACE_DIM>(*gradPtr);
321 double blockPermittivity = 0.0;
323 for (
const auto &
n : *permBlockSetsPtr) {
324 if (
n.second.domainEnts.find(getFEEntityHandle()) !=
325 n.second.domainEnts.end()) {
326 blockPermittivity =
n.second.epsPermit;
329 auto N_InLoop = getNinTheLoop();
330 auto sensee = getSkeletonSense();
331 auto nb_gauss_pts = getGaussPts().size2();
334 djump->resize(
SPACE_DIM, nb_gauss_pts,
false);
337 auto t_jump = getFTensor1FromMat<SPACE_DIM>(*djump);
339 for (
int gg = 0; gg != nb_gauss_pts; gg++) {
340 t_jump(
i) -= t_field_grad(
i) * blockPermittivity * sensee;
350 boost::shared_ptr<MatrixDouble>
djump;
359 const std::string
field_name, boost::shared_ptr<MatrixDouble> d_jump,
361 boost::shared_ptr<std::map<int, BlockData>> electrode_block_sets_ptr)
363 petscVec(alpha_vec), elecBlockSetsPtr(electrode_block_sets_ptr) {
364 std::fill(&doEntities[MBVERTEX], &doEntities[MBMAXTYPE],
false);
365 doEntities[MBVERTEX] =
true;
371 auto fe_ent = getFEEntityHandle();
372 auto nb_gauss_pts = getGaussPts().size2();
373 double area = getMeasure();
374 dJumpPtr->resize(
SPACE_DIM, nb_gauss_pts,
false);
375 auto t_jump = getFTensor1FromMat<SPACE_DIM>(*dJumpPtr);
376 auto t_normal = getFTensor1NormalsAtGaussPts();
377 auto t_w = getFTensor0IntegrationWeight();
378 for (
auto &
m : *elecBlockSetsPtr) {
379 double alphaPart = 0.0;
380 if (
m.second.electrodeEnts.find(fe_ent) !=
m.second.electrodeEnts.end()) {
382 for (
int gg = 0; gg != nb_gauss_pts; gg++) {
384 t_r(
i) = t_normal(
i);
386 alphaPart += (t_jump(
i) * t_r(
i)) * t_w * area;
408 boost::shared_ptr<MatrixDouble> grad_u)
410 gradUNegative(grad_u_negative), gradU(grad_u) {}
416 const size_t nb_gauss_pts = getGaussPts().size2();
417 gradUNegative->resize(
SPACE_DIM, nb_gauss_pts,
false);
418 gradUNegative->clear();
419 auto t_grad_u = getFTensor1FromMat<SPACE_DIM>(*gradU);
420 auto t_negative_grad_u = getFTensor1FromMat<SPACE_DIM>(*gradUNegative);
423 for (
int gg = 0; gg != nb_gauss_pts; gg++) {
424 t_negative_grad_u(
I) = -t_grad_u(
I);
434 boost::shared_ptr<MatrixDouble>
gradU;
437 #endif // __ELECTROSTATICS_HPP__