mfem: Question about anisotropic materials for Darcy-type problem
Hi all, we’ve been doing pretty great progress on an electromagnetic solver for modeling electrostatic problems with anisotropic materials (related to https://github.com/mfem/mfem/issues/4475 and also https://github.com/mfem/mfem/issues/2008).
I am using a Darcy-type solver (similar to ex5) which is starting to work pretty well (we’re using fairly complex mixed meshes but I am going to show results for coil.gen). Essentially I want to set anisotropic electric conductivity for some attributes (representing on of the conductive media) while the rest has isotropic conductivity. My approach of getting the parallel direction for the different mesh elements is to solve a simple isotropic diffusion problem and take the gradient of the scalar potential as a surrogate for the direction, which is working pretty well (also looked at other approaches, incl. semi-analytic approaches):
The label rho_ij refer to the resistivity tensor elements (2-rank). In the example above I used a parallel conductivity equivalent to copper and a perpendicular conductivity to 1/1000th of the parallel one. If I solve these two cases, I get the following current density.
The voltage and port current values are as follows:
Isotropic:
-- Port currents: [ -493.8926 kA, 493.8970 kA ]
-- Port voltages: [ -0.5000 mV, +0.5000 mV ]
Anisotropic:
-- Port currents: [ -414.4124 kA, 414.4124 kA ]
-- Port voltages: [ -0.5000 mV, +0.5000 mV ]
I don’t fully trust these results. I don’t think I would expect such a dramatic drop in current density (or in other words, such a big increase in “measured” resistance). The overall noisy solution for the anisotropic case plus the poor convergence (47 vs. 882 iterations) suggest that something is going wrong here. Ultimately, we also want to run this with a much greater parallel vs. perpendicular contrast (about 10 orders of magnitude).
Am I missing something obvious here? Maybe I am too liberal in the way that the anisotropic conductivity is defined (steep transition from anisotropic to isotropic)? Or could this be address with a different solver and/or preconditioner (current using HypreDiagScale and HypreBoomerAMG for the Darcy block system).
Big thanks in advance for any helpful comments!! Mathias
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 1
- Comments: 85 (43 by maintainers)
I am happy to announce linear hybridization is out! 🎉 Nonlinear extension should follow soon 🚀 .
To give you an idea, I may show you the results from
ex5-aniso.cpp, in particular the problem of “diffusion ring”, where the conduction along the circle is 1e8 stronger than perpendicular to it. The initial arc segment is then diffused onsquare-disc.meshfrom MFEM, yielding the following results:Hi @najlkin , sorry not responding for a while: we had to (temporarily) shift our focus to some other work, and this somehow disappeared from my radar. I will try to give this a test run this week or next week; I am curious to see how the solution-based iterator performs. We’ll definitely revisit this problem with some time commitment hopefully soon (it’s not become less important, quite the opposite actually).
Thanks for continuing to work on this! 🚀 Mathias
Hi @najlkin , I got a chance to run some tests with the new version yesterday. Below are some results; looks like it’s going in a good direction, but still some effects I don’t quite understand. Also: as mentioned before I am more than happy to share the two test meshes used below and integrate those in the most recent version, if you would like to run some tests on your end.
Test cases:
sigma = 5.8e+07) and a high conductivity beam in the central plate (sigma_par = 5e+15,sigma_perp = 1e+06sigma_paris used for “along the beam” and for the “through the screen” directionsRT cases
Few things I noticed:
hybridizationin the anisotropic cases looks great for the tet-only mesh (bottom) but seems to fail for the mixed meshreductionseems quite noisy, and does not seem compatible with the mixed mesh (got an error about incompatible finite elements)DG isotropic cases
Few things I noticed:
hybridizationgenerally looking good,reductionalso good but noisyDG anisotropic cases
Few things I noticed:
hybridizationgenerally looking good,reductionis noisySo it seems that hybridized RT is the current front runner! I think it’s moving in a great direction, thank again for making these very cool additions.
BTW: I also looked into the
ex5-nguyenexamples, but these are quite difficult to follow due to the sparsity of comments. Any chance you would be okay with adding some comments (especially regarding the functionscFun,tFun,fFun, …). I think that would be super helpful (probably for others, too).Thanks again for the extensive help with this so far, Jan! Mathias
Potential reduction (RTDG) is out too! 🚀 There is just no example code for it now 😅 .
Ok, I just added parallelized flux reduction (LDG), give it a try😉
Hi @najlkin , I ran a quick first test yesterday on one of the test models I used before, without employing any anisotropic materials and solved using GMRES. The base RT case (left) is running fine (as expected); for the DG case (right) I assume there is something missing in how I am setting up the problem:
I made the following changes to your code:
Define voltage ports
Zero flux BC on non-port boundaries
Set flux TDOFs
Anything I am missing here when setting up the DG case? Also want to reiterate: this is great stuff!! Excited to dive into some test cases! 😃 Have a great weekend! Mathias
Hi, the parallelization is underway 🚀 . There is
ParDarcyForm, which is limited currently only to RTDG or LDG, but you may try it already 😉 . See the newex5p-hdg.cppfor an example. The next should be reduction and then hybridization.Perfect timing, @najlkin ! Was just looking into
UMFPackSolverand actually had some trouble with hybridization (which I assume your modifications might address). I also ran some tests with DG and that started to work better (especially given your suggestion). I was working on a simpler test mesh today (for which I can generate the ideal anisotropy) and will rerun those tests shortly and post some updates. In any case, big thanks for the continuous help on this!! It’s greatly appreciated! 😃 MathiasHi @najlkin , thanks for checking in! I had to put this aside for a few days, but just resumed working on this. I am currently trying a few of the experimental features and various
devbranches directly in MFEM (rather than in PyMFEM) and directly on our more complex meshes (rather than the more simple meshes). For one, my runs were previously restricted to lower order basis functions since our meshes use Pyramid basis functions (currently looking into pyramid-dev to address this), which might play a role. I will also run some more complex test cases using yourDarcyOperatorclasses indarcy-hdg-dev. I will try to post a more detailed update in a couple of days here MathiasHi, @mdavids-cfs, Just a quick question (I hope). Am I correct in thinking that you’re solving a simple Laplacian problem $\nabla\cdot\sigma\nabla\phi=0$ with voltage boundary conditions and your spatially varying anisotropic $\sigma$? If so, my main question is how do you recover the current density that you’re displaying? Best wishes, Mark
The bot wants to close this issue again 🤖 . I understand if you do not have much time to work on this project, but your input is valuable for us and helps us among other things to decide what should go into master 😉 . It is true that getting the whole thing there will take time, but there will be multiple phases and with completed parallelization and reconstruction of total fluxes it is closer than ever 🚀 .
Great results! 👍 The winning stage is split for me 🥇 , HRT and HDG results are very close. The port errors of HDG look ugly, but it is a known problem of DG, where we do not have an essential boundary condition and they are not harmful overall. HRT shows some extra artifacts, which is rather worrying to me. I have not tried mixed meshes, I need to have a look later at that reduction what happens there. However, reduction does not have a priority, as it performs worse in all aspects than hybridization basically, so no guarantees this case will be supported. LDG is there mainly for reference. In any case, what is striking here is the very low number of iterations for such difficult cases, where convergence is indicated, but you can see visually there are big errors (especially that mixed anisotropic case is funny 😄 ). I think you should really try to redefine the solver norm. We have run into that before, but it is even more important here when most of the domain is covered by background and the object of interest is immersed in it. Good news are that #4483 has got merged 🎉 , so you may easily define the norm through
IterativeSolverController. The question is what norm to use and how to construct it. For HRT/DG, we would need a flux norm derived from the trace values, so something like $|\kappa [\hat{t}]|$. Unfortunately, I had to switch fromRT_Traceelements toDG_Interfaceelements in hybridization because of the parallelization, which means there is no easy way how to get (generalized) gradient of the traces🤔 . However, we do not need the orientation of the gradient for the norm, so it is still doable with a bit of some extra work. Anyway, I would propose to start with LDG (=reduction), where the primary quantity is the potential, so you may easily take $||\kappa [t]|| + ||\kappa \nabla t||$ 😉 . CheckGridFunction::ComputeDGFaceJumpError()andGridFunction::ComputeGradError(). Withex5-nguyen.cpp, it really follows the notation in the header.tcoefis the analytic temperature,ccoefthe velocity,fcoefthe temperature rhs. Do not read much in their definitions, they are complex, but it just follows the paper, so check there what the problems are about 😉 .That’s very exciting, @najlkin ! I am currently traveling, but will give this a test run once I am back! Thanks again for putting this together! It’s a great addition (to a great library)! Mathias
These are great results and also progress with LDG 👍 There are two things we need to distinguish:
wq = max(wq, ni * nor)orwq = min(wq, ni * nor)if it will have some effect.Ok, it seems like stabilization only on the interior but not on the boundary produces some decent results, however, still with somewhat poor convergence.
There still seem to be artifacts though, especially in the transition zone between port and beam, where the current amplitude seems way too high.
Looks amazing! Try to play with that stabilization parameter
tdas I mentioned earlier and add it to the boundary term or try to remove the stabilization term for the boundary altogether. Nice weekend 👋 .Hi @najlkin ! That’s fantastic!! 🚀 I will start running some tests and will post these soon!
That makes a lot of sense, thanks @najlkin for clarifying! I guess I wasn’t ready to fully give up on the non-“HDG-hybridization-reduction” approach 🙈 (which was only meant as a temporary solution, while the Darcy-dev is work in progress), but I think you’re right. I will just wait for the parallelized version of the
darcy-hdg-devbranch. Very exciting to hear that you’re working on the parallelization though! Please let me know if/when I can help with running any test-cases or provide test meshes, etc. Thanks again! MathiasMaybe the fundamental problem here is that you have a system of two equations, which you put into a block and solve them like one, i.e., the solver uses a single norm, which is like ||j|| + ||phi||, which does not make much sense as you are mixing apples with oranges here 🍏 🟠 . It should be more like ||j|| + ||kappa grad phi||, which it actually almost is, because the residuum is measured, so it is more complicated than this, but to give you an idea. It can happen it is insensitive to one of the equations, so you get maybe perfect solution in phi, but poor in j. You are not the only one facing this and there is pull request #4483 for generalization of the norm used by solvers. With that you could decide that the solution is converged only when both quantities are converged.
In any case, I would not spend too much time on this at your place, as you do not need to care about it with hybridization/reduction and their parallelization is underway 🚀 .
Hi, all the best to the new year! 🎉 The idea of virtual time stepping is simple - start with higher values of mass/stabilization and iteratively decrease it to small values, where every iteration serves as the initial condition (in the case of mass) / guess (in the case of stabilization) for the next one 👍 . This is getting complicated in such settings and that is why the main focus should be on HDG here. I would like to parallelize it with MPI soon. In the meantime you may try to solve
(curl B, curl Xi) = <phi, n . curl Xi>_phifor B, Xi in Hcurl. For the BC term you will need to write your own integrator probably. The current you will get then asj = curl BthroughCurlInterpolator😉 .Hi @najlkin , awesome, thanks so much for looking into this. About the virtual time stepping: how can this be implemented? I.e., how can I decrease/increase the stabilization/mass portion of the problem? Happy to give it a try.
Also, regarding
DivergenceCleaningand stationary magnetic diffusion approaches: is there a starting point somewhere one github (or maybe someone has a few more thoughts on how to tackle this?). Not sure how the filter could be implemented (not sure how theCurlCurlIntegratorwould fit into a problem whereJis inHDiv). Also, for solving the magnetic diffusion problem directly, I am not sure how I could impose the appropriate BCs (i.e., either voltage or current BCs). But would love to give it a try, if someone has some helpful thoughts on how get started with this 😃Thanks a lot and happy new year! Mathias
Nice holiday time ☃️, I found some time to look at the code and ran the cases 1 and 2 (3 is too big for my laptop 😊 ). And identified a few things with L/HDG:
HDGDiffusionIntegrator, the drop is gone, but you may have hard time to get it converged. This returns us to the idea of virtual time stepping proposed above, where you could solve this predominantly boundary problem iteratively and gradually decrease the stabilization/mass.DofTransformation, but it isNULLwhen returned byGetElementVDofs. Zero order looks relatively fine, but first and higher have concentrated random currents at the boundaries (like the right column of your results) I do not know, do you think it could be some bug of L2 elements on tets, @mlstowell ?Hi, that is the thing, it is a different equation for different quantities, i.e., electric current and magnetic field (or something acting like that). So compatibility is an issue, but you may use it at least for that Helmholtz decomposition, because there must exist a vector field which produces purely solenoidal, divergence-free electric current field. However, I am confused now, I thought you have
Jin Hdiv. If it is in Hcurl, which makes more sense as you may get it throughGradientInterpolatorfromphiin H1, then it is purely gradient, not solenoidal.Hi, sorry, I had no time for that, I was working on projects for running collaborations. Maybe I will get to it later during vacation.
Yes, I think it might be a good approach for now before we do parallelization of HDG/HRT to solve a single equation instead. If you want a divergence-free solution the equation should rather be
curl sigma^-1 curl B = 0in Hcurl and then you may getJ = curl Bwith the discreteCurlInterpolator. That is an equation for stationary magnetic diffusion instead of the electrostatic problem. This is conceptually similar to the Helmholtz decomposition inDivergenceFreeProjector, but there it is between H1 and Hcurl through Laplace similar to yours. So if you cannot solve the problem with B directly, you may solve with phi instead and then use the mentioned equation as a filter, trying to find a B that would correspond to the solution, eliminating the divergence part.@mdavids-cfs , this is exactly why we are working on HDG and why it is important for tokamaks 🙂 . This anisotropy is causing failure of classical methods, while they might be perfectly fine for isotropic diffusion. This is what we discussed before. HDG outperforms other methods, as far as I can say and also your results suggest that, but it is not parallelized, so you cannot use multi-grid preconditioners/solvers, so convergence might be slower sometimes for that reason.
Hi, @mdavids-cfs, This may not be relevant but some time ago I was looking at highly anisotropic scalar diffusion. I found that refining the mesh helped but increasing the basis function order helped much more. If I remember correctly, I found that for a given number of degrees of freedom it was best to use 3rd or 4th order basis functions on a relatively coarse mesh rather than 1st or 2nd order on a finer mesh. I think 1e9 was the highest contrast I looked at so your case will be even more challenging. Best wishes, Mark
Hi @najlkin and others, I just uploaded the modified version of
ex5-hdgthat I’ve been using along with the meshes and resistivity values (stored in text files with the ending.mat, not to be confused with Matlab data files) here.You can use the flag
-mto switch between the different meshes (1 = hex beam, 2 = tet beam, 3 = tet solenoid based oncoil.gen) and-isoor-anisoto switch between isotropic and anisotropic materials. Note that for anisotropic materials, I am using per-element attributes to define per-element tensors (this was due to a limitation of PyMFEM which I believe is now resolved), but it should all be handled automatically in the modified version ofex5-hdg. Thanks again for offering to have a look, and let me know if any more test cases or meshes etc. would be helpful. Of course, I am also doing more testing on my end, and will keep you posted about these, too. Thanks and warm regards, MathiasHi all, I ran another set of simulations today, especially comparing HEX and TET meshes of the same geometry.
Here are results for the TET mesh case.
(similar to yesterday’s results on the HEX mesh)
I looked at fully isotropic case (top) as well anisotropic cases using “analytic (uniform) tensors” and tensors obtained by solving a simple isotropic diffusion on the sub-mesh representing the central beam. I actually ended up fine-tuning this, because my initial approach had some noise in the resulting vector field which is now mostly resolved. Also I left out
-dgand-dg -rdcases, since they didn’t work very well (similarly to what I’ve shown yesterday).A few things I noticed:
ex5-hdg, i.e., no hybridization or DG) the solve did not converge within 1000 iterations and had an artifact in the potential. EDIT: It converged after 1700 iterations and the artifact was gone, so again just slow convergenceI will make sure to also try the things you suggested above, @najlkin . Just got a bit into the TET mesh rabbit hole today, but glad I found the issue with how I am generating the tensor field.
Mathias
EDIT: Regarding this suggestion:
What pre-conditioner would you use in this case with GMRES? If try to use the solver code block following this line: https://github.com/mfem/mfem/blob/e92c3f4a5b4f582c2af9bec41b59a4a8bccf862c/examples/ex5-hdg.cpp#L282
I get the following error:
There is a LOT more in the 519 commits 😄 . I would like to get to parallelization soon, but there are still other things to do. However, it is only a preconditioner for the Schur complement or eventually the hybridized matrix, so it does not change the properties of the scheme, just accelerates the convergence. If it shows convergence with Gauss-Seidel or UMFPack, that should be it, nothing to improve except the speed (unless there is some ambiguity in the solution 😯 ).
Hi @najlkin , thanks for the comments; I will run some more tests as you suggested. Also more than happy to share the code and the test mesh I was using. Another quick question: is it possible to test
ex5pinmasterwith hybridization and run with HyperAMG? I.e., does it work toEnableHybridizationfor the different blocks inBlockOperator, or is there more going on behind the scenes (I guess there must be, since you ended up writing a specific class for this). Thanks again! MathiasWow, these are very interesting results indeed! 🤩 There a few points from my side:
ex5-hdg) and HRT (-hb) are equivalent schemes (not so LDG and HDG), so it keeps me wondering why they show different results even when reportedly are both converged 🤔 We do not have an analytic solution, but HRT result looks better to me. Maybe MINRES does some gimmicks, is there any difference when you run RTDG with GMRES?-dg -hb) looks great 👍 . The results are nicely smooth like for HRT, while the iteration count (and computation time, I guess) starts to be lower with higher anisotropy. Btw, you do not need to use-rdin combination with-hb, it is one or the other, so it is ignored in this case.-dg (-rd)) looks really bad 🫠 . I wonder if there is not a bug as I would expect it to converge at least in the isotropic case 🤔 . Could you share the code somehow? Maybe in a public fork?Hi all, here is some more test results: First, I took a step back and generated the simplest model possible: a straight high-conductivity (anisotropic) slab embedded in a low conductivity (isotropic) region. The anisotropic direction is left-right, and the direction along the slab and top-down is the high-conductivity direction. I solved this for both isotropic and anisotropic conductivity cases using my default workflow (in PyMFEM based on
ex5pinmasterwith added BC on the flux on the non-port regions) and saw (almost) no difference, which makes sense since given the port configuration, the current is only flowing along the high conductivity direction, so all good here.I then ran the same model using
ex5-hdgindarcy-hdg-devwith a few different configurations (hybridization, DG, etc.)Only isotropic materials
With anisotropic high-conductivity material
So at least for this simple example, DG seems to work quite well with hybridization. I will rerun the more complex example of the full solenoid tomorrow. DG without hybridization did not work for both the isotropic and anisotropic cases; would this point a problem, or is this expected?
Cheers! Mathias
Ok, I investigated that MINRES and the problem is in how it calculates “norms”, where it takes
r * P(r), while GMRES usesP(r) * P(r)(r-residuum,P- preconditioner). The former is negative sometimes, so the square root of it yields that NaN. You may just comment out the preconditioner and MINRES runs fine 😉 I also added completion of the diagonal of the hybridized matrix with ones, so you may use more solvers, including direct solvers like UMFPackSolver 😉 . In any case, try those DGs, I am curious how that will work…Cool, that is an impressive comparison 👍 . I think hybridization runs quite well, considering it uses just a poor Gauss-Seidel for preconditioning. Sure, maybe you get better results with the mixed form and AMG for Schur now, but the thing is hybridization is robust when it comes to anisotropy, so it is a better choice for the future 😉 . Hopefully, I will get to parallelization soon. Anyway, maybe try using MINRES instead of GMRES like you do without hybridization. Regarding DGs, the problem is that there are no essential BCs as there are no boundary DOFs 😄 I did not demonstrate that in this example, because the original problem had no BC for flux. You may find it in more advanced examples, but it is too complicated there maybe. With zero BC, all you need to do should be:
That is extension of the weak gradient to the boundary, i.e., natural BC. PS: You may use hybridization with DGs too 😉
Hi @najlkin , just ran a few tests using
ex5-hdg. As before, the hybridization approach worked slightly better but still not as good as theex5pexample inmasterwithHypreAMG. The DG options didn’t really work, although I am wondering if enforcing the BC on the potential/pressure works in a similar fashion, or if other steps would be needed here:Here is an overview of the results with the four approaches (regular, hybridization, DG, DG + reduction)
The conductivity of the wire is ~10 orders of magnitude higher than the surrounding materials, so the current should be mostly confined to the wire, which I do indeed see in
ex5pinmaster.Also, @mlstowell : I forgot to add the question following the quote in my previous post: you made a comment about how I am calculating the current density. In fact, I was wondering if a step might be missing in how I am calculating the current density? Using something similar to this in my implementation based on
ex5pinmaster(didn’t make changes toex5-hdg):Thanks again for the help with this! Mathias
Cool, @mdavids-cfs , there is a big difference between the poor Gauss-Seidel and a multi-grid (BoomerAMG), as the residuum shows, but both did not converge. It is good for regression using plain
DarcyForm, so we know it works the same way asmaster. However, the main benefit is that you may turn on hybridization (-hb, works for RTs and DGs) or reduction of the DG flux (-rd) 😮 (I just added that reduction toex5-hdg.cpp). Does that work?Hi @najlkin , I’ve done a few more tests, especially comparing my current approach based on
ex5andex5pin the main branch withex5indarcy-hdg-devthat uses theDarcyOperatorclass. For now, I am solving with only isotropic materials usingcoil.gen. Few comments on the overall setup:DSmootherandGSSmootherfor the two blocks (also tried GMRES, which didn’t really have an impact)HypreDiagScaleandHypreBoomerAMGrhobetween 6.6e-17 and 5.14e-07):These are the results for
order = 0for the three cases:(three rows are potential, current (linear scale) and current (log scale))
Switching to
order = 1seemed to make things worse for the serial methods indarcy-hdg-devandmain(three rows are potential, current (log scale) and current (linear scale))Here is the code changes I made to implement the model described above:
Boundary constraints for
phiandJEnforce voltage boundary values only on ports
Only for
ex5andex5pinmainIt seems that I am missing something in setting up the serial cases, or is it only the Hypre preconditioners that causes the big difference between the serial and parallel runs? Also @najlkin if you have some guidance on how to set up this problem using the
DarcyOperatorclass (or would even be interested in doing a run on your end) that would be incredibly helpful. I would guess that this problem should be a pretty easy solve for your dedicated operator (especially since there’s no anisotropy). Also happy to share the full code I used in each case, if that’s helpful.Also @mlstowell regarding your previous comment above:
Thanks again everyone for the help so far! Mathias
Hi @mdavids-cfs , thanks for your interest! 😉 The code looks alright at first glance 👍 . Maybe try solving it without hybridization first, to verify the setup is correct. However, is your mesh conforming? Because that is also one of the current limitations of the implementation. I believe I will get to it soon together with that parallelization (as both things are conceptually close in MFEM), but it is as it is for now. Sure, a beer sounds good 🍻 , but let us wait with that until something works 😅 . PS: Yes, I think you need to be member of some of those teams to be able to make branches and contribute directly. However, it is not critical now, I think…
Hi @najlkin , thanks a lot for looking into this!
The conductivity tensors are all symmetric. They are all 2-rank tensors given by a directional vector
v_parand two conductivitiessigma_parandsigma_perpusingI will generate some more plots tomorrow (would something similar to my earlier post be helpful?).
Also, here is a bit of a clean-up version of the relevant code pieces I am currently using:
Boundary markers and values
Linear forms
Bilinear forms
Boundary DoFs
Darcy operator
Darcy preconditioner
Solver
Get final solutions
Thanks again for offering to help with this! It’s greatly appreciated!! (also applies to @mlstowell and anyone on the MFEM team)! Mathias
PS: I started to look into your Darcy forms and operators in
darcy-hdg-dev, looks super interesting and very relevant indeed. Since we’re currently using PyMFEM (which is part of a bigger library we’re working on), I’d love to stay within PyMFEM, but if nothing else helps, I could also try to expand PyMFEM’s swig interface to include your classes.@mdavids-cfs , we discussed the problem today and a few things came up:
It seems that GMRES does not converge, which indicates it is a pretty hard problem indeed and the simple approach of example 5 is not ideal. Two things to it:
darcy-hdg-devwith minimal effort. It is just not parallelized atm.Hi @mlstowell , I am solving a Darcy type problem (following ex5p) with voltage boundary condition on two ports, and then of course divergence-free
Jis enforced everywhere except on the two ports. I am extractingJviai.e., again following ex5p. The implementation is very close to this post I made a while back.
Thanks @najlkin for the recommendations! Just ran a quick test:
The results across the different solvers and pre-conditioners were almost identical, although the
MINRESandHypreSmoothercombination really improved the convergence so that’s good. It makes me wonder though if this is less of a convergence/solver issue, but rather a model setup/tensor issue… I will try to remesh this model and run it with refinement to see if makes a difference. But if anything else comes to mind let me know! Thanks a lot and have a great weekend everyone \o/ Mathias@mdavids-cfs , try GMRES, which is more resilient for asymmetric cases and also you may try
HypreSmootherinstead ofHypreDiagScale, which has more options to play with. What exactly parameters to set forHypreBoomerAMG, I do not remember from top of my head and it might be problem-dependent. However, this should not affect the converged solution, just the convergence rate. That GMRES is more important for that and also maybe set lower absolute tolerance 🤔Hi @mlstowell , I guess the wording was bit misleading: with the most recent runs, the solver always converged, although of course much slower for the anisotropic case:
Here are some details on the solver:
HypreDiagScale+HypreBoomerAMGfor the two blocksHi, @mdavids-cfs, You said “if the solver just goes astray”. Did the solver converge when the above artifacts were seen? If it did not converge these artifacts may not mean much. Best wishes, Mark
Hi, @mdavids-cfs, This looks very good to me. One possible improvement to the resistivity tensor would be to compute it at each quadrature point. The basic idea is to create a custom MatrixCoefficient which evaluates the gradient field and computes the tensor on the fly. This might take better advantage of the continuous nature of the gradient field. I would be curious to see how much difference this might produce (perhaps not that much). Best wishes, Mark
Yes, you may use a direct solver like
UMFPackSolverwhich is also used in example 5. Unfortunately, these solvers do not scale well to computing clusters and have significant memory usage, so we try to depart from those and use iterative solvers for HDG instead 😉 .Hi, @mdavids-cfs,
I don’t have a code snippet handy but the basic pieces you need are a pair of bilinear forms; one using
GradientIntegratorand the other usingVectorMassIntegrator. Multiply theGradientIntegratorbilinear form by your H1 field to produce a right hand side vector. Then solve theVectorMassIntegratorbilinear form using that right hand side. The resulting solution vector should be a vector-H1 field (using a finite element space created with an extra “dim” argument e.g.FiniteElementSpace fespace_h1v(&mesh, &fec_h1, dim);).Best wishes, Mark
Hi @mdavids-cfs , I agree with @mlstowell that H1 is probably a better option. But I would like to comment on the performance and discretization in general, as I am working on anisotropic diffusion. The thing is that the good performance of the classical mixed scheme does not translate well to anisotropic media and you may observe (even in much simpler scenarios) decay of the precision of the solution and convergence rate. The classical mixed discretization follows de Rham complex, but this starts to be inefficient when the anisotropic coefficient couples together the continuous and discontinuous components of Raviart-Thomas or Nedelec. Not only you are losing the polynomial order, but also conditioning of such system is in question. The second thing is preconditioning, where the classical multigrids also lose performance as they do dimensional split, which does not work much anymore if the conductivity changes rapidly. You may play with the options of AMG, there are plenty and some may improve the performance. Finally, the global solver has a hard time to solve an asymmetric saddle-point problem. All these points led us to development of the L/HDG framework for mixed systems, which you may find in #4350 . I am going to present the recent progress there in my talk at the MFEM workshop. If you are around, we may talk about it 😉 . The main focus is on heat diffusion though, so support for Maxwell’s equations is limited right now, but I would like to add that feature set for Nedelecs and curl of DGs soon 🚀 .
Hi, @mdavids-cfs,
As always you produce such interesting simulations.
My first impression is that higher order basis functions would probably produce significantly smoother results. This is often the case with tetrahedral elements in particular. However, that is probably too simplistic. To go further we would need to know more about your discretization.
I assume your electrostatic solution to obtain the parallel direction uses H1 elements. The natural choice for the gradient would then be Nedelec elements. Normally I’m a big fan of Nedelec elements but they might be a poor choice in this context. My guess is that a low order Nedelec gradient on a tetrahedral mesh would produce a direction field which zig zags through the coil aligning with the local edges which are most closely aligned with the direction along the coil. This is likely to produce a discontinuous conductivity and a longer effective path through the coil (just a guess). Raviart-Thomas might do a little better at producing a conductivity which is continuous across element interfaces but I would recommend going with a fully continuous gradient i.e. vector H1. Of course this would require that you preform a global solve to compute the direction field but I suspect the results would be worth the added computational cost. This would be particularly true if the direction field remains unchanged so the added expense would be a one time cost.
Best wishes, Mark